Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 54b926a

Browse files
author
Wliu
authored
Merge pull request #395 from bgriffith/feature/jsdoc
Add support for JSDoc optional parameters and default values
2 parents e4fbe38 + d7afe49 commit 54b926a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

grammars/javascript.cson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1605,7 +1605,7 @@
16051605
'name': 'storage.type.class.jsdoc'
16061606
}
16071607
{
1608-
'match': '({\\b(?:[a-zA-Z_$][a-zA-Z_$0-9]*)\\b})\\s+\\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b\\s*((?:(?!\\*\\/).)*)'
1608+
'match': '({\\b(?:[a-zA-Z_$][\\w$]*)\\b})\\s+(\\[\\b(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\b\\]|\\b(?:[a-zA-Z_$][\\w$]*)\\b)\\s*((?:(?!\\*\\/).)*)'
16091609
'captures':
16101610
0:
16111611
'name': 'other.meta.jsdoc'

spec/javascript-spec.coffee

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,16 @@ describe "Javascript grammar", ->
15091509
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
15101510
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
15111511

1512+
{tokens} = grammar.tokenizeLine('/** @param {object} [variable] this is the description */')
1513+
expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
1514+
expect(tokens[6]).toEqual value: '[variable]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
1515+
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
1516+
1517+
{tokens} = grammar.tokenizeLine('/** @param {object} [variable=default value] this is the description */')
1518+
expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
1519+
expect(tokens[6]).toEqual value: '[variable=default value]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
1520+
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
1521+
15121522
it "tokenizes // comments", ->
15131523
{tokens} = grammar.tokenizeLine('// comment')
15141524
expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js']

0 commit comments

Comments
 (0)