Permalink
Browse files

Add proper scope for JS tags including their own context

This makes `Foo.bar = function()` properly report a function tag "bar"
with scope "Foo" rather than a function tag "Foo.bar" with no scope.

Part of #3570192.
  • Loading branch information...
1 parent be45924 commit effc8ef86f475db15582ba0e91a9d8ce0ebfd55f @b4n b4n committed Sep 24, 2012
Showing with 17 additions and 3 deletions.
  1. +17 −3 tagmanager/ctags/js.c
View
@@ -18,6 +18,7 @@
*/
#include "general.h" /* must always come first */
#include <ctype.h> /* to define isalpha () */
+#include <string.h>
#include <setjmp.h>
#include <mio/mio.h>
#ifdef DEBUG
@@ -216,16 +217,27 @@ static void makeJsTag (tokenInfo *const token, const jsKind kind)
{
if (JsKinds [kind].enabled && ! token->ignoreTag )
{
- const char *const name = vStringValue (token->string);
+ const char *name = vStringValue (token->string);
+ vString *fullscope = vStringNewCopy (token->scope);
+ const char *p;
tagEntryInfo e;
+
+ if ((p = strrchr (name, '.')) != NULL)
+ {
+ if (vStringLength (fullscope) > 0)
+ vStringPut (fullscope, '.');
+ vStringNCatS (fullscope, name, p - name);
+ name = p + 1;
+ }
+
initTagEntry (&e, name);
e.lineNumber = token->lineNumber;
e.filePosition = token->filePosition;
e.kindName = JsKinds [kind].name;
e.kind = JsKinds [kind].letter;
- if ( vStringLength(token->scope) > 0 )
+ if ( vStringLength(fullscope) > 0 )
{
jsKind parent_kind = JSTAG_CLASS;
@@ -235,10 +247,12 @@ static void makeJsTag (tokenInfo *const token, const jsKind kind)
parent_kind = JSTAG_FUNCTION;
e.extensionFields.scope[0] = JsKinds [parent_kind].name;
- e.extensionFields.scope[1] = vStringValue (token->scope);
+ e.extensionFields.scope[1] = vStringValue (fullscope);
}
makeTagEntry (&e);
+
+ vStringDelete (fullscope);
}
}

0 comments on commit effc8ef

Please sign in to comment.