javascript: Improve support for unterminated statements
commitb85d7546102cdbe368cf130a37e67689f317fc81
authorColomban Wendling <ban@herbesfolles.org>
Sun, 23 Nov 2014 16:09:02 +0000 (23 17:09 +0100)
committerColomban Wendling <ban@herbesfolles.org>
Mon, 24 Nov 2014 01:57:38 +0000 (24 02:57 +0100)
treea2a11eb4586ec173738e93b4681b76614c7a8aad
parentf2b368e2cc507f9b074ff12f412ea222d273bb84
javascript: Improve support for unterminated statements

Add support for implicit semicolons so many unterminated statements'
end are properly recognized.

The implementation doesn't follow the ECMAScript standard because doing
so requires to recognize precise grammar of all constructs, and the
parser doesn't currently work this way.  So instead it uses some
heuristics that should work most of the time and only consider implicit
semicolons where they would be explicitly relevant to avoid most false-
positives.  See the extensive comment in `readTokenFull()` for details.

In practice, this mostly fixes handling of files using unterminated
variable assignations like the following:

    var v1 = 0
    var v2 = 1
    // ...
    function f1() {
        // ...
    }

In such situations the parser used not to be able to really tell where
the variable assignation would end and would not recognize any
statement before the next semicolon or closing curly brace at the same
level.  In practice, it wouldn't have emitted any tag for this example,
not even `v1` as it generates tags when reaching the statement's end.
tagmanager/ctags/js.c
tests/ctags/Makefile.am
tests/ctags/js-implicit-semicolons.js [new file with mode: 0644]
tests/ctags/js-implicit-semicolons.js.tags [new file with mode: 0644]