[geany/geany] 2fdcad: Allow Javascript new operator to apply to any object constructor

elextr git-noreply at xxxxx
Thu Jun 6 03:10:06 UTC 2013


Branch:      refs/heads/master
Author:      elextr <elextr at gmail.com>
Committer:   elextr <elextr at gmail.com>
Date:        Thu, 06 Jun 2013 03:10:06 UTC
Commit:      2fdcad6290d487d83d0135ada240db36c2368cbf
             https://github.com/geany/geany/commit/2fdcad6290d487d83d0135ada240db36c2368cbf

Log Message:
-----------
Allow Javascript new operator to apply to any object constructor

js.c only allowed keywords 'function' 'Function' or 'Object' after
'new' but js syntax allows any constructor function:

var name = new constructor_function( args );

ie an identifier where js.c allowed only keywords.
So changed js.c to allow any identifier as well as the keywords.


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

Modified: tagmanager/ctags/js.c
20 files changed, 15 insertions(+), 5 deletions(-)
===================================================================
@@ -1112,6 +1112,7 @@ static boolean parseStatement (tokenInfo *const token, boolean is_inside_class)
 	tokenInfo *const method_body_token = newToken ();
 	vString * saveScope = vStringNew ();
 	boolean is_class = FALSE;
+	boolean is_var = FALSE;
 	boolean is_terminated = TRUE;
 	boolean is_global = FALSE;
 	boolean has_methods = FALSE;
@@ -1495,9 +1496,11 @@ static boolean parseStatement (tokenInfo *const token, boolean is_inside_class)
 		else if (isKeyword (token, KEYWORD_new))
 		{
 			readToken (token);
+			is_var = isType (token, TOKEN_IDENTIFIER);
 			if ( isKeyword (token, KEYWORD_function) ||
 					isKeyword (token, KEYWORD_capital_function) ||
-					isKeyword (token, KEYWORD_capital_object) )
+					isKeyword (token, KEYWORD_capital_object) ||
+					is_var )
 			{
 				if ( isKeyword (token, KEYWORD_capital_object) )
 					is_class = TRUE;
@@ -1510,11 +1513,18 @@ static boolean parseStatement (tokenInfo *const token, boolean is_inside_class)
 				{
 					if ( token->nestLevel == 0 )
 					{
-						if ( is_class )
+						if ( is_var )
 						{
-							makeClassTag (name);
-						} else {
-							makeFunctionTag (name);
+							makeJsTag (name, JSTAG_VARIABLE);
+						}
+						else
+						{
+							if ( is_class )
+							{
+								makeClassTag (name);
+							} else {
+								makeFunctionTag (name);
+							}
 						}
 					}
 				}



--------------
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