[geany/geany] effc8e: Add proper scope for JS tags including their own context

Colomban Wendling git-noreply at xxxxx
Mon Sep 24 10:25:36 UTC 2012


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Mon, 24 Sep 2012 10:25:36
Commit:      effc8ef86f475db15582ba0e91a9d8ce0ebfd55f
             https://github.com/geany/geany/commit/effc8ef86f475db15582ba0e91a9d8ce0ebfd55f

Log Message:
-----------
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.


Modified Paths:
--------------
    tagmanager/ctags/js.c

Modified: tagmanager/ctags/js.c
20 files changed, 17 insertions(+), 3 deletions(-)
===================================================================
@@ -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,8 +217,19 @@ 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;
@@ -225,7 +237,7 @@ static void makeJsTag (tokenInfo *const token, const jsKind kind)
 		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);
 	}
 }
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).



More information about the Commits mailing list