@@ -305,6 +305,18 @@ describe "JavaScript grammar", ->
305
305
expect ( tokens [ 1 ] ) . toEqual value: '...' , scopes : [ 'source.js' , 'keyword.operator.spread.js' ]
306
306
expect ( tokens [ 2 ] ) . toEqual value: 'iterableObj' , scopes : [ 'source.js' ]
307
307
308
+ { tokens } = grammar . tokenizeLine ( '...arguments' )
309
+ expect ( tokens [ 0 ] ) . toEqual value: '...' , scopes : [ 'source.js' , 'keyword.operator.spread.js' ]
310
+ expect ( tokens [ 1 ] ) . toEqual value: 'arguments' , scopes : [ 'source.js' , 'variable.language.js' ]
311
+
312
+ { tokens } = grammar . tokenizeLine ( '...super' )
313
+ expect ( tokens [ 0 ] ) . toEqual value: '...' , scopes : [ 'source.js' , 'keyword.operator.spread.js' ]
314
+ expect ( tokens [ 1 ] ) . toEqual value: 'super' , scopes : [ 'source.js' , 'variable.language.js' ]
315
+
316
+ { tokens } = grammar . tokenizeLine ( '...this' )
317
+ expect ( tokens [ 0 ] ) . toEqual value: '...' , scopes : [ 'source.js' , 'keyword.operator.spread.js' ]
318
+ expect ( tokens [ 1 ] ) . toEqual value: 'this' , scopes : [ 'source.js' , 'variable.language.js' ]
319
+
308
320
describe "increment, decrement" , - >
309
321
it "tokenizes increment" , - >
310
322
{ tokens} = grammar . tokenizeLine ( 'i++' )
@@ -2063,6 +2075,54 @@ describe "JavaScript grammar", ->
2063
2075
expect(tokens[6]).toEqual value: "[ variable = ' default value ' ]", scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2064
2076
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2065
2077
2078
+ {tokens} = grammar.tokenizeLine('/** @param {Object} [variable={a: "b"}] - An object */')
2079
+ expect(tokens[4]).toEqual value: '{Object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2080
+ expect(tokens[6]).toEqual value: '[variable={a: "b"}]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2081
+ expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc']
2082
+ expect(tokens[8]).toEqual value: 'An object ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2083
+
2084
+ {tokens} = grammar.tokenizeLine('/** @param {Object} [ variable = { a : "b" } ] - An object */')
2085
+ expect(tokens[4]).toEqual value: '{Object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2086
+ expect(tokens[6]).toEqual value: '[ variable = { a : "b" } ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2087
+ expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc']
2088
+ expect(tokens[8]).toEqual value: 'An object ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2089
+
2090
+ {tokens} = grammar.tokenizeLine('/** @param {Array} [variable=[1,2,3]] - An array */')
2091
+ expect(tokens[4]).toEqual value: '{Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2092
+ expect(tokens[6]).toEqual value: '[variable=[1,2,3]]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2093
+ expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc']
2094
+ expect(tokens[8]).toEqual value: 'An array ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2095
+
2096
+ {tokens} = grammar.tokenizeLine('/** @param {Array} [ variable = [ 1 , 2 , 3 ] ] - An array */')
2097
+ expect(tokens[4]).toEqual value: '{Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2098
+ expect(tokens[6]).toEqual value: '[ variable = [ 1 , 2 , 3 ] ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2099
+ expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc']
2100
+ expect(tokens[8]).toEqual value: 'An array ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2101
+
2102
+ {tokens} = grammar.tokenizeLine('/** @param {Object} [variable={}] - Empty object */')
2103
+ expect(tokens[4]).toEqual value: '{Object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2104
+ expect(tokens[6]).toEqual value: '[variable={}]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2105
+ expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc']
2106
+ expect(tokens[8]).toEqual value: 'Empty object ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2107
+
2108
+ {tokens} = grammar.tokenizeLine('/** @param {Object} [ variable = { } ] - Empty object */')
2109
+ expect(tokens[4]).toEqual value: '{Object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2110
+ expect(tokens[6]).toEqual value: '[ variable = { } ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2111
+ expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc']
2112
+ expect(tokens[8]).toEqual value: 'Empty object ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2113
+
2114
+ {tokens} = grammar.tokenizeLine('/** @param {Array} [variable=[]] - Empty array */')
2115
+ expect(tokens[4]).toEqual value: '{Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2116
+ expect(tokens[6]).toEqual value: '[variable=[]]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2117
+ expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc']
2118
+ expect(tokens[8]).toEqual value: 'Empty array ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2119
+
2120
+ {tokens} = grammar.tokenizeLine('/** @param {Array} [ variable = [ ] ] - Empty array */')
2121
+ expect(tokens[4]).toEqual value: '{Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2122
+ expect(tokens[6]).toEqual value: '[ variable = [ ] ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2123
+ expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc']
2124
+ expect(tokens[8]).toEqual value: 'Empty array ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2125
+
2066
2126
{tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a {@link linked} description */')
2067
2127
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2068
2128
expect(tokens[8]).toEqual value: 'this is a ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
@@ -2182,6 +2242,16 @@ describe "JavaScript grammar", ->
2182
2242
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2183
2243
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2184
2244
2245
+ {tokens} = grammar.tokenizeLine('/** @param {...*} remainder */')
2246
+ expect(tokens[2]).toEqual value: '@param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc']
2247
+ expect(tokens[4]).toEqual value: '{...*}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2248
+ expect(tokens[6]).toEqual value: 'remainder', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2249
+
2250
+ {tokens} = grammar.tokenizeLine('/** @param {...?} remainder */')
2251
+ expect(tokens[2]).toEqual value: '@param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc']
2252
+ expect(tokens[4]).toEqual value: '{...?}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2253
+ expect(tokens[6]).toEqual value: 'remainder', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2254
+
2185
2255
{tokens} = grammar.tokenizeLine('/** @param {number=} variable this is the description */')
2186
2256
expect(tokens[4]).toEqual value: '{number=}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2187
2257
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
@@ -2339,6 +2409,14 @@ describe "JavaScript grammar", ->
2339
2409
{tokens} = grammar.tokenizeLine('/** @return {Some|Thing} Something to return */')
2340
2410
expect(tokens[4]).toEqual value: '{Some|Thing}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2341
2411
2412
+ {tokens} = grammar.tokenizeLine('/** @return {(String[]|Number[])} Description */')
2413
+ expect(tokens[4]).toEqual value: '{(String[]|Number[])}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2414
+ expect(tokens[6]).toEqual value: 'Description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
2415
+
2416
+ {tokens} = grammar.tokenizeLine('/** @param {(Number|Number[])} Numbers */')
2417
+ expect(tokens[4]).toEqual value: '{(Number|Number[])}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2418
+ expect(tokens[6]).toEqual value: 'Numbers', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
2419
+
2342
2420
{tokens} = grammar.tokenizeLine('/** @return {object} */')
2343
2421
expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
2344
2422
0 commit comments