From b063622189d2a8576a5044283e2650b2841060bf Mon Sep 17 00:00:00 2001 From: Alhadis Date: Fri, 10 Mar 2017 16:27:50 +1100 Subject: [PATCH 01/12] Fix boundary-matching with arrays as default values --- grammars/jsdoc.cson | 80 ++++-- spec/jsdoc-spec.coffee | 565 +++++++++++++++++++++++------------------ 2 files changed, 383 insertions(+), 262 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index 1cb84a2a..bc0ba222 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -252,28 +252,29 @@ 'name': 'variable.other.jsdoc' } { - 'name': 'variable.other.jsdoc' 'begin': '\\[' - 'end': '\\]|(?=\\*/)' + 'beginCaptures': + '0': + 'name': 'variable.other.jsdoc' + 'contentName': 'variable.other.jsdoc' + 'end': '(\\])((?:[^*\\s]|\\*[^\\s/])+)?|(?=\\*/)' + 'endCaptures': + '1': + 'name': 'variable.other.jsdoc' + '2': + 'name': 'invalid.illegal.syntax.jsdoc' 'patterns': [ { - 'match': '(=)((?:[^\\]*]|\\*[^/])*)' - 'captures': - '1': + 'begin': '=' + 'beginCaptures': + '0': 'name': 'keyword.operator.assignment.jsdoc' - '2': - 'name': 'source.embedded.js' - 'patterns': [ - { - 'include': '#inline-tags' - } - { - 'include': 'source.js' - } - ] - } - { - 'include': '#brackets' + 'end': '(?=\\]|\\*/)' + 'patterns': [ + { + 'include': '#default-value' + } + ] } { 'include': '#quotes' @@ -411,6 +412,49 @@ ] } ] + # Default @param value, highlighted as JavaScript + 'default-value': + 'patterns': [ + { + # Nested arrays matched to keep brackets balanced + 'begin': '(\\[)' + 'beginCaptures': + '0': + 'name': 'source.embedded.js' + '1': + # NOTE: Should ideally be "punctuation.definition.bracket.square.begin.js" + # We're using the old/"incorrect" scope to ensure consistent highlighting. + 'name': 'meta.brace.square.js' + 'end': '(\\])|(?=\\*/)' + 'endCaptures': + '0': + 'name': 'source.embedded.js' + '1': + 'name': 'meta.brace.square.js' + 'patterns': [ + { + 'include': '#default-value' + } + ] + } + # Chunk of JS source (excluding nested arrays; see above). Note we "clamp" the + # imported highlighting within a fixed range to stop runaway problems with any + # begin/end patterns the JavaScript grammar matches. + { + 'match': '(?:[^\\[\\]*]|\\*[^/])+' + 'name': 'source.embedded.js' + 'captures': + '0': + 'patterns': [ + { + 'include': '#inline-tags' + } + { + 'include': 'source.js' + } + ] + } + ] 'inline-tags': 'patterns': [ { diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index 6163992d..c3317bb0 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -280,247 +280,325 @@ describe "JSDoc grammar", -> expect(tokens[11]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - it "tokenises @param tags with unquoted default values", -> - {tokens} = grammar.tokenizeLine('/** @param {object} [variable=default value] this is the description */') - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[12]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] - expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[14]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [variable = default value] this is the description */') - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: 'variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[12]).toEqual value: ' default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] - expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[14]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [ variable = default value ] this is the description */') - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[12]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] - expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[14]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [variable=default.value] this is the description */') - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[12]).toEqual value: 'default', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'variable.other.object.js'] - expect(tokens[13]).toEqual value: '.', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.property.period.js'] - expect(tokens[14]).toEqual value: 'value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'support.variable.property.dom.js'] - expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[16]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - - it "tokenises @param tags with quoted default values", -> - {tokens} = grammar.tokenizeLine('/** @param {object} [variable="default value"] this is the description */') - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[13]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[16]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [variable = "default value"] this is the description */') - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: 'variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[14]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[15]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(tokens[16]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[17]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [ variable = " default value " ] this is the description */') - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[14]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[15]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[18]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - - {tokens} = grammar.tokenizeLine("/** @param {object} [variable='default value'] this is the description */") - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[12]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] - expect(tokens[13]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js'] - expect(tokens[14]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] - expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[16]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - - {tokens} = grammar.tokenizeLine("/** @param {object} [variable = 'default value'] this is the description */") - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: 'variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] - expect(tokens[14]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js'] - expect(tokens[15]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] - expect(tokens[16]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[17]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - - {tokens} = grammar.tokenizeLine("/** @param {object} [ variable = ' default value ' ] this is the description */") - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] - expect(tokens[14]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js'] - expect(tokens[15]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] - expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[18]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - - it "tokenises @param tags with objects as default values", -> - {tokens} = grammar.tokenizeLine('/** @param {Object} [variable={a: "b"}] - An object */') - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'Object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[12]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] - expect(tokens[13]).toEqual value: 'a', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] - expect(tokens[14]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] - expect(tokens[16]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[17]).toEqual value: 'b', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[18]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(tokens[19]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] - expect(tokens[20]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[21]).toEqual value: ' - An object ', scopes: ['source.js', 'comment.block.documentation.js'] - - {tokens} = grammar.tokenizeLine('/** @param {Object} [ variable = { a : "b" } ] - An object */') - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'Object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] - expect(tokens[14]).toEqual value: ' a ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] - expect(tokens[15]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] - expect(tokens[17]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[18]).toEqual value: 'b', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[19]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(tokens[21]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] - expect(tokens[23]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[24]).toEqual value: ' - An object ', scopes: ['source.js', 'comment.block.documentation.js'] - - {tokens} = grammar.tokenizeLine('/** @param {Object} [variable={}] - Empty object */') - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'Object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[12]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'punctuation.section.scope.begin.js'] - expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'punctuation.section.scope.end.js'] - expect(tokens[14]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[15]).toEqual value: ' - Empty object ', scopes: ['source.js', 'comment.block.documentation.js'] - - {tokens} = grammar.tokenizeLine('/** @param {Object} [ variable = { } ] - Empty object */') - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'Object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] - expect(tokens[15]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] - expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[18]).toEqual value: ' - Empty object ', scopes: ['source.js', 'comment.block.documentation.js'] - - it "tokenises @param tags with arrays as default values", -> - {tokens} = grammar.tokenizeLine('/** @param {Array} [variable=[1,2,3]] - An array */') - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'Array', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[12]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] - expect(tokens[13]).toEqual value: '1', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] - expect(tokens[14]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] - expect(tokens[15]).toEqual value: '2', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] - expect(tokens[16]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] - expect(tokens[17]).toEqual value: '3', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] - expect(tokens[18]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[19]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[20]).toEqual value: ' - An array ', scopes: ['source.js', 'comment.block.documentation.js'] - - {tokens} = grammar.tokenizeLine('/** @param {Array} [ variable = [ 1 , 2 , 3 ] ] - An array */') - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'Array', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] - expect(tokens[15]).toEqual value: '1', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] - expect(tokens[17]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] - expect(tokens[19]).toEqual value: '2', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] - expect(tokens[21]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] - expect(tokens[23]).toEqual value: '3', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] - expect(tokens[25]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[26]).toEqual value: ' ] - An array ', scopes: ['source.js', 'comment.block.documentation.js'] - - {tokens} = grammar.tokenizeLine('/** @param {Array} [variable=[]] - Empty array */') - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'Array', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[12]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] - expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[14]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[15]).toEqual value: ' - Empty array ', scopes: ['source.js', 'comment.block.documentation.js'] - - {tokens} = grammar.tokenizeLine('/** @param {Array} [ variable = [ ] ] - Empty array */') - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'Array', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] - expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[16]).toEqual value: ' ] - Empty array ', scopes: ['source.js', 'comment.block.documentation.js'] + describe "default @param values", -> + it "tokenises unquoted values", -> + {tokens} = grammar.tokenizeLine('/** @param {object} [variable=default value] this is the description */') + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[12]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[14]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {object} [variable = default value] this is the description */') + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[12]).toEqual value: ' default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[14]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {object} [ variable = default value ] this is the description */') + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[12]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[14]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {object} [variable=default.value] this is the description */') + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[12]).toEqual value: 'default', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'variable.other.object.js'] + expect(tokens[13]).toEqual value: '.', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.property.period.js'] + expect(tokens[14]).toEqual value: 'value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'support.variable.property.dom.js'] + expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[16]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + it "tokenises double-quoted values", -> + {tokens} = grammar.tokenizeLine('/** @param {object} [variable="default value"] this is the description */') + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] + expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[16]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {object} [variable = "default value"] this is the description */') + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[13]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[14]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] + expect(tokens[15]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[16]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[17]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {object} [ variable = " default value " ] this is the description */') + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[13]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[14]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] + expect(tokens[15]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[18]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + it "tokenises single-quoted values", -> + {tokens} = grammar.tokenizeLine("/** @param {object} [variable='default value'] this is the description */") + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[12]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js'] + expect(tokens[14]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] + expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[16]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine("/** @param {object} [variable = 'default value'] this is the description */") + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[13]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] + expect(tokens[14]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js'] + expect(tokens[15]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] + expect(tokens[16]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[17]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine("/** @param {object} [ variable = ' default value ' ] this is the description */") + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[13]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] + expect(tokens[14]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js'] + expect(tokens[15]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] + expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[18]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + it "tokenises object literals", -> + {tokens} = grammar.tokenizeLine('/** @param {Object} [variable={a: "b"}] - An object */') + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'Object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[12]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] + expect(tokens[13]).toEqual value: 'a', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[14]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] + expect(tokens[16]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[17]).toEqual value: 'b', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] + expect(tokens[18]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[19]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] + expect(tokens[20]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[21]).toEqual value: ' - An object ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Object} [ variable = { a : "b" } ] - An object */') + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'Object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[13]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] + expect(tokens[14]).toEqual value: ' a ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[15]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] + expect(tokens[17]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[18]).toEqual value: 'b', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] + expect(tokens[19]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[21]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] + expect(tokens[23]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[24]).toEqual value: ' - An object ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Object} [variable={}] - Empty object */') + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'Object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[12]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'punctuation.section.scope.begin.js'] + expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'punctuation.section.scope.end.js'] + expect(tokens[14]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[15]).toEqual value: ' - Empty object ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Object} [ variable = { } ] - Empty object */') + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'Object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[13]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] + expect(tokens[15]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] + expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[18]).toEqual value: ' - Empty object ', scopes: ['source.js', 'comment.block.documentation.js'] + + it "tokenises arrays", -> + {tokens} = grammar.tokenizeLine('/** @param {Array} [variable=[1,2,3]] - An array */') + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'Array', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[12]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[13]).toEqual value: '1', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] + expect(tokens[14]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] + expect(tokens[15]).toEqual value: '2', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] + expect(tokens[16]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] + expect(tokens[17]).toEqual value: '3', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] + expect(tokens[18]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[19]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[20]).toEqual value: ' - An array ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Array} [ variable = [ 1 , 2 , 3 ] ] - An array */') + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'Array', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[13]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[15]).toEqual value: '1', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] + expect(tokens[17]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] + expect(tokens[19]).toEqual value: '2', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] + expect(tokens[21]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] + expect(tokens[23]).toEqual value: '3', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] + expect(tokens[25]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[27]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[28]).toEqual value: ' - An array ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[29]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Array} [variable=[]] - Empty array */') + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'Array', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[12]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[14]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[15]).toEqual value: ' - Empty array ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Array} [ variable = [ ] ] - Empty array */') + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'Array', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] + expect(tokens[13]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[14]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[16]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[18]).toEqual value: ' - Empty array ', scopes: ['source.js', 'comment.block.documentation.js'] + + it "tokenises arrays inside object literals", -> + {tokens} = grammar.tokenizeLine('/** @param {Object} [thing={a: [], b: [0, 2], c: "String"}] [Not Highlighted] [] [] [] */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[2]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(tokens[3]).toEqual value: 'param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'Object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'thing', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] + expect(tokens[12]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] + expect(tokens[13]).toEqual value: 'a', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[14]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] + expect(tokens[16]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[18]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] + expect(tokens[19]).toEqual value: ' b', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[20]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] + expect(tokens[22]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[23]).toEqual value: '0', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] + expect(tokens[24]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] + expect(tokens[26]).toEqual value: '2', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] + expect(tokens[27]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[28]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] + expect(tokens[29]).toEqual value: ' c', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[30]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] + expect(tokens[32]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[33]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] + expect(tokens[34]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[35]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[36]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[37]).toEqual value: ' [Not Highlighted] [] [] [] ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[38]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + it "flags any description text touching the closing bracket", -> + {tokens} = grammar.tokenizeLine('/** @param {Object} [thing={a: [], b: [0, 2], c: "String"}][Bad Description] [] [] [] */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[2]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(tokens[3]).toEqual value: 'param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'Object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'thing', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] + expect(tokens[12]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] + expect(tokens[13]).toEqual value: 'a', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[14]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] + expect(tokens[16]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[18]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] + expect(tokens[19]).toEqual value: ' b', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[20]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] + expect(tokens[22]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[23]).toEqual value: '0', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] + expect(tokens[24]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] + expect(tokens[26]).toEqual value: '2', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] + expect(tokens[27]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[28]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] + expect(tokens[29]).toEqual value: ' c', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[30]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] + expect(tokens[32]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[33]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] + expect(tokens[34]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[35]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[36]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[37]).toEqual value: '[Bad', scopes: ['source.js', 'comment.block.documentation.js', 'invalid.illegal.syntax.jsdoc'] + expect(tokens[38]).toEqual value: ' Description] [] [] [] ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[39]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] it "tokenises @param tags with accessor-style names", -> {tokens} = grammar.tokenizeLine('/** @param {object} parameter.property this is the description */') @@ -1211,7 +1289,6 @@ describe "JSDoc grammar", -> expect(lines[3][7]).toEqual value: '', scopes: ['source.js', 'comment.block.documentation.js'] expect(lines[4][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] - describe "when the containing comment ends unexpectedly", -> it "terminates any unclosed tags", -> {tokens} = grammar.tokenizeLine('/** @param {String */ aa') @@ -1313,8 +1390,8 @@ describe "JSDoc grammar", -> expect(tokens[21]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] expect(tokens[22]).toEqual value: '22', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] expect(tokens[23]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(tokens[24]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] - expect(tokens[25]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[24]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[25]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] expect(tokens[27]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] expect(tokens[29]).toEqual value: '20', scopes: ['source.js', 'constant.numeric.decimal.js'] expect(tokens[30]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] From a9c95c6351e5adfbb3e465c6a5148213a33c8692 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Fri, 10 Mar 2017 17:02:08 +1100 Subject: [PATCH 02/12] Fix tokenisation of string literals in @param defaults --- grammars/jsdoc.cson | 53 +++++++++++++++++++++++++++++++++++++++++- spec/jsdoc-spec.coffee | 41 +++++++++++++++++++++++++++++--- 2 files changed, 90 insertions(+), 4 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index bc0ba222..888c7a57 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -415,6 +415,52 @@ # Default @param value, highlighted as JavaScript 'default-value': 'patterns': [ + # Double-quoted string + { + 'begin': '(")' + 'beginCaptures': + '0': + 'name': 'string.quoted.double.js' + '1': + 'name': 'punctuation.definition.string.begin.js' + 'contentName': 'string.quoted.double.js' + 'end': '(")|(?=\\*/)' + 'endCaptures': + '0': + 'name': 'string.quoted.double.js' + '1': + 'name': 'punctuation.definition.string.end.js' + 'name': 'source.embedded.js' + 'patterns': [ + { + 'match': '\\\\(?:[^*]|\\*(?!/))' + 'name': 'constant.character.escape.js' + } + ] + } + # Single-quoted string + { + 'begin': "(')" + 'beginCaptures': + '0': + 'name': 'string.quoted.single.js' + '1': + 'name': 'punctuation.definition.string.begin.js' + 'contentName': 'string.quoted.single.js' + 'end': "(')|(?=\\*/)" + 'endCaptures': + '0': + 'name': 'string.quoted.single.js' + '1': + 'name': 'punctuation.definition.string.end.js' + 'name': 'source.embedded.js' + 'patterns': [ + { + 'match': '\\\\(?:[^*]|\\*(?!/))' + 'name': 'constant.character.escape.js' + } + ] + } { # Nested arrays matched to keep brackets balanced 'begin': '(\\[)' @@ -441,11 +487,16 @@ # imported highlighting within a fixed range to stop runaway problems with any # begin/end patterns the JavaScript grammar matches. { - 'match': '(?:[^\\[\\]*]|\\*[^/])+' + 'match': '(?:[^"\'\\[\\]*]|\\*[^/])+' 'name': 'source.embedded.js' 'captures': '0': 'patterns': [ + # Unmatched } after a string literal: `"string"}` + { + 'match': '}' + 'name': 'meta.brace.curly.js' + } { 'include': '#inline-tags' } diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index c3317bb0..57755b6d 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -559,7 +559,7 @@ describe "JSDoc grammar", -> expect(tokens[32]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] expect(tokens[33]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] expect(tokens[34]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(tokens[35]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[35]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[36]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[37]).toEqual value: ' [Not Highlighted] [] [] [] ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[38]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] @@ -594,12 +594,47 @@ describe "JSDoc grammar", -> expect(tokens[32]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] expect(tokens[33]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] expect(tokens[34]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(tokens[35]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[35]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[36]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[37]).toEqual value: '[Bad', scopes: ['source.js', 'comment.block.documentation.js', 'invalid.illegal.syntax.jsdoc'] expect(tokens[38]).toEqual value: ' Description] [] [] [] ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[39]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + it "does not tokenise arrays inside strings", -> + {tokens} = grammar.tokenizeLine('/** @param {Object} [thing=\'{a: [], b: [0, 2], c: "String"}][Quoted Description] [\'] [Unquoted Description] */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[2]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(tokens[3]).toEqual value: 'param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'Object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'thing', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] + expect(tokens[12]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: '{a: [], b: [0, 2], c: "String"}][Quoted Description] [', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js'] + expect(tokens[14]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] + expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[16]).toEqual value: ' [Unquoted Description] ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Object} [thing="{a: [], b: [0, 2], c: \'String\'}][Quoted Description] ["] [] [] */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[2]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(tokens[3]).toEqual value: 'param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'Object', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'thing', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] + expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: '{a: [], b: [0, 2], c: \'String\'}][Quoted Description] [', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] + expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[16]).toEqual value: ' [] [] ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + it "tokenises @param tags with accessor-style names", -> {tokens} = grammar.tokenizeLine('/** @param {object} parameter.property this is the description */') expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] @@ -1390,7 +1425,7 @@ describe "JSDoc grammar", -> expect(tokens[21]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] expect(tokens[22]).toEqual value: '22', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] expect(tokens[23]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(tokens[24]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] + expect(tokens[24]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[25]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] expect(tokens[27]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] expect(tokens[29]).toEqual value: '20', scopes: ['source.js', 'constant.numeric.decimal.js'] From 18754125fc5331d6f4cbbb434a325741a0374b18 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Fri, 10 Mar 2017 17:06:24 +1100 Subject: [PATCH 03/12] Add specs for matching escape sequences in strings --- spec/jsdoc-spec.coffee | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index 57755b6d..e2b8fced 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -635,6 +635,43 @@ describe "JSDoc grammar", -> expect(tokens[16]).toEqual value: ' [] [] ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + it "tokenises escape sequences inside strings", -> + {tokens} = grammar.tokenizeLine('/** @param {String} [key="a[\\"]z"] */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[2]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(tokens[3]).toEqual value: 'param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'key', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] + expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: 'a[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] + expect(tokens[14]).toEqual value: '\\"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'constant.character.escape.js'] + expect(tokens[15]).toEqual value: ']z', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] + expect(tokens[16]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine("/** @param {String} [key='a[\\']z'] */") + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[2]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(tokens[3]).toEqual value: 'param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'key', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] + expect(tokens[12]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: 'a[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js'] + expect(tokens[14]).toEqual value: '\\\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'constant.character.escape.js'] + expect(tokens[15]).toEqual value: ']z', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js'] + expect(tokens[16]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] + expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + it "tokenises @param tags with accessor-style names", -> {tokens} = grammar.tokenizeLine('/** @param {object} parameter.property this is the description */') expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] From 3f21285df2c23f93b94b0f532a1f0afe3a340edd Mon Sep 17 00:00:00 2001 From: Alhadis Date: Fri, 10 Mar 2017 17:10:54 +1100 Subject: [PATCH 04/12] Add additional specs for invalid descriptions --- spec/jsdoc-spec.coffee | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index e2b8fced..76dec637 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -635,6 +635,19 @@ describe "JSDoc grammar", -> expect(tokens[16]).toEqual value: ' [] [] ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + {tokens} = grammar.tokenizeLine('/** @param {Object} [thing="{a: [], b: [0, 2], c: \'String\'}][Quoted Description] ["][Bad Description] [] */') + expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[16]).toEqual value: '[Bad', scopes: ['source.js', 'comment.block.documentation.js', 'invalid.illegal.syntax.jsdoc'] + expect(tokens[17]).toEqual value: ' Description] [] ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Object} [thing=\'{a: [], b: [0, 2], c: "String"}][Quoted Description] [\'][Bad_Unquoted Description] */') + expect(tokens[14]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] + expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[16]).toEqual value: '[Bad_Unquoted', scopes: ['source.js', 'comment.block.documentation.js', 'invalid.illegal.syntax.jsdoc'] + expect(tokens[17]).toEqual value: ' Description] ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[18]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + it "tokenises escape sequences inside strings", -> {tokens} = grammar.tokenizeLine('/** @param {String} [key="a[\\"]z"] */') expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] From 7372282dfd830e4db5156a24ea0de50289f0854b Mon Sep 17 00:00:00 2001 From: Alhadis Date: Fri, 10 Mar 2017 23:13:09 +1100 Subject: [PATCH 05/12] =?UTF-8?q?Fix=20tokenisation=20of=20"@see=20{@link?= =?UTF-8?q?=20=E2=80=A6}"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- grammars/jsdoc.cson | 10 +++++++++- spec/jsdoc-spec.coffee | 45 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index 888c7a57..7224038e 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -155,7 +155,15 @@ | # JSDoc namepath ( - (?!https?://) + (?! + # Avoid matching bare URIs (also acceptable as links) + https?:// + | + # Avoid matching {@inline tags}; we match those below + (?:\\[[^\\[\\]]*\\])? # Possible description [preceding]{@tag} + {@(?:link|linkcode|linkplain|tutorial)\\b + ) + # Matched namepath (?:[^@\\s*/]|\\*[^/])+ ) ) diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index 76dec637..a6726544 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -161,6 +161,51 @@ describe "JSDoc grammar", -> expect(tokens[7]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + it "tokenises @see tags with basic links", -> + {tokens} = grammar.tokenizeLine('/** @see name#path */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[2]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(tokens[3]).toEqual value: 'see', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + expect(tokens[4]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[5]).toEqual value: 'name#path', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @see http://atom.io/ */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[2]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(tokens[3]).toEqual value: 'see', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + expect(tokens[4]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[5]).toEqual value: 'http://atom.io/', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.link.underline.jsdoc'] + expect(tokens[6]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + it "tokenises @see tags with {@link} tags", -> + {tokens} = grammar.tokenizeLine('/** @see {@link text|Description} */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[2]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(tokens[3]).toEqual value: 'see', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[6]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.jsdoc'] + expect(tokens[7]).toEqual value: 'link', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[9]).toEqual value: 'text', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[10]).toEqual value: '|', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.separator.pipe.jsdoc'] + expect(tokens[11]).toEqual value: 'Description', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[12]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[14]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @see [Description]{@link name#path} */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[2]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(tokens[3]).toEqual value: 'see', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + expect(tokens[5]).toEqual value: '[Description]', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[7]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.jsdoc'] + expect(tokens[8]).toEqual value: 'link', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[10]).toEqual value: 'name#path', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[11]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[13]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + it "tokenises tags with type expressions", -> {tokens} = grammar.tokenizeLine('/** @const {object} */') expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] From a8f1e4e7e8045627f75db6068fdd6441f926f17e Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 14 Mar 2017 21:21:53 +1100 Subject: [PATCH 06/12] Improve tokenisation of tags in @example * Embedded HTML is now highlighted correctly * tags will match after the opening @example line --- grammars/jsdoc.cson | 67 ++++++++++++---- spec/jsdoc-spec.coffee | 168 +++++++++++++++++++++++++++++------------ 2 files changed, 171 insertions(+), 64 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index 7224038e..b55da0d0 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -78,13 +78,9 @@ '2': 'name': 'punctuation.definition.block.tag.jsdoc' 'patterns': [ - { - # Match to prevent leading asterisk being highlighted as JS - 'match': '^\\s\\*\\s+' - } { # Leading … before example - 'begin': '\\G(<)caption(>)' + 'begin': '(<)caption(>)' 'beginCaptures': '0': 'name': 'entity.name.tag.inline.jsdoc' @@ -92,7 +88,6 @@ 'name': 'punctuation.definition.bracket.angle.begin.jsdoc' '2': 'name': 'punctuation.definition.bracket.angle.end.jsdoc' - 'contentName': 'constant.other.description.jsdoc' 'end': '()|(?=\\*/)' 'endCaptures': '0': @@ -101,18 +96,38 @@ 'name': 'punctuation.definition.bracket.angle.begin.jsdoc' '2': 'name': 'punctuation.definition.bracket.angle.end.jsdoc' + 'name': 'meta.caption.jsdoc' + 'patterns': [ + { + # Keep leading asterisks highlighted as comments in multiline captions + 'match': '^\\s\\*\\s+' + } + { + # Highlight contents as embedded HTML + 'match': '(?:[^<*]|\\*[^/]|<(?!/caption>))+' + 'name': 'constant.other.description.jsdoc' + 'captures': + '0': + 'patterns': [ + { + 'include': 'text.html.basic' + } + ] + } + ] } { - # Highlighted JavaScript example - 'match': '[^\\s@*](?:[^*]|\\*[^/])*' - 'captures': - '0': - 'name': 'source.embedded.js' - 'patterns': [ - { - 'include': 'source.js' - } - ] + # Make sure only matches once in each @example + 'begin': '(?<=)' + 'end': '(?=@|\\*/)' + 'patterns': [ + { + 'include': '#example-js' + } + ] + } + { + 'include': '#example-js' } ] } @@ -514,6 +529,26 @@ ] } ] + # Highlighted JavaScript for @example tag + 'example-js': + 'patterns': [ + { + # Match to prevent leading asterisk being highlighted as JS + 'match': '^\\s\\*\\s+' + } + { + # "Clamped" line of JS source + 'match': '[^\\s@*](?:[^*]|\\*[^/])+' + 'captures': + '0': + 'name': 'source.embedded.js' + 'patterns': [ + { + 'include': 'source.js' + } + ] + } + ] 'inline-tags': 'patterns': [ { diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index a6726544..3772972e 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -1370,54 +1370,126 @@ describe "JSDoc grammar", -> expect(lines[3][6]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] expect(lines[4][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] - it "tokenises tags at the start of an example block", -> - {tokens} = grammar.tokenizeLine('/** @example Text */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] - expect(tokens[2]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] - expect(tokens[3]).toEqual value: 'example', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[5]).toEqual value: '<', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'entity.name.tag.inline.jsdoc', 'punctuation.definition.bracket.angle.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'caption', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'entity.name.tag.inline.jsdoc'] - expect(tokens[7]).toEqual value: '>', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'entity.name.tag.inline.jsdoc', 'punctuation.definition.bracket.angle.end.jsdoc'] - expect(tokens[8]).toEqual value: 'Text', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'constant.other.description.jsdoc'] - expect(tokens[9]).toEqual value: '', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'entity.name.tag.inline.jsdoc', 'punctuation.definition.bracket.angle.end.jsdoc'] - expect(tokens[13]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] - - lines = grammar.tokenizeLines """ - /** - * @example Text - * foo("bar"); - * @return {String} - */ - """ - expect(lines[0][0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] - expect(lines[1][0]).toEqual value: ' * ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(lines[1][1]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] - expect(lines[1][2]).toEqual value: 'example', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'storage.type.class.jsdoc'] - expect(lines[1][4]).toEqual value: '<', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'entity.name.tag.inline.jsdoc', 'punctuation.definition.bracket.angle.begin.jsdoc'] - expect(lines[1][5]).toEqual value: 'caption', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'entity.name.tag.inline.jsdoc'] - expect(lines[1][6]).toEqual value: '>', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'entity.name.tag.inline.jsdoc', 'punctuation.definition.bracket.angle.end.jsdoc'] - expect(lines[1][7]).toEqual value: 'Text', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'constant.other.description.jsdoc'] - expect(lines[1][8]).toEqual value: '', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'entity.name.tag.inline.jsdoc', 'punctuation.definition.bracket.angle.end.jsdoc'] - expect(lines[2][0]).toEqual value: ' * ', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc'] - expect(lines[2][1]).toEqual value: 'foo', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'entity.name.function.js'] - expect(lines[2][2]).toEqual value: '(', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] - expect(lines[2][3]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(lines[2][4]).toEqual value: 'bar', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js'] - expect(lines[2][5]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(lines[2][6]).toEqual value: ')', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] - expect(lines[2][7]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] - expect(lines[3][0]).toEqual value: ' * ', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc'] - expect(lines[3][1]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] - expect(lines[3][2]).toEqual value: 'return', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] - expect(lines[3][4]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(lines[3][5]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(lines[3][6]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(lines[3][7]).toEqual value: '', scopes: ['source.js', 'comment.block.documentation.js'] - expect(lines[4][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + describe "HTML captions", -> + ### + NOTE: Loading the HTML grammar triggers an inexplicable case of infinite recursion during the following two specs. + Loading JS's grammar first mitigates the issue, but also has the effect of not tokenising the source correctly. + For lack of a better solution, we're running these tests without checking HTML scopes. (It should also be noted + that no such overflow occurs during a real Atom session: only while running specs). + Output: https://gist.github.com/Alhadis/a4dc83c2fc5b113ab6e2e7dbbf17e3f6 + ### + it "tokenises tags at the start of an example block", -> + {tokens} = grammar.tokenizeLine('/** @example Text */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[2]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(tokens[3]).toEqual value: 'example', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[5]).toEqual value: '<', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'meta.caption.jsdoc', 'entity.name.tag.inline.jsdoc', 'punctuation.definition.bracket.angle.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'caption', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'meta.caption.jsdoc', 'entity.name.tag.inline.jsdoc'] + expect(tokens[7]).toEqual value: '>', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'meta.caption.jsdoc', 'entity.name.tag.inline.jsdoc', 'punctuation.definition.bracket.angle.end.jsdoc'] + expect(tokens[8]).toEqual value: 'Text', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'meta.caption.jsdoc', 'constant.other.description.jsdoc'] + expect(tokens[9]).toEqual value: '', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'meta.caption.jsdoc', 'entity.name.tag.inline.jsdoc', 'punctuation.definition.bracket.angle.end.jsdoc'] + expect(tokens[13]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + lines = grammar.tokenizeLines """ + /** + * @example Text + * foo("bar"); + * @return {String} + */ + """ + expect(lines[0][0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(lines[1][0]).toEqual value: ' * ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(lines[1][1]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(lines[1][2]).toEqual value: 'example', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'storage.type.class.jsdoc'] + expect(lines[1][4]).toEqual value: '<', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'meta.caption.jsdoc', 'entity.name.tag.inline.jsdoc', 'punctuation.definition.bracket.angle.begin.jsdoc'] + expect(lines[1][5]).toEqual value: 'caption', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'meta.caption.jsdoc', 'entity.name.tag.inline.jsdoc'] + expect(lines[1][6]).toEqual value: '>', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'meta.caption.jsdoc', 'entity.name.tag.inline.jsdoc', 'punctuation.definition.bracket.angle.end.jsdoc'] + expect(lines[1][7]).toEqual value: 'Text', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'meta.caption.jsdoc', 'constant.other.description.jsdoc'] + expect(lines[1][8]).toEqual value: '', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'meta.caption.jsdoc', 'entity.name.tag.inline.jsdoc', 'punctuation.definition.bracket.angle.end.jsdoc'] + expect(lines[2][0]).toEqual value: ' * ', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc'] + expect(lines[2][1]).toEqual value: 'foo', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'entity.name.function.js'] + expect(lines[2][2]).toEqual value: '(', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] + expect(lines[2][3]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(lines[2][4]).toEqual value: 'bar', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js'] + expect(lines[2][5]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(lines[2][6]).toEqual value: ')', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(lines[2][7]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] + expect(lines[3][0]).toEqual value: ' * ', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc'] + expect(lines[3][1]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(lines[3][2]).toEqual value: 'return', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + expect(lines[3][4]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(lines[3][5]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(lines[3][6]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(lines[3][7]).toEqual value: '', scopes: ['source.js', 'comment.block.documentation.js'] + expect(lines[4][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + it "does not tokenise blocks within JS source", -> + lines = grammar.tokenizeLines """ + /** + * @example + * foo(2); Text; + * @return {String} + */ + """ + expect(lines[2][7]).toEqual value: '<', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'keyword.operator.comparison.js'] + expect(lines[2][8]).toEqual value: 'caption', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js'] + expect(lines[2][9]).toEqual value: '>', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'keyword.operator.comparison.js'] + expect(lines[2][10]).toEqual value: 'Text', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'support.class.dom.js'] + expect(lines[2][11]).toEqual value: '<', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'keyword.operator.comparison.js'] + expect(lines[2][12]).toEqual value: '/', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'keyword.operator.js'] + expect(lines[2][13]).toEqual value: 'caption', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js'] + expect(lines[2][14]).toEqual value: '>', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'keyword.operator.comparison.js'] + expect(lines[2][15]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] + + it "only tokenises … once", -> + lines = grammar.tokenizeLines """ + /** + * @example Text + * Text + * foo("bar"); + * @return {String} + */ + """ + expect(lines[0][0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(lines[1][0]).toEqual value: ' * ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(lines[1][1]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(lines[1][2]).toEqual value: 'example', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'storage.type.class.jsdoc'] + expect(lines[1][4]).toEqual value: '<', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'meta.caption.jsdoc', 'entity.name.tag.inline.jsdoc', 'punctuation.definition.bracket.angle.begin.jsdoc'] + expect(lines[1][5]).toEqual value: 'caption', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'meta.caption.jsdoc', 'entity.name.tag.inline.jsdoc'] + expect(lines[1][6]).toEqual value: '>', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'meta.caption.jsdoc', 'entity.name.tag.inline.jsdoc', 'punctuation.definition.bracket.angle.end.jsdoc'] + expect(lines[1][7]).toEqual value: 'Text', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'meta.caption.jsdoc', 'constant.other.description.jsdoc'] + expect(lines[1][8]).toEqual value: '', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'meta.caption.jsdoc', 'entity.name.tag.inline.jsdoc', 'punctuation.definition.bracket.angle.end.jsdoc'] + expect(lines[2][0]).toEqual value: ' * ', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc'] + expect(lines[2][1]).toEqual value: '<', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'keyword.operator.comparison.js'] + expect(lines[2][2]).toEqual value: 'caption', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js'] + expect(lines[2][3]).toEqual value: '>', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'keyword.operator.comparison.js'] + expect(lines[2][4]).toEqual value: 'Text', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'support.class.dom.js'] + expect(lines[2][5]).toEqual value: '<', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'keyword.operator.comparison.js'] + expect(lines[2][6]).toEqual value: '/', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'keyword.operator.js'] + expect(lines[2][7]).toEqual value: 'caption', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js'] + expect(lines[2][8]).toEqual value: '>', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'keyword.operator.comparison.js'] + expect(lines[3][0]).toEqual value: ' * ', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc'] + expect(lines[3][1]).toEqual value: 'foo', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'entity.name.function.js'] + expect(lines[3][2]).toEqual value: '(', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] + expect(lines[3][3]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(lines[3][4]).toEqual value: 'bar', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js'] + expect(lines[3][5]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(lines[3][6]).toEqual value: ')', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(lines[3][7]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] + expect(lines[4][0]).toEqual value: ' * ', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc'] + expect(lines[4][1]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(lines[4][2]).toEqual value: 'return', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + expect(lines[4][4]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(lines[4][5]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(lines[4][6]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(lines[4][7]).toEqual value: '', scopes: ['source.js', 'comment.block.documentation.js'] + expect(lines[5][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] describe "when the containing comment ends unexpectedly", -> it "terminates any unclosed tags", -> From 7969d32c25d1ea4a2be45606a5b6c03f1a191ddf Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 14 Mar 2017 21:24:44 +1100 Subject: [PATCH 07/12] Add @api and @internal to recognised JSDoc tags Not part of the official JSDoc spec, yet occasionally used in-the-wild. --- grammars/jsdoc.cson | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index b55da0d0..c1af9533 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -11,7 +11,7 @@ '3': 'name': 'constant.language.access-type.jsdoc' 'match': '''(?x) - ((@)access) + ((@)(?:access|api)) \\s+ (private|protected|public) \\b @@ -393,16 +393,16 @@ '1': 'name': 'punctuation.definition.block.tag.jsdoc' 'match': '''(?x) (@) - (?:abstract|access|alias|arg|argument|async|attribute|augments|author|beta|borrows|bubbles + (?:abstract|access|alias|api|arg|argument|async|attribute|augments|author|beta|borrows|bubbles |callback|chainable|class|classdesc|code|config|const|constant|constructor|constructs|copyright |default|defaultvalue|define|deprecated|desc|description|dict|emits|enum|event|example|exception |exports?|extends|extension(?:_?for)?|external|externs|file|fileoverview|final|fires|for|func - |function|global|host|ignore|implements|implicitCast|inherit[Dd]oc|inner|instance|interface|kind - |lends|license|listens|main|member|memberof!?|method|mixes|mixins?|modifies|module|name|namespace - |noalias|nocollapse|nocompile|nosideeffects|override|overview|package|param|preserve|private|prop - |property|protected|public|read[Oo]nly|record|require[ds]|returns?|see|since|static|struct|submodule - |summary|suppress|template|this|throws|todo|tutorial|type|typedef|unrestricted|uses|var|variation - |version|virtual|writeOnce) + |function|global|host|ignore|implements|implicitCast|inherit[Dd]oc|inner|instance|interface + |internal|kind|lends|license|listens|main|member|memberof!?|method|mixes|mixins?|modifies|module + |name|namespace|noalias|nocollapse|nocompile|nosideeffects|override|overview|package|param|preserve + |private|prop|property|protected|public|read[Oo]nly|record|require[ds]|returns?|see|since|static + |struct|submodule|summary|suppress|template|this|throws|todo|tutorial|type|typedef|unrestricted + |uses|var|variation|version|virtual|writeOnce) \\b ''' 'name': 'storage.type.class.jsdoc' From eb046965c8c1639799b331a7b1b00492e9fb7411 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Thu, 6 Apr 2017 03:34:01 +1000 Subject: [PATCH 08/12] Amend scopes used to highlight invalid param names Requested in review. See: https://github.com/atom/language-javascript/pull/497/ files/7969d32c25d1ea4a2be45606a5b6c03f1a191ddf#r109976644 (comment) --- grammars/jsdoc.cson | 9 ++------- spec/jsdoc-spec.coffee | 6 +++--- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index c1af9533..5823246e 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -276,16 +276,11 @@ } { 'begin': '\\[' - 'beginCaptures': - '0': - 'name': 'variable.other.jsdoc' - 'contentName': 'variable.other.jsdoc' - 'end': '(\\])((?:[^*\\s]|\\*[^\\s/])+)?|(?=\\*/)' + 'end': '\\]((?:[^*\\s]|\\*[^\\s/])+)?|(?=\\*/)' 'endCaptures': '1': - 'name': 'variable.other.jsdoc' - '2': 'name': 'invalid.illegal.syntax.jsdoc' + 'name': 'variable.other.jsdoc' 'patterns': [ { 'begin': '=' diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index 3772972e..566bc30a 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -641,7 +641,7 @@ describe "JSDoc grammar", -> expect(tokens[34]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] expect(tokens[35]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[36]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[37]).toEqual value: '[Bad', scopes: ['source.js', 'comment.block.documentation.js', 'invalid.illegal.syntax.jsdoc'] + expect(tokens[37]).toEqual value: '[Bad', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'invalid.illegal.syntax.jsdoc'] expect(tokens[38]).toEqual value: ' Description] [] [] [] ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[39]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] @@ -683,13 +683,13 @@ describe "JSDoc grammar", -> {tokens} = grammar.tokenizeLine('/** @param {Object} [thing="{a: [], b: [0, 2], c: \'String\'}][Quoted Description] ["][Bad Description] [] */') expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[16]).toEqual value: '[Bad', scopes: ['source.js', 'comment.block.documentation.js', 'invalid.illegal.syntax.jsdoc'] + expect(tokens[16]).toEqual value: '[Bad', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'invalid.illegal.syntax.jsdoc'] expect(tokens[17]).toEqual value: ' Description] [] ', scopes: ['source.js', 'comment.block.documentation.js'] {tokens} = grammar.tokenizeLine('/** @param {Object} [thing=\'{a: [], b: [0, 2], c: "String"}][Quoted Description] [\'][Bad_Unquoted Description] */') expect(tokens[14]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[16]).toEqual value: '[Bad_Unquoted', scopes: ['source.js', 'comment.block.documentation.js', 'invalid.illegal.syntax.jsdoc'] + expect(tokens[16]).toEqual value: '[Bad_Unquoted', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'invalid.illegal.syntax.jsdoc'] expect(tokens[17]).toEqual value: ' Description] ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[18]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] From bd688cc0c02d4e8ae094f47b6ce4b0ad692f6cc5 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 8 Apr 2017 01:08:01 +1000 Subject: [PATCH 09/12] Simplify tokenisation of quoted strings in JSDoc --- grammars/jsdoc.cson | 36 ++------------- spec/jsdoc-spec.coffee | 102 ++++++++++++++++++++--------------------- 2 files changed, 55 insertions(+), 83 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index 5823246e..b1c15f11 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -433,45 +433,17 @@ # Default @param value, highlighted as JavaScript 'default-value': 'patterns': [ - # Double-quoted string + # Strings { - 'begin': '(")' + 'begin': '("|\')' 'beginCaptures': '0': - 'name': 'string.quoted.double.js' - '1': - 'name': 'punctuation.definition.string.begin.js' - 'contentName': 'string.quoted.double.js' - 'end': '(")|(?=\\*/)' - 'endCaptures': - '0': - 'name': 'string.quoted.double.js' - '1': - 'name': 'punctuation.definition.string.end.js' - 'name': 'source.embedded.js' - 'patterns': [ - { - 'match': '\\\\(?:[^*]|\\*(?!/))' - 'name': 'constant.character.escape.js' - } - ] - } - # Single-quoted string - { - 'begin': "(')" - 'beginCaptures': - '0': - 'name': 'string.quoted.single.js' - '1': 'name': 'punctuation.definition.string.begin.js' - 'contentName': 'string.quoted.single.js' - 'end': "(')|(?=\\*/)" + 'end': '\\1|(?=\\*/)' 'endCaptures': '0': - 'name': 'string.quoted.single.js' - '1': 'name': 'punctuation.definition.string.end.js' - 'name': 'source.embedded.js' + 'name': 'string.quoted.js' 'patterns': [ { 'match': '\\\\(?:[^*]|\\*(?!/))' diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index 566bc30a..12d70881 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -381,9 +381,9 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[13]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[16]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -394,9 +394,9 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[14]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[15]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[13]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] + expect(tokens[14]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[15]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[16]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[17]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -407,9 +407,9 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[14]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[15]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[13]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] + expect(tokens[14]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[15]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[18]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -421,9 +421,9 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[12]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] - expect(tokens[13]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js'] - expect(tokens[14]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] + expect(tokens[12]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[14]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[16]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -434,9 +434,9 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] - expect(tokens[14]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js'] - expect(tokens[15]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] + expect(tokens[13]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] + expect(tokens[14]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[15]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[16]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[17]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -447,9 +447,9 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] - expect(tokens[14]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js'] - expect(tokens[15]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] + expect(tokens[13]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] + expect(tokens[14]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[15]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[18]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -464,9 +464,9 @@ describe "JSDoc grammar", -> expect(tokens[12]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[13]).toEqual value: 'a', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] expect(tokens[14]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] - expect(tokens[16]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[17]).toEqual value: 'b', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[18]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[16]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] + expect(tokens[17]).toEqual value: 'b', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[18]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[19]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[20]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[21]).toEqual value: ' - An object ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -481,9 +481,9 @@ describe "JSDoc grammar", -> expect(tokens[13]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[14]).toEqual value: ' a ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] expect(tokens[15]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] - expect(tokens[17]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[18]).toEqual value: 'b', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[19]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[17]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] + expect(tokens[18]).toEqual value: 'b', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[19]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[21]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[23]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[24]).toEqual value: ' - An object ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -601,9 +601,9 @@ describe "JSDoc grammar", -> expect(tokens[28]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] expect(tokens[29]).toEqual value: ' c', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] expect(tokens[30]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] - expect(tokens[32]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[33]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[34]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[32]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] + expect(tokens[33]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[34]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[35]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[36]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[37]).toEqual value: ' [Not Highlighted] [] [] [] ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -636,9 +636,9 @@ describe "JSDoc grammar", -> expect(tokens[28]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] expect(tokens[29]).toEqual value: ' c', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] expect(tokens[30]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] - expect(tokens[32]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[33]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[34]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[32]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] + expect(tokens[33]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[34]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[35]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[36]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[37]).toEqual value: '[Bad', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'invalid.illegal.syntax.jsdoc'] @@ -656,9 +656,9 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'thing', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] - expect(tokens[12]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] - expect(tokens[13]).toEqual value: '{a: [], b: [0, 2], c: "String"}][Quoted Description] [', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js'] - expect(tokens[14]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] + expect(tokens[12]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: '{a: [], b: [0, 2], c: "String"}][Quoted Description] [', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[14]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[16]).toEqual value: ' [Unquoted Description] ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] @@ -673,21 +673,21 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'thing', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] - expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[13]).toEqual value: '{a: [], b: [0, 2], c: \'String\'}][Quoted Description] [', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: '{a: [], b: [0, 2], c: \'String\'}][Quoted Description] [', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[16]).toEqual value: ' [] [] ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] {tokens} = grammar.tokenizeLine('/** @param {Object} [thing="{a: [], b: [0, 2], c: \'String\'}][Quoted Description] ["][Bad Description] [] */') - expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[16]).toEqual value: '[Bad', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'invalid.illegal.syntax.jsdoc'] expect(tokens[17]).toEqual value: ' Description] [] ', scopes: ['source.js', 'comment.block.documentation.js'] {tokens} = grammar.tokenizeLine('/** @param {Object} [thing=\'{a: [], b: [0, 2], c: "String"}][Quoted Description] [\'][Bad_Unquoted Description] */') - expect(tokens[14]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] + expect(tokens[14]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[16]).toEqual value: '[Bad_Unquoted', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'invalid.illegal.syntax.jsdoc'] expect(tokens[17]).toEqual value: ' Description] ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -704,11 +704,11 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'key', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] - expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[13]).toEqual value: 'a[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[14]).toEqual value: '\\"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'constant.character.escape.js'] - expect(tokens[15]).toEqual value: ']z', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[16]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: 'a[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[14]).toEqual value: '\\"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'constant.character.escape.js'] + expect(tokens[15]).toEqual value: ']z', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[16]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] @@ -722,11 +722,11 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'key', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] - expect(tokens[12]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] - expect(tokens[13]).toEqual value: 'a[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js'] - expect(tokens[14]).toEqual value: '\\\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'constant.character.escape.js'] - expect(tokens[15]).toEqual value: ']z', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js'] - expect(tokens[16]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] + expect(tokens[12]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: 'a[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[14]).toEqual value: '\\\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'constant.character.escape.js'] + expect(tokens[15]).toEqual value: ']z', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[16]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] @@ -1589,9 +1589,9 @@ describe "JSDoc grammar", -> expect(tokens[17]).toEqual value: 'value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] expect(tokens[18]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] expect(tokens[20]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] - expect(tokens[21]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[22]).toEqual value: '22', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js'] - expect(tokens[23]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[21]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] + expect(tokens[22]).toEqual value: '22', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] + expect(tokens[23]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] expect(tokens[24]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[25]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] expect(tokens[27]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] From da0b7b2fc0dea12565b4db99d2ad60a8767de79c Mon Sep 17 00:00:00 2001 From: Alhadis Date: Fri, 21 Apr 2017 00:00:11 +1000 Subject: [PATCH 10/12] Remove embedded HTML highlighting from captions --- grammars/jsdoc.cson | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index b1c15f11..176fe7f1 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -88,6 +88,7 @@ 'name': 'punctuation.definition.bracket.angle.begin.jsdoc' '2': 'name': 'punctuation.definition.bracket.angle.end.jsdoc' + 'contentName': 'constant.other.description.jsdoc' 'end': '()|(?=\\*/)' 'endCaptures': '0': @@ -97,24 +98,6 @@ '2': 'name': 'punctuation.definition.bracket.angle.end.jsdoc' 'name': 'meta.caption.jsdoc' - 'patterns': [ - { - # Keep leading asterisks highlighted as comments in multiline captions - 'match': '^\\s\\*\\s+' - } - { - # Highlight contents as embedded HTML - 'match': '(?:[^<*]|\\*[^/]|<(?!/caption>))+' - 'name': 'constant.other.description.jsdoc' - 'captures': - '0': - 'patterns': [ - { - 'include': 'text.html.basic' - } - ] - } - ] } { # Make sure only matches once in each @example From dab4bb97d2e2ccbf826edd8c4642afe1714f6cac Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 22 Apr 2017 16:52:18 +1000 Subject: [PATCH 11/12] Differentiate between double and single-quoted strings --- grammars/jsdoc.cson | 26 +++++++++-- spec/jsdoc-spec.coffee | 102 ++++++++++++++++++++--------------------- 2 files changed, 73 insertions(+), 55 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index 176fe7f1..eda53325 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -416,17 +416,35 @@ # Default @param value, highlighted as JavaScript 'default-value': 'patterns': [ - # Strings + # Double-quoted string { - 'begin': '("|\')' + 'begin': '"' + 'beginCaptures': + '0': + 'name': 'punctuation.definition.string.begin.js' + 'end': '"|(?=\\*/)' + 'endCaptures': + '0': + 'name': 'punctuation.definition.string.end.js' + 'name': 'string.quoted.double.js' + 'patterns': [ + { + 'match': '\\\\(?:[^*]|\\*(?!/))' + 'name': 'constant.character.escape.js' + } + ] + } + # Single-quoted string + { + 'begin': '\'' 'beginCaptures': '0': 'name': 'punctuation.definition.string.begin.js' - 'end': '\\1|(?=\\*/)' + 'end': '\'|(?=\\*/)' 'endCaptures': '0': 'name': 'punctuation.definition.string.end.js' - 'name': 'string.quoted.js' + 'name': 'string.quoted.single.js' 'patterns': [ { 'match': '\\\\(?:[^*]|\\*(?!/))' diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index 12d70881..abd8380d 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -381,9 +381,9 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] - expect(tokens[13]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js'] + expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[16]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -394,9 +394,9 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] - expect(tokens[14]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[15]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[13]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[14]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js'] + expect(tokens[15]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] expect(tokens[16]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[17]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -407,9 +407,9 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] - expect(tokens[14]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[15]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[13]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[14]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js'] + expect(tokens[15]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[18]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -421,9 +421,9 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[12]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] - expect(tokens[13]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[14]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[12]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js'] + expect(tokens[14]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[16]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -434,9 +434,9 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] - expect(tokens[14]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[15]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[13]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] + expect(tokens[14]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js'] + expect(tokens[15]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] expect(tokens[16]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[17]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -447,9 +447,9 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' variable ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc' ] - expect(tokens[13]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] - expect(tokens[14]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[15]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[13]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] + expect(tokens[14]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js'] + expect(tokens[15]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[18]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -464,9 +464,9 @@ describe "JSDoc grammar", -> expect(tokens[12]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[13]).toEqual value: 'a', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] expect(tokens[14]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] - expect(tokens[16]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] - expect(tokens[17]).toEqual value: 'b', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[18]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[16]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[17]).toEqual value: 'b', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js'] + expect(tokens[18]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] expect(tokens[19]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[20]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[21]).toEqual value: ' - An object ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -481,9 +481,9 @@ describe "JSDoc grammar", -> expect(tokens[13]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[14]).toEqual value: ' a ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] expect(tokens[15]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] - expect(tokens[17]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] - expect(tokens[18]).toEqual value: 'b', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[19]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[17]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[18]).toEqual value: 'b', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js'] + expect(tokens[19]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] expect(tokens[21]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[23]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[24]).toEqual value: ' - An object ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -601,9 +601,9 @@ describe "JSDoc grammar", -> expect(tokens[28]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] expect(tokens[29]).toEqual value: ' c', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] expect(tokens[30]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] - expect(tokens[32]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] - expect(tokens[33]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[34]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[32]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[33]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js'] + expect(tokens[34]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] expect(tokens[35]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[36]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[37]).toEqual value: ' [Not Highlighted] [] [] [] ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -636,9 +636,9 @@ describe "JSDoc grammar", -> expect(tokens[28]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] expect(tokens[29]).toEqual value: ' c', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] expect(tokens[30]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] - expect(tokens[32]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] - expect(tokens[33]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[34]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[32]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[33]).toEqual value: 'String', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js'] + expect(tokens[34]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] expect(tokens[35]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[36]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[37]).toEqual value: '[Bad', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'invalid.illegal.syntax.jsdoc'] @@ -656,9 +656,9 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'thing', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] - expect(tokens[12]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] - expect(tokens[13]).toEqual value: '{a: [], b: [0, 2], c: "String"}][Quoted Description] [', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[14]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[12]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: '{a: [], b: [0, 2], c: "String"}][Quoted Description] [', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js'] + expect(tokens[14]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[16]).toEqual value: ' [Unquoted Description] ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] @@ -673,21 +673,21 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'thing', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] - expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] - expect(tokens[13]).toEqual value: '{a: [], b: [0, 2], c: \'String\'}][Quoted Description] [', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: '{a: [], b: [0, 2], c: \'String\'}][Quoted Description] [', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js'] + expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[16]).toEqual value: ' [] [] ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] {tokens} = grammar.tokenizeLine('/** @param {Object} [thing="{a: [], b: [0, 2], c: \'String\'}][Quoted Description] ["][Bad Description] [] */') - expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[14]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[16]).toEqual value: '[Bad', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'invalid.illegal.syntax.jsdoc'] expect(tokens[17]).toEqual value: ' Description] [] ', scopes: ['source.js', 'comment.block.documentation.js'] {tokens} = grammar.tokenizeLine('/** @param {Object} [thing=\'{a: [], b: [0, 2], c: "String"}][Quoted Description] [\'][Bad_Unquoted Description] */') - expect(tokens[14]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[14]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[16]).toEqual value: '[Bad_Unquoted', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'invalid.illegal.syntax.jsdoc'] expect(tokens[17]).toEqual value: ' Description] ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -704,11 +704,11 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'key', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] - expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] - expect(tokens[13]).toEqual value: 'a[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[14]).toEqual value: '\\"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'constant.character.escape.js'] - expect(tokens[15]).toEqual value: ']z', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[16]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[12]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: 'a[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js'] + expect(tokens[14]).toEqual value: '\\"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'constant.character.escape.js'] + expect(tokens[15]).toEqual value: ']z', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js'] + expect(tokens[16]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] @@ -722,11 +722,11 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'key', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] - expect(tokens[12]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] - expect(tokens[13]).toEqual value: 'a[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[14]).toEqual value: '\\\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'constant.character.escape.js'] - expect(tokens[15]).toEqual value: ']z', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[16]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[12]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] + expect(tokens[13]).toEqual value: 'a[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js'] + expect(tokens[14]).toEqual value: '\\\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js', 'constant.character.escape.js'] + expect(tokens[15]).toEqual value: ']z', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js'] + expect(tokens[16]).toEqual value: '\'', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] @@ -1589,9 +1589,9 @@ describe "JSDoc grammar", -> expect(tokens[17]).toEqual value: 'value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js'] expect(tokens[18]).toEqual value: ',', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.delimiter.object.comma.js'] expect(tokens[20]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] - expect(tokens[21]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.begin.js'] - expect(tokens[22]).toEqual value: '22', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js'] - expect(tokens[23]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.js', 'punctuation.definition.string.end.js'] + expect(tokens[21]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[22]).toEqual value: '22', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js'] + expect(tokens[23]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] expect(tokens[24]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] expect(tokens[25]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] expect(tokens[27]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] From 840c818e1bf213982d9cf596342fbb4280bbc0b9 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Wed, 3 May 2017 21:04:49 +1000 Subject: [PATCH 12/12] Revert removal of embedded HTML highlighting This reverts commit da0b7b2fc0dea12565b4db99d2ad60a8767de79c. --- grammars/jsdoc.cson | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index eda53325..2be62df7 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -88,7 +88,6 @@ 'name': 'punctuation.definition.bracket.angle.begin.jsdoc' '2': 'name': 'punctuation.definition.bracket.angle.end.jsdoc' - 'contentName': 'constant.other.description.jsdoc' 'end': '()|(?=\\*/)' 'endCaptures': '0': @@ -98,6 +97,24 @@ '2': 'name': 'punctuation.definition.bracket.angle.end.jsdoc' 'name': 'meta.caption.jsdoc' + 'patterns': [ + { + # Keep leading asterisks highlighted as comments in multiline captions + 'match': '^\\s\\*\\s+' + } + { + # Highlight contents as embedded HTML + 'match': '(?:[^<*]|\\*[^/]|<(?!/caption>))+' + 'name': 'constant.other.description.jsdoc' + 'captures': + '0': + 'patterns': [ + { + 'include': 'text.html.basic' + } + ] + } + ] } { # Make sure only matches once in each @example