Skip to content

Commit 1b849ae

Browse files
committed
Add support for bracketed-type notation
Refs: jsdoc/jsdoc#1104
1 parent 2c1ca8c commit 1b849ae

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

grammars/javascript.cson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,7 @@
16811681
}
16821682
{
16831683
'match': '''(?x)
1684-
({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*(?:\\[\\])?=?)})
1684+
({(?:\\*|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*\\)|[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*)(?:\\[\\])?=?)})
16851685
\\s+
16861686
(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*))
16871687
\\s+

spec/javascript-spec.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,11 @@ describe "Javascript grammar", ->
14971497
expect(tokens[4]).toEqual value: '{Function|String}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
14981498
expect(tokens[6]).toEqual value: 'callback', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
14991499

1500+
{tokens} = grammar.tokenizeLine('/** @param {(Number|Function)} types - Bracket notation */')
1501+
expect(tokens[2]).toEqual value: '@param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc']
1502+
expect(tokens[4]).toEqual value: '{(Number|Function)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
1503+
expect(tokens[6]).toEqual value: 'types', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
1504+
15001505
{tokens} = grammar.tokenizeLine('/** @param {?number} variable this is the description */')
15011506
expect(tokens[4]).toEqual value: '{?number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
15021507
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']

0 commit comments

Comments
 (0)