Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Wed, 26 Jun 2013 14:33:35 UTC Commit: 08fe915ce8b4ed180f16e43becdfa8c177d02032 https://github.com/geany/geany/commit/08fe915ce8b4ed180f16e43becdfa8c177d020...
Log Message: ----------- SQL: report scope as such, not as part of the tag name
Modified Paths: -------------- tagmanager/ctags/sql.c tests/ctags/3184782.sql.tags tests/ctags/bug1570779.sql.tags tests/ctags/bug1938565.sql.tags tests/ctags/bug1944150.sql.tags tests/ctags/bug823000.sql.tags tests/ctags/db-trig.sql.tags tests/ctags/random.sql.tags tests/ctags/readlob.sql.tags tests/ctags/readlong.sql.tags tests/ctags/refcurs.sql.tags
Modified: tagmanager/ctags/sql.c 81 files changed, 41 insertions(+), 40 deletions(-) =================================================================== @@ -169,6 +169,7 @@ keywordId keyword; vString * string; vString * scope; + int scopeKind; int begin_end_nest_lvl; unsigned long lineNumber; MIOPos filePosition; @@ -424,6 +425,7 @@ static tokenInfo *newToken (void) token->keyword = KEYWORD_NONE; token->string = vStringNew (); token->scope = vStringNew (); + token->scopeKind = SQLTAG_COUNT; token->begin_end_nest_lvl = 0; token->lineNumber = getSourceLineNumber (); token->filePosition = getInputFilePosition (); @@ -452,7 +454,7 @@ static int analyzeToken (vString *const name, langType language) * Tag generation functions */
-static void makeConstTag (tokenInfo *const token, const sqlKind kind) +static void makeSqlTag (tokenInfo *const token, const sqlKind kind) { if (SqlKinds [kind].enabled) { @@ -465,31 +467,14 @@ static void makeConstTag (tokenInfo *const token, const sqlKind kind) e.kindName = SqlKinds [kind].name; e.kind = SqlKinds [kind].letter;
- makeTagEntry (&e); - } -} - -static void makeSqlTag (tokenInfo *const token, const sqlKind kind) -{ - vString * fulltag; - - if (SqlKinds [kind].enabled) - { - /* - * If a scope has been added to the token, change the token - * string to include the scope when making the tag. - */ - if ( vStringLength(token->scope) > 0 ) + if (vStringLength (token->scope) > 0) { - fulltag = vStringNew (); - vStringCopy(fulltag, token->scope); - vStringCatS (fulltag, "."); - vStringCatS (fulltag, vStringValue(token->string)); - vStringTerminate(fulltag); - vStringCopy(token->string, fulltag); - vStringDelete (fulltag); + Assert (token->scopeKind < SQLTAG_COUNT); + e.extensionFields.scope[0] = SqlKinds [token->scopeKind].name; + e.extensionFields.scope[1] = vStringValue (token->scope); } - makeConstTag (token, kind); + + makeTagEntry (&e); } }
@@ -723,7 +708,7 @@ static void readIdentifier (tokenInfo *const token) * } */
-static void addToScope (tokenInfo* const token, vString* const extra) +static void addToScope (tokenInfo* const token, vString* const extra, sqlKind kind) { if (vStringLength (token->scope) > 0) { @@ -731,6 +716,7 @@ static void addToScope (tokenInfo* const token, vString* const extra) } vStringCatS (token->scope, vStringValue(extra)); vStringTerminate(token->scope); + token->scopeKind = kind; }
/* @@ -820,6 +806,7 @@ static void copyToken (tokenInfo *const dest, tokenInfo *const src) dest->keyword = src->keyword; vStringCopy(dest->string, src->string); vStringCopy(dest->scope, src->scope); + dest->scopeKind = src->scopeKind; }
static void skipArgumentList (tokenInfo *const token) @@ -841,6 +828,7 @@ static void parseSubProgram (tokenInfo *const token) { tokenInfo *const name = newToken (); vString * saveScope = vStringNew (); + sqlKind saveScopeKind;
/* * This must handle both prototypes and the body of @@ -898,6 +886,7 @@ static void parseSubProgram (tokenInfo *const token) isKeyword (token, KEYWORD_procedure));
vStringCopy(saveScope, token->scope); + saveScopeKind = token->scopeKind; readToken (token); copyToken (name, token); readToken (token); @@ -914,7 +903,7 @@ static void parseSubProgram (tokenInfo *const token) */ if ( vStringLength(saveScope) > 0 ) { - addToScope(token, name->string); + addToScope(token, name->string, kind); } readToken (token); copyToken (name, token); @@ -979,7 +968,7 @@ static void parseSubProgram (tokenInfo *const token) isKeyword (token, KEYWORD_internal) || isKeyword (token, KEYWORD_external) ) { - addToScope(token, name->string); + addToScope(token, name->string, kind); if (isType (name, TOKEN_IDENTIFIER) || isType (name, TOKEN_STRING) || !isKeyword (token, KEYWORD_NONE) @@ -987,6 +976,7 @@ static void parseSubProgram (tokenInfo *const token) makeSqlTag (name, kind);
vStringClear (token->scope); + token->scopeKind = SQLTAG_COUNT; } if ( isType (token, TOKEN_EQUAL) ) readToken (token); @@ -997,7 +987,7 @@ static void parseSubProgram (tokenInfo *const token) if (isKeyword (token, KEYWORD_is) || isKeyword (token, KEYWORD_begin) ) { - addToScope(token, name->string); + addToScope(token, name->string, kind); if (isType (name, TOKEN_IDENTIFIER) || isType (name, TOKEN_STRING) || !isKeyword (token, KEYWORD_NONE) @@ -1006,9 +996,11 @@ static void parseSubProgram (tokenInfo *const token)
parseBlock (token, TRUE); vStringClear (token->scope); + token->scopeKind = SQLTAG_COUNT; } } vStringCopy(token->scope, saveScope); + token->scopeKind = saveScopeKind; deleteToken (name); vStringDelete(saveScope); } @@ -1086,10 +1078,12 @@ static void parseType (tokenInfo *const token) { tokenInfo *const name = newToken (); vString * saveScope = vStringNew (); + sqlKind saveScopeKind;
vStringCopy(saveScope, token->scope); /* If a scope has been set, add it to the name */ - addToScope (name, token->scope); + addToScope (name, token->scope, token->scopeKind); + saveScopeKind = token->scopeKind; readToken (name); if (isType (name, TOKEN_IDENTIFIER)) { @@ -1097,12 +1091,12 @@ static void parseType (tokenInfo *const token) if (isKeyword (token, KEYWORD_is)) { readToken (token); - addToScope (token, name->string); switch (token->keyword) { case KEYWORD_record: case KEYWORD_object: makeSqlTag (name, SQLTAG_RECORD); + addToScope (token, name->string, SQLTAG_RECORD); parseRecord (token); break;
@@ -1119,9 +1113,11 @@ static void parseType (tokenInfo *const token) default: break; } vStringClear (token->scope); + token->scopeKind = SQLTAG_COUNT; } } vStringCopy(token->scope, saveScope); + token->scopeKind = saveScopeKind; deleteToken (name); vStringDelete(saveScope); } @@ -1659,9 +1655,10 @@ static void parsePackage (tokenInfo *const token) if (isType (name, TOKEN_IDENTIFIER) || isType (name, TOKEN_STRING)) makeSqlTag (name, SQLTAG_PACKAGE); - addToScope (token, name->string); + addToScope (token, name->string, SQLTAG_PACKAGE); parseBlock (token, FALSE); vStringClear (token->scope); + token->scopeKind = SQLTAG_COUNT; } findCmdTerm (token, FALSE); deleteToken (name); @@ -1724,8 +1721,10 @@ static void parseTable (tokenInfo *const token) { makeSqlTag (name, SQLTAG_TABLE); vStringCopy(token->scope, name->string); + token->scopeKind = SQLTAG_TABLE; parseRecord (token); vStringClear (token->scope); + token->scopeKind = SQLTAG_COUNT; } } else if (isKeyword (token, KEYWORD_at)) @@ -1770,7 +1769,7 @@ static void parseIndex (tokenInfo *const token) readIdentifier (owner); readToken (token); } - addToScope(name, owner->string); + addToScope(name, owner->string, SQLTAG_TABLE /* FIXME? */); makeSqlTag (name, SQLTAG_INDEX); } findCmdTerm (token, FALSE); @@ -1867,9 +1866,10 @@ static void parseTrigger (tokenInfo *const token) { if ( isKeyword (token, KEYWORD_declare) ) { - addToScope(token, name->string); + addToScope(token, name->string, SQLTAG_TRIGGER); parseDeclare(token, TRUE); vStringClear(token->scope); + token->scopeKind = SQLTAG_COUNT; } else readToken (token); @@ -1878,14 +1878,15 @@ static void parseTrigger (tokenInfo *const token) if ( isKeyword (token, KEYWORD_begin) || isKeyword (token, KEYWORD_call) ) { - addToScope(name, table->string); + addToScope(name, table->string, SQLTAG_TABLE); makeSqlTag (name, SQLTAG_TRIGGER); - addToScope(token, table->string); + addToScope(token, table->string, SQLTAG_TABLE); if ( isKeyword (token, KEYWORD_begin) ) { parseBlock (token, TRUE); } vStringClear(token->scope); + token->scopeKind = SQLTAG_COUNT; } }
@@ -2128,8 +2129,8 @@ static void parseMLTable (tokenInfo *const token) isType (table, TOKEN_STRING) && isType (event, TOKEN_STRING) ) { - addToScope(version, table->string); - addToScope(version, event->string); + addToScope(version, table->string, SQLTAG_TABLE); + addToScope(version, event->string, SQLTAG_EVENT); makeSqlTag (version, SQLTAG_MLTABLE); } } @@ -2176,7 +2177,7 @@ static void parseMLConn (tokenInfo *const token) if (isType (version, TOKEN_STRING) && isType (event, TOKEN_STRING) ) { - addToScope(version, event->string); + addToScope(version, event->string, SQLTAG_EVENT); makeSqlTag (version, SQLTAG_MLCONN); } } @@ -2238,8 +2239,8 @@ static void parseMLProp (tokenInfo *const token) isType (prop_set_name, TOKEN_STRING) && isType (prop_name, TOKEN_STRING) ) { - addToScope(component, prop_set_name->string); - addToScope(component, prop_name->string); + addToScope(component, prop_set_name->string, SQLTAG_MLPROP /* FIXME */); + addToScope(component, prop_name->string, SQLTAG_MLPROP /* FIXME */); makeSqlTag (component, SQLTAG_MLPROP); } }
Modified: tests/ctags/3184782.sql.tags 8 files changed, 4 insertions(+), 4 deletions(-) =================================================================== @@ -1,6 +1,6 @@ # format=tagmanager +do_this_stuff�256�p_test�0 +myfn1�256�p_test�0 +myfn2�256�p_test�0 p_test�512�0 -p_test.do_this_stuff�256�0 -p_test.myfn1�256�0 -p_test.myfn2�256�0 -p_test.process_this�256�0 +process_this�256�p_test�0
Modified: tests/ctags/bug1570779.sql.tags 6 files changed, 3 insertions(+), 3 deletions(-) =================================================================== @@ -1,5 +1,5 @@ # format=tagmanager +address�8�employees�0 employees�1�0 -employees.address�8�0 -employees.id�8�0 -employees.name�8�0 +id�8�employees�0 +name�8�employees�0
Modified: tests/ctags/bug1938565.sql.tags 4 files changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -1,4 +1,4 @@ # format=tagmanager demo_pkg�512�0 -demo_pkg.func1�16�0 -demo_pkg.func2�16�0 +func1�16�demo_pkg�0 +func2�16�demo_pkg�0
Modified: tests/ctags/bug1944150.sql.tags 2 files changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -1,2 +1,2 @@ # format=tagmanager -cash_trade_comment.tr_d_cash_trade_comment�65536�0 +tr_d_cash_trade_comment�65536�cash_trade_comment�0
Modified: tests/ctags/bug823000.sql.tags 4 files changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -1,4 +1,4 @@ # format=tagmanager TEST�512�0 -TEST.TestFunc1�256�0 -TEST.TestFunc2�256�0 +TestFunc1�256�TEST�0 +TestFunc2�256�TEST�0
Modified: tests/ctags/db-trig.sql.tags 4 files changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -1,3 +1,3 @@ # format=tagmanager -database.restrict_login�65536�0 -database.startup_db�65536�0 +restrict_login�65536�database�0 +startup_db�65536�database�0
Modified: tests/ctags/random.sql.tags 20 files changed, 10 insertions(+), 10 deletions(-) =================================================================== @@ -1,12 +1,12 @@ # format=tagmanager +Seed�16384�random�0 +get_rand�256�random�0 +get_rand_max�256�random�0 +increment�16384�random�0 +multiplier�16384�random�0 +rand�16�random�0 +rand_max�16�random�0 +rand_string�16�random�0 random�512�0 -random.Seed�16384�0 -random.get_rand�256�0 -random.get_rand_max�256�0 -random.increment�16384�0 -random.multiplier�16384�0 -random.rand�16�0 -random.rand_max�16�0 -random.rand_string�16�0 -random.smaller�16�0 -random.srand�256�0 +smaller�16�random�0 +srand�256�random�0
Modified: tests/ctags/readlob.sql.tags 8 files changed, 4 insertions(+), 4 deletions(-) =================================================================== @@ -1,10 +1,10 @@ # format=tagmanager +b_file�8�lob_table�0 +b_lob�8�lob_table�0 +c_lob�8�lob_table�0 charbuf�16384�0 clob_locator�16384�0 +id�8�lob_table�0 lob_table�1�0 -lob_table.b_file�8�0 -lob_table.b_lob�8�0 -lob_table.c_lob�8�0 -lob_table.id�8�0 read_amount�16384�0 read_offset�16384�0
Modified: tests/ctags/readlong.sql.tags 2 files changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -3,7 +3,7 @@ cur1 long_len�16384�0 long_piece�16384�0 long_tab�16384�0 +longcol�8�longtable�0 longtable�1�0 -longtable.longcol�8�0 piece_len�16384�0 rc�16384�0
Modified: tests/ctags/refcurs.sql.tags 6 files changed, 3 insertions(+), 3 deletions(-) =================================================================== @@ -1,6 +1,6 @@ # format=tagmanager +get_cursor_ref�16�test_ref_cursor�0 +main�256�test_ref_cursor�0 +process_cursor�256�test_ref_cursor�0 test_ref_cursor�512�0 -test_ref_cursor.get_cursor_ref�16�0 -test_ref_cursor.main�256�0 -test_ref_cursor.process_cursor�256�0 types�512�0
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).