Skip to content

Commit 18fb843

Browse files
committed
JavaScript: skip spread operators
Related to universal-ctags#3435. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
1 parent 1039940 commit 18fb843

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--sort=no
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
foo input.js /^const embedded = { foo: 'bar' }$/;" p variable:embedded
2+
embedded input.js /^const embedded = { foo: 'bar' }$/;" v
3+
baz input.js /^ baz: 'fox',$/;" p variable:something
4+
something input.js /^const something = {$/;" v
5+
mapGetters input.js /^const mapGetters = function() {}$/;" f
6+
computed input.js /^const computed = {$/;" C
7+
fn input.js /^ fn: () => { \/* doing something *\/ },$/;" m variable:FNO
8+
FNO input.js /^const FNO = {$/;" v
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// This test input is based on the comment submitted by AdrienGiboire in #3435
3+
//
4+
5+
const embedded = { foo: 'bar' }
6+
const something = {
7+
...embedded,
8+
baz: 'fox',
9+
}
10+
11+
const mapGetters = function() {}
12+
const computed = {
13+
...mapGetters([
14+
'getAsylumAssistant',
15+
'getModel',
16+
'getType',
17+
]),
18+
}
19+
20+
const FNO = {
21+
fn: () => { /* doing something */ },
22+
}

parsers/jscript.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,12 @@ static bool parseMethods (tokenInfo *const token, int class_index,
20192019

20202020
deleteToken (saved_token);
20212021
}
2022+
else if (isType (token, TOKEN_DOTS))
2023+
{
2024+
/* maybe spread operator. Just skip the next expression. */
2025+
findCmdTerm(token, true, true);
2026+
continue;
2027+
}
20222028

20232029
if (! isType (token, TOKEN_KEYWORD) &&
20242030
! isType (token, TOKEN_SEMICOLON))

0 commit comments

Comments
 (0)