diff --git a/Units/parser-javascript.r/spread-operator.d/args.ctags b/Units/parser-javascript.r/spread-operator.d/args.ctags new file mode 100644 index 0000000000..5ee5f79f70 --- /dev/null +++ b/Units/parser-javascript.r/spread-operator.d/args.ctags @@ -0,0 +1 @@ +--sort=no diff --git a/Units/parser-javascript.r/spread-operator.d/expected.tags b/Units/parser-javascript.r/spread-operator.d/expected.tags new file mode 100644 index 0000000000..87e8ac2005 --- /dev/null +++ b/Units/parser-javascript.r/spread-operator.d/expected.tags @@ -0,0 +1,8 @@ +foo input.js /^const embedded = { foo: 'bar' }$/;" p variable:embedded +embedded input.js /^const embedded = { foo: 'bar' }$/;" v +baz input.js /^ baz: 'fox',$/;" p variable:something +something input.js /^const something = {$/;" v +mapGetters input.js /^const mapGetters = function() {}$/;" f +computed input.js /^const computed = {$/;" C +fn input.js /^ fn: () => { \/* doing something *\/ },$/;" m variable:FNO +FNO input.js /^const FNO = {$/;" v diff --git a/Units/parser-javascript.r/spread-operator.d/input.js b/Units/parser-javascript.r/spread-operator.d/input.js new file mode 100644 index 0000000000..6d0c194c5a --- /dev/null +++ b/Units/parser-javascript.r/spread-operator.d/input.js @@ -0,0 +1,22 @@ +// +// This test input is based on the comment submitted by AdrienGiboire in #3435 +// + +const embedded = { foo: 'bar' } +const something = { + ...embedded, + baz: 'fox', +} + +const mapGetters = function() {} +const computed = { + ...mapGetters([ + 'getAsylumAssistant', + 'getModel', + 'getType', + ]), +} + +const FNO = { + fn: () => { /* doing something */ }, +} diff --git a/parsers/jscript.c b/parsers/jscript.c index 78f563ddec..44f694065a 100644 --- a/parsers/jscript.c +++ b/parsers/jscript.c @@ -2019,6 +2019,12 @@ static bool parseMethods (tokenInfo *const token, int class_index, deleteToken (saved_token); } + else if (isType (token, TOKEN_DOTS)) + { + /* maybe spread operator. Just skip the next expression. */ + findCmdTerm(token, true, true); + continue; + } if (! isType (token, TOKEN_KEYWORD) && ! isType (token, TOKEN_SEMICOLON))