[geany/geany] ef8c40: javascript: Add support for the `const` keyword
Colomban Wendling
git-noreply at xxxxx
Mon Nov 24 01:59:08 UTC 2014
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Mon, 24 Nov 2014 01:59:08 UTC
Commit: ef8c40f1e44e03059f34f7dc00ff82a8a089b10a
https://github.com/geany/geany/commit/ef8c40f1e44e03059f34f7dc00ff82a8a089b10a
Log Message:
-----------
javascript: Add support for the `const` keyword
`const` is not yet part of the current ECMAScript standard but is
part of the ECMAScript 6 draft and is supported by popular engines
including Mozilla and WebKit, and people already use it.
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const
Modified Paths:
--------------
tagmanager/ctags/js.c
tests/ctags/Makefile.am
tests/ctags/js-const.js
tests/ctags/js-const.js.tags
Modified: tagmanager/ctags/js.c
20 lines changed, 14 insertions(+), 6 deletions(-)
===================================================================
@@ -58,6 +58,7 @@ typedef enum eKeywordId {
KEYWORD_capital_object,
KEYWORD_prototype,
KEYWORD_var,
+ KEYWORD_const,
KEYWORD_new,
KEYWORD_this,
KEYWORD_for,
@@ -131,6 +132,7 @@ typedef enum {
JSTAG_CLASS,
JSTAG_METHOD,
JSTAG_PROPERTY,
+ JSTAG_CONSTANT,
JSTAG_VARIABLE,
JSTAG_COUNT
} jsKind;
@@ -140,6 +142,7 @@ static kindOption JsKinds [] = {
{ TRUE, 'c', "class", "classes" },
{ TRUE, 'm', "method", "methods" },
{ TRUE, 'p', "member", "properties" },
+ { TRUE, 'C', "macro", "constants" },
{ TRUE, 'v', "variable", "global variables" }
};
@@ -150,6 +153,7 @@ static const keywordDesc JsKeywordTable [] = {
{ "Object", KEYWORD_capital_object },
{ "prototype", KEYWORD_prototype },
{ "var", KEYWORD_var },
+ { "const", KEYWORD_const },
{ "new", KEYWORD_new },
{ "this", KEYWORD_this },
{ "for", KEYWORD_for },
@@ -1079,7 +1083,8 @@ static boolean parseBlock (tokenInfo *const token, tokenInfo *const orig_parent)
vStringCopy(token->scope, saveScope);
}
- else if (isKeyword (token, KEYWORD_var))
+ else if (isKeyword (token, KEYWORD_var) ||
+ isKeyword (token, KEYWORD_const))
{
/*
* Potentially we have found an inner function.
@@ -1253,6 +1258,7 @@ static boolean parseStatement (tokenInfo *const token, tokenInfo *const parent,
vString * saveScope = vStringNew ();
boolean is_class = FALSE;
boolean is_var = FALSE;
+ boolean is_const = FALSE;
boolean is_terminated = TRUE;
boolean is_global = FALSE;
boolean has_methods = FALSE;
@@ -1292,8 +1298,10 @@ static boolean parseStatement (tokenInfo *const token, tokenInfo *const parent,
/*
* var can preceed an inner function
*/
- if ( isKeyword(token, KEYWORD_var) )
+ if ( isKeyword(token, KEYWORD_var) ||
+ isKeyword(token, KEYWORD_const) )
{
+ is_const = isKeyword(token, KEYWORD_const);
/*
* Only create variables for global scope
*/
@@ -1482,7 +1490,7 @@ static boolean parseStatement (tokenInfo *const token, tokenInfo *const parent,
* var g_var2;
*/
if (isType (token, TOKEN_SEMICOLON))
- makeJsTag (name, JSTAG_VARIABLE, NULL);
+ makeJsTag (name, is_const ? JSTAG_CONSTANT : JSTAG_VARIABLE, NULL);
}
/*
* Statement has ended.
@@ -1617,7 +1625,7 @@ static boolean parseStatement (tokenInfo *const token, tokenInfo *const parent,
if ( ! stringListHas(FunctionNames, vStringValue (fulltag)) &&
! stringListHas(ClassNames, vStringValue (fulltag)) )
{
- makeJsTag (name, JSTAG_VARIABLE, NULL);
+ makeJsTag (name, is_const ? JSTAG_CONSTANT : JSTAG_VARIABLE, NULL);
}
vStringDelete (fulltag);
}
@@ -1653,7 +1661,7 @@ static boolean parseStatement (tokenInfo *const token, tokenInfo *const parent,
{
if ( is_var )
{
- makeJsTag (name, JSTAG_VARIABLE, NULL);
+ makeJsTag (name, is_const ? JSTAG_CONSTANT : JSTAG_VARIABLE, NULL);
}
else
{
@@ -1708,7 +1716,7 @@ static boolean parseStatement (tokenInfo *const token, tokenInfo *const parent,
if ( ! stringListHas(FunctionNames, vStringValue (fulltag)) &&
! stringListHas(ClassNames, vStringValue (fulltag)) )
{
- makeJsTag (name, JSTAG_VARIABLE, NULL);
+ makeJsTag (name, is_const ? JSTAG_CONSTANT : JSTAG_VARIABLE, NULL);
}
vStringDelete (fulltag);
}
Modified: tests/ctags/Makefile.am
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -160,6 +160,7 @@ test_sources = \
invalid_name.f90 \
java_enum.java \
js-class-related-unterminated.js \
+ js-const.js \
js-implicit-semicolons.js \
js-scope.js \
js-signature.js \
Modified: tests/ctags/js-const.js
10 lines changed, 10 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,10 @@
+
+const A = 1;
+const B = 1;
+const Group = {
+ X:1,
+ Y:2,
+ Z:3
+};
+
+const func = function () {}
Modified: tests/ctags/js-const.js.tags
8 lines changed, 8 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,8 @@
+# format=tagmanager
+A�65536�0
+B�65536�0
+Group�1�0
+X�64�Group�0
+Y�64�Group�0
+Z�64�Group�0
+func�16�()�0
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list