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

Commit 605d040

Browse files
author
Wliu
authored
Merge pull request #399 from bgriffith/feature/jsdoc
Improve JSDoc type support
2 parents 1781408 + a86ab62 commit 605d040

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

grammars/javascript.cson

+1-1
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_$][\\w$]*)\\b})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)'
1608+
'match': '({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)'
16091609
'captures':
16101610
0:
16111611
'name': 'other.meta.jsdoc'

spec/javascript-spec.coffee

+25
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,31 @@ describe "Javascript grammar", ->
15291529
expect(tokens[6]).toEqual value: 'parameter.property', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
15301530
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
15311531

1532+
{tokens} = grammar.tokenizeLine('/** @param {*} variable this is the description */')
1533+
expect(tokens[4]).toEqual value: '{*}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
1534+
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
1535+
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
1536+
1537+
{tokens} = grammar.tokenizeLine('/** @param {myNamespace.MyClass} variable this is the description */')
1538+
expect(tokens[4]).toEqual value: '{myNamespace.MyClass}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
1539+
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
1540+
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
1541+
1542+
{tokens} = grammar.tokenizeLine('/** @param {?number} variable this is the description */')
1543+
expect(tokens[4]).toEqual value: '{?number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
1544+
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
1545+
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
1546+
1547+
{tokens} = grammar.tokenizeLine('/** @param {!number} variable this is the description */')
1548+
expect(tokens[4]).toEqual value: '{!number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
1549+
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
1550+
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
1551+
1552+
{tokens} = grammar.tokenizeLine('/** @param {...number} variable this is the description */')
1553+
expect(tokens[4]).toEqual value: '{...number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc']
1554+
expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc']
1555+
expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc']
1556+
15321557
it "tokenizes // comments", ->
15331558
{tokens} = grammar.tokenizeLine('// comment')
15341559
expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js']

0 commit comments

Comments
 (0)