| 1 |
From a499a10833d525c9af794c616dc40f7425110c71 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Colin Watson <[email protected]> |
| 3 |
Date: Sat, 27 Sep 2014 14:37:19 +0100 |
| 4 |
Subject: Changed the javascript parser to set the tag's scope rather than |
| 5 |
including it in the tag name. |
| 6 |
|
| 7 |
Patch from Colomban. |
| 8 |
|
| 9 |
Author: David Fishburn |
| 10 |
Origin: upstream, http://sourceforge.net/p/ctags/code/791/ |
| 11 |
Bug-Debian: https://bugs.debian.org/742605 |
| 12 |
Last-Update: 2014-09-27 |
| 13 |
|
| 14 |
Patch-Name: jscript-set-tag-scope.patch |
| 15 |
--- |
| 16 |
jscript.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- |
| 17 |
1 file changed, 51 insertions(+), 3 deletions(-) |
| 18 |
|
| 19 |
diff --git a/jscript.c b/jscript.c |
| 20 |
index 5de3367f9..a790355b8 100644 |
| 21 |
--- a/jscript.c |
| 22 |
+++ b/jscript.c |
| 23 |
@@ -215,6 +215,7 @@ static void deleteToken (tokenInfo *const token) |
| 24 |
* Tag generation functions |
| 25 |
*/ |
| 26 |
|
| 27 |
+/* |
| 28 |
static void makeConstTag (tokenInfo *const token, const jsKind kind) |
| 29 |
{ |
| 30 |
if (JsKinds [kind].enabled && ! token->ignoreTag ) |
| 31 |
@@ -238,12 +239,13 @@ static void makeJsTag (tokenInfo *const token, const jsKind kind) |
| 32 |
|
| 33 |
if (JsKinds [kind].enabled && ! token->ignoreTag ) |
| 34 |
{ |
| 35 |
- /* |
| 36 |
+ * |
| 37 |
* If a scope has been added to the token, change the token |
| 38 |
* string to include the scope when making the tag. |
| 39 |
- */ |
| 40 |
+ * |
| 41 |
if ( vStringLength(token->scope) > 0 ) |
| 42 |
{ |
| 43 |
+ * |
| 44 |
fulltag = vStringNew (); |
| 45 |
vStringCopy(fulltag, token->scope); |
| 46 |
vStringCatS (fulltag, "."); |
| 47 |
@@ -251,8 +253,54 @@ static void makeJsTag (tokenInfo *const token, const jsKind kind) |
| 48 |
vStringTerminate(fulltag); |
| 49 |
vStringCopy(token->string, fulltag); |
| 50 |
vStringDelete (fulltag); |
| 51 |
+ * |
| 52 |
+ jsKind parent_kind = JSTAG_CLASS; |
| 53 |
+ |
| 54 |
+ * |
| 55 |
+ * if we're creating a function (and not a method), |
| 56 |
+ * guess we're inside another function |
| 57 |
+ * |
| 58 |
+ if (kind == JSTAG_FUNCTION) |
| 59 |
+ parent_kind = JSTAG_FUNCTION; |
| 60 |
+ |
| 61 |
+ e.extensionFields.scope[0] = JsKinds [parent_kind].name; |
| 62 |
+ e.extensionFields.scope[1] = vStringValue (token->scope); |
| 63 |
+ } |
| 64 |
+ * makeConstTag (token, kind); * |
| 65 |
+ makeTagEntry (&e); |
| 66 |
+ } |
| 67 |
+} |
| 68 |
+*/ |
| 69 |
+ |
| 70 |
+static void makeJsTag (tokenInfo *const token, const jsKind kind) |
| 71 |
+{ |
| 72 |
+ if (JsKinds [kind].enabled && ! token->ignoreTag ) |
| 73 |
+ { |
| 74 |
+ const char *const name = vStringValue (token->string); |
| 75 |
+ tagEntryInfo e; |
| 76 |
+ initTagEntry (&e, name); |
| 77 |
+ |
| 78 |
+ e.lineNumber = token->lineNumber; |
| 79 |
+ e.filePosition = token->filePosition; |
| 80 |
+ e.kindName = JsKinds [kind].name; |
| 81 |
+ e.kind = JsKinds [kind].letter; |
| 82 |
+ |
| 83 |
+ if ( vStringLength(token->scope) > 0 ) |
| 84 |
+ { |
| 85 |
+ jsKind parent_kind = JSTAG_CLASS; |
| 86 |
+ |
| 87 |
+ /* |
| 88 |
+ * If we're creating a function (and not a method), |
| 89 |
+ * guess we're inside another function |
| 90 |
+ */ |
| 91 |
+ if (kind == JSTAG_FUNCTION) |
| 92 |
+ parent_kind = JSTAG_FUNCTION; |
| 93 |
+ |
| 94 |
+ e.extensionFields.scope[0] = JsKinds [parent_kind].name; |
| 95 |
+ e.extensionFields.scope[1] = vStringValue (token->scope); |
| 96 |
} |
| 97 |
- makeConstTag (token, kind); |
| 98 |
+ |
| 99 |
+ makeTagEntry (&e); |
| 100 |
} |
| 101 |
} |
| 102 |
|