Skip to content

Commit a63485f

Browse files
edammasatake
authored andcommitted
JavaScript: added foreigndecl role
1 parent 6878f6d commit a63485f

File tree

9 files changed

+63
-15
lines changed

9 files changed

+63
-15
lines changed

Tmain/list-roles.d/stdout-expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ HTML J/script extFile on referenced as extern
6464
HTML c/class attribute on assigned as attributes
6565
Java p/package imported on imported package
6666
JavaScript c/class chainElt off (EXPERIMENTAL)used as an element in a name chain like a.b.c
67+
JavaScript f/function foreigndecl on declared in foreign languages
6768
JavaScript v/variable chainElt off (EXPERIMENTAL)used as an element in a name chain like a.b.c
6869
Julia Y/unknown imported on loaded by "import"
6970
Julia Y/unknown used on loaded by "using"
@@ -192,6 +193,7 @@ HTML J/script extFile on referenced as extern
192193
HTML c/class attribute on assigned as attributes
193194
Java p/package imported on imported package
194195
JavaScript c/class chainElt off (EXPERIMENTAL)used as an element in a name chain like a.b.c
196+
JavaScript f/function foreigndecl on declared in foreign languages
195197
JavaScript v/variable chainElt off (EXPERIMENTAL)used as an element in a name chain like a.b.c
196198
Julia Y/unknown imported on loaded by "import"
197199
Julia Y/unknown used on loaded by "using"

docs/man/ctags-lang-javascript.7.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ CLASSES
2525

2626
ES6 introduced the ``class`` keyword, but there is still the original method of defining a function and attaching a ``prototype``. ctags follows the convention that function names that start with a capital letter are class constructors.
2727

28+
Change since "0.0"
29+
~~~~~~~~~~~~~~~~~~
30+
31+
* New role ``foreigndecl`` for ``function`` kind
32+
2833
SEE ALSO
2934
--------
3035
:ref:`ctags(1) <ctags(1)>`, :ref:`ctags-client-tools(7) <ctags-client-tools(7)>`

makefiles/testing.mak

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ validate-input:
173173
--categories=$(CATEGORIES) \
174174
$${VALIDATORS}"; \
175175
$(SHELL) $${c} $(srcdir)/Units $(srcdir)/misc/validators
176+
176177
#
177178
# Test main part, not parsers
178179
#
@@ -292,6 +293,7 @@ CPPCHECK_FLAGS = --enable=all
292293
cppcheck:
293294
cppcheck $(CPPCHECK_DEFS) $(CPPCHECK_UNDEFS) $(CPPCHECK_FLAGS) \
294295
$$(git ls-files | grep '^\(parsers\|main\)/.*\.[ch]' )
296+
295297
#
296298
# Testing examples in per-language man pages
297299
#

man/ctags-lang-javascript.7.rst.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ CLASSES
2525

2626
ES6 introduced the ``class`` keyword, but there is still the original method of defining a function and attaching a ``prototype``. ctags follows the convention that function names that start with a capital letter are class constructors.
2727

28+
Change since "0.0"
29+
~~~~~~~~~~~~~~~~~~
30+
31+
* New role ``foreigndecl`` for ``function`` kind
32+
2833
SEE ALSO
2934
--------
3035
ctags(1), ctags-client-tools(7)

parsers/jscript.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
#include "mbcs.h"
4949
#include "trace.h"
5050

51+
#include "jscript.h"
52+
5153
/*
5254
* MACROS
5355
*/
@@ -150,20 +152,6 @@ static objPool *TokenPool = NULL;
150152
static iconv_t JSUnicodeConverter = (iconv_t) -2;
151153
#endif
152154

153-
typedef enum {
154-
JSTAG_FUNCTION,
155-
JSTAG_CLASS,
156-
JSTAG_METHOD,
157-
JSTAG_PROPERTY,
158-
JSTAG_CONSTANT,
159-
JSTAG_VARIABLE,
160-
JSTAG_GENERATOR,
161-
JSTAG_GETTER,
162-
JSTAG_SETTER,
163-
JSTAG_FIELD,
164-
JSTAG_COUNT
165-
} jsKind;
166-
167155
/*
168156
* "chain element" role is introduced when adapting the JavaScript parser
169157
* to corkAPI.
@@ -255,6 +243,11 @@ typedef enum {
255243
JS_CLASS_CHAINELT,
256244
} jsClassRole;
257245

246+
static roleDefinition JsFunctionRoles [] = {
247+
/* Currently V parser wants this items. */
248+
{ true, "foreigndecl", "declared in foreign languages" },
249+
};
250+
258251
static roleDefinition JsVariableRoles [] = {
259252
{ false, "chainElt", "(EXPERIMENTAL)used as an element in a name chain like a.b.c" },
260253
};
@@ -264,7 +257,8 @@ static roleDefinition JsClassRoles [] = {
264257
};
265258

266259
static kindDefinition JsKinds [] = {
267-
{ true, 'f', "function", "functions" },
260+
{ true, 'f', "function", "functions",
261+
.referenceOnly = false, ATTACH_ROLES(JsFunctionRoles) },
268262
{ true, 'c', "class", "classes",
269263
.referenceOnly = false, ATTACH_ROLES(JsClassRoles) },
270264
{ true, 'm', "method", "methods" },
@@ -3324,5 +3318,8 @@ extern parserDefinition* JavaScriptParser (void)
33243318
def->useCork = CORK_QUEUE|CORK_SYMTAB;
33253319
def->requestAutomaticFQTag = true;
33263320

3321+
def->versionCurrent = 1;
3322+
def->versionAge = 1;
3323+
33273324
return def;
33283325
}

parsers/jscript.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2003, Darren Hiebert
3+
*
4+
* This source code is released for free distribution under the terms of the
5+
* GNU General Public License version 2 or (at your option) any later version.
6+
*
7+
* This module contains functions for generating tags for JavaScript language
8+
* files.
9+
*/
10+
11+
#ifndef CTAGS_JSCRIPT_H
12+
#define CTAGS_JSCRIPT_H
13+
14+
typedef enum {
15+
JSTAG_FUNCTION,
16+
JSTAG_CLASS,
17+
JSTAG_METHOD,
18+
JSTAG_PROPERTY,
19+
JSTAG_CONSTANT,
20+
JSTAG_VARIABLE,
21+
JSTAG_GENERATOR,
22+
JSTAG_GETTER,
23+
JSTAG_SETTER,
24+
JSTAG_FIELD,
25+
JSTAG_COUNT
26+
} jsKind;
27+
28+
typedef enum {
29+
JSTAG_FUNCTIONRoleFOREIGNDECL
30+
} JSTAGFunctionRole;
31+
32+
#endif

source.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ PARSER_HEADS = \
290290
parsers/bibtex.h \
291291
parsers/frontmatter.h \
292292
parsers/iniconf.h \
293+
parsers/jscript.h \
293294
parsers/m4.h \
294295
parsers/make.h \
295296
parsers/markdown.h \

win32/ctags_vs2013.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@
462462
<ClInclude Include="..\parsers\cxx\cxx_token_chain.h" />
463463
<ClInclude Include="..\parsers\frontmatter.h" />
464464
<ClInclude Include="..\parsers\iniconf.h" />
465+
<ClInclude Include="..\parsers\jscript.h" />
465466
<ClInclude Include="..\parsers\m4.h" />
466467
<ClInclude Include="..\parsers\make.h" />
467468
<ClInclude Include="..\parsers\markdown.h" />

win32/ctags_vs2013.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,9 @@
905905
<ClInclude Include="..\parsers\iniconf.h">
906906
<Filter>Header Files</Filter>
907907
</ClInclude>
908+
<ClInclude Include="..\parsers\jscript.h">
909+
<Filter>Header Files</Filter>
910+
</ClInclude>
908911
<ClInclude Include="..\parsers\m4.h">
909912
<Filter>Header Files</Filter>
910913
</ClInclude>

0 commit comments

Comments
 (0)