Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Mon, 24 Nov 2014 01:43:29 UTC Commit: 7e6215661e64475a891921848149bd12a57c8a65 https://github.com/geany/geany/commit/7e6215661e64475a891921848149bd12a57c8a...
Log Message: ----------- javascript: Fix handling some class-related unterminated statements
Modified Paths: -------------- tagmanager/ctags/js.c tests/ctags/Makefile.am tests/ctags/js-class-related-unterminated.js tests/ctags/js-class-related-unterminated.js.tags
Modified: tagmanager/ctags/js.c 11 lines changed, 7 insertions(+), 4 deletions(-) =================================================================== @@ -967,7 +967,7 @@ static boolean parseBlock (tokenInfo *const token, tokenInfo *const orig_parent) * Ignore the remainder of the line * findCmdTerm(token); */ - parseLine (token, is_class); + read_next_token = parseLine (token, is_class);
vStringCopy(token->scope, saveScope); } @@ -979,7 +979,7 @@ static boolean parseBlock (tokenInfo *const token, tokenInfo *const orig_parent) */ vStringCopy(saveScope, token->scope); addToScope (token, parent->string); - parseLine (token, is_class); + read_next_token = parseLine (token, is_class); vStringCopy(token->scope, saveScope); } else if (isKeyword (token, KEYWORD_function)) @@ -1287,9 +1287,12 @@ static boolean parseStatement (tokenInfo *const token, boolean is_inside_class) }
if ( isType (method_body_token, TOKEN_OPEN_CURLY)) + { parseBlock (method_body_token, token); - - is_terminated = TRUE; + is_terminated = TRUE; + } + else + is_terminated = isType (method_body_token, TOKEN_SEMICOLON); goto cleanUp; } }
Modified: tests/ctags/Makefile.am 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -159,6 +159,7 @@ test_sources = \ intro.tex \ invalid_name.f90 \ java_enum.java \ + js-class-related-unterminated.js \ js-scope.js \ js-unknown-construct-nesting.js \ jsFunc_tutorial.js \
Modified: tests/ctags/js-class-related-unterminated.js 50 lines changed, 50 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,50 @@ + +var Cls = { + // add a member just so Cls is recognized as a class from the start + A: {} +} + +Cls.B = function(a, b) { + this.a = a; + this.b = b; +} + +Cls.B.Sub = function() { + this.a = 0 +} + +Cls.B.prototype.m1 = function(a) { + this.a = a; + if (a > 2) { + this.a *= 2 + } +} +Cls.B.prototype.m2 = function(b) { + var a = b +} +Cls.B.prototype.m3 = function(c) { + this.c = c +} +Cls.B.prototype.m4 = function(d) { + this.d = d +} +Cls.B.prototype.m5 = function(e) { + /* this should rather be written `Cls.B.Sub.prototype.dyn1 = this.m6`, but + * then parser then thinks it's a child of this very scope. it isn't really + * possible to fix this as the only reason it's actually not a child of the + * current scope is because it exists in the root scope but not in this one */ + var Sub = Cls.B.Sub; + Sub.prototype.dyn1 = this.m4 +} +Cls.B.prototype.m6 = function(f) { +} + +function main() { + var c = new Cls.B(1, 2); + var d = new Cls.B.Sub(); + print(d.dyn1); + c.m5(); + print(d.dyn1); +} + +main();
Modified: tests/ctags/js-class-related-unterminated.js.tags 13 lines changed, 13 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,13 @@ +# format=tagmanager +A�64�Cls�0 +B�1�Cls�0 +Cls�1�0 +Sub�1�Cls.B�0 +dyn1�128�Cls.B.Sub�0 +m1�128�Cls.B�0 +m2�128�Cls.B�0 +m3�128�Cls.B�0 +m4�128�Cls.B�0 +m5�128�Cls.B�0 +m6�128�Cls.B�0 +main�16�0
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).