From c56dfbe85bfd6209488c0412c10fc546721b3382 Mon Sep 17 00:00:00 2001 From: Maxim Sokolov Date: Thu, 14 Apr 2016 15:53:49 +0300 Subject: [PATCH 001/420] :bug: Fix 'console', 'Math' matching --- grammars/javascript.cson | 6 +++--- spec/javascript-spec.coffee | 41 ++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 84d1dc4a..00e795f4 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -702,11 +702,11 @@ { # console # console.log(arg1, "arg2", [...]) - 'begin': '\\bconsole\\b' + 'begin': '\\bconsole\\b(?!\\$)' 'beginCaptures': '0': 'name': 'entity.name.type.object.console.js' - 'end': '(?!\\G)' + 'end': '(?=(?!\\s*\\.)\\S)' 'patterns': [ { 'begin': '\\s*(\\.)\\s*(assert|clear|debug|error|info|log|profile|profileEnd|time|timeEnd|warn)\\s*(?=\\()' @@ -731,7 +731,7 @@ 'beginCaptures': '0': 'name': 'support.class.js' - 'end': '(?!\\G)' + 'end': '(?=(?!\\s*\\.)\\S)' 'patterns': [ { # Math.random() diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 07687a41..6bfbde0d 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1534,8 +1534,12 @@ describe "Javascript grammar", -> describe "console", -> it "tokenizes the console keyword", -> - {tokens} = grammar.tokenizeLine('console') + {tokens} = grammar.tokenizeLine('console;') expect(tokens[0]).toEqual value: 'console', scopes: ['source.js', 'entity.name.type.object.console.js'] + expect(tokens[1]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + + {tokens} = grammar.tokenizeLine('console$') + expect(tokens[0]).not.toEqual value: 'console', scopes: ['source.js', 'entity.name.type.object.console.js'] it "tokenizes console support functions", -> {tokens} = grammar.tokenizeLine('console.log()') @@ -1545,30 +1549,57 @@ describe "Javascript grammar", -> expect(tokens[3]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] - {tokens} = grammar.tokenizeLine('console . log()') + lines = grammar.tokenizeLines ''' + console + .log(); + ''' + expect(lines[0][0]).toEqual value: 'console', scopes: ['source.js', 'entity.name.type.object.console.js'] + expect(lines[1][0]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] + expect(lines[1][1]).toEqual value: 'log', scopes: ['source.js', 'meta.method-call.js', 'support.function.console.js'] + expect(lines[1][2]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] + expect(lines[1][3]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(lines[1][4]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + + {tokens} = grammar.tokenizeLine('console . log();') expect(tokens[0]).toEqual value: 'console', scopes: ['source.js', 'entity.name.type.object.console.js'] expect(tokens[2]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] expect(tokens[4]).toEqual value: 'log', scopes: ['source.js', 'meta.method-call.js', 'support.function.console.js'] expect(tokens[5]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] expect(tokens[6]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(tokens[7]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] describe "math", -> it "tokenizes the math object", -> - {tokens} = grammar.tokenizeLine('Math') + {tokens} = grammar.tokenizeLine('Math;') expect(tokens[0]).toEqual value: 'Math', scopes: ['source.js', 'support.class.js'] + expect(tokens[1]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] it "tokenizes math support functions/properties", -> - {tokens} = grammar.tokenizeLine('Math.random()') + {tokens} = grammar.tokenizeLine('Math.random();') expect(tokens[0]).toEqual value: 'Math', scopes: ['source.js', 'support.class.js'] expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] expect(tokens[2]).toEqual value: 'random', scopes: ['source.js', 'meta.method-call.js', 'support.function.math.js'] expect(tokens[3]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(tokens[5]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + + lines = grammar.tokenizeLines ''' + Math + .random(); + ''' + expect(lines[0][0]).toEqual value: 'Math', scopes: ['source.js', 'support.class.js'] + expect(lines[1][0]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] + expect(lines[1][1]).toEqual value: 'random', scopes: ['source.js', 'meta.method-call.js', 'support.function.math.js'] + expect(lines[1][2]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] + expect(lines[1][3]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(lines[1][4]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + - {tokens} = grammar.tokenizeLine('Math.PI') + {tokens} = grammar.tokenizeLine('Math.PI;') expect(tokens[0]).toEqual value: 'Math', scopes: ['source.js', 'support.class.js'] expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.delimiter.property.period.js'] expect(tokens[2]).toEqual value: 'PI', scopes: ['source.js', 'support.constant.property.math.js'] + expect(tokens[3]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] describe "indentation", -> editor = null From a73cb86b06b89783ef24653d005801d3c3d8b89a Mon Sep 17 00:00:00 2001 From: CentricStorm Date: Thu, 14 Apr 2016 15:14:51 +0100 Subject: [PATCH 002/420] :bug: Don't match `$console`, `$Math` --- grammars/javascript.cson | 6 +++--- spec/javascript-spec.coffee | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 00e795f4..a13c80d3 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -702,7 +702,7 @@ { # console # console.log(arg1, "arg2", [...]) - 'begin': '\\bconsole\\b(?!\\$)' + 'begin': '(? {tokens} = grammar.tokenizeLine('console$') expect(tokens[0]).not.toEqual value: 'console', scopes: ['source.js', 'entity.name.type.object.console.js'] + {tokens} = grammar.tokenizeLine('$console') + expect(tokens[1]).not.toEqual value: 'console', scopes: ['source.js', 'entity.name.type.object.console.js'] + it "tokenizes console support functions", -> {tokens} = grammar.tokenizeLine('console.log()') expect(tokens[0]).toEqual value: 'console', scopes: ['source.js', 'entity.name.type.object.console.js'] From 56a1c8c19d1e18309626fbb63831fa83c98fcd91 Mon Sep 17 00:00:00 2001 From: Maxim Sokolov Date: Sat, 16 Apr 2016 20:01:19 +0300 Subject: [PATCH 003/420] :bug: Fix regular functions/props after math/console --- grammars/javascript.cson | 28 ++++++++++++++++++++++------ spec/javascript-spec.coffee | 27 ++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index a13c80d3..0d6bb635 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -706,10 +706,17 @@ 'beginCaptures': '0': 'name': 'entity.name.type.object.console.js' - 'end': '(?=(?!\\s*\\.)\\S)' + 'end': '''(?x) + (?= + (?! \\s*(\\.)\\s* + (assert|clear|debug|error|info|log|profile|profileEnd|time|timeEnd|warn) + \\s*\\( + ) \\S + ) + ''' 'patterns': [ { - 'begin': '\\s*(\\.)\\s*(assert|clear|debug|error|info|log|profile|profileEnd|time|timeEnd|warn)\\s*(?=\\()' + 'begin': '\\s*(\\.)\\s*(\\w+)\\s*(?=\\()' 'beginCaptures': '1': 'name': 'meta.delimiter.method.period.js' @@ -730,12 +737,21 @@ 'begin': '(? expect(tokens[6]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] expect(tokens[7]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + it "tokenizes console custom functions", -> + {tokens} = grammar.tokenizeLine('console.foo();') + expect(tokens[0]).toEqual value: 'console', scopes: ['source.js', 'entity.name.type.object.console.js'] + expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] + expect(tokens[2]).toEqual value: 'foo', scopes: ['source.js', 'meta.method-call.js', 'entity.name.function.js'] + expect(tokens[3]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] + expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(tokens[5]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + describe "math", -> it "tokenizes the math object", -> {tokens} = grammar.tokenizeLine('Math;') - expect(tokens[0]).toEqual value: 'Math', scopes: ['source.js', 'support.class.js'] + expect(tokens[0]).toEqual value: 'Math', scopes: ['source.js', 'support.class.math.js'] expect(tokens[1]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] it "tokenizes math support functions/properties", -> {tokens} = grammar.tokenizeLine('Math.random();') - expect(tokens[0]).toEqual value: 'Math', scopes: ['source.js', 'support.class.js'] + expect(tokens[0]).toEqual value: 'Math', scopes: ['source.js', 'support.class.math.js'] expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] expect(tokens[2]).toEqual value: 'random', scopes: ['source.js', 'meta.method-call.js', 'support.function.math.js'] expect(tokens[3]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] @@ -1590,20 +1599,28 @@ describe "Javascript grammar", -> Math .random(); ''' - expect(lines[0][0]).toEqual value: 'Math', scopes: ['source.js', 'support.class.js'] + expect(lines[0][0]).toEqual value: 'Math', scopes: ['source.js', 'support.class.math.js'] expect(lines[1][0]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] expect(lines[1][1]).toEqual value: 'random', scopes: ['source.js', 'meta.method-call.js', 'support.function.math.js'] expect(lines[1][2]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] expect(lines[1][3]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] expect(lines[1][4]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] - {tokens} = grammar.tokenizeLine('Math.PI;') - expect(tokens[0]).toEqual value: 'Math', scopes: ['source.js', 'support.class.js'] + expect(tokens[0]).toEqual value: 'Math', scopes: ['source.js', 'support.class.math.js'] expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.delimiter.property.period.js'] expect(tokens[2]).toEqual value: 'PI', scopes: ['source.js', 'support.constant.property.math.js'] expect(tokens[3]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + it "tokenizes math custom functions", -> + {tokens} = grammar.tokenizeLine('Math.PI();') + expect(tokens[0]).toEqual value: 'Math', scopes: ['source.js', 'support.class.math.js'] + expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] + expect(tokens[2]).toEqual value: 'PI', scopes: ['source.js', 'meta.method-call.js', 'entity.name.function.js'] + expect(tokens[3]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] + expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(tokens[5]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + describe "indentation", -> editor = null From f62582359b5edbfd16f388e38144886a84d3a535 Mon Sep 17 00:00:00 2001 From: Maxim Sokolov Date: Sun, 17 Apr 2016 11:34:33 +0300 Subject: [PATCH 004/420] :bug: Fix `console`, `math` custom methods --- grammars/javascript.cson | 4 ++-- spec/javascript-spec.coffee | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 0d6bb635..43931945 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -711,7 +711,7 @@ (?! \\s*(\\.)\\s* (assert|clear|debug|error|info|log|profile|profileEnd|time|timeEnd|warn) \\s*\\( - ) \\S + ) \\s*\\S ) ''' 'patterns': [ @@ -745,7 +745,7 @@ expm1|floor|fround|hypot|imul|log|log10|log1p|log2|max|min|pow|random| round|sign|sin|sinh|sqrt|tan|tanh|trunc)\\s*\\( ) | (E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2)(?!\\s*\\()) - ) \\S + ) \\s*\\S ) ''' 'patterns': [ diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 53307f2c..0783d6be 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1580,6 +1580,9 @@ describe "Javascript grammar", -> expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] expect(tokens[5]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + {tokens} = grammar.tokenizeLine('console .foo();') + expect(tokens[3]).toEqual value: 'foo', scopes: ['source.js', 'meta.method-call.js', 'entity.name.function.js'] + describe "math", -> it "tokenizes the math object", -> {tokens} = grammar.tokenizeLine('Math;') From 7bddd57fc73eb7139f2a07fa7d0e3acac7b737e9 Mon Sep 17 00:00:00 2001 From: Maxim Sokolov Date: Sun, 17 Apr 2016 16:58:27 +0300 Subject: [PATCH 005/420] :bug: Fix more issues --- grammars/javascript.cson | 7 ++++--- spec/javascript-spec.coffee | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 9f97527e..5c35a85f 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -707,7 +707,7 @@ '0': 'name': 'entity.name.type.object.console.js' 'end': '''(?x) - (?= + (?<=\\)) | (?= (?! \\s*(\\.)\\s* (assert|clear|debug|error|info|log|profile|profileEnd|time|timeEnd|warn) \\s*\\( @@ -739,12 +739,13 @@ '0': 'name': 'support.class.math.js' 'end': '''(?x) - (?= + (?<=E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2|\\) + ) | (?= (?! \\s*\\.\\s* ( ((abs|acos|acosh|asin|asinh|atan|atan2|atanh|cbrt|ceil|clz32|cos|cosh|exp| expm1|floor|fround|hypot|imul|log|log10|log1p|log2|max|min|pow|random| round|sign|sin|sinh|sqrt|tan|tanh|trunc)\\s*\\( - ) | (E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2)(?!\\s*\\()) + ) | (E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2)(?!\\s*[\\w$(])) ) \\s*\\S ) ''' diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index aef2947d..27b6db59 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1556,12 +1556,13 @@ describe "Javascript grammar", -> expect(tokens[1]).not.toEqual value: 'console', scopes: ['source.js', 'entity.name.type.object.console.js'] it "tokenizes console support functions", -> - {tokens} = grammar.tokenizeLine('console.log()') + {tokens} = grammar.tokenizeLine('console.log().log()') expect(tokens[0]).toEqual value: 'console', scopes: ['source.js', 'entity.name.type.object.console.js'] expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] expect(tokens[2]).toEqual value: 'log', scopes: ['source.js', 'meta.method-call.js', 'support.function.console.js'] expect(tokens[3]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(tokens[6]).not.toEqual value: 'log', scopes: ['source.js', 'meta.method-call.js', 'support.function.console.js'] lines = grammar.tokenizeLines ''' console From cd6d3c2c88d8e3d4a10b703f6f58e5d3ba8a8c71 Mon Sep 17 00:00:00 2001 From: Maxim Sokolov Date: Wed, 20 Apr 2016 14:53:28 +0300 Subject: [PATCH 006/420] Tokenize console, Math methods after comments --- grammars/javascript.cson | 14 ++++++++++---- spec/javascript-spec.coffee | 9 +++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 5c35a85f..592923d7 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -708,13 +708,16 @@ 'name': 'entity.name.type.object.console.js' 'end': '''(?x) (?<=\\)) | (?= - (?! \\s*(\\.)\\s* + (?! (\\s*//)|(\\s*/\\*)|(\\s*(\\.)\\s* (assert|clear|debug|error|info|log|profile|profileEnd|time|timeEnd|warn) \\s*\\( - ) \\s*\\S + )) \\s*\\S ) ''' 'patterns': [ + { + 'include': '#comments' + } { 'begin': '\\s*(\\.)\\s*(\\w+)\\s*(?=\\()' 'beginCaptures': @@ -741,15 +744,18 @@ 'end': '''(?x) (?<=E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2|\\) ) | (?= - (?! \\s*\\.\\s* ( + (?! (\\s*//)|(\\s*/\\*)|(\\s*\\.\\s* ( ((abs|acos|acosh|asin|asinh|atan|atan2|atanh|cbrt|ceil|clz32|cos|cosh|exp| expm1|floor|fround|hypot|imul|log|log10|log1p|log2|max|min|pow|random| round|sign|sin|sinh|sqrt|tan|tanh|trunc)\\s*\\( ) | (E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2)(?!\\s*[\\w$(])) - ) \\s*\\S + )) \\s*\\S ) ''' 'patterns': [ + { + 'include': '#comments' + } { # Math.random() 'begin': '\\s*(\\.)\\s*(\\w+)\\s*(?=\\()' diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 27b6db59..d0e81635 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1564,6 +1564,15 @@ describe "Javascript grammar", -> expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] expect(tokens[6]).not.toEqual value: 'log', scopes: ['source.js', 'meta.method-call.js', 'support.function.console.js'] + {tokens} = grammar.tokenizeLine('console/**/.log()') + expect(tokens[0]).toEqual value: 'console', scopes: ['source.js', 'entity.name.type.object.console.js'] + expect(tokens[1]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[3]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] + expect(tokens[4]).toEqual value: 'log', scopes: ['source.js', 'meta.method-call.js', 'support.function.console.js'] + expect(tokens[5]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] + expect(tokens[6]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + lines = grammar.tokenizeLines ''' console .log(); From d61d14e5bb6d1c5598e31fe254466d0372265388 Mon Sep 17 00:00:00 2001 From: Wliu Date: Fri, 22 Apr 2016 18:42:36 -0400 Subject: [PATCH 007/420] Prepare 0.118.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3e8912f8..151b85bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.117.0", + "version": "0.118.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From cbbe69376ca69eab1b20bfb0785904cc43e9dd30 Mon Sep 17 00:00:00 2001 From: Wliu Date: Fri, 22 Apr 2016 18:47:01 -0400 Subject: [PATCH 008/420] Allow brackets in regex --- grammars/javascript.cson | 2 +- spec/javascript-spec.coffee | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index ac60318f..a82c630e 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -967,7 +967,7 @@ 'name': 'constant.language.js' } { - 'begin': '(?<=[\\[=(?:+,!]|^|return|=>|&&|\\|\\|)\\s*(/)(?![/*+{}?])(?=.*/)' + 'begin': '(?<=[\\[=(?:+,!]|^|return|=>|&&|\\|\\|)\\s*(/)(?![/*+?])(?=.*/)' 'beginCaptures': '1': 'name': 'punctuation.definition.string.begin.js' diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 6cd6ca12..b913060a 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -128,6 +128,10 @@ describe "Javascript grammar", -> expect(tokens[1]).toEqual value: 'test', scopes: ['source.js', 'string.regexp.js'] expect(tokens[2]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] + {tokens} = grammar.tokenizeLine('/{"}/') + expect(tokens[0]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] + expect(tokens[2]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] + {tokens} = grammar.tokenizeLine('foo + /test/') expect(tokens[0]).toEqual value: 'foo ', scopes: ['source.js'] expect(tokens[1]).toEqual value: '+', scopes: ['source.js', 'keyword.operator.js'] From bb0df12b935c866369d2d546e8cf59ea3e7a1d55 Mon Sep 17 00:00:00 2001 From: Wliu Date: Tue, 26 Apr 2016 22:53:55 -0400 Subject: [PATCH 009/420] Add support for ES6 HTML-style comments Also end comments when a tag is encountered (bad solution, but that's the best we can do with regex right now) --- grammars/javascript.cson | 49 ++++++++++++++++++++++++++++--------- spec/javascript-spec.coffee | 33 +++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 12 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index ac60318f..b4bfe03d 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -803,15 +803,6 @@ { 'include': '#comments' } - { - 'captures': - '0': - 'name': 'punctuation.definition.comment.html.js' - '2': - 'name': 'punctuation.definition.comment.html.js' - 'match': '()' - 'name': 'comment.block.html.js' - } { 'match': '(?)' # Unfortunately, we don't know when we're embedded, so this is as good as it gets 'name': 'comment.block.documentation.js' } { @@ -1637,7 +1628,7 @@ 'captures': '0': 'name': 'punctuation.definition.comment.js' - 'end': '\\*/' + 'end': '\\*/|(?=)' # Unfortunately, we don't know when we're embedded, so this is as good as it gets 'name': 'comment.block.js' } { @@ -1652,9 +1643,43 @@ 'beginCaptures': '0': 'name': 'punctuation.definition.comment.js' - 'end': '\\n' + 'end': '$|(?=)' # Unfortunately, we don't know when we're embedded, so this is as good as it gets 'name': 'comment.line.double-slash.js' } ] } + { + 'begin': '(^[ \\t]+)?(?=)' + 'beginCaptures': + '1': + 'name': 'punctuation.whitespace.comment.leading.js' + 'end': '(?!\\G)' + 'patterns': [ + { + 'begin': '-->' + 'beginCaptures': + '0': + 'name': 'punctuation.definition.comment.html.js' + 'end': '$|(?=)' # Unfortunately, we don't know when we're embedded, so this is as good as it gets + 'name': 'comment.line.html.js' + } + ] + } ] diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 6cd6ca12..764bb96d 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1563,6 +1563,39 @@ describe "Javascript grammar", -> expect(tokens[7]).toEqual value: ', p2 ', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js'] expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.definition.comment.js'] + it "tokenizes HTML-style comments correctly", -> + {tokens} = grammar.tokenizeLine ' comment' + expect(tokens[0]).toEqual value: '-->', scopes: ['source.js', 'comment.line.html.js', 'punctuation.definition.comment.html.js'] + expect(tokens[1]).toEqual value: ' comment', scopes: ['source.js', 'comment.line.html.js'] + + it "stops comments when a tag is encountered", -> + # HTML doesn't count comments if they're followed by a tag. Unfortunately we have + # no idea if we're embedded or not, so we err on the side of caution and always assume that we are :/ + + {tokens} = grammar.tokenizeLine '/* ' + expect(tokens[0]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[1]).not.toEqual value: ' ', scopes: ['source.js', 'comment.block.js'] + + {tokens} = grammar.tokenizeLine '/** ' + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[1]).not.toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine '// ' + expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] + expect(tokens[1]).not.toEqual value: ' ', scopes: ['source.js', 'comment.line.double-slash.js'] + + {tokens} = grammar.tokenizeLine ' ' + expect(tokens[0]).toEqual value: '-->', scopes: ['source.js', 'comment.line.html.js', 'punctuation.definition.comment.html.js'] + expect(tokens[1]).not.toEqual value: ' ', scopes: ['source.js', 'comment.line.html.js'] + describe "console", -> it "tokenizes the console keyword", -> {tokens} = grammar.tokenizeLine('console;') From 55af01787477974b885aca5145de00eb53fffd62 Mon Sep 17 00:00:00 2001 From: Wliu Date: Tue, 26 Apr 2016 22:54:19 -0400 Subject: [PATCH 010/420] Revert "Add support for ES6 HTML-style comments" This reverts commit bb0df12b935c866369d2d546e8cf59ea3e7a1d55. --- grammars/javascript.cson | 49 +++++++++---------------------------- spec/javascript-spec.coffee | 33 ------------------------- 2 files changed, 12 insertions(+), 70 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index b4bfe03d..ac60318f 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -803,6 +803,15 @@ { 'include': '#comments' } + { + 'captures': + '0': + 'name': 'punctuation.definition.comment.html.js' + '2': + 'name': 'punctuation.definition.comment.html.js' + 'match': '()' + 'name': 'comment.block.html.js' + } { 'match': '(?)' # Unfortunately, we don't know when we're embedded, so this is as good as it gets + 'end': '\\*/' 'name': 'comment.block.documentation.js' } { @@ -1628,7 +1637,7 @@ 'captures': '0': 'name': 'punctuation.definition.comment.js' - 'end': '\\*/|(?=)' # Unfortunately, we don't know when we're embedded, so this is as good as it gets + 'end': '\\*/' 'name': 'comment.block.js' } { @@ -1643,43 +1652,9 @@ 'beginCaptures': '0': 'name': 'punctuation.definition.comment.js' - 'end': '$|(?=)' # Unfortunately, we don't know when we're embedded, so this is as good as it gets + 'end': '\\n' 'name': 'comment.line.double-slash.js' } ] } - { - 'begin': '(^[ \\t]+)?(?=)' - 'beginCaptures': - '1': - 'name': 'punctuation.whitespace.comment.leading.js' - 'end': '(?!\\G)' - 'patterns': [ - { - 'begin': '-->' - 'beginCaptures': - '0': - 'name': 'punctuation.definition.comment.html.js' - 'end': '$|(?=)' # Unfortunately, we don't know when we're embedded, so this is as good as it gets - 'name': 'comment.line.html.js' - } - ] - } ] diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 764bb96d..6cd6ca12 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1563,39 +1563,6 @@ describe "Javascript grammar", -> expect(tokens[7]).toEqual value: ', p2 ', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js'] expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.definition.comment.js'] - it "tokenizes HTML-style comments correctly", -> - {tokens} = grammar.tokenizeLine ' comment' - expect(tokens[0]).toEqual value: '-->', scopes: ['source.js', 'comment.line.html.js', 'punctuation.definition.comment.html.js'] - expect(tokens[1]).toEqual value: ' comment', scopes: ['source.js', 'comment.line.html.js'] - - it "stops comments when a tag is encountered", -> - # HTML doesn't count comments if they're followed by a tag. Unfortunately we have - # no idea if we're embedded or not, so we err on the side of caution and always assume that we are :/ - - {tokens} = grammar.tokenizeLine '/* ' - expect(tokens[0]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(tokens[1]).not.toEqual value: ' ', scopes: ['source.js', 'comment.block.js'] - - {tokens} = grammar.tokenizeLine '/** ' - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - expect(tokens[1]).not.toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] - - {tokens} = grammar.tokenizeLine '// ' - expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] - expect(tokens[1]).not.toEqual value: ' ', scopes: ['source.js', 'comment.line.double-slash.js'] - - {tokens} = grammar.tokenizeLine ' ' - expect(tokens[0]).toEqual value: '-->', scopes: ['source.js', 'comment.line.html.js', 'punctuation.definition.comment.html.js'] - expect(tokens[1]).not.toEqual value: ' ', scopes: ['source.js', 'comment.line.html.js'] - describe "console", -> it "tokenizes the console keyword", -> {tokens} = grammar.tokenizeLine('console;') From fb8c711f50616db2e2e363dbfba501cb379cc0b5 Mon Sep 17 00:00:00 2001 From: impinball Date: Mon, 2 May 2016 19:08:04 -0400 Subject: [PATCH 011/420] Style `arguments` like `this`, style superclass name distinctly --- grammars/javascript.cson | 6 +++--- spec/javascript-spec.coffee | 22 ++++++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index ac60318f..f3f138c1 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -275,7 +275,7 @@ 'name': 'meta.export.js' } { - 'match': '(? expect(tokens[0]).toEqual value: 'class', scopes: ['source.js', 'meta.class.js', 'storage.type.class.js'] expect(tokens[2]).toEqual value: 'MyClass', scopes: ['source.js', 'meta.class.js', 'entity.name.type.class.js'] expect(tokens[4]).toEqual value: 'extends', scopes: ['source.js', 'meta.class.js', 'storage.modifier.js'] - expect(tokens[6]).toEqual value: 'SomeClass', scopes: ['source.js', 'meta.class.js', 'entity.name.type.class.js'] + expect(tokens[6]).toEqual value: 'SomeClass', scopes: ['source.js', 'meta.class.js', 'entity.other.inherited-class.js'] {tokens} = grammar.tokenizeLine('class MyClass extends $abc$') - expect(tokens[6]).toEqual value: '$abc$', scopes: ['source.js', 'meta.class.js', 'entity.name.type.class.js'] + expect(tokens[6]).toEqual value: '$abc$', scopes: ['source.js', 'meta.class.js', 'entity.other.inherited-class.js'] {tokens} = grammar.tokenizeLine('class MyClass extends $$') - expect(tokens[6]).toEqual value: '$$', scopes: ['source.js', 'meta.class.js', 'entity.name.type.class.js'] + expect(tokens[6]).toEqual value: '$$', scopes: ['source.js', 'meta.class.js', 'entity.other.inherited-class.js'] it "tokenizes anonymous class", -> {tokens} = grammar.tokenizeLine('class extends SomeClass') expect(tokens[0]).toEqual value: 'class', scopes: ['source.js', 'meta.class.js', 'storage.type.class.js'] expect(tokens[2]).toEqual value: 'extends', scopes: ['source.js', 'meta.class.js', 'storage.modifier.js'] - expect(tokens[4]).toEqual value: 'SomeClass', scopes: ['source.js', 'meta.class.js', 'entity.name.type.class.js'] + expect(tokens[4]).toEqual value: 'SomeClass', scopes: ['source.js', 'meta.class.js', 'entity.other.inherited-class.js'] {tokens} = grammar.tokenizeLine('class extends $abc$') - expect(tokens[4]).toEqual value: '$abc$', scopes: ['source.js', 'meta.class.js', 'entity.name.type.class.js'] + expect(tokens[4]).toEqual value: '$abc$', scopes: ['source.js', 'meta.class.js', 'entity.other.inherited-class.js'] {tokens} = grammar.tokenizeLine('class extends $$') - expect(tokens[4]).toEqual value: '$$', scopes: ['source.js', 'meta.class.js', 'entity.name.type.class.js'] + expect(tokens[4]).toEqual value: '$$', scopes: ['source.js', 'meta.class.js', 'entity.other.inherited-class.js'] describe "ES6 import", -> it "tokenizes import", -> @@ -1188,6 +1188,16 @@ describe "Javascript grammar", -> {tokens} = grammar.tokenizeLine('super') expect(tokens[0]).toEqual value: 'super', scopes: ['source.js', 'variable.language.js'] + it "tokenizes 'arguments'", -> + {tokens} = grammar.tokenizeLine('arguments') + expect(tokens[0]).toEqual value: 'arguments', scopes: ['source.js', 'variable.language.js'] + + {tokens} = grammar.tokenizeLine('arguments[0]') + expect(tokens[0]).toEqual value: 'arguments', scopes: ['source.js', 'variable.language.js'] + + {tokens} = grammar.tokenizeLine('arguments.length') + expect(tokens[0]).toEqual value: 'arguments', scopes: ['source.js', 'variable.language.js'] + it "tokenizes illegal identifiers", -> {tokens} = grammar.tokenizeLine('0illegal') expect(tokens[0]).toEqual value: '0illegal', scopes: ['source.js', 'invalid.illegal.identifier.js'] From 5fb7053b459ba595459f93fea10f5341cd3cc206 Mon Sep 17 00:00:00 2001 From: Wliu Date: Wed, 4 May 2016 15:46:18 -0400 Subject: [PATCH 012/420] Prepare 0.119.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 151b85bd..c23b6035 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.118.0", + "version": "0.119.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 795943b9bc4582391928ba71bd528d5bca869513 Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Mon, 13 Jun 2016 21:20:52 -0700 Subject: [PATCH 013/420] Enable Windows builds on AppVeyor --- README.md | 5 ++++- appveyor.yml | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 appveyor.yml diff --git a/README.md b/README.md index 04da220f..7ad8b74a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -# JavaScript language support in Atom [![Build Status](https://travis-ci.org/atom/language-javascript.svg?branch=master)](https://travis-ci.org/atom/language-javascript) +# JavaScript language support in Atom +[![OS X Build Status](https://travis-ci.org/atom/language-javascript.svg?branch=master)](https://travis-ci.org/atom/language-javascript) +[![Windows Build Status](https://ci.appveyor.com/api/projects/status/ktooccwna96ssiyr/branch/master?svg=true)](https://ci.appveyor.com/project/Atom/language-javascript-dijf8/branch/master) +[![Dependency Status](https://david-dm.org/atom/language-javascript.svg)](https://david-dm.org/atom/language-javascript) Adds syntax highlighting and snippets for JavaScript in Atom. diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..efe989f2 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,17 @@ +version: "{build}" + +os: Windows Server 2012 R2 + +install: + - choco install atom -y + - cd %APPVEYOR_BUILD_FOLDER% + - "%LOCALAPPDATA%/atom/bin/apm clean" + - "%LOCALAPPDATA%/atom/bin/apm install" + +build_script: + - cd %APPVEYOR_BUILD_FOLDER% + - "%LOCALAPPDATA%/atom/bin/apm test --path %LOCALAPPDATA%/atom/bin/atom.cmd" + +test: off + +deploy: off From dc39dd5c163b34ac3c3dac0e57ded86cbdf147d0 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Thu, 16 Jun 2016 01:43:55 +0200 Subject: [PATCH 014/420] Add @public docblock match in Javascript grammar Since it exists in official JSDoc dictionary : * http://usejsdoc.org/tags-public.html --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index f3f138c1..6d4771c2 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1601,7 +1601,7 @@ 'docblock': 'patterns': [ { - 'match': '(? Date: Fri, 24 Jun 2016 17:08:42 -0700 Subject: [PATCH 015/420] AppVeyor should test against stable & beta --- appveyor.yml | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index efe989f2..2b0fde43 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,17 +1,27 @@ version: "{build}" -os: Windows Server 2012 R2 +platform: x64 + +branches: + only: + - master + +clone_depth: 10 + +skip_tags: true + +environment: + APM_TEST_PACKAGES: + + matrix: + - ATOM_CHANNEL: stable + - ATOM_CHANNEL: beta install: - - choco install atom -y - - cd %APPVEYOR_BUILD_FOLDER% - - "%LOCALAPPDATA%/atom/bin/apm clean" - - "%LOCALAPPDATA%/atom/bin/apm install" + - ps: Install-Product node 4 build_script: - - cd %APPVEYOR_BUILD_FOLDER% - - "%LOCALAPPDATA%/atom/bin/apm test --path %LOCALAPPDATA%/atom/bin/atom.cmd" + - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/atom/ci/master/build-package.ps1')) test: off - deploy: off From e2a84a09fecdab56abecf95e165f9d6dae6aa0b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Segersv=C3=A4rd?= Date: Tue, 26 Jul 2016 13:22:33 +0200 Subject: [PATCH 016/420] Add JSDoc tags used by Closure Compiler --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 6d4771c2..000523e4 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1601,7 +1601,7 @@ 'docblock': 'patterns': [ { - 'match': '(? Date: Thu, 4 Aug 2016 11:15:04 +0300 Subject: [PATCH 017/420] :bug: Allow 'from' as identifier --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 000523e4..859c7d8d 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -891,7 +891,7 @@ 'name': 'meta.control.yield.js' } { - 'match': '(? Date: Thu, 4 Aug 2016 11:25:12 +0300 Subject: [PATCH 018/420] :bug: Fix 'constructor' boundary ```js a = { constructorABC: {} }; ``` --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 000523e4..ed54af7f 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -416,7 +416,7 @@ ] } { - 'begin': '(?=\\b(constructor)\\s*)' + 'begin': '(?=\\bconstructor\\b\\s*)' 'end': '(?<=})' 'patterns': [ { From 479dd5ec19c57af9d52f938e886d5ba648446136 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Mon, 8 Aug 2016 03:33:15 +1000 Subject: [PATCH 019/420] Allow multiple spaces in JSDoc tags --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 859c7d8d..02236f9d 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1605,7 +1605,7 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({\\b(?:[a-zA-Z_$][a-zA-Z_$0-9]*)\\b})\\s\\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b\\s*((?:(?!\\*\\/).)*)' + 'match': '({\\b(?:[a-zA-Z_$][a-zA-Z_$0-9]*)\\b})\\s+\\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b\\s*((?:(?!\\*\\/).)*)' 'captures': 0: 'name': 'other.meta.jsdoc' From 52926a5ef8a2ffa438b2e2e1e57c851643c4f3e5 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Mon, 8 Aug 2016 22:16:48 +0100 Subject: [PATCH 020/420] :bug: Add support for JSDoc optional parameters --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 02236f9d..479fa830 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1605,7 +1605,7 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({\\b(?:[a-zA-Z_$][a-zA-Z_$0-9]*)\\b})\\s+\\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b\\s*((?:(?!\\*\\/).)*)' + 'match': '({\\b(?:[a-zA-Z_$][\\w$]*)\\b})\\s+(\\[\\b(?:[a-zA-Z_$][\\w$]*)\\b\\]|\\b(?:[a-zA-Z_$][\\w$]*)\\b)\\s*((?:(?!\\*\\/).)*)' 'captures': 0: 'name': 'other.meta.jsdoc' From a33dcdca5603e12687af13541ef2f198334f7ca9 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Mon, 8 Aug 2016 22:17:12 +0100 Subject: [PATCH 021/420] :white_check_mark: Add spec for JSDoc optional parameters --- spec/javascript-spec.coffee | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index da4c209e..bd0a5828 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1509,6 +1509,13 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} [variable] this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[variable]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + + it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] From a06143a7798b10686937f34eb3e6f20e9706b27c Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Mon, 8 Aug 2016 23:49:47 +0100 Subject: [PATCH 022/420] :bug: Add support for JSDoc optional parameter default value --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 479fa830..150e94c1 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1605,7 +1605,7 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({\\b(?:[a-zA-Z_$][\\w$]*)\\b})\\s+(\\[\\b(?:[a-zA-Z_$][\\w$]*)\\b\\]|\\b(?:[a-zA-Z_$][\\w$]*)\\b)\\s*((?:(?!\\*\\/).)*)' + 'match': '({\\b(?:[a-zA-Z_$][\\w$]*)\\b})\\s+(\\[\\b(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\b\\]|\\b(?:[a-zA-Z_$][\\w$]*)\\b)\\s*((?:(?!\\*\\/).)*)' 'captures': 0: 'name': 'other.meta.jsdoc' From d7afe49d57b407d8751bdcdf7344685560543e0d Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Mon, 8 Aug 2016 23:50:05 +0100 Subject: [PATCH 023/420] :white_check_mark: Add spec for JSDoc optional parameter default values --- spec/javascript-spec.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index bd0a5828..b68a7e4e 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1514,7 +1514,10 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: '[variable]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - + {tokens} = grammar.tokenizeLine('/** @param {object} [variable=default value] this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[variable=default value]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') From 0b56f705efc45a2c2268cc4c431c2c209802fff5 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Tue, 9 Aug 2016 08:47:33 +0100 Subject: [PATCH 024/420] Add support for JSDoc parameter properties --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 150e94c1..ffa33202 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1605,7 +1605,7 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({\\b(?:[a-zA-Z_$][\\w$]*)\\b})\\s+(\\[\\b(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\b\\]|\\b(?:[a-zA-Z_$][\\w$]*)\\b)\\s*((?:(?!\\*\\/).)*)' + 'match': '({\\b(?:[a-zA-Z_$][\\w$]*)\\b})\\s+(\\[\\b(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\b\\]|\\b(?:[a-zA-Z_$][\\w$]*(?:.[a-zA-Z_$][\\w$]*)*)\\b)\\s*((?:(?!\\*\\/).)*)' 'captures': 0: 'name': 'other.meta.jsdoc' From 11325c86cd740c3c98997d733be1aabe2c1759d9 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Tue, 9 Aug 2016 08:47:45 +0100 Subject: [PATCH 025/420] :white_check_mark: Add spec for JSDoc parameter properties --- spec/javascript-spec.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index b68a7e4e..f63f62bd 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1519,6 +1519,11 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: '[variable=default value]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} parameter.property this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'parameter.property', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] From 165662bedb5e3d6ef676f52ab3063cbc27ab2887 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Tue, 9 Aug 2016 14:27:07 +0100 Subject: [PATCH 026/420] Fix escaping for JSDoc parameter properties regex --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index ffa33202..ba4272c3 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1605,7 +1605,7 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({\\b(?:[a-zA-Z_$][\\w$]*)\\b})\\s+(\\[\\b(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\b\\]|\\b(?:[a-zA-Z_$][\\w$]*(?:.[a-zA-Z_$][\\w$]*)*)\\b)\\s*((?:(?!\\*\\/).)*)' + 'match': '({\\b(?:[a-zA-Z_$][\\w$]*)\\b})\\s+(\\[\\b(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\b\\]|\\b(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*)\\b)\\s*((?:(?!\\*\\/).)*)' 'captures': 0: 'name': 'other.meta.jsdoc' From 94f93c1194b49a3c71ad52c967aaf01eecbe0feb Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Tue, 9 Aug 2016 16:38:22 +0100 Subject: [PATCH 027/420] :bug: Allow for dollar sign with JSDoc parameters --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index ba4272c3..f1ae6fbb 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1605,7 +1605,7 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({\\b(?:[a-zA-Z_$][\\w$]*)\\b})\\s+(\\[\\b(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\b\\]|\\b(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*)\\b)\\s*((?:(?!\\*\\/).)*)' + 'match': '({\\b(?:[a-zA-Z_$][\\w$]*)\\b})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' 'captures': 0: 'name': 'other.meta.jsdoc' From 189ace182c410cd70f8157f449bf6f10ddd7a79d Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Tue, 9 Aug 2016 16:40:11 +0100 Subject: [PATCH 028/420] :white_check_mark: Add spec for dollar sign with JSDoc parameters --- spec/javascript-spec.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index f63f62bd..0cb46a4c 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1509,6 +1509,11 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} $variable this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '$variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} [variable] this is the description */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: '[variable]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] From 045ee24188257782e37fdeba34be9fc212504c51 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 10 Aug 2016 14:31:52 +0100 Subject: [PATCH 029/420] :bug: Allow the use of * as a JSDoc type --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index f1ae6fbb..aacca329 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1605,7 +1605,7 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({\\b(?:[a-zA-Z_$][\\w$]*)\\b})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' + 'match': '({(?:\\*|[a-zA-Z_$][\\w$]*)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' 'captures': 0: 'name': 'other.meta.jsdoc' From 313a5310051188a2ebde7b296339e43b58e8e535 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 10 Aug 2016 14:32:28 +0100 Subject: [PATCH 030/420] :white_check_mark: Add spec for use of * as a JSDoc type --- spec/javascript-spec.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 0cb46a4c..393d4eee 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1529,6 +1529,11 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'parameter.property', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {*} variable this is the description */') + expect(tokens[4]).toEqual value: '{*}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] From e1b5268aea64a03562423325f81e2257000e3e19 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 10 Aug 2016 14:35:07 +0100 Subject: [PATCH 031/420] :bug: Allow use of namespaces in JSDoc types --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index aacca329..3b20bca8 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1605,7 +1605,7 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({(?:\\*|[a-zA-Z_$][\\w$]*)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' + 'match': '({(?:\\*|[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' 'captures': 0: 'name': 'other.meta.jsdoc' From a322e971bd49d2e787ae385d010caa5120bba858 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 10 Aug 2016 14:35:51 +0100 Subject: [PATCH 032/420] :white_check_mark: Add spec for use of namespaces in JSDoc types --- spec/javascript-spec.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 393d4eee..d26c045c 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1534,6 +1534,11 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {myNamespace.MyClass} variable this is the description */') + expect(tokens[4]).toEqual value: '{myNamespace.MyClass}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] From 9c1d2bd5b021e8521c7038533316b20e78c20951 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 10 Aug 2016 14:38:56 +0100 Subject: [PATCH 033/420] :bug: Allow for nullable JSDoc types --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 3b20bca8..0992b3b5 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1605,7 +1605,7 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({(?:\\*|[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' + 'match': '({(?:\\*|(?:\\?)?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' 'captures': 0: 'name': 'other.meta.jsdoc' From 52e10909ba968fcb0c376a4190b0f17a849964fc Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 10 Aug 2016 14:39:23 +0100 Subject: [PATCH 034/420] :white_check_mark: Add spec for nullable JSDoc types --- spec/javascript-spec.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index d26c045c..5a026c95 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1539,6 +1539,11 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {?number} variable this is the description */') + expect(tokens[4]).toEqual value: '{?number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] From 0b547f6429a52bb3191173bb56e5c53ff00e8a3e Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 10 Aug 2016 14:40:25 +0100 Subject: [PATCH 035/420] :bug: Allow for non-nullable JSDoc types --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 0992b3b5..13a1cb9d 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1605,7 +1605,7 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({(?:\\*|(?:\\?)?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' + 'match': '({(?:\\*|(?:\\?|\\!)?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' 'captures': 0: 'name': 'other.meta.jsdoc' From 5f6ca445832635d2f1c1bc94fdd5a6aef379b362 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 10 Aug 2016 14:40:42 +0100 Subject: [PATCH 036/420] :white_check_mark: Add spec for non-nullable types --- spec/javascript-spec.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 5a026c95..f7376bce 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1544,6 +1544,11 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {!number} variable this is the description */') + expect(tokens[4]).toEqual value: '{!number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] From c7523086a8bd1b433e597edac16eaca6a350140e Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 10 Aug 2016 14:51:03 +0100 Subject: [PATCH 037/420] :bug: Allow use of spread operator as prefix of JSDoc type --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 13a1cb9d..6ec36c23 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1605,7 +1605,7 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({(?:\\*|(?:\\?|\\!)?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' + 'match': '({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' 'captures': 0: 'name': 'other.meta.jsdoc' From a86ab62902a5993d5476ebce1755ff8e1be8f8dd Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 10 Aug 2016 14:51:28 +0100 Subject: [PATCH 038/420] :white_check_mark: Add spec for use of spread operator as prefix of JSDoc type --- spec/javascript-spec.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index f7376bce..a7d27a70 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1549,6 +1549,11 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {...number} variable this is the description */') + expect(tokens[4]).toEqual value: '{...number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] From 3d7bfe15c7c0771a7ffe5a03c94d5df92a4c848b Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 10 Aug 2016 19:58:05 +0100 Subject: [PATCH 039/420] :bug: Allow for alternative optional JSDoc type syntax --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 6ec36c23..ec533af0 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1605,7 +1605,7 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' + 'match': '({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*(?:\\=)?)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' 'captures': 0: 'name': 'other.meta.jsdoc' From 132dae0a3528a2a28492bb99e98121ba5bef836b Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 10 Aug 2016 19:58:35 +0100 Subject: [PATCH 040/420] :white_check_mark: Add spec for alternative optional JSDoc type syntax --- spec/javascript-spec.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index a7d27a70..6edfde8f 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1554,6 +1554,11 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {number=} variable this is the description */') + expect(tokens[4]).toEqual value: '{number=}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] From be8f99f0686c804b1d9a3ff239ab638834e0802f Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 10 Aug 2016 21:39:50 +0100 Subject: [PATCH 041/420] :fire: Remove unnecessary escaping slashes on = --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index ec533af0..675f0259 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1605,7 +1605,7 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*(?:\\=)?)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' + 'match': '({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*(?:=)?)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' 'captures': 0: 'name': 'other.meta.jsdoc' From 577695bf7013f794a3e0f065d07c0bc49461734c Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 10 Aug 2016 21:51:21 +0100 Subject: [PATCH 042/420] :fire: Remove uneccessary non-capture group --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 675f0259..b81267a7 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1605,7 +1605,7 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*(?:=)?)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' + 'match': '({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*=?)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' 'captures': 0: 'name': 'other.meta.jsdoc' From e20e6bbb5867f735f582c882fb6e1c0a1f803c72 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Thu, 11 Aug 2016 18:22:56 +0100 Subject: [PATCH 043/420] :bug: Allow for square bracket suffix in JSDoc type --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index b81267a7..8263290e 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1605,7 +1605,7 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*=?)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' + 'match': '({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*(?:\\[\\])?=?)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' 'captures': 0: 'name': 'other.meta.jsdoc' From 8b64904c5a4f766e24d5e344ebffa8ec92d4a845 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Thu, 11 Aug 2016 18:23:18 +0100 Subject: [PATCH 044/420] :white_check_mark: Add spec for square bracket suffix in JSDoc type --- spec/javascript-spec.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 6edfde8f..1cf2faef 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1559,6 +1559,11 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {number[]} variable this is the description */') + expect(tokens[4]).toEqual value: '{number[]}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] From 76d04e61affa5c4474e219e2edf74d941131150d Mon Sep 17 00:00:00 2001 From: Zirro Date: Mon, 15 Aug 2016 20:57:59 +0200 Subject: [PATCH 045/420] Add additional DOM methods --- grammars/javascript.cson | 64 ++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 8263290e..9ff5450f 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1427,13 +1427,11 @@ createEventObject|to(GMTString|UTCString|String|Source|UpperCase|LowerCase|LocaleString)| test|taint|taintEnabled|indexOf|italics|disableExternalCapture|dump|detachEvent|unshift| untaint|unwatch|updateCommands|join|javaEnabled|pop|push|plugins.refresh|paddings|parse| - print|prompt|preference|enableExternalCapture|elementFromPoint|exec|execScript| - execCommand|valueOf|UTC|queryCommandState|queryCommandIndeterm|queryCommandEnabled| - queryCommandValue|find|file|fileModifiedDate|fileSize|fileCreatedDate|fileUpdatedDate| - fixed|fontsize|fontcolor|forward|fromCharCode|watch|link|load|lastIndexOf| - anchor|attachEvent|atob|apply|alert|abort|routeEvents| - resize|resizeBy|resizeTo|recalc|returnValue|replace|reverse|reload|releaseCapture| - releaseEvents|go|get(Milliseconds|Seconds|Minutes|Hours|Month|Day|Year|FullYear| + print|prompt|preference|enableExternalCapture|exec|execScript|valueOf|UTC|find|file| + fileModifiedDate|fileSize|fileCreatedDate|fileUpdatedDate|fixed|fontsize|fontcolor| + forward|fromCharCode|watch|link|load|lastIndexOf|anchor|attachEvent|atob|apply|alert| + abort|routeEvents|resize|resizeBy|resizeTo|recalc|returnValue|replace|reverse|reload| + releaseCapture|releaseEvents|go|get(Milliseconds|Seconds|Minutes|Hours|Month|Day|Year|FullYear| Time|Date|TimezoneOffset|UTC(Milliseconds|Seconds|Minutes|Hours|Day|Month|FullYear|Date)| Attention|Selection|ResponseHeader|AllResponseHeaders)|moveBy|moveBelow|moveTo| moveToAbsolute|moveAbove|mergeAttributes|match|margins|btoa|big|bold|borderWidths|blink|back)\\b @@ -1442,15 +1440,49 @@ } { 'match': '''(?x) - \\b(substringData|submit|splitText|setNamedItem|setAttribute|setAttributeNode|select| - hasChildNodes|hasFeature|namedItem|click|close|cloneNode|createComment|createCDATASection| - createCaption|createTHead|createTextNode|createTFoot|createDocumentFragment| - createProcessingInstruction|createEntityReference|createElement|createAttribute| - tabIndex|insertRow|insertBefore|insertCell|insertData|item|open|deleteRow|deleteCell| - deleteCaption|deleteTHead|deleteTFoot|deleteData|focus|write|writeln|add|appendChild| - appendData|reset|replaceChild|replaceData|move|moveNamedItem|moveChild|moveAttribute| - moveAttributeNode|getNamedItem|getElementsByName|getElementsByTagName|getElementById| - getAttribute|getAttributeNode|blur)\\b + \\b(acceptNode|add|addEventListener|addTextTrack|adoptNode|after|animate|append| + appendChild|appendData|before|blur|canPlayType|captureStream| + caretPositionFromPoint|caretRangeFromPoint|checkValidity|clear|clear|click| + cloneContents|cloneNode|cloneRange|close|closest|collapse| + compareBoundaryPoints|compareDocumentPosition|comparePoint|contains| + convertPointFromNode|convertQuadFromNode|convertRectFromNode|createAttribute| + createAttributeNS|createCaption|createCDATASection|createComment| + createContextualFragment|createDocument|createDocumentFragment| + createDocumentType|createElement|createElementNS|createEntityReference| + createEvent|createExpression|createHTMLDocument|createNodeIterator| + createNSResolver|createProcessingInstruction|createRange|createShadowRoot| + createTBody|createTextNode|createTFoot|createTHead|createTreeWalker|delete| + deleteCaption|deleteCell|deleteContents|deleteData|deleteRow|deleteTFoot| + deleteTHead|detach|disconnect|dispatchEvent|elementFromPoint|elementsFromPoint| + enableStyleSheetsForSet|entries|evaluate|execCommand|exitFullscreen| + exitPointerLock|expand|extractContents|fastSeek|firstChild|focus|forEach|get| + getAll|getAnimations|getAttribute|getAttributeNames|getAttributeNode| + getAttributeNodeNS|getAttributeNS|getBoundingClientRect|getBoxQuads| + getClientRects|getContext|getDestinationInsertionPoints|getElementById| + getElementsByClassName|getElementsByName|getElementsByTagName| + getElementsByTagNameNS|getItem|getNamedItem|getSelection|getStartDate| + getVideoPlaybackQuality|has|hasAttribute|hasAttributeNS|hasAttributes| + hasChildNodes|hasFeature|hasFocus|importNode|initEvent|insertAdjacentElement| + insertAdjacentHTML|insertAdjacentText|insertBefore|insertCell|insertData| + insertNode|insertRow|intersectsNode|isDefaultNamespace|isEqualNode| + isPointInRange|isSameNode|item|key|keys|lastChild|load|lookupNamespaceURI| + lookupPrefix|matches|move|moveAttribute|moveAttributeNode|moveChild| + moveNamedItem|namedItem|nextNode|nextSibling|normalize|observe|open| + parentNode|pause|play|postMessage|prepend|preventDefault|previousNode| + previousSibling|probablySupportsContext|queryCommandEnabled| + queryCommandIndeterm|queryCommandState|queryCommandSupported|queryCommandValue| + querySelector|querySelectorAll|registerContentHandler|registerElement| + registerProtocolHandler|releaseCapture|releaseEvents|remove|removeAttribute| + removeAttributeNode|removeAttributeNS|removeChild|removeEventListener| + removeItem|replace|replaceChild|replaceData|replaceWith|reportValidity| + requestFullscreen|requestPointerLock|reset|scroll|scrollBy|scrollIntoView| + scrollTo|seekToNextFrame|select|selectNode|selectNodeContents|set|setAttribute| + setAttributeNode|setAttributeNodeNS|setAttributeNS|setCapture| + setCustomValidity|setEnd|setEndAfter|setEndBefore|setItem|setNamedItem| + setRangeText|setSelectionRange|setSinkId|setStart|setStartAfter|setStartBefore| + slice|splitText|stepDown|stepUp|stopImmediatePropagation|stopPropagation| + submit|substringData|supports|surroundContents|takeRecords|terminate|toBlob| + toDataURL|toggle|toString|values|write|writeln)\\b ''' 'name': 'support.function.dom.js' } From 744927151a70c0fafac1b207de6e5b1ed4e593b1 Mon Sep 17 00:00:00 2001 From: Zirro Date: Tue, 16 Aug 2016 17:46:34 +0200 Subject: [PATCH 046/420] Remove duplicate 'clear' --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 9ff5450f..bb329d76 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1442,7 +1442,7 @@ 'match': '''(?x) \\b(acceptNode|add|addEventListener|addTextTrack|adoptNode|after|animate|append| appendChild|appendData|before|blur|canPlayType|captureStream| - caretPositionFromPoint|caretRangeFromPoint|checkValidity|clear|clear|click| + caretPositionFromPoint|caretRangeFromPoint|checkValidity|clear|click| cloneContents|cloneNode|cloneRange|close|closest|collapse| compareBoundaryPoints|compareDocumentPosition|comparePoint|contains| convertPointFromNode|convertQuadFromNode|convertRectFromNode|createAttribute| From 93f5dc001f5e48bb5feb0e19d5a827addeed1f46 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 20 Aug 2016 00:27:47 +1000 Subject: [PATCH 047/420] Fix missing highlighting of certain case statements Certain primitives and "special" variables (such as "this" or __dirname) lose their highlighting when used in a case statement. This commit fixes that - even if "case debugger:" isn't valid JavaScript, an author should still be aware of the keyword's significance. --- grammars/javascript.cson | 50 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index bb329d76..1d4a423c 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -275,12 +275,20 @@ 'name': 'meta.export.js' } { - 'match': '(? Date: Sat, 20 Aug 2016 01:05:54 +1000 Subject: [PATCH 048/420] Include spec for 93f5dc0 --- spec/javascript-spec.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 1cf2faef..7a938bad 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -86,6 +86,12 @@ describe "Javascript grammar", -> expect(tokens[4]).toEqual value: ' ', scopes: ['source.js'] expect(tokens[5]).toEqual value: keyword, scopes: ['source.js', scope] + it "tokenises `#{keyword}` in case statements", -> + {tokens} = grammar.tokenizeLine("case #{keyword}:") + expect(tokens[0]).toEqual value: 'case', scopes: ['source.js', 'keyword.control.js'] + expect(tokens[2]).toEqual value: keyword, scopes: ['source.js', scope] + expect(tokens[3]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.js'] + describe "built-in globals", -> it "tokenizes built-in classes", -> {tokens} = grammar.tokenizeLine('window') From f300a4de2eacda4ce671adbb1c041da7fcde8129 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 20 Aug 2016 02:42:49 +1000 Subject: [PATCH 049/420] Use triple-quoted blocks for extended regex --- grammars/javascript.cson | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 1d4a423c..710f83d8 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -275,13 +275,13 @@ 'name': 'meta.export.js' } { - 'match': '(?x) + 'match': '''(?x) (? Date: Sat, 20 Aug 2016 06:11:01 +1000 Subject: [PATCH 050/420] Clean up grammar source * Simplified character classes for matching variable names: [a-zA-Z_$][a-zA-Z_$0-9]* -> [a-zA-Z_$][\\w$]* * Extended patterns now use triple-quoted blocks consistently * Lengthy patterns converted into extended patterns for readability --- grammars/javascript.cson | 59 ++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 710f83d8..dc68f405 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -50,13 +50,13 @@ 'name': 'invalid.illegal.js' '5': 'name': 'variable.other.module-alias.js' - 'match': '(?x) - (?: \\b(default)\\b | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) + 'match': '''(?x) + (?: \\b(default)\\b | \\b([a-zA-Z_$][\\w$]*)\\b) \\s* (\\b as \\b) \\s* - (?: (\\b default \\b | \\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) - ' + (?: (\\b default \\b | \\*) | \\b([a-zA-Z_$][\\w$]*)\\b) + ''' } { 'match': ',' @@ -66,7 +66,7 @@ 'include': '#comments' } { - 'match': '\\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b' + 'match': '\\b([a-zA-Z_$][\\w$]*)\\b' 'name': 'variable.other.module.js' } ] @@ -86,13 +86,13 @@ 'name': 'invalid.illegal.js' '6': 'name': 'variable.other.module-alias.js' - 'match': '(?x) - (?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) + 'match': '''(?x) + (?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][\\w$]*)\\b) \\s* (\\b as \\b) \\s* - (?: (\\b default \\b | \\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) - ' + (?: (\\b default \\b | \\*) | \\b([a-zA-Z_$][\\w$]*)\\b) + ''' } { 'match': '\\*' @@ -113,7 +113,7 @@ 'name': 'keyword.control.js' } { - 'match': '\\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b(?=.*\\bfrom\\b)' + 'match': '\\b([a-zA-Z_$][\\w$]*)\\b(?=.*\\bfrom\\b)' 'name': 'variable.other.module.js' } { @@ -126,7 +126,11 @@ } { 'comment': 'ES6 export: `export default (variable|class|function, etc.)`' - 'match': '(?x) \\b(export)\\b \\s* \\b(default)\\b (?:\\s*) \\b((?!\\bfunction\\b|\\bclass\\b|\\blet\\b|\\bvar\\b|\\bconst\\b)[a-zA-Z_$][a-zA-Z_$0-9]*)?\\b' + 'match': '''(?x) + \\b(export)\\b\\s* + \\b(default)\\b\\s* + \\b((?!\\b(?:function|class|let|var|const)\\b)[a-zA-Z_$][\\w$]*)?\\b + ''' 'captures': '0': 'name': 'meta.export.js' @@ -173,13 +177,13 @@ 'name': 'invalid.illegal.js' '6': 'name': 'variable.other.module-alias.js' - 'match': '(?x) - (?: \\b(default)\\b | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) + 'match': '''(?x) + (?: \\b(default)\\b | \\b([a-zA-Z_$][\\w$]*)\\b) \\s* (\\b as \\b) \\s* - (?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) - ' + (?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][\\w$]*)\\b) + ''' } { 'match': ',' @@ -189,7 +193,7 @@ 'include': '#comments' } { - 'match': '\\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b' + 'match': '\\b([a-zA-Z_$][\\w$]*)\\b' 'name': 'variable.other.module.js' } ] @@ -220,13 +224,13 @@ 'name': 'invalid.illegal.js' '6': 'name': 'variable.other.module-alias.js' - 'match': '(?x) - (?: \\b(default)\\b | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) + 'match': '''(?x) + (?: \\b(default)\\b | \\b([a-zA-Z_$][\\w$]*)\\b) \\s* (\\b as \\b) \\s* - (?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b) - ' + (?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][\\w$]*)\\b) + ''' } { 'include': '#comments' @@ -236,7 +240,7 @@ 'name': 'meta.delimiter.object.comma.js' } { - 'match': '\\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b' + 'match': '\\b([a-zA-Z_$][\\w$]*)\\b' 'name': 'variable.other.module.js' } ] @@ -260,7 +264,7 @@ 'name': 'keyword.control.js' } { - 'match': '\\b([a-zA-Z_$][a-zA-Z_$0-9]*)\\b' + 'match': '\\b([a-zA-Z_$][\\w$]*)\\b' 'name': 'variable.other.module.js' } { @@ -1673,7 +1677,16 @@ 'docblock': 'patterns': [ { - 'match': '(? Date: Sat, 20 Aug 2016 15:21:59 +0300 Subject: [PATCH 051/420] :bug: Fix arrow functions inside ternary expressions --- grammars/javascript.cson | 125 +++++++++++++++---- spec/javascript-spec.coffee | 232 +++++++++++++++++++++++------------- 2 files changed, 253 insertions(+), 104 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 710f83d8..e812a079 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -279,16 +279,12 @@ (? expect(lines[2][1]).toEqual value: delim, scopes: ['source.js', scope, 'punctuation.definition.string.end.js'] describe "keywords", -> - it "tokenizes with as a keyword", -> - {tokens} = grammar.tokenizeLine('with') - expect(tokens[0]).toEqual value: 'with', scopes: ['source.js', 'keyword.control.js'] + keywords = ['await', 'break', 'catch', 'continue', 'do'] - map = - super: 'variable.language.js' - this: 'variable.language.js' - null: 'constant.language.null.js' - true: 'constant.language.boolean.true.js' - false: 'constant.language.boolean.false.js' - debugger: 'keyword.other.js' - exports: 'support.variable.js' - __filename: 'support.variable.js' - - for keyword, scope of map - do (keyword, scope) -> - it "does not tokenize `#{keyword}` when it is an object key", -> - {tokens} = grammar.tokenizeLine("#{keyword}: 1") - expect(tokens[0]).toEqual value: keyword, scopes: ['source.js'] - expect(tokens[1]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.js'] - - it "tokenizes `#{keyword}` in the middle of ternary expressions", -> - {tokens} = grammar.tokenizeLine("a ? #{keyword} : b") - expect(tokens[2]).toEqual value: ' ', scopes: ['source.js'] - expect(tokens[3]).toEqual value: keyword, scopes: ['source.js', scope] - - it "tokenizes `#{keyword}` at the end of ternary expressions", -> - {tokens} = grammar.tokenizeLine("a ? b : #{keyword}") - expect(tokens[4]).toEqual value: ' ', scopes: ['source.js'] - expect(tokens[5]).toEqual value: keyword, scopes: ['source.js', scope] - - it "tokenises `#{keyword}` in case statements", -> - {tokens} = grammar.tokenizeLine("case #{keyword}:") - expect(tokens[0]).toEqual value: 'case', scopes: ['source.js', 'keyword.control.js'] - expect(tokens[2]).toEqual value: keyword, scopes: ['source.js', scope] - expect(tokens[3]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.js'] + for keyword in keywords + it "tokenizes the #{keyword} keyword", -> + {tokens} = grammar.tokenizeLine(keyword) + expect(tokens[0]).toEqual value: keyword, scopes: ['source.js', 'keyword.control.js'] describe "built-in globals", -> it "tokenizes built-in classes", -> @@ -160,21 +130,6 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] expect(tokens[7]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] - it "tokenizes regular expressions inside ternary expressions", -> - {tokens} = grammar.tokenizeLine('a ? /b/ : /c/') - expect(tokens[ 0]).toEqual value: 'a ', scopes: ['source.js'] - expect(tokens[ 1]).toEqual value: '?', scopes: ['source.js', 'keyword.operator.js'] - expect(tokens[ 2]).toEqual value: ' ', scopes: ['source.js', 'string.regexp.js'] - expect(tokens[ 3]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] - expect(tokens[ 4]).toEqual value: 'b', scopes: ['source.js', 'string.regexp.js'] - expect(tokens[ 5]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] - expect(tokens[ 6]).toEqual value: ' ', scopes: ['source.js'] - expect(tokens[ 7]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.js'] - expect(tokens[ 8]).toEqual value: ' ', scopes: ['source.js', 'string.regexp.js'] - expect(tokens[ 9]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] - expect(tokens[10]).toEqual value: 'c', scopes: ['source.js', 'string.regexp.js'] - expect(tokens[11]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] - it "tokenizes regular expressions inside arrow function expressions", -> {tokens} = grammar.tokenizeLine('getRegex = () => /^helloworld$/;') expect(tokens[9]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] @@ -283,15 +238,6 @@ describe "Javascript grammar", -> expect(tokens[0]).toEqual value: 'i', scopes: ['source.js'] expect(tokens[1]).toEqual value: '--', scopes: ['source.js', 'keyword.operator.decrement.js'] - describe "conditional ternary", -> - it "tokenizes them", -> - {tokens} = grammar.tokenizeLine('test ? expr1 : expr2') - expect(tokens[0]).toEqual value: 'test ', scopes: ['source.js'] - expect(tokens[1]).toEqual value: '?', scopes: ['source.js', 'keyword.operator.js'] - expect(tokens[2]).toEqual value: ' expr1 ', scopes: ['source.js'] - expect(tokens[3]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.js'] - expect(tokens[4]).toEqual value: ' expr2', scopes: ['source.js'] - describe "logical", -> operators = ["&&", "||", "!"] @@ -523,18 +469,13 @@ describe "Javascript grammar", -> expect(tokens[5]).toEqual value: 'systemLanguage', scopes: ['source.js', 'support.constant.js'] expect(tokens[6]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] - it "does not tokenize constants when they are object keys", -> - {tokens} = grammar.tokenizeLine('FOO: 1') - expect(tokens[0]).toEqual value: 'FOO', scopes: ['source.js'] - expect(tokens[1]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.js'] - it "tokenizes constants in the middle of ternary expressions", -> {tokens} = grammar.tokenizeLine('a ? FOO : b') expect(tokens[3]).toEqual value: 'FOO', scopes: ['source.js', 'constant.other.js'] it "tokenizes constants at the end of ternary expressions", -> {tokens} = grammar.tokenizeLine('a ? b : FOO') - expect(tokens[5]).toEqual value: 'FOO', scopes: ['source.js', 'constant.other.js'] + expect(tokens[7]).toEqual value: 'FOO', scopes: ['source.js', 'constant.other.js'] describe "ES6 string templates", -> it "tokenizes them as strings", -> @@ -823,7 +764,7 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: "'", scopes: ['source.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] expect(tokens[7]).toEqual value: "prop", scopes: ['source.js', 'string.quoted.single.js'] expect(tokens[8]).toEqual value: "'", scopes: ['source.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] - expect(tokens[9]).toEqual value: ":", scopes: ['source.js', 'keyword.operator.js'] + expect(tokens[9]).toEqual value: ":", scopes: ['source.js', 'keyword.operator.assignment.js'] expect(tokens[11]).toEqual value: "'", scopes: ['source.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] expect(tokens[12]).toEqual value: "value", scopes: ['source.js', 'string.quoted.single.js'] expect(tokens[13]).toEqual value: "'", scopes: ['source.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] @@ -908,19 +849,6 @@ describe "Javascript grammar", -> expect(tokens[0]).toEqual value: 'yield', scopes: ['source.js', 'meta.control.yield.js', 'keyword.control.js'] expect(tokens[2]).toEqual value: '*', scopes: ['source.js', 'meta.control.yield.js', 'storage.modifier.js'] - it "does not tokenize yield when it is an object key", -> - {tokens} = grammar.tokenizeLine('yield: 1') - expect(tokens[0]).toEqual value: 'yield', scopes: ['source.js'] - expect(tokens[1]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.js'] - - it "tokenizes yield in the middle of ternary expressions", -> - {tokens} = grammar.tokenizeLine('a ? yield : b') - expect(tokens[3]).toEqual value: 'yield', scopes: ['source.js', 'meta.control.yield.js', 'keyword.control.js'] - - it "tokenizes yield at the end of ternary expressions", -> - {tokens} = grammar.tokenizeLine('a ? b : yield') - expect(tokens[5]).toEqual value: 'yield', scopes: ['source.js', 'meta.control.yield.js', 'keyword.control.js'] - describe "default: in a switch statement", -> it "tokenizes it as a keyword", -> {tokens} = grammar.tokenizeLine('default: ') @@ -1253,7 +1181,7 @@ describe "Javascript grammar", -> expect(tokens[8]).toEqual value: ',', scopes: ['source.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.delimiter.object.comma.js'] expect(tokens[10]).toEqual value: '{', scopes: ['source.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.brace.curly.js'] expect(tokens[11]).toEqual value: 'a', scopes: ['source.js', 'meta.function-call.js', 'meta.arguments.js'] - expect(tokens[12]).toEqual value: ':', scopes: ['source.js', 'meta.function-call.js', 'meta.arguments.js', 'keyword.operator.js'] + expect(tokens[12]).toEqual value: ':', scopes: ['source.js', 'meta.function-call.js', 'meta.arguments.js', 'keyword.operator.assignment.js'] expect(tokens[14]).toEqual value: '123', scopes: ['source.js', 'meta.function-call.js', 'meta.arguments.js', 'constant.numeric.decimal.js'] expect(tokens[15]).toEqual value: '}', scopes: ['source.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.brace.curly.js'] expect(tokens[16]).toEqual value: ')', scopes: ['source.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] @@ -1736,6 +1664,150 @@ describe "Javascript grammar", -> expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] expect(tokens[5]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + describe "object literals", -> + keywords = ['super', 'this', 'null', 'true', 'false', 'debugger', 'exports', '__filename'] + + for keyword in keywords + it "tokenizes the #{keyword} keyword when it is an object key", -> + {tokens} = grammar.tokenizeLine("#{keyword}: 1") + expect(tokens[0]).toEqual value: keyword, scopes: ['source.js'] + expect(tokens[1]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.assignment.js'] + + it "tokenizes object keys", -> + {tokens} = grammar.tokenizeLine('foo: 1') + expect(tokens[0]).toEqual value: 'foo', scopes: ['source.js'] + expect(tokens[1]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.assignment.js'] + + {tokens} = grammar.tokenizeLine('$abc$: 1') + expect(tokens[0]).toEqual value: '$abc$', scopes: ['source.js'] + expect(tokens[1]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.assignment.js'] + + {tokens} = grammar.tokenizeLine('0abc: 1') + expect(tokens[0]).toEqual value: '0abc', scopes: ['source.js', 'invalid.illegal.identifier.js'] + expect(tokens[1]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.assignment.js'] + + {tokens} = grammar.tokenizeLine('"key": 1') + expect(tokens[0]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[1]).toEqual value: 'key', scopes: ['source.js', 'string.quoted.double.js'] + expect(tokens[2]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[3]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.assignment.js'] + + it "tokenizes numbers when they are object keys", -> + {tokens} = grammar.tokenizeLine('123: 1') + expect(tokens[0]).toEqual value: '123', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[1]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.assignment.js'] + + it "tokenizes constants when they are object keys", -> + {tokens} = grammar.tokenizeLine('FOO: 1') + expect(tokens[0]).toEqual value: 'FOO', scopes: ['source.js'] + expect(tokens[1]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.assignment.js'] + + describe "ternary expressions", -> + map = + FOO: 'constant.other.js' + super: 'variable.language.js' + this: 'variable.language.js' + null: 'constant.language.null.js' + true: 'constant.language.boolean.true.js' + false: 'constant.language.boolean.false.js' + exports: 'support.variable.js' + __filename: 'support.variable.js' + + for keyword, scope of map + do (keyword, scope) -> + it "tokenizes `#{keyword}` in the middle of ternary expressions", -> + {tokens} = grammar.tokenizeLine("a ? #{keyword} : b") + expect(tokens[3]).toEqual value: keyword, scopes: ['source.js', scope] + + it "tokenizes `#{keyword}` at the end of ternary expressions", -> + {tokens} = grammar.tokenizeLine("a ? b : #{keyword}") + expect(tokens[7]).toEqual value: keyword, scopes: ['source.js', scope] + + it "tokenizes yield at the end of ternary expressions", -> + {tokens} = grammar.tokenizeLine('a ? b : yield') + expect(tokens[7]).toEqual value: 'yield', scopes: ['source.js', 'meta.control.yield.js', 'keyword.control.js'] + + it "tokenizes yield in the middle of ternary expressions", -> + {tokens} = grammar.tokenizeLine('a ? yield : b') + expect(tokens[3]).toEqual value: 'yield', scopes: ['source.js', 'meta.control.yield.js', 'keyword.control.js'] + + it "tokenizes regular expressions inside ternary expressions", -> + {tokens} = grammar.tokenizeLine('a ? /b/ : /c/') + expect(tokens[0]).toEqual value: 'a ', scopes: ['source.js'] + expect(tokens[1]).toEqual value: '?', scopes: ['source.js', 'keyword.operator.ternary.js'] + expect(tokens[2]).toEqual value: ' ', scopes: ['source.js', 'string.regexp.js'] + expect(tokens[3]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] + expect(tokens[4]).toEqual value: 'b', scopes: ['source.js', 'string.regexp.js'] + expect(tokens[5]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] + expect(tokens[6]).toEqual value: ' ', scopes: ['source.js'] + expect(tokens[7]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.ternary.js'] + expect(tokens[8]).toEqual value: ' ', scopes: ['source.js', 'string.regexp.js'] + expect(tokens[9]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] + expect(tokens[10]).toEqual value: 'c', scopes: ['source.js', 'string.regexp.js'] + expect(tokens[11]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] + + it "tokenizes object literals in the middle of ternary expressions", -> + {tokens} = grammar.tokenizeLine('a ? {key: value} : b') + expect(tokens[1]).toEqual value: '?', scopes: ['source.js', 'keyword.operator.ternary.js'] + expect(tokens[9]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.ternary.js'] + + it "tokenizes arrow functions inside ternary expressions", -> + {tokens} = grammar.tokenizeLine('result = condition ? something : (a, b) => a + b') + expect(tokens[3]).toEqual value: '?', scopes: ['source.js', 'keyword.operator.ternary.js'] + expect(tokens[7]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.ternary.js'] + expect(tokens[16]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.js', 'storage.type.function.arrow.js'] + + {tokens} = grammar.tokenizeLine('result = condition ? (a, b) => a + b : something') + expect(tokens[3]).toEqual value: '?', scopes: ['source.js', 'keyword.operator.ternary.js'] + expect(tokens[12]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.js', 'storage.type.function.arrow.js'] + expect(tokens[18]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.ternary.js'] + + describe "switch statements", -> + it "tokenizes the switch keyword", -> + {tokens} = grammar.tokenizeLine('switch(){}') + expect(tokens[0]).toEqual value: 'switch', scopes: ['source.js', 'meta.switch-statement.js', 'keyword.control.switch.js'] + + it "tokenizes switch expression", -> + {tokens} = grammar.tokenizeLine('switch(foo + bar){}') + expect(tokens[1]).toEqual value: '(', scopes: ['source.js', 'meta.switch-statement.js', 'punctuation.definition.switch-expression.begin.bracket.round.js'] + expect(tokens[2]).toEqual value: 'foo ', scopes: ['source.js', 'meta.switch-statement.js'] + expect(tokens[3]).toEqual value: '+', scopes: ['source.js', 'meta.switch-statement.js', 'keyword.operator.js'] + expect(tokens[4]).toEqual value: ' bar', scopes: ['source.js', 'meta.switch-statement.js'] + expect(tokens[5]).toEqual value: ')', scopes: ['source.js', 'meta.switch-statement.js', 'punctuation.definition.switch-expression.end.bracket.round.js'] + + it "tokenizes switch block", -> + lines = grammar.tokenizeLines ''' + switch (foo()) + { + case abc: + case 1+1: + 2+2 + break; + case null: + default: + } + ''' + expect(lines[1][0]).toEqual value: '{', scopes: ['source.js', 'meta.switch-statement.js', 'punctuation.definition.section.switch-block.begin.bracket.curly.js'] + expect(lines[2][1]).toEqual value: 'case', scopes: ['source.js', 'meta.switch-statement.js', 'keyword.control.case.js'] + expect(lines[2][3]).toEqual value: 'abc', scopes: ['source.js', 'meta.switch-statement.js'] + expect(lines[2][4]).toEqual value: ':', scopes: ['source.js', 'meta.switch-statement.js', 'punctuation.definition.section.case-statement.js'] + expect(lines[3][1]).toEqual value: 'case', scopes: ['source.js', 'meta.switch-statement.js', 'keyword.control.case.js'] + expect(lines[3][3]).toEqual value: '1', scopes: ['source.js', 'meta.switch-statement.js', 'constant.numeric.decimal.js'] + expect(lines[3][4]).toEqual value: '+', scopes: ['source.js', 'meta.switch-statement.js', 'keyword.operator.js'] + expect(lines[3][5]).toEqual value: '1', scopes: ['source.js', 'meta.switch-statement.js', 'constant.numeric.decimal.js'] + expect(lines[3][6]).toEqual value: ':', scopes: ['source.js', 'meta.switch-statement.js', 'punctuation.definition.section.case-statement.js'] + expect(lines[4][1]).toEqual value: '2', scopes: ['source.js', 'meta.switch-statement.js', 'constant.numeric.decimal.js'] + expect(lines[4][2]).toEqual value: '+', scopes: ['source.js', 'meta.switch-statement.js', 'keyword.operator.js'] + expect(lines[4][3]).toEqual value: '2', scopes: ['source.js', 'meta.switch-statement.js', 'constant.numeric.decimal.js'] + expect(lines[5][1]).toEqual value: 'break', scopes: ['source.js', 'meta.switch-statement.js', 'keyword.control.js'] + expect(lines[5][2]).toEqual value: ';', scopes: ['source.js', 'meta.switch-statement.js', 'punctuation.terminator.statement.js'] + expect(lines[6][1]).toEqual value: 'case', scopes: ['source.js', 'meta.switch-statement.js', 'keyword.control.case.js'] + expect(lines[6][3]).toEqual value: 'null', scopes: ['source.js', 'meta.switch-statement.js', 'constant.language.null.js'] + expect(lines[6][4]).toEqual value: ':', scopes: ['source.js', 'meta.switch-statement.js', 'punctuation.definition.section.case-statement.js'] + expect(lines[7][1]).toEqual value: 'default', scopes: ['source.js', 'meta.switch-statement.js', 'keyword.control.default.js'] + expect(lines[7][2]).toEqual value: ':', scopes: ['source.js', 'meta.switch-statement.js', 'punctuation.definition.section.case-statement.js'] + expect(lines[8][0]).toEqual value: '}', scopes: ['source.js', 'meta.switch-statement.js', 'punctuation.definition.section.switch-block.end.bracket.curly.js'] + describe "indentation", -> editor = null From 883e1e0c65dcb5b386178939753251d8527d0c69 Mon Sep 17 00:00:00 2001 From: Maxim Sokolov Date: Sat, 20 Aug 2016 15:56:01 +0300 Subject: [PATCH 052/420] :white_check_mark: Add spec for constructor --- spec/javascript-spec.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index da4c209e..9072af2e 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1043,6 +1043,9 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: ')', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'punctuation.definition.parameters.end.bracket.round.js'] expect(tokens[10]).toEqual value: 'this', scopes: ['source.js', 'variable.language.js'] + {tokens} = grammar.tokenizeLine('constructorABC: {}') + expect(tokens[0]).not.toEqual value: 'constructor', scopes: ['source.js', 'meta.function.js', 'entity.name.function.constructor.js'] + it "tokenizes named function expressions", -> {tokens} = grammar.tokenizeLine('var func = function foo(){}') expect(tokens[0]).toEqual value: 'var', scopes: ['source.js', 'storage.type.var.js'] From 9f6a8acba4b3538e6679b55d2bab8a9289922e8b Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sun, 21 Aug 2016 00:53:35 +1000 Subject: [PATCH 053/420] Add pattern-matching for Unicode escape sequences --- grammars/javascript.cson | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 710f83d8..b9e93f81 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1214,8 +1214,7 @@ 'name': 'string.quoted.single.js' 'patterns': [ { - 'match': '\\\\(x\\h{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)' - 'name': 'constant.character.escape.js' + 'include': '#string_escapes' } { 'match': "[^']*[^\\n\\r'\\\\]$" @@ -1235,8 +1234,7 @@ 'name': 'string.quoted.double.js' 'patterns': [ { - 'match': '\\\\(x\\h{2}|[0-2][0-7]{0,2}|3[0-6][0-7]|37[0-7]?|[4-7][0-7]?|.)' - 'name': 'constant.character.escape.js' + 'include': '#string_escapes' } { 'match': '[^"]*[^\\n\\r"\\\\]$' @@ -1258,8 +1256,7 @@ 'name': 'string.quoted.template.html.js' 'patterns': [ { - 'match': '\\\\(x\\h{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)' - 'name': 'constant.character.escape.js' + 'include': '#string_escapes' } { 'include': '#interpolated_js' @@ -1283,8 +1280,7 @@ 'name': 'string.quoted.template.graphql.js' 'patterns': [ { - 'match': '\\\\(x\\h{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)' - 'name': 'constant.character.escape.js' + 'include': '#string_escapes' } { 'include': '#interpolated_js' @@ -1306,8 +1302,7 @@ 'name': 'string.quoted.template.js' 'patterns': [ { - 'match': '\\\\(x\\h{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)' - 'name': 'constant.character.escape.js' + 'include': '#string_escapes' } { 'include': '#interpolated_js' @@ -1315,6 +1310,26 @@ ] } ] + 'string_escapes': + 'patterns': [ + { + 'match': '\\\\u(?![A-Fa-f0-9]{4}|\\{[A-Fa-f0-9]+\\})[^\'"]*' + 'name': 'invalid.illegal.identifier.js' + } + { + 'match': '\\\\u(?:[A-Fa-f0-9]{4}|(\\{)[A-Fa-f0-9]+(\\}))' + 'name': 'constant.character.escape.js' + 'captures': + '1': + 'name': 'punctuation.section.scope.begin.js' + '2': + 'name': 'punctuation.section.scope.end.js' + } + { + 'match': '\\\\(x\\h{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)' + 'name': 'constant.character.escape.js' + } + ] 'function_params': 'patterns': [ { From a208ceb10f6fd154b2798e0197ccaa26e864f74b Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sun, 21 Aug 2016 01:15:49 +1000 Subject: [PATCH 054/420] Add error highlighting to codepoints over U+10FFFF --- grammars/javascript.cson | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index b9e93f81..20c28b4e 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1317,12 +1317,20 @@ 'name': 'invalid.illegal.identifier.js' } { - 'match': '\\\\u(?:[A-Fa-f0-9]{4}|(\\{)[A-Fa-f0-9]+(\\}))' + 'match': '\\\\u(?:[A-Fa-f0-9]{4}|(\\{)([A-Fa-f0-9]+)(\\}))' 'name': 'constant.character.escape.js' 'captures': '1': 'name': 'punctuation.section.scope.begin.js' '2': + 'patterns': [ + { + # Max codepoint: \u{10FFFF} + 'match': '[A-Fa-f\\d]{7,}|(?!10)[A-Fa-f\\d]{6}' + 'name': 'invalid.illegal.identifier.js' + } + ] + '3': 'name': 'punctuation.section.scope.end.js' } { From 6e63fcc4e31036781527866489a949e02cce20cb Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sun, 21 Aug 2016 02:13:46 +1000 Subject: [PATCH 055/420] Expand patterns for matching DOM/support constants --- grammars/javascript.cson | 53 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index dc68f405..32794b5a 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -967,11 +967,37 @@ 'name': 'keyword.other.js' } { - 'match': '(? Date: Sat, 20 Aug 2016 19:17:41 +0300 Subject: [PATCH 056/420] Clean up pattern groups Closes #276. --- grammars/javascript.cson | 90 +++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 42 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 32794b5a..ca00a202 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -20,14 +20,16 @@ 'name': 'JavaScript' 'patterns': [ { - 'comment': 'ES6 import' + # ES6 import 'begin': '(?)' 'captures': '0': 'name': 'punctuation.definition.comment.html.js' '2': 'name': 'punctuation.definition.comment.html.js' - 'match': '()' 'name': 'comment.block.html.js' } { @@ -1114,13 +1114,13 @@ 'name': 'meta.delimiter.method.period.js' } { + # Allows the special return snippet to fire. + 'match': '({)(})' 'captures': '1': 'name': 'punctuation.section.scope.begin.js' '2': 'name': 'punctuation.section.scope.end.js' - 'comment': 'Allows the special return snippet to fire.' - 'match': '({)(})' } { 'begin': '{' @@ -1751,23 +1751,29 @@ 'patterns': [ { 'begin': '/\\*\\*(?!/)' - 'captures': + 'beginCaptures': + '0': + 'name': 'punctuation.definition.comment.js' + 'end': '\\*/' + 'endCaptures': '0': 'name': 'punctuation.definition.comment.js' + 'name': 'comment.block.documentation.js' 'patterns': [ { 'include': '#docblock' } ] - 'end': '\\*/' - 'name': 'comment.block.documentation.js' } { 'begin': '/\\*' - 'captures': + 'beginCaptures': '0': 'name': 'punctuation.definition.comment.js' 'end': '\\*/' + 'endCaptures': + '0': + 'name': 'punctuation.definition.comment.js' 'name': 'comment.block.js' } { From a2ae4660408c88f6094fa02cb2eb728ae98eac0f Mon Sep 17 00:00:00 2001 From: Maxim Sokolov Date: Mon, 22 Aug 2016 07:07:13 +0300 Subject: [PATCH 057/420] :fire: Remove unneeded code --- grammars/javascript.cson | 4 ---- spec/javascript-spec.coffee | 5 ----- 2 files changed, 9 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index e812a079..c7d7a20f 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -898,10 +898,6 @@ 'match': '(? expect(tokens[0]).toEqual value: 'yield', scopes: ['source.js', 'meta.control.yield.js', 'keyword.control.js'] expect(tokens[2]).toEqual value: '*', scopes: ['source.js', 'meta.control.yield.js', 'storage.modifier.js'] - describe "default: in a switch statement", -> - it "tokenizes it as a keyword", -> - {tokens} = grammar.tokenizeLine('default: ') - expect(tokens[0]).toEqual value: 'default', scopes: ['source.js', 'keyword.control.js'] - describe "functions", -> it "tokenizes regular function declarations", -> {tokens} = grammar.tokenizeLine('function foo(){}') From 619316e520a37ea9234c009f96ad179ece6aab01 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Tue, 23 Aug 2016 23:15:58 +0100 Subject: [PATCH 058/420] :bug: Add improved JSDoc highlighting for return --- grammars/javascript.cson | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index f32a26fa..4236125b 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1677,16 +1677,38 @@ 'name': 'storage.type.class.jsdoc' } { - 'match': '({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*(?:\\[\\])?=?)})\\s+(\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*))\\s*((?:(?!\\*\\/).)*)' + 'match': '''(?x) + ({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*(?:\\[\\])?=?)}) + \\s+ + (\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*)) + \\s+ + ((?:(?!\\*\\/).)*) + ''' + 'captures': + '0': + 'name': 'other.meta.jsdoc' + '1': + 'name': 'entity.name.type.instance.jsdoc' + '2': + 'name': 'variable.other.jsdoc' + '3': + 'name': 'other.description.jsdoc' + } + { + 'match': '''(?x) + (?:(?<=@returns)|(?<=@return)) + \\s+ + ({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*(?:\\[\\])?=?)}) + \\s+ + ((?:(?!\\*\\/).)*) + ''' 'captures': - 0: - 'name': 'other.meta.jsdoc' - 1: - 'name': 'entity.name.type.instance.jsdoc' - 2: - 'name': 'variable.other.jsdoc' - 3: - 'name': 'other.description.jsdoc' + '0': + 'name': 'other.meta.jsdoc' + '1': + 'name': 'entity.name.type.instance.jsdoc' + '2': + 'name': 'other.description.jsdoc' } ] 'comments': From 2a24cc249f876287776175045fccfd5a7baa8301 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Tue, 23 Aug 2016 23:16:35 +0100 Subject: [PATCH 059/420] :white_check_mark: Add specs for improved JSDoc highlighting for return --- spec/javascript-spec.coffee | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index d890beba..68f0b29c 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1573,6 +1573,20 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {object} this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @return {object} */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @returns {object} this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @returns {object} */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] From b04283b4d847bc78c5ece6dcba65e72ff5e4c638 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 23 Aug 2016 14:55:05 +1000 Subject: [PATCH 060/420] Allow whitespace in "support.constant" accessors This commit fixes a minor bug with scope-matching: window.innerWidth # Ends in support.constant.js window. innerWidth # Doesn't Both lines are nonetheless identical in JavaScript. --- grammars/javascript.cson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 0b8a1989..2ec05e53 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -977,7 +977,7 @@ 'name': 'support.class.js' } { - 'match': '''(?x) (\\.) + 'match': '''(?x) (\\.) \\s* (MAX_VALUE|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY|URLUnencoded|X[MS]LDocument|[xyz]|_content|aLinkcolor |above|all|appCodeName|appCore|appMinorVersion|appName|appVersion|arguments|arity|availHeight|availLeft|availTop |availWidth|backgroundColor|backgroundImage|below|borderBottomWidth|borderColor|borderLeftWidth|borderRightWidth @@ -1005,7 +1005,7 @@ 'name': 'support.constant.js' } { - 'match': '''(?x) (\\.) + 'match': '''(?x) (\\.) \\s* (abbr|accept|acceptCharset|accessKey|action|align|aLink|alt|anchors|applets|archive|areas|attributes|axis|background |bgColor|body|border|caption|cells|cellPadding|cellSpacing|ch|charset|checked|childNodes|chOff|cite|className|clear |code|codeBase|codeType|color|cols|colSpan|compact|content|cookie|cords|data|dateTime|declare|defaultChecked From fb9f7d8f2df8bef2a076cdce8e8a501d74d2f0da Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 23 Aug 2016 17:17:20 +1000 Subject: [PATCH 061/420] Update and correctly classify "support" keywords MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added the full list of standardised web APIs from MDN: https://developer.mozilla.org/en-US/docs/Web/API * Added support for less heard-of ES6+ value types (ArrayBuffer, SIMD …) * Added "dom" scope for DOM-specific interfaces and objects * Removed highlighting for non-standard/deprecated properties/classes --- grammars/javascript.cson | 161 ++++++++++++++++++++++++++---------- spec/javascript-spec.coffee | 8 +- 2 files changed, 120 insertions(+), 49 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 2ec05e53..a23ac152 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -968,72 +968,143 @@ } { 'match': '''(?x) (? describe "built-in globals", -> it "tokenizes built-in classes", -> {tokens} = grammar.tokenizeLine('window') - expect(tokens[0]).toEqual value: 'window', scopes: ['source.js', 'support.class.js'] + expect(tokens[0]).toEqual value: 'window', scopes: ['source.js', 'support.variable.dom.js'] {tokens} = grammar.tokenizeLine('window.name') - expect(tokens[0]).toEqual value: 'window', scopes: ['source.js', 'support.class.js'] + expect(tokens[0]).toEqual value: 'window', scopes: ['source.js', 'support.variable.dom.js'] {tokens} = grammar.tokenizeLine('$window') expect(tokens[0]).toEqual value: '$window', scopes: ['source.js'] @@ -515,12 +515,12 @@ describe "Javascript grammar", -> expect(tokens[4]).toEqual value: '=', scopes: ['source.js', 'keyword.operator.assignment.js'] it "tokenizes support constants", -> - {tokens} = grammar.tokenizeLine('awesome = cool.systemLanguage;') + {tokens} = grammar.tokenizeLine('awesome = cool.EPSILON;') expect(tokens[0]).toEqual value: 'awesome ', scopes: ['source.js'] expect(tokens[1]).toEqual value: '=', scopes: ['source.js', 'keyword.operator.assignment.js'] expect(tokens[3]).toEqual value: 'cool', scopes: ['source.js', 'variable.other.object.js'] expect(tokens[4]).toEqual value: '.', scopes: ['source.js', 'meta.delimiter.property.period.js'] - expect(tokens[5]).toEqual value: 'systemLanguage', scopes: ['source.js', 'support.constant.js'] + expect(tokens[5]).toEqual value: 'EPSILON', scopes: ['source.js', 'support.constant.js'] expect(tokens[6]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] it "does not tokenize constants when they are object keys", -> From 3d1f8f38c3f91e85dd0cb8b3348a8783c652d6ef Mon Sep 17 00:00:00 2001 From: Maxim Sokolov Date: Tue, 23 Aug 2016 10:26:47 +0300 Subject: [PATCH 062/420] :white_check_mark: Add test for debugger statement --- spec/javascript-spec.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index ab3ac771..458eaa92 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -62,6 +62,11 @@ describe "Javascript grammar", -> {tokens} = grammar.tokenizeLine(keyword) expect(tokens[0]).toEqual value: keyword, scopes: ['source.js', 'keyword.control.js'] + it "tokenizes the debugger statement", -> + {tokens} = grammar.tokenizeLine("debugger;") + expect(tokens[0]).toEqual value: "debugger", scopes: ['source.js', 'keyword.other.js'] + expect(tokens[1]).toEqual value: ";", scopes: ['source.js', 'punctuation.terminator.statement.js'] + describe "built-in globals", -> it "tokenizes built-in classes", -> {tokens} = grammar.tokenizeLine('window') From 7296d5df7a242f4d99831f7e35c4fbfc39db4bc8 Mon Sep 17 00:00:00 2001 From: Maxim Sokolov Date: Tue, 23 Aug 2016 10:35:20 +0300 Subject: [PATCH 063/420] :fire: Remove unneeded code --- grammars/javascript.cson | 76 +++++++--------------------------------- 1 file changed, 13 insertions(+), 63 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index c7d7a20f..14aa8ab5 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -275,16 +275,8 @@ 'name': 'meta.export.js' } { - 'match': '''(?x) - (? Date: Tue, 23 Aug 2016 10:36:46 +0300 Subject: [PATCH 064/420] Add subscope for debugger keyword --- grammars/javascript.cson | 2 +- spec/javascript-spec.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 14aa8ab5..08085a57 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -907,7 +907,7 @@ } { 'match': '(? it "tokenizes the debugger statement", -> {tokens} = grammar.tokenizeLine("debugger;") - expect(tokens[0]).toEqual value: "debugger", scopes: ['source.js', 'keyword.other.js'] + expect(tokens[0]).toEqual value: "debugger", scopes: ['source.js', 'keyword.other.debugger.js'] expect(tokens[1]).toEqual value: ";", scopes: ['source.js', 'punctuation.terminator.statement.js'] describe "built-in globals", -> From 157241d0fd3c8804f15a4387e1275d5fdbb050dc Mon Sep 17 00:00:00 2001 From: Maxim Sokolov Date: Tue, 23 Aug 2016 11:09:07 +0300 Subject: [PATCH 065/420] :art: Move rule to the repo --- grammars/javascript.cson | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 08085a57..41aabcaa 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -968,12 +968,7 @@ 'name': 'keyword.operator.ternary.js' 'patterns': [ { - 'match': '(\\w+)(?=\\s*:)' - 'captures': - '1': - 'patterns': [ - 'include': '$self' - ] + 'include': '#prevent_object_keys_matching' } { 'include': '$self' @@ -1725,12 +1720,7 @@ 'name': 'punctuation.definition.section.case-statement.js' 'patterns': [ { - 'match': '(\\w+)(?=\\s*:)' - 'captures': - '1': - 'patterns': [ - 'include': '$self' - ] + 'include': '#prevent_object_keys_matching' } { 'include': '$self' @@ -1753,3 +1743,17 @@ ] } ] + 'prevent_object_keys_matching': + 'patterns': [ + { + # e.g. don't treat null as an object key in + # ? null : + # case null: + 'match': '(\\w+)(?=\\s*:)' + 'captures': + '1': + 'patterns': [ + 'include': '$self' + ] + } + ] From 2fac2bd8482282f6593086d7ff9dd54478ff3318 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 23 Aug 2016 18:11:48 +1000 Subject: [PATCH 066/420] Fix bugs with matching dollar-signs in constants Fixes #409. --- grammars/javascript.cson | 6 +++++- spec/javascript-spec.coffee | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index a23ac152..0844efc1 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1161,7 +1161,11 @@ 'include': '#properties' } { - 'match': '(? {tokens} = grammar.tokenizeLine('OBJ.prop') expect(tokens[0]).toEqual value: 'OBJ', scopes: ['source.js', 'constant.other.object.js'] + it "tokenises constants with dollar signs", -> + constants = ['CON$TANT', 'ABC$', 'ABC$D', '$_ALL', 'ALL_$', 'ANGULAR$$$$$$$$$$$'] + for constant in constants + {tokens} = grammar.tokenizeLine(constant) + expect(tokens[0]).toEqual value: constant, scopes: ['source.js', 'constant.other.js'] + it "tokenizes variables declared using `const` as constants", -> {tokens} = grammar.tokenizeLine('const myCoolVar = 42;') expect(tokens[0]).toEqual value: 'const', scopes: ['source.js', 'storage.modifier.js'] From de3212648440ae367f9c19ddc4c9eb8334dd2b33 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 23 Aug 2016 18:19:16 +1000 Subject: [PATCH 067/420] Avoid matching "this" in "$this" Fixes #344. --- grammars/javascript.cson | 2 +- spec/javascript-spec.coffee | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 0844efc1..fb47c6ed 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -280,7 +280,7 @@ } { 'match': '''(?x) - (? {tokens} = grammar.tokenizeLine('this.obj.prototype = new El()') expect(tokens[0]).toEqual value: 'this', scopes: ['source.js', 'variable.language.js'] + {tokens} = grammar.tokenizeLine('$this') + expect(tokens[0].value).toEqual '$this' + + {tokens} = grammar.tokenizeLine('this$') + expect(tokens[0].value).toEqual 'this$' + it "tokenizes 'super'", -> {tokens} = grammar.tokenizeLine('super') expect(tokens[0]).toEqual value: 'super', scopes: ['source.js', 'variable.language.js'] From fb456ca9411b19aff3f417da00923df6023c29e0 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 23 Aug 2016 19:09:48 +1000 Subject: [PATCH 068/420] Fix bugs with matching instantiation patterns * Fixes inconsistent scopes with full-stops (closes #280) * Fixes "new obj.ct.Class();" stopping at "new obj.ct" * Fixes "new obj.ct.Cla$$();" not matching due to dollar signs --- grammars/javascript.cson | 10 ++++++++-- spec/javascript-spec.coffee | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index fb47c6ed..b50b3198 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -717,13 +717,19 @@ 'name': 'meta.class.js' } { + 'match': '(new)\\s+([\\w$]+[\\w.$]*)' + 'name': 'meta.class.instance.constructor' 'captures': '1': 'name': 'keyword.operator.new.js' '2': 'name': 'entity.name.type.instance.js' - 'match': '(new)\\s+(\\$?\\w+(?:\\.\\w*)?)' - 'name': 'meta.class.instance.constructor' + 'patterns':[ + { + 'match': '\\.' + 'name': 'meta.delimiter.property.period.js' + } + ] } { # console diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 5f415291..5fbd9e3d 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -127,6 +127,24 @@ describe "Javascript grammar", -> expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'meta.class.instance.constructor'] expect(tokens[2]).toEqual value: '$something', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js'] + {tokens} = grammar.tokenizeLine('var instance = new obj.ct.Cla$s();') + expect(tokens).toEqual [ + {value: 'var', scopes: ['source.js', 'storage.type.var.js']} + {value: ' instance ', scopes: ['source.js']} + {value: '=', scopes: ['source.js', 'keyword.operator.assignment.js']} + {value: ' ', scopes: ['source.js']} + {value: 'new', scopes: ['source.js', 'meta.class.instance.constructor', 'keyword.operator.new.js']} + {value: ' ', scopes: ['source.js', 'meta.class.instance.constructor']} + {value: 'obj', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js']} + {value: '.', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js', 'meta.delimiter.property.period.js']} + {value: 'ct', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js']} + {value: '.', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js', 'meta.delimiter.property.period.js']} + {value: 'Cla$s', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js']} + {value: '(', scopes: ['source.js', 'meta.brace.round.js']} + {value: ')', scopes: ['source.js', 'meta.brace.round.js']} + {value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js']} + ] + describe "regular expressions", -> it "tokenizes regular expressions", -> {tokens} = grammar.tokenizeLine('/test/') From 50b02a4c35216ebe39eadf1afa6a619ee832a1f6 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 23 Aug 2016 19:16:27 +1000 Subject: [PATCH 069/420] Allow solitary majuscules to match as constants Fixes #413. --- grammars/javascript.cson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index b50b3198..56cc3c01 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1168,9 +1168,9 @@ } { 'match': '''(?x) - ((? Date: Tue, 23 Aug 2016 20:24:55 +1000 Subject: [PATCH 070/420] Add specs for 9f6a8ac and a208ceb --- spec/javascript-spec.coffee | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 5fbd9e3d..c70033a0 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -54,6 +54,55 @@ describe "Javascript grammar", -> expect(lines[2][0]).toEqual value: 'line3', scopes: ['source.js', scope] expect(lines[2][1]).toEqual value: delim, scopes: ['source.js', scope, 'punctuation.definition.string.end.js'] + describe "Unicode escape sequences", -> + delimsByScope = + "string.quoted.double.js": '"' + "string.quoted.single.js": "'" + + it "tokenises 2-digit sequences", -> + for scope, quote of delimsByScope + {tokens} = grammar.tokenizeLine(quote + '\\x2011' + quote) + expect(tokens[0]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.begin.js'] + expect(tokens[1]).toEqual value: '\\x20', scopes: ['source.js', scope, 'constant.character.escape.js'] + expect(tokens[2]).toEqual value: '11', scopes: ['source.js', scope] + expect(tokens[3]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.end.js'] + + it "tokenises 4-digit sequences", -> + for scope, quote of delimsByScope + {tokens} = grammar.tokenizeLine(quote + '\\u2011' + quote) + expect(tokens[0]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.begin.js'] + expect(tokens[1]).toEqual value: '\\u2011', scopes: ['source.js', scope, 'constant.character.escape.js'] + expect(tokens[2]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.end.js'] + + it "tokenises variable-length sequences", -> + for scope, quote of delimsByScope + {tokens} = grammar.tokenizeLine(quote + '\\u{2000}' + quote) + expect(tokens[0]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.begin.js'] + expect(tokens[1]).toEqual value: '\\u', scopes: ['source.js', scope, 'constant.character.escape.js'] + expect(tokens[2]).toEqual value: '{', scopes: ['source.js', scope, 'constant.character.escape.js', 'punctuation.section.scope.begin.js'] + expect(tokens[3]).toEqual value: '2000', scopes: ['source.js', scope, 'constant.character.escape.js'] + expect(tokens[4]).toEqual value: '}', scopes: ['source.js', scope, 'constant.character.escape.js', 'punctuation.section.scope.end.js'] + expect(tokens[5]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.end.js'] + + it "highlights sequences with invalid syntax", -> + for invalid in ['\\u', '\\u{2000', '\\u{G}'] + {tokens} = grammar.tokenizeLine('"' + invalid + '"') + expect(tokens[1]).toEqual value: invalid, scopes: ['source.js', 'string.quoted.double.js', 'invalid.illegal.identifier.js'] + + it "highlights sequences with invalid codepoints", -> + maxCodepoint = 0x10FFFF + for codepoint in [0x5000, 0x11FFFF, 0x1000000, maxCodepoint] + pointStr = codepoint.toString(16).toUpperCase().replace(/^0x/, "") + {tokens} = grammar.tokenizeLine('"\\u{' + pointStr + '}"') + pointScopes = ['source.js', 'string.quoted.double.js', 'constant.character.escape.js'] + if codepoint > maxCodepoint then pointScopes.push 'invalid.illegal.identifier.js' + expect(tokens[0]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[1]).toEqual value: '\\u', scopes: ['source.js', 'string.quoted.double.js', 'constant.character.escape.js'] + expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'string.quoted.double.js', 'constant.character.escape.js', 'punctuation.section.scope.begin.js'] + expect(tokens[3]).toEqual value: pointStr, scopes: pointScopes + expect(tokens[4]).toEqual value: '}', scopes: ['source.js', 'string.quoted.double.js', 'constant.character.escape.js', 'punctuation.section.scope.end.js'] + expect(tokens[5]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + describe "keywords", -> it "tokenizes with as a keyword", -> {tokens} = grammar.tokenizeLine('with') From d95b0ea8758effc8cfaff22f53b991807064a1d9 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 23 Aug 2016 20:33:37 +1000 Subject: [PATCH 071/420] Avoid matching constants without majuscules --- grammars/javascript.cson | 2 +- spec/javascript-spec.coffee | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 56cc3c01..f9a47b64 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1168,7 +1168,7 @@ } { 'match': '''(?x) - ((? {tokens} = grammar.tokenizeLine(constant) expect(tokens[0]).toEqual value: constant, scopes: ['source.js', 'constant.other.js'] + it "doesn't tokenise constants without alphabetic characters", -> + for name in ['$_', '$', '_', '$_$_$_$___$___$____$'] + {tokens} = grammar.tokenizeLine(name) + expect(tokens[0]).toEqual value: name, scopes: ['source.js'] + it "tokenizes variables declared using `const` as constants", -> {tokens} = grammar.tokenizeLine('const myCoolVar = 42;') expect(tokens[0]).toEqual value: 'const', scopes: ['source.js', 'storage.modifier.js'] From 0ee586487b00ef3ea506669d819b26f06f363d76 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 23 Aug 2016 21:25:01 +1000 Subject: [PATCH 072/420] Use more specific scope-names when possible --- grammars/javascript.cson | 12 ++++++------ spec/javascript-spec.coffee | 16 ++++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index f9a47b64..98cc9a14 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1443,25 +1443,25 @@ 'string_escapes': 'patterns': [ { - 'match': '\\\\u(?![A-Fa-f0-9]{4}|\\{[A-Fa-f0-9]+\\})[^\'"]*' - 'name': 'invalid.illegal.identifier.js' + 'match': '\\\\u(?![A-Fa-f0-9]{4}|{[A-Fa-f0-9]+})[^\'"]*' + 'name': 'invalid.illegal.unicode-escape.js' } { - 'match': '\\\\u(?:[A-Fa-f0-9]{4}|(\\{)([A-Fa-f0-9]+)(\\}))' + 'match': '\\\\u(?:[A-Fa-f0-9]{4}|({)([A-Fa-f0-9]+)(}))' 'name': 'constant.character.escape.js' 'captures': '1': - 'name': 'punctuation.section.scope.begin.js' + 'name': 'punctuation.definition.unicode-escape.begin.bracket.curly.js' '2': 'patterns': [ { # Max codepoint: \u{10FFFF} 'match': '[A-Fa-f\\d]{7,}|(?!10)[A-Fa-f\\d]{6}' - 'name': 'invalid.illegal.identifier.js' + 'name': 'invalid.illegal.unicode-escape.js' } ] '3': - 'name': 'punctuation.section.scope.end.js' + 'name': 'punctuation.definition.unicode-escape.end.bracket.curly.js' } { 'match': '\\\\(x\\h{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)' diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 36667549..5e9151c1 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -55,6 +55,10 @@ describe "Javascript grammar", -> expect(lines[2][1]).toEqual value: delim, scopes: ['source.js', scope, 'punctuation.definition.string.end.js'] describe "Unicode escape sequences", -> + bracketScopes = [ + 'punctuation.definition.unicode-escape.begin.bracket.curly.js', + 'punctuation.definition.unicode-escape.end.bracket.curly.js' + ] delimsByScope = "string.quoted.double.js": '"' "string.quoted.single.js": "'" @@ -79,15 +83,15 @@ describe "Javascript grammar", -> {tokens} = grammar.tokenizeLine(quote + '\\u{2000}' + quote) expect(tokens[0]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.begin.js'] expect(tokens[1]).toEqual value: '\\u', scopes: ['source.js', scope, 'constant.character.escape.js'] - expect(tokens[2]).toEqual value: '{', scopes: ['source.js', scope, 'constant.character.escape.js', 'punctuation.section.scope.begin.js'] + expect(tokens[2]).toEqual value: '{', scopes: ['source.js', scope, 'constant.character.escape.js', bracketScopes[0]] expect(tokens[3]).toEqual value: '2000', scopes: ['source.js', scope, 'constant.character.escape.js'] - expect(tokens[4]).toEqual value: '}', scopes: ['source.js', scope, 'constant.character.escape.js', 'punctuation.section.scope.end.js'] + expect(tokens[4]).toEqual value: '}', scopes: ['source.js', scope, 'constant.character.escape.js', bracketScopes[1]] expect(tokens[5]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.end.js'] it "highlights sequences with invalid syntax", -> for invalid in ['\\u', '\\u{2000', '\\u{G}'] {tokens} = grammar.tokenizeLine('"' + invalid + '"') - expect(tokens[1]).toEqual value: invalid, scopes: ['source.js', 'string.quoted.double.js', 'invalid.illegal.identifier.js'] + expect(tokens[1]).toEqual value: invalid, scopes: ['source.js', 'string.quoted.double.js', 'invalid.illegal.unicode-escape.js'] it "highlights sequences with invalid codepoints", -> maxCodepoint = 0x10FFFF @@ -95,12 +99,12 @@ describe "Javascript grammar", -> pointStr = codepoint.toString(16).toUpperCase().replace(/^0x/, "") {tokens} = grammar.tokenizeLine('"\\u{' + pointStr + '}"') pointScopes = ['source.js', 'string.quoted.double.js', 'constant.character.escape.js'] - if codepoint > maxCodepoint then pointScopes.push 'invalid.illegal.identifier.js' + if codepoint > maxCodepoint then pointScopes.push 'invalid.illegal.unicode-escape.js' expect(tokens[0]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] expect(tokens[1]).toEqual value: '\\u', scopes: ['source.js', 'string.quoted.double.js', 'constant.character.escape.js'] - expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'string.quoted.double.js', 'constant.character.escape.js', 'punctuation.section.scope.begin.js'] + expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'string.quoted.double.js', 'constant.character.escape.js', bracketScopes[0]] expect(tokens[3]).toEqual value: pointStr, scopes: pointScopes - expect(tokens[4]).toEqual value: '}', scopes: ['source.js', 'string.quoted.double.js', 'constant.character.escape.js', 'punctuation.section.scope.end.js'] + expect(tokens[4]).toEqual value: '}', scopes: ['source.js', 'string.quoted.double.js', 'constant.character.escape.js', bracketScopes[1]] expect(tokens[5]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] describe "keywords", -> From fc8560ee6f03b8de6386984989ab883c2caf0d42 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 23 Aug 2016 22:16:14 +1000 Subject: [PATCH 073/420] Fix failing specs --- grammars/javascript.cson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index f76b30e7..59d79cc4 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -279,7 +279,7 @@ ] } { - 'match': '(? Date: Tue, 23 Aug 2016 17:47:57 +0300 Subject: [PATCH 074/420] :bug: Fix function keyword as property name --- grammars/javascript.cson | 2 +- spec/javascript-spec.coffee | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 5572d851..b74a5c84 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -297,7 +297,7 @@ { # [async] function [name](params) # function* name(params) – generator function declaration - 'begin': '(?=(\\basync\\b\\s*)?\\bfunction\\b)' + 'begin': '(?=(\\basync\\b\\s*)?\\bfunction\\b(?!:))' 'end': '(?<=})' 'patterns': [ { diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 68f0b29c..cefc4fea 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1084,6 +1084,13 @@ describe "Javascript grammar", -> expect(tokens[7]).toEqual value: 'foo', scopes: ['source.js', 'meta.function.json.js', 'entity.name.function.js'] expect(tokens[8]).toEqual value: '(', scopes: ['source.js', 'meta.function.json.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] + {tokens} = grammar.tokenizeLine('function: a => a') + expect(tokens[0]).toEqual value: 'function', scopes: ['source.js', 'meta.function.arrow.json.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: ':', scopes: ['source.js', 'meta.function.arrow.json.js', 'keyword.operator.assignment.js'] + expect(tokens[3]).toEqual value: 'a', scopes: ['source.js', 'meta.function.arrow.json.js', 'meta.parameters.js', 'variable.parameter.function.js'] + expect(tokens[5]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.json.js', 'storage.type.function.arrow.js'] + expect(tokens[6]).toEqual value: ' a', scopes: ['source.js'] + it "tokenizes generator functions", -> {tokens} = grammar.tokenizeLine('function* foo(){}') expect(tokens[0]).toEqual value: 'function', scopes: ['source.js', 'meta.function.js', 'storage.type.function.js'] From 3a2cb948cbe26b6ad1b91240cebcc052791401a5 Mon Sep 17 00:00:00 2001 From: Maxim Sokolov Date: Tue, 23 Aug 2016 18:06:49 +0300 Subject: [PATCH 075/420] :white_check_mark: Add test for arrow function --- spec/javascript-spec.coffee | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index cefc4fea..cf1119f0 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1091,6 +1091,13 @@ describe "Javascript grammar", -> expect(tokens[5]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.json.js', 'storage.type.function.arrow.js'] expect(tokens[6]).toEqual value: ' a', scopes: ['source.js'] + {tokens} = grammar.tokenizeLine('"func": a => a') + expect(tokens[1]).toEqual value: 'func', scopes: ['source.js', 'meta.function.arrow.json.js', 'string.quoted.double.js', 'entity.name.function.js'] + expect(tokens[3]).toEqual value: ':', scopes: ['source.js', 'meta.function.arrow.json.js', 'keyword.operator.assignment.js'] + expect(tokens[5]).toEqual value: 'a', scopes: ['source.js', 'meta.function.arrow.json.js', 'meta.parameters.js', 'variable.parameter.function.js'] + expect(tokens[7]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.json.js', 'storage.type.function.arrow.js'] + expect(tokens[8]).toEqual value: ' a', scopes: ['source.js'] + it "tokenizes generator functions", -> {tokens} = grammar.tokenizeLine('function* foo(){}') expect(tokens[0]).toEqual value: 'function', scopes: ['source.js', 'meta.function.js', 'storage.type.function.js'] From 86b6ac1e5aa3a6c6e07b6c6aad61260f14d744b4 Mon Sep 17 00:00:00 2001 From: Maxim Sokolov Date: Tue, 23 Aug 2016 18:25:58 +0300 Subject: [PATCH 076/420] :bug: Allow whitespaces before colon with arrow function as a property --- grammars/javascript.cson | 4 ++-- spec/javascript-spec.coffee | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index b74a5c84..6a3b81e8 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -297,7 +297,7 @@ { # [async] function [name](params) # function* name(params) – generator function declaration - 'begin': '(?=(\\basync\\b\\s*)?\\bfunction\\b(?!:))' + 'begin': '(?=(\\basync\\b\\s*)?\\bfunction\\b(?!\\s*:))' 'end': '(?<=})' 'patterns': [ { @@ -591,7 +591,7 @@ (?<=})| ((?! \\s*{| - \\G[\\w$]+:| + \\G[\\w$]+\\s*:| \\s*/\\*|\\s*// )(?=\\s*\\S)) ''' diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index cf1119f0..8cf4e9b9 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1084,12 +1084,12 @@ describe "Javascript grammar", -> expect(tokens[7]).toEqual value: 'foo', scopes: ['source.js', 'meta.function.json.js', 'entity.name.function.js'] expect(tokens[8]).toEqual value: '(', scopes: ['source.js', 'meta.function.json.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] - {tokens} = grammar.tokenizeLine('function: a => a') + {tokens} = grammar.tokenizeLine('function : a => a') expect(tokens[0]).toEqual value: 'function', scopes: ['source.js', 'meta.function.arrow.json.js', 'entity.name.function.js'] - expect(tokens[1]).toEqual value: ':', scopes: ['source.js', 'meta.function.arrow.json.js', 'keyword.operator.assignment.js'] - expect(tokens[3]).toEqual value: 'a', scopes: ['source.js', 'meta.function.arrow.json.js', 'meta.parameters.js', 'variable.parameter.function.js'] - expect(tokens[5]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.json.js', 'storage.type.function.arrow.js'] - expect(tokens[6]).toEqual value: ' a', scopes: ['source.js'] + expect(tokens[2]).toEqual value: ':', scopes: ['source.js', 'meta.function.arrow.json.js', 'keyword.operator.assignment.js'] + expect(tokens[4]).toEqual value: 'a', scopes: ['source.js', 'meta.function.arrow.json.js', 'meta.parameters.js', 'variable.parameter.function.js'] + expect(tokens[6]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.json.js', 'storage.type.function.arrow.js'] + expect(tokens[7]).toEqual value: ' a', scopes: ['source.js'] {tokens} = grammar.tokenizeLine('"func": a => a') expect(tokens[1]).toEqual value: 'func', scopes: ['source.js', 'meta.function.arrow.json.js', 'string.quoted.double.js', 'entity.name.function.js'] From 3a402d4d9bf6cd3785ee5556f8d2c817cd7516ff Mon Sep 17 00:00:00 2001 From: Maxim Sokolov Date: Tue, 23 Aug 2016 18:29:53 +0300 Subject: [PATCH 077/420] :white_check_mark: Test --- spec/javascript-spec.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 8cf4e9b9..4c7bee56 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1098,6 +1098,9 @@ describe "Javascript grammar", -> expect(tokens[7]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.json.js', 'storage.type.function.arrow.js'] expect(tokens[8]).toEqual value: ' a', scopes: ['source.js'] + {tokens} = grammar.tokenizeLine('"func" : a => a') + expect(tokens[8]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.json.js', 'storage.type.function.arrow.js'] + it "tokenizes generator functions", -> {tokens} = grammar.tokenizeLine('function* foo(){}') expect(tokens[0]).toEqual value: 'function', scopes: ['source.js', 'meta.function.js', 'storage.type.function.js'] From 3b082efe08cc22225e680ae867f729f1627620c9 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Wed, 24 Aug 2016 03:34:09 +1000 Subject: [PATCH 078/420] Add missing space and scope-name --- grammars/javascript.cson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 59d79cc4..3195438f 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -706,13 +706,13 @@ } { 'match': '(new)\\s+([\\w$]+[\\w.$]*)' - 'name': 'meta.class.instance.constructor' + 'name': 'meta.class.instance.constructor.js' 'captures': '1': 'name': 'keyword.operator.new.js' '2': 'name': 'entity.name.type.instance.js' - 'patterns':[ + 'patterns': [ { 'match': '\\.' 'name': 'meta.delimiter.property.period.js' From 70a1a68af70cedf62e2cd0ddcab978cf00b187c9 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Wed, 24 Aug 2016 03:37:06 +1000 Subject: [PATCH 079/420] Remove whitespace in specs --- spec/javascript-spec.coffee | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index d9db9d11..34e783c7 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -66,27 +66,27 @@ describe "Javascript grammar", -> it "tokenises 2-digit sequences", -> for scope, quote of delimsByScope {tokens} = grammar.tokenizeLine(quote + '\\x2011' + quote) - expect(tokens[0]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.begin.js'] + expect(tokens[0]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.begin.js'] expect(tokens[1]).toEqual value: '\\x20', scopes: ['source.js', scope, 'constant.character.escape.js'] - expect(tokens[2]).toEqual value: '11', scopes: ['source.js', scope] - expect(tokens[3]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.end.js'] + expect(tokens[2]).toEqual value: '11', scopes: ['source.js', scope] + expect(tokens[3]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.end.js'] it "tokenises 4-digit sequences", -> for scope, quote of delimsByScope {tokens} = grammar.tokenizeLine(quote + '\\u2011' + quote) - expect(tokens[0]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.begin.js'] + expect(tokens[0]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.begin.js'] expect(tokens[1]).toEqual value: '\\u2011', scopes: ['source.js', scope, 'constant.character.escape.js'] - expect(tokens[2]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.end.js'] + expect(tokens[2]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.end.js'] it "tokenises variable-length sequences", -> for scope, quote of delimsByScope {tokens} = grammar.tokenizeLine(quote + '\\u{2000}' + quote) - expect(tokens[0]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.begin.js'] - expect(tokens[1]).toEqual value: '\\u', scopes: ['source.js', scope, 'constant.character.escape.js'] - expect(tokens[2]).toEqual value: '{', scopes: ['source.js', scope, 'constant.character.escape.js', bracketScopes[0]] - expect(tokens[3]).toEqual value: '2000', scopes: ['source.js', scope, 'constant.character.escape.js'] - expect(tokens[4]).toEqual value: '}', scopes: ['source.js', scope, 'constant.character.escape.js', bracketScopes[1]] - expect(tokens[5]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.end.js'] + expect(tokens[0]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.begin.js'] + expect(tokens[1]).toEqual value: '\\u', scopes: ['source.js', scope, 'constant.character.escape.js'] + expect(tokens[2]).toEqual value: '{', scopes: ['source.js', scope, 'constant.character.escape.js', bracketScopes[0]] + expect(tokens[3]).toEqual value: '2000', scopes: ['source.js', scope, 'constant.character.escape.js'] + expect(tokens[4]).toEqual value: '}', scopes: ['source.js', scope, 'constant.character.escape.js', bracketScopes[1]] + expect(tokens[5]).toEqual value: quote, scopes: ['source.js', scope, 'punctuation.definition.string.end.js'] it "highlights sequences with invalid syntax", -> for invalid in ['\\u', '\\u{2000', '\\u{G}'] @@ -100,12 +100,12 @@ describe "Javascript grammar", -> {tokens} = grammar.tokenizeLine('"\\u{' + pointStr + '}"') pointScopes = ['source.js', 'string.quoted.double.js', 'constant.character.escape.js'] if codepoint > maxCodepoint then pointScopes.push 'invalid.illegal.unicode-escape.js' - expect(tokens[0]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[1]).toEqual value: '\\u', scopes: ['source.js', 'string.quoted.double.js', 'constant.character.escape.js'] - expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'string.quoted.double.js', 'constant.character.escape.js', bracketScopes[0]] + expect(tokens[0]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[1]).toEqual value: '\\u', scopes: ['source.js', 'string.quoted.double.js', 'constant.character.escape.js'] + expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'string.quoted.double.js', 'constant.character.escape.js', bracketScopes[0]] expect(tokens[3]).toEqual value: pointStr, scopes: pointScopes - expect(tokens[4]).toEqual value: '}', scopes: ['source.js', 'string.quoted.double.js', 'constant.character.escape.js', bracketScopes[1]] - expect(tokens[5]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[4]).toEqual value: '}', scopes: ['source.js', 'string.quoted.double.js', 'constant.character.escape.js', bracketScopes[1]] + expect(tokens[5]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] describe "keywords", -> keywords = ['await', 'break', 'catch', 'continue', 'do'] From 33fcb714e36a831b8cd343da645d40daec1a557b Mon Sep 17 00:00:00 2001 From: Alhadis Date: Wed, 24 Aug 2016 05:19:04 +1000 Subject: [PATCH 080/420] Update specs to accommodate 3b082ef's changes --- spec/javascript-spec.coffee | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 0906b0af..e8903f35 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -141,19 +141,19 @@ describe "Javascript grammar", -> describe "instantiation", -> it "tokenizes the new keyword and instance entities", -> {tokens} = grammar.tokenizeLine('new something') - expect(tokens[0]).toEqual value: 'new', scopes: ['source.js', 'meta.class.instance.constructor', 'keyword.operator.new.js'] - expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'meta.class.instance.constructor'] - expect(tokens[2]).toEqual value: 'something', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js'] + expect(tokens[0]).toEqual value: 'new', scopes: ['source.js', 'meta.class.instance.constructor.js', 'keyword.operator.new.js'] + expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'meta.class.instance.constructor.js'] + expect(tokens[2]).toEqual value: 'something', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js'] {tokens} = grammar.tokenizeLine('new Something') - expect(tokens[0]).toEqual value: 'new', scopes: ['source.js', 'meta.class.instance.constructor', 'keyword.operator.new.js'] - expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'meta.class.instance.constructor'] - expect(tokens[2]).toEqual value: 'Something', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js'] + expect(tokens[0]).toEqual value: 'new', scopes: ['source.js', 'meta.class.instance.constructor.js', 'keyword.operator.new.js'] + expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'meta.class.instance.constructor.js'] + expect(tokens[2]).toEqual value: 'Something', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js'] {tokens} = grammar.tokenizeLine('new $something') - expect(tokens[0]).toEqual value: 'new', scopes: ['source.js', 'meta.class.instance.constructor', 'keyword.operator.new.js'] - expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'meta.class.instance.constructor'] - expect(tokens[2]).toEqual value: '$something', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js'] + expect(tokens[0]).toEqual value: 'new', scopes: ['source.js', 'meta.class.instance.constructor.js', 'keyword.operator.new.js'] + expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'meta.class.instance.constructor.js'] + expect(tokens[2]).toEqual value: '$something', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js'] {tokens} = grammar.tokenizeLine('var instance = new obj.ct.Cla$s();') expect(tokens).toEqual [ @@ -161,13 +161,13 @@ describe "Javascript grammar", -> {value: ' instance ', scopes: ['source.js']} {value: '=', scopes: ['source.js', 'keyword.operator.assignment.js']} {value: ' ', scopes: ['source.js']} - {value: 'new', scopes: ['source.js', 'meta.class.instance.constructor', 'keyword.operator.new.js']} - {value: ' ', scopes: ['source.js', 'meta.class.instance.constructor']} - {value: 'obj', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js']} - {value: '.', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js', 'meta.delimiter.property.period.js']} - {value: 'ct', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js']} - {value: '.', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js', 'meta.delimiter.property.period.js']} - {value: 'Cla$s', scopes: ['source.js', 'meta.class.instance.constructor', 'entity.name.type.instance.js']} + {value: 'new', scopes: ['source.js', 'meta.class.instance.constructor.js', 'keyword.operator.new.js']} + {value: ' ', scopes: ['source.js', 'meta.class.instance.constructor.js']} + {value: 'obj', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js']} + {value: '.', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js', 'meta.delimiter.property.period.js']} + {value: 'ct', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js']} + {value: '.', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js', 'meta.delimiter.property.period.js']} + {value: 'Cla$s', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js']} {value: '(', scopes: ['source.js', 'meta.brace.round.js']} {value: ')', scopes: ['source.js', 'meta.brace.round.js']} {value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js']} From 2c1ca8cde00f1b3061753c47b2c3800dbe137d85 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Wed, 24 Aug 2016 05:36:55 +1000 Subject: [PATCH 081/420] Allow multiple types to be specified in JSDoc tags --- grammars/javascript.cson | 6 +++--- spec/javascript-spec.coffee | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 8e7bde93..9f4d04a1 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1681,9 +1681,9 @@ } { 'match': '''(?x) - ({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*(?:\\[\\])?=?)}) + ({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*(?:\\[\\])?=?)}) \\s+ - (\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*)) + (\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*)) \\s+ ((?:(?!\\*\\/).)*) ''' @@ -1701,7 +1701,7 @@ 'match': '''(?x) (?:(?<=@returns)|(?<=@return)) \\s+ - ({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*(?:\\[\\])?=?)}) + ({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*(?:\\[\\])?=?)}) \\s+ ((?:(?!\\*\\/).)*) ''' diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index bdfd3941..cc43b55d 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1493,6 +1493,10 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @type {Function|String} callback - Something to call */') + expect(tokens[4]).toEqual value: '{Function|String}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'callback', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {?number} variable this is the description */') expect(tokens[4]).toEqual value: '{?number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] @@ -1522,6 +1526,9 @@ describe "Javascript grammar", -> expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {Some|Thing} Something to return */') + expect(tokens[4]).toEqual value: '{Some|Thing}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {object} */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] From 1b849ae4f0968f846142c956640baf462e792607 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Wed, 24 Aug 2016 06:47:58 +1000 Subject: [PATCH 082/420] Add support for bracketed-type notation Refs: jsdoc3/jsdoc#1104 --- grammars/javascript.cson | 2 +- spec/javascript-spec.coffee | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 9f4d04a1..ebfda88e 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1681,7 +1681,7 @@ } { 'match': '''(?x) - ({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*(?:\\[\\])?=?)}) + ({(?:\\*|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*\\)|[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*)(?:\\[\\])?=?)}) \\s+ (\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*)) \\s+ diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index cc43b55d..5f12449c 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1497,6 +1497,11 @@ describe "Javascript grammar", -> expect(tokens[4]).toEqual value: '{Function|String}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'callback', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {(Number|Function)} types - Bracket notation */') + expect(tokens[2]).toEqual value: '@param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + expect(tokens[4]).toEqual value: '{(Number|Function)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'types', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {?number} variable this is the description */') expect(tokens[4]).toEqual value: '{?number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] From f2871d41f9494479a4d4a93f7ef530485ab599e2 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Wed, 24 Aug 2016 15:07:30 +1000 Subject: [PATCH 083/420] Conform to formatting of existing specs --- spec/javascript-spec.coffee | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index e8903f35..e681c9e6 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -156,22 +156,20 @@ describe "Javascript grammar", -> expect(tokens[2]).toEqual value: '$something', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js'] {tokens} = grammar.tokenizeLine('var instance = new obj.ct.Cla$s();') - expect(tokens).toEqual [ - {value: 'var', scopes: ['source.js', 'storage.type.var.js']} - {value: ' instance ', scopes: ['source.js']} - {value: '=', scopes: ['source.js', 'keyword.operator.assignment.js']} - {value: ' ', scopes: ['source.js']} - {value: 'new', scopes: ['source.js', 'meta.class.instance.constructor.js', 'keyword.operator.new.js']} - {value: ' ', scopes: ['source.js', 'meta.class.instance.constructor.js']} - {value: 'obj', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js']} - {value: '.', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js', 'meta.delimiter.property.period.js']} - {value: 'ct', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js']} - {value: '.', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js', 'meta.delimiter.property.period.js']} - {value: 'Cla$s', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js']} - {value: '(', scopes: ['source.js', 'meta.brace.round.js']} - {value: ')', scopes: ['source.js', 'meta.brace.round.js']} - {value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js']} - ] + expect(tokens[0]).toEqual value: 'var', scopes: ['source.js', 'storage.type.var.js'] + expect(tokens[1]).toEqual value: ' instance ', scopes: ['source.js'] + expect(tokens[2]).toEqual value: '=', scopes: ['source.js', 'keyword.operator.assignment.js'] + expect(tokens[3]).toEqual value: ' ', scopes: ['source.js'] + expect(tokens[4]).toEqual value: 'new', scopes: ['source.js', 'meta.class.instance.constructor.js', 'keyword.operator.new.js'] + expect(tokens[5]).toEqual value: ' ', scopes: ['source.js', 'meta.class.instance.constructor.js'] + expect(tokens[6]).toEqual value: 'obj', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js'] + expect(tokens[7]).toEqual value: '.', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js', 'meta.delimiter.property.period.js'] + expect(tokens[8]).toEqual value: 'ct', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js'] + expect(tokens[9]).toEqual value: '.', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js', 'meta.delimiter.property.period.js'] + expect(tokens[10]).toEqual value: 'Cla$s', scopes: ['source.js', 'meta.class.instance.constructor.js', 'entity.name.type.instance.js'] + expect(tokens[11]).toEqual value: '(', scopes: ['source.js', 'meta.brace.round.js'] + expect(tokens[12]).toEqual value: ')', scopes: ['source.js', 'meta.brace.round.js'] + expect(tokens[13]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] describe "regular expressions", -> it "tokenizes regular expressions", -> @@ -1221,10 +1219,10 @@ describe "Javascript grammar", -> expect(tokens[0]).toEqual value: 'this', scopes: ['source.js', 'variable.language.js'] {tokens} = grammar.tokenizeLine('$this') - expect(tokens[0].value).toEqual '$this' + expect(tokens[0]).toEqual value: '$this', scopes: ['source.js'] {tokens} = grammar.tokenizeLine('this$') - expect(tokens[0].value).toEqual 'this$' + expect(tokens[0]).toEqual value: 'this$', scopes: ['source.js'] it "tokenizes 'super'", -> {tokens} = grammar.tokenizeLine('super') From 379297e568cb130b1c47d0dc1c6f3f81d741fb10 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Wed, 24 Aug 2016 15:19:06 +1000 Subject: [PATCH 084/420] Ensure bracketed-type notation works in @return --- grammars/javascript.cson | 2 +- spec/javascript-spec.coffee | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index ebfda88e..f898f0fa 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1701,7 +1701,7 @@ 'match': '''(?x) (?:(?<=@returns)|(?<=@return)) \\s+ - ({(?:\\*|(?:\\?|\\!|\\.{3})?[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*(?:\\[\\])?=?)}) + ({(?:\\*|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*\\)|[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*)(?:\\[\\])?=?)}) \\s+ ((?:(?!\\*\\/).)*) ''' diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 5f12449c..fa2f2d02 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1544,6 +1544,9 @@ describe "Javascript grammar", -> {tokens} = grammar.tokenizeLine('/** @returns {object} */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @returns {(Something)} */') + expect(tokens[4]).toEqual value: '{(Something)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] From 21c6ccbdad7b3e9956abce64c465ceb2c53b8140 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 24 Aug 2016 22:31:36 +0100 Subject: [PATCH 085/420] :bug: Modify JSDoc to default to 3 scopes before 4 --- grammars/javascript.cson | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 48c1fcfa..5e7f1237 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1781,9 +1781,11 @@ } { 'match': '''(?x) + (?:(?<=@param)|(?<=@type)) + \\s+ ({(?:\\*|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*\\)|[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*)(?:\\[\\])?=?)}) \\s+ - (\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*)) + (\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*)?) \\s+ ((?:(?!\\*\\/).)*) ''' @@ -1799,8 +1801,6 @@ } { 'match': '''(?x) - (?:(?<=@returns)|(?<=@return)) - \\s+ ({(?:\\*|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*\\)|[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*)(?:\\[\\])?=?)}) \\s+ ((?:(?!\\*\\/).)*) From a2a8310f2cf2e051b32c3a4ee2ee5a8797316814 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 24 Aug 2016 22:31:53 +0100 Subject: [PATCH 086/420] :white_check_mark: Add specs for JSDoc defaulting to 3 scopes before 4 --- spec/javascript-spec.coffee | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index da4528ed..f695c057 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1544,6 +1544,19 @@ describe "Javascript grammar", -> expect(tokens[4]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] it "tokenizes JSDoc comment documentation", -> + {tokens} = grammar.tokenizeLine('/** @const {object} */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @define {object} */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {object} */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {object} variable */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} variable this is the description */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] From 4605922ca9f60072dca0b3a0e81d24eb2f7d7749 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 24 Aug 2016 22:47:17 +0100 Subject: [PATCH 087/420] :bug: Add JSDoc support for a type with a set of type arguments --- grammars/javascript.cson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 5e7f1237..bfcb7369 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1783,7 +1783,7 @@ 'match': '''(?x) (?:(?<=@param)|(?<=@type)) \\s+ - ({(?:\\*|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*\\)|[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*)(?:\\[\\])?=?)}) + ({(?:\\*|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*\\)|[a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*)(?:\\[\\])?=?)}) \\s+ (\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*)?) \\s+ @@ -1801,7 +1801,7 @@ } { 'match': '''(?x) - ({(?:\\*|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*\\)|[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*)(?:\\[\\])?=?)}) + ({(?:\\*|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*\\)|[a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*)(?:\\[\\])?=?)}) \\s+ ((?:(?!\\*\\/).)*) ''' From 2f0f77f50bb2f693225f526911eed9bb8f1144cd Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 24 Aug 2016 22:47:52 +0100 Subject: [PATCH 088/420] :white_check_mark: Add specs for JSDoc and types with a set of type arguments --- spec/javascript-spec.coffee | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index f695c057..9e1a8351 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1552,7 +1552,7 @@ describe "Javascript grammar", -> {tokens} = grammar.tokenizeLine('/** @param {object} */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - + {tokens} = grammar.tokenizeLine('/** @param {object} variable */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] @@ -1626,6 +1626,21 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {Array} variable this is the description */') + expect(tokens[4]).toEqual value: '{Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {Array|Array} variable this is the description */') + expect(tokens[4]).toEqual value: '{Array|Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {(Array|Array)} variable this is the description */') + expect(tokens[4]).toEqual value: '{(Array|Array)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {object} this is the description */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] From 794e7a8358e4812e854e60415dcd6f7fe3253cfa Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 24 Aug 2016 23:01:52 +0100 Subject: [PATCH 089/420] :bug: Add JSDoc support for unknown type --- grammars/javascript.cson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index bfcb7369..d8a17cae 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1783,7 +1783,7 @@ 'match': '''(?x) (?:(?<=@param)|(?<=@type)) \\s+ - ({(?:\\*|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*\\)|[a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*)(?:\\[\\])?=?)}) + ({(?:\\*|\\?|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*\\)|[a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*)(?:\\[\\])?=?)}) \\s+ (\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*)?) \\s+ @@ -1801,7 +1801,7 @@ } { 'match': '''(?x) - ({(?:\\*|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*\\)|[a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*)(?:\\[\\])?=?)}) + ({(?:\\*|\\?|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*\\)|[a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*)(?:\\[\\])?=?)}) \\s+ ((?:(?!\\*\\/).)*) ''' From 787fe82af7d252b7e8798ad7d7ec2ac74469adc8 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 24 Aug 2016 23:02:15 +0100 Subject: [PATCH 090/420] :white_check_mark: Add specs for JSDoc unknown type --- spec/javascript-spec.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 9e1a8351..5e17b31b 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1587,6 +1587,11 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {?} variable this is the description */') + expect(tokens[4]).toEqual value: '{?}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {myNamespace.MyClass} variable this is the description */') expect(tokens[4]).toEqual value: '{myNamespace.MyClass}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] From 2f583b38d40846b49ce94b13c256adc664cb5947 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 24 Aug 2016 23:24:30 +0100 Subject: [PATCH 091/420] :bug: Add JSDoc support for key-value type pairs --- grammars/javascript.cson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index d8a17cae..9d6c4f63 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1783,7 +1783,7 @@ 'match': '''(?x) (?:(?<=@param)|(?<=@type)) \\s+ - ({(?:\\*|\\?|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*\\)|[a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*)(?:\\[\\])?=?)}) + ({(?:\\*|\\?|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>))*\\)|[a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>))*)(?:\\[\\])?=?)}) \\s+ (\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*)?) \\s+ @@ -1801,7 +1801,7 @@ } { 'match': '''(?x) - ({(?:\\*|\\?|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*\\)|[a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+\\>))*)(?:\\[\\])?=?)}) + ({(?:\\*|\\?|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>))*\\)|[a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>))*)(?:\\[\\])?=?)}) \\s+ ((?:(?!\\*\\/).)*) ''' From fbeea175400be903051f432ff424e0b23cfb54bb Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 24 Aug 2016 23:25:03 +0100 Subject: [PATCH 092/420] :white_check_mark: Add specs for JSDoc key-value type pairs --- spec/javascript-spec.coffee | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 5e17b31b..f32ef5a0 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1646,6 +1646,21 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {Object} variable this is the description */') + expect(tokens[4]).toEqual value: '{Object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {Object|Array} variable this is the description */') + expect(tokens[4]).toEqual value: '{Object|Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {(Array|Object)} variable this is the description */') + expect(tokens[4]).toEqual value: '{(Array|Object)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {object} this is the description */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] From 219150fd50e66719d62dd4a878a46b5b9fcdc959 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Thu, 25 Aug 2016 00:31:10 +0100 Subject: [PATCH 093/420] :art: Add whitespace to JSDoc rules to increase readability --- grammars/javascript.cson | 53 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 9d6c4f63..8459e119 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1783,9 +1783,35 @@ 'match': '''(?x) (?:(?<=@param)|(?<=@type)) \\s+ - ({(?:\\*|\\?|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>))*\\)|[a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>))*)(?:\\[\\])?=?)}) + ({(?: + \\* | + \\? | + (?:\\?|\\!|\\.{3})? + (?: + \\( + [a-zA-Z_$]+ + (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + (?: + [\\.|][a-zA-Z_$]+ + (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + )* + \\) | + [a-zA-Z_$]+ + (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + (?: + [\\.|][a-zA-Z_$]+ + (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + )* + ) + (?:\\[\\])?=? + )}) \\s+ - (\\[(?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?)\\]|(?:[a-zA-Z_$][\\w$]*(?:[\\.|][a-zA-Z_$][\\w$]*)*)?) + ( + \\[ + (?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?) + \\] | + (?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*)? + ) \\s+ ((?:(?!\\*\\/).)*) ''' @@ -1801,7 +1827,28 @@ } { 'match': '''(?x) - ({(?:\\*|\\?|(?:\\?|\\!|\\.{3})?(?:\\([a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>))*\\)|[a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>)(?:[\\.|][a-zA-Z_$]+(?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>))*)(?:\\[\\])?=?)}) + ({(?: + \\* | + \\? | + (?:\\?|\\!|\\.{3})? + (?: + \\( + [a-zA-Z_$]+ + (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + (?: + [\\.|][a-zA-Z_$]+ + (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + )* + \\) | + [a-zA-Z_$]+ + (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + (?: + [\\.|][a-zA-Z_$]+ + (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + )* + ) + (?:\\[\\])?=? + )}) \\s+ ((?:(?!\\*\\/).)*) ''' From 92d12c4876eb668b532fa08275424253edd10ab9 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Thu, 25 Aug 2016 18:12:23 +0100 Subject: [PATCH 094/420] :art: Add comments and remove uncessary escaping --- grammars/javascript.cson | 93 +++++++++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 24 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 8459e119..6d62d214 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1784,36 +1784,61 @@ (?:(?<=@param)|(?<=@type)) \\s+ ({(?: - \\* | - \\? | - (?:\\?|\\!|\\.{3})? + \\* | # {*} any type + \\? | # {?} unknown type + + (?: # Check for a prefix + \\? | # {?string} nullable type + ! | # {!string} non-nullable type + \\.{3} # {...string} variable number of parameters + )? + (?: - \\( + \\( # {(string|number)} type union, mulitple types with parenthesis [a-zA-Z_$]+ - (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + (?: + [\\w$]* | + <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + ) (?: [\\.|][a-zA-Z_$]+ - (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + (?: + [\\w$]* | + <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + ) )* - \\) | + \\) | # {string|number} type union, multiple types without parenthesis [a-zA-Z_$]+ - (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + (?: + [\\w$]* | + <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + ) (?: [\\.|][a-zA-Z_$]+ - (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + (?: + [\\w$]* | + <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + ) )* ) - (?:\\[\\])?=? + # Check for suffix + (?:\\[\\])? # {string[]} type application, an array of strings + =? # {string=} optional parameter )}) \\s+ ( - \\[ + \\[ # [foo] optional parameter (?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?) \\] | - (?:[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*)*)? + (?: + [a-zA-Z_$][\\w$]* + (?: + \\.[a-zA-Z_$][\\w$]* # Foo.Bar namespaced parameter + )* + )? ) \\s+ - ((?:(?!\\*\\/).)*) + ((?:(?!\\*\\/).)*) # The type description ''' 'captures': '0': @@ -1828,29 +1853,49 @@ { 'match': '''(?x) ({(?: - \\* | - \\? | - (?:\\?|\\!|\\.{3})? + \\* | # {*} any type + \\? | # {?} unknown type + + (?: # Check for a prefix + \\? | # {?string} nullable type + ! | # {!string} non-nullable type + \\.{3} # {...string} variable number of parameters + )? + (?: - \\( + \\( # {(string|number)} type union, mulitple types with parenthesis [a-zA-Z_$]+ - (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + (?: + [\\w$]* | + <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + ) (?: [\\.|][a-zA-Z_$]+ - (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + (?: + [\\w$]* | + <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + ) )* - \\) | + \\) | # {string|number} type union, multiple types without parenthesis [a-zA-Z_$]+ - (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + (?: + [\\w$]* | + <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + ) (?: [\\.|][a-zA-Z_$]+ - (?:[\\w$]*|\\<[\\w$]+(?:\\,\\s+[\\w$]+)*\\>) + (?: + [\\w$]* | + <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + ) )* ) - (?:\\[\\])?=? + # Check for suffix + (?:\\[\\])? # {string[]} type application, an array of strings + =? # {string=} optional parameter )}) \\s+ - ((?:(?!\\*\\/).)*) + ((?:(?!\\*\\/).)*) # The type description ''' 'captures': '0': From d7733d21547b28dd11907fef1dc12084845dc917 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Thu, 25 Aug 2016 18:18:24 +0100 Subject: [PATCH 095/420] :art: Tidy up comments and fix typos --- grammars/javascript.cson | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 6d62d214..ec901e0c 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1794,29 +1794,31 @@ )? (?: - \\( # {(string|number)} type union, mulitple types with parenthesis + \\( # Opening bracket of multiple types with parenthesis {(string|number)} [a-zA-Z_$]+ (?: [\\w$]* | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) (?: - [\\.|][a-zA-Z_$]+ + [\\.|] # Check for . namespaced types {Foo.bar} or | for multiple types {string|number} + [a-zA-Z_$]+ (?: [\\w$]* | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) )* - \\) | # {string|number} type union, multiple types without parenthesis + \\) | [a-zA-Z_$]+ (?: [\\w$]* | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) (?: - [\\.|][a-zA-Z_$]+ + [\\.|] # Check for . namespaced types {Foo.bar} or | for multiple types {string|number} + [a-zA-Z_$]+ (?: - [\\w$]* | + [\\w$]* | # Check for . namespaced types {Foo.bar} or | for multiple types {string|number} <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) )* @@ -1863,29 +1865,31 @@ )? (?: - \\( # {(string|number)} type union, mulitple types with parenthesis + \\( # Opening bracket of multiple types with parenthesis {(string|number)} [a-zA-Z_$]+ (?: [\\w$]* | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) (?: - [\\.|][a-zA-Z_$]+ + [\\.|] # Check for . namespaced types {Foo.bar} or | for multiple types {string|number} + [a-zA-Z_$]+ (?: [\\w$]* | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) )* - \\) | # {string|number} type union, multiple types without parenthesis + \\) | [a-zA-Z_$]+ (?: [\\w$]* | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) (?: - [\\.|][a-zA-Z_$]+ + [\\.|] # Check for . namespaced types {Foo.bar} or | for multiple types {string|number} + [a-zA-Z_$]+ (?: - [\\w$]* | + [\\w$]* | # Check for . namespaced types {Foo.bar} or | for multiple types {string|number} <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) )* From 8e1cacd13b09bbd0c341b0a690856e406cfe7c1b Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Thu, 25 Aug 2016 18:24:12 +0100 Subject: [PATCH 096/420] :fire: Remove incorrect comment --- grammars/javascript.cson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index ec901e0c..4a1ddd62 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1818,7 +1818,7 @@ [\\.|] # Check for . namespaced types {Foo.bar} or | for multiple types {string|number} [a-zA-Z_$]+ (?: - [\\w$]* | # Check for . namespaced types {Foo.bar} or | for multiple types {string|number} + [\\w$]* | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) )* @@ -1889,7 +1889,7 @@ [\\.|] # Check for . namespaced types {Foo.bar} or | for multiple types {string|number} [a-zA-Z_$]+ (?: - [\\w$]* | # Check for . namespaced types {Foo.bar} or | for multiple types {string|number} + [\\w$]* | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) )* From 260a9b7ad5f05042ab29ac9601c6483bf05ff007 Mon Sep 17 00:00:00 2001 From: Wliu Date: Sun, 28 Aug 2016 16:54:59 -0400 Subject: [PATCH 097/420] Prepare 0.120.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c23b6035..4b7a3778 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.119.0", + "version": "0.120.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From f6d34ecf744f5e9ce7bb1ac927880e913a97af88 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Mon, 29 Aug 2016 20:46:35 +1000 Subject: [PATCH 098/420] Add modeline support --- grammars/javascript.cson | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 4a1ddd62..d0c6671a 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -16,7 +16,19 @@ 'xsjs' 'xsjslib' ] -'firstLineMatch': '^#!.*\\b(node|iojs|JavaScript)' +'firstLineMatch': '''(?x) + # Hashbang + ^\\#!.*\\b(?:node|iojs|JavaScript) + | + # Modeline + (?i: + # Emacs + -\\*-[^*]*(?:mode:\\s*)?\\b(?:js|javascript)(?:\\s*;.*?)?\\s*-\\*- + | + # Vim + (?:vim?|ex):\\s*(?:set?.*\\s)?(?:syntax|filetype|ft)=(javascript)\\s?(?:.*:)? + ) +''' 'name': 'JavaScript' 'patterns': [ { From 43afdd50a7320d63cf17da283cf5ba564d383cb0 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Mon, 29 Aug 2016 21:12:55 +1000 Subject: [PATCH 099/420] Add specs for JavaScript modeline detection --- spec/fixtures/emacs-1 | 1 + spec/fixtures/emacs-2 | 1 + spec/fixtures/emacs-3 | 1 + spec/fixtures/emacs-4 | 1 + spec/fixtures/emacs-5 | 1 + spec/fixtures/emacs-6 | 1 + spec/fixtures/vim-1 | 1 + spec/fixtures/vim-2 | 1 + spec/fixtures/vim-3 | 1 + spec/fixtures/vim-4 | 1 + spec/fixtures/vim-5 | 1 + spec/fixtures/vim-6 | 1 + spec/javascript-spec.coffee | 24 ++++++++++++++++++++++++ 13 files changed, 36 insertions(+) create mode 100644 spec/fixtures/emacs-1 create mode 100644 spec/fixtures/emacs-2 create mode 100644 spec/fixtures/emacs-3 create mode 100644 spec/fixtures/emacs-4 create mode 100644 spec/fixtures/emacs-5 create mode 100644 spec/fixtures/emacs-6 create mode 100644 spec/fixtures/vim-1 create mode 100644 spec/fixtures/vim-2 create mode 100644 spec/fixtures/vim-3 create mode 100644 spec/fixtures/vim-4 create mode 100644 spec/fixtures/vim-5 create mode 100644 spec/fixtures/vim-6 diff --git a/spec/fixtures/emacs-1 b/spec/fixtures/emacs-1 new file mode 100644 index 00000000..2d9afc44 --- /dev/null +++ b/spec/fixtures/emacs-1 @@ -0,0 +1 @@ +/* -*-js-*- */ diff --git a/spec/fixtures/emacs-2 b/spec/fixtures/emacs-2 new file mode 100644 index 00000000..e9a04be9 --- /dev/null +++ b/spec/fixtures/emacs-2 @@ -0,0 +1 @@ +// -*- JS -*- diff --git a/spec/fixtures/emacs-3 b/spec/fixtures/emacs-3 new file mode 100644 index 00000000..1bc7e8c1 --- /dev/null +++ b/spec/fixtures/emacs-3 @@ -0,0 +1 @@ + /* -*- mode:js -*- */ diff --git a/spec/fixtures/emacs-4 b/spec/fixtures/emacs-4 new file mode 100644 index 00000000..71636f15 --- /dev/null +++ b/spec/fixtures/emacs-4 @@ -0,0 +1 @@ +// -*- font:bar;mode:JavaScript -*- diff --git a/spec/fixtures/emacs-5 b/spec/fixtures/emacs-5 new file mode 100644 index 00000000..4839565a --- /dev/null +++ b/spec/fixtures/emacs-5 @@ -0,0 +1 @@ +" -*-foo:bar;mode:JavaScript;bar:foo-*- "; diff --git a/spec/fixtures/emacs-6 b/spec/fixtures/emacs-6 new file mode 100644 index 00000000..b5080853 --- /dev/null +++ b/spec/fixtures/emacs-6 @@ -0,0 +1 @@ +"-*- font:x;foo : bar ; mode : javaScript ; bar : foo ; foooooo:baaaaar;fo:ba-*-"; diff --git a/spec/fixtures/vim-1 b/spec/fixtures/vim-1 new file mode 100644 index 00000000..5981512c --- /dev/null +++ b/spec/fixtures/vim-1 @@ -0,0 +1 @@ +// vim: set ft=javascript: diff --git a/spec/fixtures/vim-2 b/spec/fixtures/vim-2 new file mode 100644 index 00000000..e60ae00c --- /dev/null +++ b/spec/fixtures/vim-2 @@ -0,0 +1 @@ +// vim: set filetype=JavaScript: diff --git a/spec/fixtures/vim-3 b/spec/fixtures/vim-3 new file mode 100644 index 00000000..436abce8 --- /dev/null +++ b/spec/fixtures/vim-3 @@ -0,0 +1 @@ +/* vim: ft=javascript */ diff --git a/spec/fixtures/vim-4 b/spec/fixtures/vim-4 new file mode 100644 index 00000000..7b58a344 --- /dev/null +++ b/spec/fixtures/vim-4 @@ -0,0 +1 @@ +// vim: syntax=javascript diff --git a/spec/fixtures/vim-5 b/spec/fixtures/vim-5 new file mode 100644 index 00000000..7df00d4b --- /dev/null +++ b/spec/fixtures/vim-5 @@ -0,0 +1 @@ +/* vim: se syntax=javascript: */ diff --git a/spec/fixtures/vim-6 b/spec/fixtures/vim-6 new file mode 100644 index 00000000..de25bb1e --- /dev/null +++ b/spec/fixtures/vim-6 @@ -0,0 +1 @@ +/* ex: syntax=javascript */ diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index f32ef5a0..7b1b7176 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -2081,3 +2081,27 @@ describe "Javascript grammar", -> j ); """ + + describe "Modelines", -> + beforeEach -> + atom.project.setPaths [__dirname + "/fixtures"] + + it "can recognise Emacs modelines", -> + waitsForPromise -> + promises = for i in [1..6] + atom.workspace.open "emacs-#{i}" + Promise.all promises + + runs -> + for editor in atom.workspace.getTextEditors() + expect(editor.getGrammar().scopeName).toBe("source.js") + + it "can recognise Vim modelines", -> + waitsForPromise -> + promises = for i in [1..6] + atom.workspace.open "vim-#{i}" + Promise.all promises + + runs -> + for editor in atom.workspace.getTextEditors() + expect(editor.getGrammar().scopeName).toBe("source.js") From ca1b40f0e65c3ad422596dc55dabdf0a0686b61c Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 1 Sep 2016 00:04:40 +0200 Subject: [PATCH 100/420] Add \t \r \n \v & \f to RegEx character-class scope These are also character classes: - \t (horizontal tab) - \r (carriage return) - \n (linefeed) - \v (vertical tab) - \f (form-feed) See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#Special_characters_meaning_in_regular_expressions --- grammars/regular expressions (javascript).cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/regular expressions (javascript).cson b/grammars/regular expressions (javascript).cson index 213b8363..16b7c969 100644 --- a/grammars/regular expressions (javascript).cson +++ b/grammars/regular expressions (javascript).cson @@ -10,7 +10,7 @@ 'regex-character-class': 'patterns': [ { - 'match': '\\\\[wWsSdD]|\\.' + 'match': '\\\\[wWsSdDtrnvf]|\\.' 'name': 'constant.character.character-class.regexp' } { From 89c392982020c892dc0ec3051527299eaa4e0544 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 31 Aug 2016 23:05:50 +0100 Subject: [PATCH 101/420] :bug: Add JSDoc support for param props with optional or default values --- grammars/javascript.cson | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 4a1ddd62..e77bf9a8 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1830,7 +1830,17 @@ \\s+ ( \\[ # [foo] optional parameter - (?:[a-zA-Z_$]+(?:=[\\w][\\s\\w$]*)?) + (?: + [a-zA-Z_$][\\w$]* + (?: + \\. # Foo.Bar namespaced parameter + [a-zA-Z_$][\\w$]* + )* + (?: + = # [foo=bar] Default parameter value + [\\s\\w$]* + )? + ) \\] | (?: [a-zA-Z_$][\\w$]* From 27d3e967a8339bf1bed837c5e29ab12e6db3dfd0 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 31 Aug 2016 23:12:56 +0100 Subject: [PATCH 102/420] :white_check_mark: Add specs for JSDoc param props with optional and default values --- spec/javascript-spec.coffee | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index f32ef5a0..ae013bf9 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1582,6 +1582,16 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'parameter.property', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} [parameter.property] this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[parameter.property]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {object} [parameter.property=default value] this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[parameter.property=default value]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {*} variable this is the description */') expect(tokens[4]).toEqual value: '{*}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] @@ -1597,6 +1607,7 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @type {Function|String} callback - Something to call */') expect(tokens[4]).toEqual value: '{Function|String}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'callback', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] From e96d3f55c95478450030713abf6ac5e6dc09c096 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 31 Aug 2016 23:23:00 +0100 Subject: [PATCH 103/420] :bug: Allow for possible whitespace within square brackets --- grammars/javascript.cson | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index e77bf9a8..9417ed6f 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1830,6 +1830,7 @@ \\s+ ( \\[ # [foo] optional parameter + \\s* (?: [a-zA-Z_$][\\w$]* (?: @@ -1837,10 +1838,12 @@ [a-zA-Z_$][\\w$]* )* (?: + \\s* = # [foo=bar] Default parameter value [\\s\\w$]* )? ) + \\s* \\] | (?: [a-zA-Z_$][\\w$]* From b4a5009126bc04e7f78f808b2859356929724ecb Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Wed, 31 Aug 2016 23:23:41 +0100 Subject: [PATCH 104/420] :white_check_mark: Add specs for possible whitespace within square brackets --- spec/javascript-spec.coffee | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index ae013bf9..852419b3 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1572,11 +1572,26 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: '[variable]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} [ variable ] this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[ variable ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} [variable=default value] this is the description */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: '[variable=default value]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} [variable = default value] this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[variable = default value]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {object} [ variable = default value ] this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[ variable = default value ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} parameter.property this is the description */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'parameter.property', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] @@ -1587,11 +1602,26 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: '[parameter.property]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} [ parameter.property ] this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[ parameter.property ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} [parameter.property=default value] this is the description */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: '[parameter.property=default value]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} [parameter.property = default value] this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[parameter.property = default value]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {object} [ parameter.property = default value ] this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[ parameter.property = default value ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {*} variable this is the description */') expect(tokens[4]).toEqual value: '{*}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] @@ -1607,7 +1637,6 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - {tokens} = grammar.tokenizeLine('/** @type {Function|String} callback - Something to call */') expect(tokens[4]).toEqual value: '{Function|String}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'callback', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] From 34d9bd3e19e74b1be72364e33df6378d0d464cbc Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Thu, 1 Sep 2016 15:35:18 +0100 Subject: [PATCH 105/420] :art: Refactor code for readability --- grammars/javascript.cson | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 9417ed6f..e3a99562 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1840,7 +1840,8 @@ (?: \\s* = # [foo=bar] Default parameter value - [\\s\\w$]* + \\s* + [\\w$\\s]* )? ) \\s* From 52d1359b3801c0b79a6f8d69cde9671458138293 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Thu, 1 Sep 2016 20:05:38 +0100 Subject: [PATCH 106/420] :bug: Allow tilde char in JSDoc types --- grammars/javascript.cson | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index e3a99562..e9ff6507 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1801,7 +1801,7 @@ <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) (?: - [\\.|] # Check for . namespaced types {Foo.bar} or | for multiple types {string|number} + [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback [a-zA-Z_$]+ (?: [\\w$]* | @@ -1815,7 +1815,7 @@ <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) (?: - [\\.|] # Check for . namespaced types {Foo.bar} or | for multiple types {string|number} + [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback [a-zA-Z_$]+ (?: [\\w$]* | @@ -1886,7 +1886,7 @@ <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) (?: - [\\.|] # Check for . namespaced types {Foo.bar} or | for multiple types {string|number} + [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback [a-zA-Z_$]+ (?: [\\w$]* | @@ -1900,7 +1900,7 @@ <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) (?: - [\\.|] # Check for . namespaced types {Foo.bar} or | for multiple types {string|number} + [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback [a-zA-Z_$]+ (?: [\\w$]* | From bbf46857ab47b3f1614c06424fd4340104d4e4db Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Thu, 1 Sep 2016 20:07:42 +0100 Subject: [PATCH 107/420] :white_check_mark: Add specs for tilde char in JSDoc types --- spec/javascript-spec.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 852419b3..279532e8 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1701,6 +1701,11 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {Foo~cb} variable this is the description */') + expect(tokens[4]).toEqual value: '{Foo~cb}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {object} this is the description */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] From 513f50aad222db5210513cb0d49019283ad97446 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Thu, 1 Sep 2016 21:02:01 +0100 Subject: [PATCH 108/420] :bug: Add JSDoc support for properties within an array --- grammars/javascript.cson | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index e3a99562..b1081f6f 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1834,6 +1834,7 @@ (?: [a-zA-Z_$][\\w$]* (?: + (?:\\[\\])? # Foo[].bar properties within an array \\. # Foo.Bar namespaced parameter [a-zA-Z_$][\\w$]* )* @@ -1849,7 +1850,9 @@ (?: [a-zA-Z_$][\\w$]* (?: - \\.[a-zA-Z_$][\\w$]* # Foo.Bar namespaced parameter + (?:\\[\\])? # Foo[].bar properties within an array + \\. # Foo.Bar namespaced parameter + [a-zA-Z_$][\\w$]* )* )? ) From c5702ef2535933808dbb52cc6228bf9a837118eb Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Thu, 1 Sep 2016 21:07:27 +0100 Subject: [PATCH 109/420] :white_check_mark: Add spec JSDoc properties within an array --- spec/javascript-spec.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 852419b3..79b8f91f 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1671,6 +1671,11 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {Foo[].bar} variable this is the description */') + expect(tokens[4]).toEqual value: '{Foo[].bar}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {Array} variable this is the description */') expect(tokens[4]).toEqual value: '{Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] From cd94fb67c2ddf1f4efb2e51a13fd8188f30505b9 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Thu, 1 Sep 2016 21:24:52 +0100 Subject: [PATCH 110/420] :bug: Add JSDoc support for type application within a union type --- grammars/javascript.cson | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index b1081f6f..0106ede7 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1797,21 +1797,30 @@ \\( # Opening bracket of multiple types with parenthesis {(string|number)} [a-zA-Z_$]+ (?: - [\\w$]* | + (?: + [\\w$]* + (?:\\[\\])? # {(string[]|number)} type application, an array of strings or a number + ) | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) (?: [\\.|] # Check for . namespaced types {Foo.bar} or | for multiple types {string|number} [a-zA-Z_$]+ (?: - [\\w$]* | + (?: + [\\w$]* + (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers + ) | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) )* \\) | [a-zA-Z_$]+ (?: - [\\w$]* | + (?: + [\\w$]* + (?:\\[\\])? # {string[]|number} type application, an array of strings or a number + ) | <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application ) (?: From 6f3ba26c8a788816eeda159098fa01271bd5dbcd Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Thu, 1 Sep 2016 22:39:18 +0100 Subject: [PATCH 111/420] :white_check_mark: Add spec for JSDoc type application within a union type --- spec/javascript-spec.coffee | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 79b8f91f..8d014ede 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1637,14 +1637,36 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - {tokens} = grammar.tokenizeLine('/** @type {Function|String} callback - Something to call */') - expect(tokens[4]).toEqual value: '{Function|String}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'callback', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @type {function|string} variable this is the description */') + expect(tokens[4]).toEqual value: '{function|string}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {string[]|number} variable this is the description */') + expect(tokens[4]).toEqual value: '{string[]|number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {string|number[]} variable this is the description */') + expect(tokens[4]).toEqual value: '{string|number[]}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - {tokens} = grammar.tokenizeLine('/** @param {(Number|Function)} types - Bracket notation */') + {tokens} = grammar.tokenizeLine('/** @param {(number|function)} variable this is the description */') expect(tokens[2]).toEqual value: '@param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] - expect(tokens[4]).toEqual value: '{(Number|Function)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'types', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[4]).toEqual value: '{(number|function)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {(string[]|number)} variable this is the description */') + expect(tokens[4]).toEqual value: '{(string[]|number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {(string|number[])} variable this is the description */') + expect(tokens[4]).toEqual value: '{(string|number[])}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] {tokens} = grammar.tokenizeLine('/** @param {?number} variable this is the description */') expect(tokens[4]).toEqual value: '{?number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] From 37912ad42ca27e64d937062689684dd83d12a964 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Fri, 2 Sep 2016 20:21:30 +0100 Subject: [PATCH 112/420] :bug: Allow optional prefix for JSDoc type application --- grammars/javascript.cson | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 9e8b8d59..d3ab60cb 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1801,7 +1801,7 @@ [\\w$]* (?:\\[\\])? # {(string[]|number)} type application, an array of strings or a number ) | - <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) ) (?: [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback @@ -1811,7 +1811,7 @@ [\\w$]* (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers ) | - <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) ) )* \\) | @@ -1821,14 +1821,14 @@ [\\w$]* (?:\\[\\])? # {string[]|number} type application, an array of strings or a number ) | - <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array.} or {Object.} type application (optional .) ) (?: [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback [a-zA-Z_$]+ (?: [\\w$]* | - <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) ) )* ) @@ -1895,28 +1895,28 @@ [a-zA-Z_$]+ (?: [\\w$]* | - <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) ) (?: [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback [a-zA-Z_$]+ (?: [\\w$]* | - <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) ) )* \\) | [a-zA-Z_$]+ (?: [\\w$]* | - <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) ) (?: [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback [a-zA-Z_$]+ (?: [\\w$]* | - <[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) ) )* ) From c14929e807848d409a696c700f59e45a2d52ba03 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Fri, 2 Sep 2016 20:21:54 +0100 Subject: [PATCH 113/420] :white_check_mark: Add spec for optional prefix for JSDoc type application --- spec/javascript-spec.coffee | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index e2105df1..333c0a96 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1703,31 +1703,61 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {Array.} variable this is the description */') + expect(tokens[4]).toEqual value: '{Array.}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {Array|Array} variable this is the description */') expect(tokens[4]).toEqual value: '{Array|Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {Array.|Array.} variable this is the description */') + expect(tokens[4]).toEqual value: '{Array.|Array.}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {(Array|Array)} variable this is the description */') expect(tokens[4]).toEqual value: '{(Array|Array)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {(Array.|Array.)} variable this is the description */') + expect(tokens[4]).toEqual value: '{(Array.|Array.)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {Object} variable this is the description */') expect(tokens[4]).toEqual value: '{Object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {Object.} variable this is the description */') + expect(tokens[4]).toEqual value: '{Object.}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {Object|Array} variable this is the description */') expect(tokens[4]).toEqual value: '{Object|Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {Object.|Array.} variable this is the description */') + expect(tokens[4]).toEqual value: '{Object.|Array.}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {(Array|Object)} variable this is the description */') expect(tokens[4]).toEqual value: '{(Array|Object)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {(Array.|Object.)} variable this is the description */') + expect(tokens[4]).toEqual value: '{(Array.|Object.)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {Foo~cb} variable this is the description */') expect(tokens[4]).toEqual value: '{Foo~cb}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] From 1c6406d123a971d8a0ef9d6f6a7901ad3e666489 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Mon, 5 Sep 2016 16:19:05 +1000 Subject: [PATCH 114/420] Drop fixtures in favour of an inlined approach --- spec/fixtures/emacs-1 | 1 - spec/fixtures/emacs-2 | 1 - spec/fixtures/emacs-3 | 1 - spec/fixtures/emacs-4 | 1 - spec/fixtures/emacs-5 | 1 - spec/fixtures/emacs-6 | 1 - spec/fixtures/vim-1 | 1 - spec/fixtures/vim-2 | 1 - spec/fixtures/vim-3 | 1 - spec/fixtures/vim-4 | 1 - spec/fixtures/vim-5 | 1 - spec/fixtures/vim-6 | 1 - spec/javascript-spec.coffee | 39 +++++++++++++++++++------------------ 13 files changed, 20 insertions(+), 31 deletions(-) delete mode 100644 spec/fixtures/emacs-1 delete mode 100644 spec/fixtures/emacs-2 delete mode 100644 spec/fixtures/emacs-3 delete mode 100644 spec/fixtures/emacs-4 delete mode 100644 spec/fixtures/emacs-5 delete mode 100644 spec/fixtures/emacs-6 delete mode 100644 spec/fixtures/vim-1 delete mode 100644 spec/fixtures/vim-2 delete mode 100644 spec/fixtures/vim-3 delete mode 100644 spec/fixtures/vim-4 delete mode 100644 spec/fixtures/vim-5 delete mode 100644 spec/fixtures/vim-6 diff --git a/spec/fixtures/emacs-1 b/spec/fixtures/emacs-1 deleted file mode 100644 index 2d9afc44..00000000 --- a/spec/fixtures/emacs-1 +++ /dev/null @@ -1 +0,0 @@ -/* -*-js-*- */ diff --git a/spec/fixtures/emacs-2 b/spec/fixtures/emacs-2 deleted file mode 100644 index e9a04be9..00000000 --- a/spec/fixtures/emacs-2 +++ /dev/null @@ -1 +0,0 @@ -// -*- JS -*- diff --git a/spec/fixtures/emacs-3 b/spec/fixtures/emacs-3 deleted file mode 100644 index 1bc7e8c1..00000000 --- a/spec/fixtures/emacs-3 +++ /dev/null @@ -1 +0,0 @@ - /* -*- mode:js -*- */ diff --git a/spec/fixtures/emacs-4 b/spec/fixtures/emacs-4 deleted file mode 100644 index 71636f15..00000000 --- a/spec/fixtures/emacs-4 +++ /dev/null @@ -1 +0,0 @@ -// -*- font:bar;mode:JavaScript -*- diff --git a/spec/fixtures/emacs-5 b/spec/fixtures/emacs-5 deleted file mode 100644 index 4839565a..00000000 --- a/spec/fixtures/emacs-5 +++ /dev/null @@ -1 +0,0 @@ -" -*-foo:bar;mode:JavaScript;bar:foo-*- "; diff --git a/spec/fixtures/emacs-6 b/spec/fixtures/emacs-6 deleted file mode 100644 index b5080853..00000000 --- a/spec/fixtures/emacs-6 +++ /dev/null @@ -1 +0,0 @@ -"-*- font:x;foo : bar ; mode : javaScript ; bar : foo ; foooooo:baaaaar;fo:ba-*-"; diff --git a/spec/fixtures/vim-1 b/spec/fixtures/vim-1 deleted file mode 100644 index 5981512c..00000000 --- a/spec/fixtures/vim-1 +++ /dev/null @@ -1 +0,0 @@ -// vim: set ft=javascript: diff --git a/spec/fixtures/vim-2 b/spec/fixtures/vim-2 deleted file mode 100644 index e60ae00c..00000000 --- a/spec/fixtures/vim-2 +++ /dev/null @@ -1 +0,0 @@ -// vim: set filetype=JavaScript: diff --git a/spec/fixtures/vim-3 b/spec/fixtures/vim-3 deleted file mode 100644 index 436abce8..00000000 --- a/spec/fixtures/vim-3 +++ /dev/null @@ -1 +0,0 @@ -/* vim: ft=javascript */ diff --git a/spec/fixtures/vim-4 b/spec/fixtures/vim-4 deleted file mode 100644 index 7b58a344..00000000 --- a/spec/fixtures/vim-4 +++ /dev/null @@ -1 +0,0 @@ -// vim: syntax=javascript diff --git a/spec/fixtures/vim-5 b/spec/fixtures/vim-5 deleted file mode 100644 index 7df00d4b..00000000 --- a/spec/fixtures/vim-5 +++ /dev/null @@ -1 +0,0 @@ -/* vim: se syntax=javascript: */ diff --git a/spec/fixtures/vim-6 b/spec/fixtures/vim-6 deleted file mode 100644 index de25bb1e..00000000 --- a/spec/fixtures/vim-6 +++ /dev/null @@ -1 +0,0 @@ -/* ex: syntax=javascript */ diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 178f62f5..e8f0b6b7 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -2155,25 +2155,26 @@ describe "Javascript grammar", -> """ describe "Modelines", -> - beforeEach -> - atom.project.setPaths [__dirname + "/fixtures"] - it "can recognise Emacs modelines", -> - waitsForPromise -> - promises = for i in [1..6] - atom.workspace.open "emacs-#{i}" - Promise.all promises - - runs -> - for editor in atom.workspace.getTextEditors() - expect(editor.getGrammar().scopeName).toBe("source.js") + modelines = """ + /* -*-js-*- */ + // -*- JS -*- + /* -*- mode:js -*- */ + // -*- font:bar;mode:JavaScript -*- + " -*-foo:bar;mode:JavaScript;bar:foo-*- "; + "-*- font:x;foo : bar ; mode : javaScript ; bar : foo ; foooooo:baaaaar;fo:ba-*-"; + """ + for line in modelines.split /\n/ + expect(grammar.firstLineRegex.scanner.findNextMatchSync(line)).not.toBeNull() it "can recognise Vim modelines", -> - waitsForPromise -> - promises = for i in [1..6] - atom.workspace.open "vim-#{i}" - Promise.all promises - - runs -> - for editor in atom.workspace.getTextEditors() - expect(editor.getGrammar().scopeName).toBe("source.js") + modelines = """ + // vim: set ft=javascript: + // vim: set filetype=JavaScript: + /* vim: ft=javascript */ + // vim: syntax=javascript + /* vim: se syntax=javascript: */ + /* ex: syntax=javascript */ + """ + for line in modelines.split /\n/ + expect(grammar.firstLineRegex.scanner.findNextMatchSync(line)).not.toBeNull() From 1e9eee42c100b929156dedc2345e7c1370bcdb7d Mon Sep 17 00:00:00 2001 From: Alhadis Date: Fri, 9 Sep 2016 04:27:40 +1000 Subject: [PATCH 115/420] Rewrite patterns for matching hashbangs/modelines The existing code doesn't take into account some less obvious cases: #!/bin/env --type=node -*- not-mode: js -*- vim: noexpandtab: ft=javascript --- grammars/javascript.cson | 12 +++- spec/javascript-spec.coffee | 120 +++++++++++++++++++++++++++++++----- 2 files changed, 112 insertions(+), 20 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index a9a029e8..f925d91b 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -18,15 +18,21 @@ ] 'firstLineMatch': '''(?x) # Hashbang - ^\\#!.*\\b(?:node|iojs|JavaScript) + ^\\#!.*(?:\\s|\\/|(?<=!)\\b) + (?:node|iojs|JavaScript) + (?:$|\\s) | # Modeline (?i: # Emacs - -\\*-[^*]*(?:mode:\\s*)?\\b(?:js|javascript)(?:\\s*;.*?)?\\s*-\\*- + -\\*-(?:(?:(?!mode\\s*:)[^:;]+:[^:;]+;)*\\s*mode\\s*:)?\\s* + (?:js|javascript) + \\s*(?:;[^:;]+:[^:;]+?)*;?\\s*-\\*- | # Vim - (?:vim?|ex):\\s*(?:set?.*\\s)?(?:syntax|filetype|ft)=(javascript)\\s?(?:.*:)? + (?:(?:\\s|^)vi(?:m[<=>]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s*set?\\s))(?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:](?:filetype|ft|syntax)\\s*= + javascript + (?=\\s|:|$) ) ''' 'name': 'JavaScript' diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index e8f0b6b7..fac0bdb6 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -2154,27 +2154,113 @@ describe "Javascript grammar", -> ); """ - describe "Modelines", -> - it "can recognise Emacs modelines", -> - modelines = """ + describe "firstLineMatch", -> + it "recognises interpreter directives", -> + valid = """ + #!/usr/sbin/node foo + #!/usr/bin/iojs foo=bar/ + #!/usr/sbin/node + #!/usr/sbin/node foo bar baz + #!/usr/bin/node perl + #!/usr/bin/node bin/perl + #!/usr/bin/node + #!/bin/node + #!/usr/bin/node --script=usr/bin + #! /usr/bin/env A=003 B=149 C=150 D=xzd E=base64 F=tar G=gz H=head I=tail node + #!\t/usr/bin/env --foo=bar node --quu=quux + #! /usr/bin/node + #!/usr/bin/env node + """ + for line in valid.split /\n/ + expect(grammar.firstLineRegex.scanner.findNextMatchSync(line)).not.toBeNull() + + invalid = """ + \x20#!/usr/sbin/node + \t#!/usr/sbin/node + #!/usr/bin/env-node/node-env/ + #!/usr/bin/env-node + #! /usr/binnode + #!\t/usr/bin/env --node=bar + """ + for line in invalid.split /\n/ + expect(grammar.firstLineRegex.scanner.findNextMatchSync(line)).toBeNull() + + it "recognises Emacs modelines", -> + valid = """ + #-*-js-*- + #-*-mode:js-*- /* -*-js-*- */ - // -*- JS -*- + // -*- JavaScript -*- /* -*- mode:js -*- */ - // -*- font:bar;mode:JavaScript -*- - " -*-foo:bar;mode:JavaScript;bar:foo-*- "; - "-*- font:x;foo : bar ; mode : javaScript ; bar : foo ; foooooo:baaaaar;fo:ba-*-"; + // -*- font:bar;mode:JS -*- + // -*- font:bar;mode:JavaScript;foo:bar; -*- + // -*-font:mode;mode:JS-*- + " -*-foo:bar;mode:JS;bar:foo-*- "; + " -*-font-mode:foo;mode:JavaScript;foo-bar:quux-*-" + "-*-font:x;foo:bar; mode : js;bar:foo;foooooo:baaaaar;fo:ba;-*-"; + "-*- font:x;foo : bar ; mode : jS ; bar : foo ; foooooo:baaaaar;fo:ba-*-"; """ - for line in modelines.split /\n/ + for line in valid.split /\n/ expect(grammar.firstLineRegex.scanner.findNextMatchSync(line)).not.toBeNull() - it "can recognise Vim modelines", -> - modelines = """ - // vim: set ft=javascript: - // vim: set filetype=JavaScript: - /* vim: ft=javascript */ - // vim: syntax=javascript - /* vim: se syntax=javascript: */ - /* ex: syntax=javascript */ + invalid = """ + /* --*js-*- */ + /* -*-- js -*- + /* -*- -- js -*- + /* -*- javascripts -;- -*- + // -*- iJS -*- + // -*- js-stuff -*- + /* -*- model:js -*- + /* -*- indent-mode:js -*- + // -*- font:mode;JS -*- + // -*- mode: -*- JS + // -*- mode: grok-with-js -*- + // -*-font:mode;mode:js--*- + """ + for line in invalid.split /\n/ + expect(grammar.firstLineRegex.scanner.findNextMatchSync(line)).toBeNull() + + it "recognises Vim modelines", -> + valid = """ + vim: se filetype=javascript: + # vim: se ft=javascript: + # vim: set ft=javascript: + # vim: set filetype=JavaScript: + # vim: ft=javascript + # vim: syntax=jAvaScRIPT + # vim: se syntax=JAVASCRIPT: + # ex: syntax=javascript + # vim:ft=javascript + # vim600: ft=javascript + # vim>600: set ft=javascript: + # vi:noai:sw=3 ts=6 ft=javascript + # vi::::::::::noai:::::::::::: ft=javascript + # vim:ts=4:sts=4:sw=4:noexpandtab:ft=javascript + # vi:: noai : : : : sw =3 ts =6 ft =javascript + # vim: ts=4: pi sts=4: ft=javascript: noexpandtab: sw=4: + # vim: ts=4 sts=4: ft=javascript noexpandtab: + # vim:noexpandtab sts=4 ft=javascript ts=4 + # vim:noexpandtab:ft=javascript + # vim:ts=4:sts=4 ft=javascript:noexpandtab:\x20 + # vim:noexpandtab titlestring=hi\|there\\\\ ft=javascript ts=4 """ - for line in modelines.split /\n/ + for line in valid.split /\n/ expect(grammar.firstLineRegex.scanner.findNextMatchSync(line)).not.toBeNull() + + invalid = """ + ex: se filetype=javascript: + _vi: se filetype=javascript: + vi: se filetype=javascript + # vim set ft=javascripts + # vim: soft=javascript + # vim: hairy-syntax=javascript: + # vim set ft=javascript: + # vim: setft=javascript: + # vim: se ft=javascript backupdir=tmp + # vim: set ft=javascript set cmdheight=1 + # vim:noexpandtab sts:4 ft:javascript ts:4 + # vim:noexpandtab titlestring=hi\\|there\\ ft=javascript ts=4 + # vim:noexpandtab titlestring=hi\\|there\\\\\\ ft=javascript ts=4 + """ + for line in invalid.split /\n/ + expect(grammar.firstLineRegex.scanner.findNextMatchSync(line)).toBeNull() From 9140650abf60aae4e9933b11ffe6fe851a0a944f Mon Sep 17 00:00:00 2001 From: Robert Jefe Lindstaedt Date: Sat, 17 Sep 2016 13:08:12 +0200 Subject: [PATCH 116/420] add arrow function snippet --- snippets/language-javascript.cson | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snippets/language-javascript.cson b/snippets/language-javascript.cson index 172b7048..61533fb5 100644 --- a/snippets/language-javascript.cson +++ b/snippets/language-javascript.cson @@ -38,6 +38,9 @@ 'Anonymous Function': 'prefix': 'f' 'body': 'function ($1) {\n\t$2\n}' + 'Arrow Function': + 'prefix': 'af' + 'body': '($1) => {\n\t$2\n}' 'Generator': 'prefix': 'gen', 'body': 'function* ${1:functionName}($2) {\n\t$0\n}' From 1161a5cb8fc61c93a4802e3bd150bc2cfa70193a Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sun, 18 Sep 2016 02:41:31 +1000 Subject: [PATCH 117/420] Revise pattern for matching Emacs modelines Invalid modelines like "-*- js; -*-" are rejected by Emacs, but accepted by the previous pattern. Conversely, the old pattern incorrectly rejects lines that use whitespace to separate variables, which is legal syntax: -*- foo:bar mode:js bar:baz -*- --- grammars/javascript.cson | 4 ++-- spec/javascript-spec.coffee | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index a035900d..ef6aed65 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -25,9 +25,9 @@ # Modeline (?i: # Emacs - -\\*-(?:(?:(?!mode\\s*:)[^:;]+:[^:;]+;)*\\s*mode\\s*:)?\\s* + -\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*) (?:js|javascript) - \\s*(?:;[^:;]+:[^:;]+?)*;?\\s*-\\*- + (?=[\\s;]|(?]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s*set?\\s))(?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:](?:filetype|ft|syntax)\\s*= diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 422f4649..b5b1ab50 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -2199,6 +2199,7 @@ describe "Javascript grammar", -> // -*- font:bar;mode:JS -*- // -*- font:bar;mode:JavaScript;foo:bar; -*- // -*-font:mode;mode:JS-*- + // -*- foo:bar mode: js bar:baz -*- " -*-foo:bar;mode:JS;bar:foo-*- "; " -*-font-mode:foo;mode:JavaScript;foo-bar:quux-*-" "-*-font:x;foo:bar; mode : js;bar:foo;foooooo:baaaaar;fo:ba;-*-"; @@ -2213,6 +2214,7 @@ describe "Javascript grammar", -> /* -*- -- js -*- /* -*- javascripts -;- -*- // -*- iJS -*- + // -*- JS; -*- // -*- js-stuff -*- /* -*- model:js -*- /* -*- indent-mode:js -*- From b54256989f2cea16bde254a3c1653de0d3fb5e65 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Mon, 26 Sep 2016 21:07:14 +0100 Subject: [PATCH 118/420] Fix inconsistent comment --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index d3ab60cb..127a3d52 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1821,7 +1821,7 @@ [\\w$]* (?:\\[\\])? # {string[]|number} type application, an array of strings or a number ) | - \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array.} or {Object.} type application (optional .) + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) ) (?: [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback From 489d86fdbdba8de77413f72f3db0b0f6474b372b Mon Sep 17 00:00:00 2001 From: Wliu Date: Wed, 28 Sep 2016 20:53:13 -0400 Subject: [PATCH 119/420] Prepare 0.121.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4b7a3778..28072de8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.120.0", + "version": "0.121.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 4fd3d8d6786b59d080c97b5d8cb4aad21e600081 Mon Sep 17 00:00:00 2001 From: Long Nhat Nguyen Date: Thu, 29 Sep 2016 19:33:36 +0000 Subject: [PATCH 120/420] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7ad8b74a..42d9ef46 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # JavaScript language support in Atom -[![OS X Build Status](https://travis-ci.org/atom/language-javascript.svg?branch=master)](https://travis-ci.org/atom/language-javascript) +[![macOS Build Status](https://travis-ci.org/atom/language-javascript.svg?branch=master)](https://travis-ci.org/atom/language-javascript) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/ktooccwna96ssiyr/branch/master?svg=true)](https://ci.appveyor.com/project/Atom/language-javascript-dijf8/branch/master) [![Dependency Status](https://david-dm.org/atom/language-javascript.svg)](https://david-dm.org/atom/language-javascript) Adds syntax highlighting and snippets for JavaScript in Atom. -Originally [converted](http://atom.io/docs/latest/converting-a-text-mate-bundle) +Originally [converted](http://flight-manual.atom.io/hacking-atom/sections/converting-from-textmate) from the [JavaScript TextMate bundle](https://github.com/textmate/javascript.tmbundle). Contributions are greatly appreciated. Please fork this repository and open a From c7ea09c050a837b2bb42c2b5eab35c9abf97c70d Mon Sep 17 00:00:00 2001 From: Wliu Date: Thu, 6 Oct 2016 16:05:59 -0400 Subject: [PATCH 121/420] Create an embedded grammar When embedded, a tag will break out of the script block even if it would otherwise be in a comment. There's no way to catch when we're embedded with javascript.cson, but we can do it using an injectionSelector. --- grammars/embedded javascript.cson | 30 ++++++++++++++++++++++++++++++ grammars/javascript.cson | 19 +++++++++---------- 2 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 grammars/embedded javascript.cson diff --git a/grammars/embedded javascript.cson b/grammars/embedded javascript.cson new file mode 100644 index 00000000..e0a87742 --- /dev/null +++ b/grammars/embedded javascript.cson @@ -0,0 +1,30 @@ +'scopeName': 'source.js.embedded.html' +'name': 'Embedded JavaScript' +'injectionSelector': 'L:source.js.embedded.html' +'patterns': [ + { + 'begin': '(^[ \\t]+)?(?=//)' + 'beginCaptures': + '1': + 'name': 'punctuation.whitespace.comment.leading.js' + 'end': '(?!\\G)' + 'patterns': [ + { + 'begin': '//' + 'beginCaptures': + '0': + 'name': 'punctuation.definition.comment.js' + 'end': '(?=)|\\n' + 'name': 'comment.line.double-slash.js' + } + ] + } + { + 'begin': '' + 'beginCaptures': + '0': + 'name': 'punctuation.definition.comment.html.js' + 'end': '(?=)|$' + 'name': 'comment.line.deprecated.html.js' + } +] diff --git a/grammars/javascript.cson b/grammars/javascript.cson index e6d2468f..e567e5bc 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1,4 +1,5 @@ 'scopeName': 'source.js' +'name': 'JavaScript' 'fileTypes': [ 'js' '_js' @@ -35,7 +36,6 @@ (?=\\s|:|$) ) ''' -'name': 'JavaScript' 'patterns': [ { # ES6 import @@ -827,15 +827,6 @@ { 'include': '#comments' } - { - 'match': '()' - 'captures': - '0': - 'name': 'punctuation.definition.comment.html.js' - '2': - 'name': 'punctuation.definition.comment.html.js' - 'name': 'comment.block.html.js' - } { 'match': '(?' + 'beginCaptures': + '0': + 'name': 'punctuation.definition.comment.html.js' + 'end': '$' + 'name': 'comment.line.deprecated.html.js' + } ] 'switch_statement': 'patterns': [ From 001a31deaaec965fce5821b1c123eb5bfb703feb Mon Sep 17 00:00:00 2001 From: Wliu Date: Thu, 6 Oct 2016 16:13:29 -0400 Subject: [PATCH 122/420] Add specs --- spec/javascript-spec.coffee | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 6ebbd82a..cfb5d2e0 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1851,6 +1851,19 @@ describe "Javascript grammar", -> expect(tokens[7]).toEqual value: ', p2 ', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js'] expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.definition.comment.js'] + it "tokenizes deprecated HTML-style comments correctly", -> + {tokens} = grammar.tokenizeLine(' test') + expect(tokens[0]).toEqual value: '-->', scopes: ['source.js', 'comment.line.deprecated.html.js', 'punctuation.definition.comment.html.js'] + expect(tokens[1]).toEqual value: ' test', scopes: ['source.js', 'comment.line.deprecated.html.js'] + + {tokens} = grammar.tokenizeLine(' console.log()') + expect(tokens[0]).toEqual value: ' console.log()', scopes: ['source.js', 'comment.line.deprecated.html.js'] + describe "console", -> it "tokenizes the console keyword", -> {tokens} = grammar.tokenizeLine('console;') From 2a2218a0ae209ab5da09286d5075c2daa27e5d8e Mon Sep 17 00:00:00 2001 From: MoritzKn Date: Fri, 7 Oct 2016 17:25:12 +0200 Subject: [PATCH 123/420] Add synonyms for jsDoc @param tag --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index e6d2468f..358b421a 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1799,7 +1799,7 @@ } { 'match': '''(?x) - (?:(?<=@param)|(?<=@type)) + (?:(?<=@param)|(?<=@arg)|(?<=@argument)|(?<=@type)) \\s+ ({(?: \\* | # {*} any type From cbb4ab5f9b7999019696ac7fce17d51829d0485d Mon Sep 17 00:00:00 2001 From: MoritzKn Date: Fri, 7 Oct 2016 17:40:47 +0200 Subject: [PATCH 124/420] Remove hyphen before the jsDoc description from the capture In jsDoc its allowed to add a hyphen before the description. See: http://usejsdoc.org/tags-param.html --- grammars/javascript.cson | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 358b421a..05cad126 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1884,6 +1884,7 @@ )? ) \\s+ + (?:-\\s+)? # optional hyphen before the description ((?:(?!\\*\\/).)*) # The type description ''' 'captures': @@ -1943,6 +1944,7 @@ =? # {string=} optional parameter )}) \\s+ + (?:-\\s+)? # optional hyphen before the description ((?:(?!\\*\\/).)*) # The type description ''' 'captures': From bf26409a5b268be2dd44dd9306fd8fc4bd3ff1f5 Mon Sep 17 00:00:00 2001 From: Maxim Sokolov Date: Sat, 8 Oct 2016 16:08:46 +0300 Subject: [PATCH 125/420] Add support for bitwise shift operators --- grammars/javascript.cson | 4 ++++ spec/javascript-spec.coffee | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index e6d2468f..8449435b 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1260,6 +1260,10 @@ 'match': '&=|\\^=|<<=|>>=|>>>=|\\|=' 'name': 'keyword.operator.assignment.compound.bitwise.js' } + { + 'match': '<<|>>>|>>' + 'name': 'keyword.operator.bitwise.shift.js' + } { 'match': '!==|!=|<=|>=|===|==|<|>' 'name': 'keyword.operator.comparison.js' diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 6ebbd82a..4001f473 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -342,6 +342,15 @@ describe "Javascript grammar", -> expect(tokens[0]).toEqual value: '~', scopes: ['source.js', 'keyword.operator.bitwise.js'] expect(tokens[1]).toEqual value: 'a', scopes: ['source.js'] + it "tokenizes bitwise shift operators", -> + operators = ["<<", ">>", ">>>"] + + for operator in operators + {tokens} = grammar.tokenizeLine('a ' + operator + ' b') + expect(tokens[0]).toEqual value: 'a ', scopes: ['source.js'] + expect(tokens[1]).toEqual value: operator, scopes: ['source.js', 'keyword.operator.bitwise.shift.js'] + expect(tokens[2]).toEqual value: ' b', scopes: ['source.js'] + it "tokenizes them", -> operators = ["|", "^", "&"] From 724bda1240b47b13a3eec267093945311b0b8140 Mon Sep 17 00:00:00 2001 From: MoritzKn Date: Sat, 8 Oct 2016 19:39:27 +0200 Subject: [PATCH 126/420] Add specs for jsDoc grammar adjustments - hyphen before the description - @arg and @argument synonyms for @param tag --- spec/javascript-spec.coffee | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 6ebbd82a..94820f4f 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1566,6 +1566,20 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @arg {object} variable this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @argument {object} variable this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is the description */') + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} $variable this is the description */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: '$variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] From 11ee9d46b11a37dfe94602af19e2df97e656c6f2 Mon Sep 17 00:00:00 2001 From: Wliu Date: Mon, 10 Oct 2016 14:35:43 -0400 Subject: [PATCH 127/420] Prepare 0.122.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 28072de8..7e32c4dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.121.0", + "version": "0.122.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From ada21172b984df1429fc1356a3d6630de9d1a62b Mon Sep 17 00:00:00 2001 From: DamnedScholar Date: Mon, 10 Oct 2016 15:28:34 -0500 Subject: [PATCH 128/420] Added template matching following innerHTML --- grammars/javascript.cson | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 89ee4c14..4bf8fb82 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1359,6 +1359,30 @@ } ] } + { + 'begin': '(?<=innerHTML)\\s*(=)\\s*(`)' + 'beginCaptures': + '1': + 'name': 'keyword.operator.assignment.js' + '2': + 'name': 'punctuation.definition.string.begin.js' + 'end': '`' + 'endCaptures': + '0': + 'name': 'punctuation.definition.string.end.js' + 'name': 'string.quoted.template.html.js' + 'patterns': [ + { + 'include': '#string_escapes' + } + { + 'include': '#interpolated_js' + } + { + 'include': 'text.html.basic' + } + ] + } { 'begin': '(Relay\\.QL)\\s*(`)' 'beginCaptures': From 9c785a2b523fdc93f4123b0ad74883052c80b226 Mon Sep 17 00:00:00 2001 From: Wliu Date: Thu, 13 Oct 2016 15:53:00 -0400 Subject: [PATCH 129/420] Look for everywhere instead --- grammars/embedded javascript.cson | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/grammars/embedded javascript.cson b/grammars/embedded javascript.cson index e0a87742..98a5a115 100644 --- a/grammars/embedded javascript.cson +++ b/grammars/embedded javascript.cson @@ -1,30 +1,10 @@ 'scopeName': 'source.js.embedded.html' 'name': 'Embedded JavaScript' -'injectionSelector': 'L:source.js.embedded.html' +'injectionSelector': 'L:source.js.embedded.html, L:source.js.embedded.xml' 'patterns': [ { - 'begin': '(^[ \\t]+)?(?=//)' - 'beginCaptures': - '1': - 'name': 'punctuation.whitespace.comment.leading.js' - 'end': '(?!\\G)' - 'patterns': [ - { - 'begin': '//' - 'beginCaptures': - '0': - 'name': 'punctuation.definition.comment.js' - 'end': '(?=)|\\n' - 'name': 'comment.line.double-slash.js' - } - ] - } - { - 'begin': '' - 'beginCaptures': - '0': - 'name': 'punctuation.definition.comment.html.js' - 'end': '(?=)|$' - 'name': 'comment.line.deprecated.html.js' + # Break out as soon as a tag is encountered, + # even if it's in a string or comment + 'match': '(?=)' } ] From fc0a9f81d0aa272188bfdd3d0231c2dd40b63b8e Mon Sep 17 00:00:00 2001 From: Wliu Date: Thu, 13 Oct 2016 15:59:57 -0400 Subject: [PATCH 130/420] HTML tags are case-insensitive There can also be trailing whitespace after the tag name --- grammars/embedded javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/embedded javascript.cson b/grammars/embedded javascript.cson index 98a5a115..6cd2575b 100644 --- a/grammars/embedded javascript.cson +++ b/grammars/embedded javascript.cson @@ -5,6 +5,6 @@ { # Break out as soon as a tag is encountered, # even if it's in a string or comment - 'match': '(?=)' + 'match': '(?=)' } ] From 5c881da59026502ecf605c8cc1d3addec268d458 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sun, 16 Oct 2016 03:05:43 +1100 Subject: [PATCH 131/420] Add pattern-matching for inline JSDoc links --- grammars/javascript.cson | 51 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 89ee4c14..a2c5a573 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1796,11 +1796,60 @@ |fileoverview|final|fires|for|function|global|host|ignore|implements|inherit[Dd]oc|inner|instance|interface|kind |lends|license|listens|main|member|memberof|method|mixex|mixins?|module|name|namespace|nocollapse|nosideeffects |override|overview|package|param|preserve|private|prop|property|protected|public|read[Oo]nly|record|require[ds] - |returns?|see|since|static|struct|submodule|summary|template|this|throws|todo|tutorial|type|typedef|unrestricted + |returns?|see|since|static|struct|submodule|summary|template|this|throws|todo|type|typedef|unrestricted |uses|var|variation|version|virtual|writeOnce)\\b ''' 'name': 'storage.type.class.jsdoc' } + { + 'match': '''(?x) + (?: + \\[ + [^\\]]+ # Optional [link text] preceding {@link syntax} + \\] + + (?! # Check to avoid highlighting two sets of link text + { + @\\w+ # Tagname + \\s+ + [^\\s|}]+ # Namepath/URL + [\\s|] # Whitespace or bar delimiting description + [^\\}]* + } + ) + )? + + (?: + { + ( + @ + (?: link # Name of tag + | linkcode + | linkplain + | tutorial + ) + ) + + \\s+ + + ([^\\s|}]+) # Namepath or URL + + (?: # Optional link text following link target + [\\s|] # Bar or space separating target and text + [^\\}]* # Actual text + )? + } + ) + ''' + 'captures': + '0': + 'name': 'entity.name.type.instance.jsdoc' + '1': + 'name': 'storage.type.class.jsdoc' + '2': + 'name': 'variable.other.description.jsdoc' + 'name': 'other.meta.jsdoc' + } { 'match': '''(?x) (?:(?<=@param)|(?<=@arg)|(?<=@argument)|(?<=@type)) From ea1124421caa5190a3e7925203a096b755df79ae Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sun, 16 Oct 2016 03:33:07 +1100 Subject: [PATCH 132/420] Add specs for JSDoc @link/@tutorial tags --- spec/javascript-spec.coffee | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 45c83805..3cb30e7b 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1563,6 +1563,52 @@ describe "Javascript grammar", -> {tokens} = grammar.tokenizeLine('/** @define {object} */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + {tokens} = grammar.tokenizeLine('/** Text {@link target} text */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[3]).toEqual value: '@link', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[5]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[6]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: ' text ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + + {tokens} = grammar.tokenizeLine('/** Text {@linkplain target|Description text} */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[3]).toEqual value: '@linkplain', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[5]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[6]).toEqual value: '|Description text}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + + {tokens} = grammar.tokenizeLine('/** Text {@linkcode target Description text} */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[3]).toEqual value: '@linkcode', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[5]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[6]).toEqual value: ' Description text}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + + {tokens} = grammar.tokenizeLine('/** Text [Description text]{@link target} */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[2]).toEqual value: '[Description text]{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[3]).toEqual value: '@link', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[5]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[6]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + + {tokens} = grammar.tokenizeLine('/** Text [Description text]{@tutorial target|Description} */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[1]).toEqual value: ' Text [Description text]', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[3]).toEqual value: '@tutorial', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[5]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[6]).toEqual value: '|Description}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + {tokens} = grammar.tokenizeLine('/** @param {object} */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] From 8f4b3deb7b897f3baf2bc52e9456126096c88b79 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sun, 16 Oct 2016 04:23:55 +1100 Subject: [PATCH 133/420] Delete superfluous backslashes --- grammars/javascript.cson | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index a2c5a573..f3fe14c2 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -48,11 +48,11 @@ 'patterns': [ { # { member1 , member2 as alias2 , [...] } - 'begin': '\\{' + 'begin': '{' 'beginCaptures': 0: 'name': 'punctuation.definition.modules.begin.js' - 'end': '\\}' + 'end': '}' 'endCaptures': 0: 'name': 'punctuation.definition.modules.end.js' @@ -173,11 +173,11 @@ } { # { member1 , member2 as alias2 , [...] } inside re-export - 'begin': '\\{(?=.*\\bfrom\\b)' + 'begin': '{(?=.*\\bfrom\\b)' 'beginCaptures': 0: 'name': 'punctuation.definition.modules.begin.js' - 'end': '\\}' + 'end': '}' 'endCaptures': 0: 'name': 'punctuation.definition.modules.end.js' @@ -220,11 +220,11 @@ } { # { member1 , member2 as alias2 , [...] } - 'begin': '(?![a-zA-Z_$0-9])\\{' + 'begin': '(?![a-zA-Z_$0-9]){' 'beginCaptures': 0: 'name': 'punctuation.definition.modules.begin.js' - 'end': '\\}' + 'end': '}' 'endCaptures': 0: 'name': 'punctuation.definition.modules.end.js' @@ -471,7 +471,7 @@ \\b[a-zA-Z_$][\\w$]* \\s*\\(\\s* (("[^"]*")|(\\'[^\\']*\\')|((?!"|\\'|\\(|\\)).))* - \\)\\s*\\{ + \\)\\s*{ ) ''' 'end': '(?<=})' @@ -1758,11 +1758,11 @@ 'interpolated_js': 'patterns': [ { - 'begin': '\\$\\{' + 'begin': '\\${' 'captures': '0': 'name': 'punctuation.section.embedded.js' - 'end': '\\}' + 'end': '}' 'name': 'source.js.embedded.source' 'patterns': [ { @@ -1814,7 +1814,7 @@ \\s+ [^\\s|}]+ # Namepath/URL [\\s|] # Whitespace or bar delimiting description - [^\\}]* + [^}]* } ) )? @@ -1836,7 +1836,7 @@ (?: # Optional link text following link target [\\s|] # Bar or space separating target and text - [^\\}]* # Actual text + [^}]* # Actual text )? } ) From 9bdb7c0d3048e0248a6e9d070b90fdd47a2c3236 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sun, 16 Oct 2016 15:25:10 +1100 Subject: [PATCH 134/420] Split scope used by preceding description text --- grammars/javascript.cson | 6 ++++-- spec/javascript-spec.coffee | 13 ++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index f3fe14c2..84a01830 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1803,7 +1803,7 @@ } { 'match': '''(?x) - (?: + ( \\[ [^\\]]+ # Optional [link text] preceding {@link syntax} \\] @@ -1845,8 +1845,10 @@ '0': 'name': 'entity.name.type.instance.jsdoc' '1': - 'name': 'storage.type.class.jsdoc' + 'name': 'constant.other.description.jsdoc' '2': + 'name': 'storage.type.class.jsdoc' + '3': 'name': 'variable.other.description.jsdoc' 'name': 'other.meta.jsdoc' } diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 3cb30e7b..511ca755 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1594,11 +1594,14 @@ describe "Javascript grammar", -> {tokens} = grammar.tokenizeLine('/** Text [Description text]{@link target} */') expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[2]).toEqual value: '[Description text]{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[3]).toEqual value: '@link', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[5]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[6]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[2]).toEqual value: '[Description text]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'constant.other.description.jsdoc'] + expect(tokens[3]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[4]).toEqual value: '@link', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[5]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** Text [Description text]{@tutorial target|Description} */') expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] From 29c228921cae8807a4412c613718f8c8c3bed962 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Sun, 16 Oct 2016 12:19:36 +0100 Subject: [PATCH 135/420] :bug: Add missing JSDoc Google closure tags --- grammars/javascript.cson | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 89ee4c14..ab4348f0 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1793,11 +1793,11 @@ (abstract|access|alias|arg|argument|async|attribute|augments|author|beta|borrows|bubbes|callback|chainable|class |classdesc|code|config|const|constant|constructor|constructs|copyright|default|defaultvalue|define|deprecated|desc |description|dict|emits|enum|event|example|exports?|extends|extension|extension_for|extensionfor|external|file - |fileoverview|final|fires|for|function|global|host|ignore|implements|inherit[Dd]oc|inner|instance|interface|kind - |lends|license|listens|main|member|memberof|method|mixex|mixins?|module|name|namespace|nocollapse|nosideeffects - |override|overview|package|param|preserve|private|prop|property|protected|public|read[Oo]nly|record|require[ds] - |returns?|see|since|static|struct|submodule|summary|template|this|throws|todo|tutorial|type|typedef|unrestricted - |uses|var|variation|version|virtual|writeOnce)\\b + |fileoverview|final|fires|for|function|global|host|ignore|implements|implicitCast|inherit[Dd]oc|inner|instance + |interface|kind|lends|license|listens|main|member|memberof|method|mixex|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 d1e51105de78d0c2187962cc7dc80dcc1b528c9c Mon Sep 17 00:00:00 2001 From: DamnedScholar Date: Sun, 16 Oct 2016 12:58:54 -0500 Subject: [PATCH 136/420] Tweaking regex --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 4bf8fb82..ae55d8f9 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1360,7 +1360,7 @@ ] } { - 'begin': '(?<=innerHTML)\\s*(=)\\s*(`)' + 'begin': '(?<=innerHTML)\\s*(\\+?=)\\s*(`)' 'beginCaptures': '1': 'name': 'keyword.operator.assignment.js' From 7eec645bdb48239b73935762d3ab02b938c390f7 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Mon, 17 Oct 2016 23:17:54 +1100 Subject: [PATCH 137/420] Improve support for property highlighting * Getter/setter keywords now recognised * Support for ES6 computed method names has been included --- grammars/javascript.cson | 43 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index ab4348f0..6ad452c9 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -468,10 +468,22 @@ import|package|return|switch|throw|try|while|with) [\\s\\(] ) - \\b[a-zA-Z_$][\\w$]* - \\s*\\(\\s* - (("[^"]*")|(\\'[^\\']*\\')|((?!"|\\'|\\(|\\)).))* - \\)\\s*\\{ + (\\b(get|set)\\s+)? # Property getter/setter: get foo(){} + ( # Method name + \\b[a-zA-Z_$][\\w$]* # Fixed name + | + \\[ # Computed property key + .*?[^\\[\\]\\s].*? # Contains at least one non-brace character + \\] + ) + \\s*\\(\\s* # Start of arguments list + ( + "[^"]*" | # Double-quoted string + '[^']*' | # Single-quoted string + [^"()'] # Any non-bracket or non-quote + )* + \\)\\s* # End of arguments + \\{ # Beginning of body ) ''' 'end': '(?<=})' @@ -487,6 +499,29 @@ 'end': '(?<=\\))' 'name': 'meta.function.method.definition.js' 'patterns': [ + { + 'match': '(\\[)(.+)(\\])(?=\\s*\\()' + 'captures': + '1': + 'name': 'meta.brace.square.js' + '2': + 'patterns': [ + { + 'include': '$self' + } + { + 'match': '[a-zA-Z_$][\\w$]*' + 'name': 'variable.parameter.property.js' + } + ] + '3': + 'name': 'meta.brace.square.js' + 'name': 'meta.computed-key.js' + } + { + 'match': '\\b(get|set)(?=\\s+[^\\s(]+\\s*\\()' + 'name': 'keyword.operator.$1ter.js' + } { 'match': '\\b([a-zA-Z_$][\\w$]*)' 'name': 'entity.name.function.js' From b6fb8f4dc06e872bb2f9082f892b91c9fc861c62 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Mon, 17 Oct 2016 23:30:00 +1100 Subject: [PATCH 138/420] Add specs for 7eec645 --- spec/javascript-spec.coffee | 104 ++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 45c83805..6c1bd06a 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1013,6 +1013,15 @@ describe "Javascript grammar", -> expect(tokens[9]).toEqual value: 'onclick', scopes: ['source.js', 'meta.function.js', 'entity.name.function.js'] expect(tokens[13]).toEqual value: 'function', scopes: ['source.js', 'meta.function.js', 'storage.type.function.js'] + it "tokenises getter/setter keywords", -> + {tokens} = grammar.tokenizeLine('get name(){ }') + expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'keyword.operator.getter.js'] + expect(tokens[2]).toEqual value: 'name', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] + expect(tokens[3]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] + expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.end.bracket.round.js'] + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] + expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'punctuation.definition.function.body.end.bracket.curly.js'] + it "tokenizes ES6 method definitions", -> {tokens} = grammar.tokenizeLine('f(a, b) {}') expect(tokens[0]).toEqual value: 'f', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] @@ -1060,6 +1069,101 @@ describe "Javascript grammar", -> expect(tokens[5]).toEqual value: ')', scopes: ['source.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] expect(tokens[6]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + it "tokenises ES6 methods with computed names", -> + {tokens} = grammar.tokenizeLine('get [ foo ] () { }') + expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] + expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[4]).toEqual value: 'foo', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'variable.parameter.property.js'] + expect(tokens[6]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[8]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] + expect(tokens[9]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.end.bracket.round.js'] + expect(tokens[11]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] + expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'punctuation.definition.function.body.end.bracket.curly.js'] + + {tokens} = grammar.tokenizeLine('get [ "Win" + bar[2] + quaz() ](){ }') + expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] + expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[4]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[5]).toEqual value: 'Win', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js'] + expect(tokens[6]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[8]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] + expect(tokens[10]).toEqual value: 'bar', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'variable.parameter.property.js'] + expect(tokens[11]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[12]).toEqual value: '2', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'constant.numeric.decimal.js'] + expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[15]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] + expect(tokens[17]).toEqual value: 'quaz', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'entity.name.function.js'] + expect(tokens[18]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] + expect(tokens[19]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(tokens[21]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[22]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] + expect(tokens[23]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.end.bracket.round.js'] + expect(tokens[24]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] + expect(tokens[26]).toEqual value: '}', scopes: ['source.js', 'punctuation.definition.function.body.end.bracket.curly.js'] + + {tokens} = grammar.tokenizeLine('get [\'string\' [ quaz()[2 + 2]] + this + "ABC" ](){ },') + expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] + expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[3]).toEqual value: '\'', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] + expect(tokens[4]).toEqual value: 'string', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js'] + expect(tokens[5]).toEqual value: '\'', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] + expect(tokens[7]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[9]).toEqual value: 'quaz', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'entity.name.function.js'] + expect(tokens[10]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] + expect(tokens[11]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(tokens[12]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[13]).toEqual value: '2', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'constant.numeric.decimal.js'] + expect(tokens[15]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] + expect(tokens[17]).toEqual value: '2', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'constant.numeric.decimal.js'] + expect(tokens[18]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[19]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[21]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] + expect(tokens[23]).toEqual value: 'this', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'variable.language.js'] + expect(tokens[25]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] + expect(tokens[27]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[28]).toEqual value: 'ABC', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js'] + expect(tokens[29]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[31]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[32]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] + expect(tokens[33]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.end.bracket.round.js'] + expect(tokens[34]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] + expect(tokens[36]).toEqual value: '}', scopes: ['source.js', 'punctuation.definition.function.body.end.bracket.curly.js'] + expect(tokens[37]).toEqual value: ',', scopes: ['source.js', 'meta.delimiter.object.comma.js'] + + {tokens} = grammar.tokenizeLine('set [\'string\' + ([ quaz()[2 + 2]]) + this + "ABC" ](k = 2){ }') + expect(tokens[0]).toEqual value: 'set', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] + expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[3]).toEqual value: '\'', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] + expect(tokens[4]).toEqual value: 'string', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js'] + expect(tokens[5]).toEqual value: '\'', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] + expect(tokens[7]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] + expect(tokens[9]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.round.js'] + expect(tokens[10]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[12]).toEqual value: 'quaz', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'entity.name.function.js'] + expect(tokens[13]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] + expect(tokens[14]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(tokens[15]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[16]).toEqual value: '2', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'constant.numeric.decimal.js'] + expect(tokens[18]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] + expect(tokens[20]).toEqual value: '2', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'constant.numeric.decimal.js'] + expect(tokens[21]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[22]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[23]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.round.js'] + expect(tokens[25]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] + expect(tokens[27]).toEqual value: 'this', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'variable.language.js'] + expect(tokens[29]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] + expect(tokens[31]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[32]).toEqual value: 'ABC', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js'] + expect(tokens[33]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[35]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[36]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] + expect(tokens[37]).toEqual value: 'k', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'variable.parameter.function.js'] + expect(tokens[39]).toEqual value: '=', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'keyword.operator.assignment.js'] + expect(tokens[41]).toEqual value: '2', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'constant.numeric.decimal.js'] + expect(tokens[42]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.end.bracket.round.js'] + expect(tokens[43]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] + expect(tokens[45]).toEqual value: '}', scopes: ['source.js', 'punctuation.definition.function.body.end.bracket.curly.js'] + it "tokenizes constructors", -> {tokens} = grammar.tokenizeLine('constructor(p1, p2) { this.p1 = p1; }') expect(tokens[0]).toEqual value: 'constructor', scopes: ['source.js', 'meta.function.js', 'entity.name.function.constructor.js'] From 9c6db29b82608367343d38d0ee3915e513d1c46f Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 18 Oct 2016 00:05:45 +1100 Subject: [PATCH 139/420] Fix wrong scope used in computed getter/setter names --- grammars/javascript.cson | 7 +++++-- spec/javascript-spec.coffee | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 6ad452c9..8a7378d2 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -468,7 +468,10 @@ import|package|return|switch|throw|try|while|with) [\\s\\(] ) - (\\b(get|set)\\s+)? # Property getter/setter: get foo(){} + ( + \\b(get|set) # Property getter/setter: get foo(){} + (?:\\s+|(?=\\[)) # Followed by whitespace or square bracket + )? ( # Method name \\b[a-zA-Z_$][\\w$]* # Fixed name | @@ -519,7 +522,7 @@ 'name': 'meta.computed-key.js' } { - 'match': '\\b(get|set)(?=\\s+[^\\s(]+\\s*\\()' + 'match': '\\b(get|set)(?=\\s*\\[.+\\]\\s*\\(|\\s+[^\\s\\[(]+\\s*\\()' 'name': 'keyword.operator.$1ter.js' } { diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 6c1bd06a..c50f159c 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1071,7 +1071,7 @@ describe "Javascript grammar", -> it "tokenises ES6 methods with computed names", -> {tokens} = grammar.tokenizeLine('get [ foo ] () { }') - expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] + expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'keyword.operator.getter.js'] expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] expect(tokens[4]).toEqual value: 'foo', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'variable.parameter.property.js'] expect(tokens[6]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] @@ -1081,7 +1081,7 @@ describe "Javascript grammar", -> expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'punctuation.definition.function.body.end.bracket.curly.js'] {tokens} = grammar.tokenizeLine('get [ "Win" + bar[2] + quaz() ](){ }') - expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] + expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'keyword.operator.getter.js'] expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] expect(tokens[4]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] expect(tokens[5]).toEqual value: 'Win', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js'] @@ -1102,7 +1102,7 @@ describe "Javascript grammar", -> expect(tokens[26]).toEqual value: '}', scopes: ['source.js', 'punctuation.definition.function.body.end.bracket.curly.js'] {tokens} = grammar.tokenizeLine('get [\'string\' [ quaz()[2 + 2]] + this + "ABC" ](){ },') - expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] + expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'keyword.operator.getter.js'] expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] expect(tokens[3]).toEqual value: '\'', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] expect(tokens[4]).toEqual value: 'string', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js'] @@ -1131,7 +1131,7 @@ describe "Javascript grammar", -> expect(tokens[37]).toEqual value: ',', scopes: ['source.js', 'meta.delimiter.object.comma.js'] {tokens} = grammar.tokenizeLine('set [\'string\' + ([ quaz()[2 + 2]]) + this + "ABC" ](k = 2){ }') - expect(tokens[0]).toEqual value: 'set', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] + expect(tokens[0]).toEqual value: 'set', scopes: ['source.js', 'meta.function.method.definition.js', 'keyword.operator.setter.js'] expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] expect(tokens[3]).toEqual value: '\'', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] expect(tokens[4]).toEqual value: 'string', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js'] From 68ad2edf624a9b7607849f15013ce80e93bbd5c4 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 18 Oct 2016 02:23:49 +1100 Subject: [PATCH 140/420] Fix incorrectly-scoped punctuation --- grammars/javascript.cson | 6 +++--- spec/javascript-spec.coffee | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 8a7378d2..89780360 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -486,7 +486,7 @@ [^"()'] # Any non-bracket or non-quote )* \\)\\s* # End of arguments - \\{ # Beginning of body + { # Beginning of body ) ''' 'end': '(?<=})' @@ -506,7 +506,7 @@ 'match': '(\\[)(.+)(\\])(?=\\s*\\()' 'captures': '1': - 'name': 'meta.brace.square.js' + 'name': 'punctuation.definition.computed-key.begin.bracket.square.js' '2': 'patterns': [ { @@ -518,7 +518,7 @@ } ] '3': - 'name': 'meta.brace.square.js' + 'name': 'punctuation.definition.computed-key.end.bracket.square.js' 'name': 'meta.computed-key.js' } { diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index c50f159c..e8b8d8df 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1072,9 +1072,9 @@ describe "Javascript grammar", -> it "tokenises ES6 methods with computed names", -> {tokens} = grammar.tokenizeLine('get [ foo ] () { }') expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'keyword.operator.getter.js'] - expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.begin.bracket.square.js'] expect(tokens[4]).toEqual value: 'foo', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'variable.parameter.property.js'] - expect(tokens[6]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[6]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.end.bracket.square.js'] expect(tokens[8]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] expect(tokens[9]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.end.bracket.round.js'] expect(tokens[11]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] @@ -1082,7 +1082,7 @@ describe "Javascript grammar", -> {tokens} = grammar.tokenizeLine('get [ "Win" + bar[2] + quaz() ](){ }') expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'keyword.operator.getter.js'] - expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.begin.bracket.square.js'] expect(tokens[4]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] expect(tokens[5]).toEqual value: 'Win', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js'] expect(tokens[6]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] @@ -1095,7 +1095,7 @@ describe "Javascript grammar", -> expect(tokens[17]).toEqual value: 'quaz', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'entity.name.function.js'] expect(tokens[18]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] expect(tokens[19]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] - expect(tokens[21]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[21]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.end.bracket.square.js'] expect(tokens[22]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] expect(tokens[23]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.end.bracket.round.js'] expect(tokens[24]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] @@ -1103,7 +1103,7 @@ describe "Javascript grammar", -> {tokens} = grammar.tokenizeLine('get [\'string\' [ quaz()[2 + 2]] + this + "ABC" ](){ },') expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'keyword.operator.getter.js'] - expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.begin.bracket.square.js'] expect(tokens[3]).toEqual value: '\'', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] expect(tokens[4]).toEqual value: 'string', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js'] expect(tokens[5]).toEqual value: '\'', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] @@ -1123,7 +1123,7 @@ describe "Javascript grammar", -> expect(tokens[27]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] expect(tokens[28]).toEqual value: 'ABC', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js'] expect(tokens[29]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(tokens[31]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[31]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.end.bracket.square.js'] expect(tokens[32]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] expect(tokens[33]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.end.bracket.round.js'] expect(tokens[34]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] @@ -1132,7 +1132,7 @@ describe "Javascript grammar", -> {tokens} = grammar.tokenizeLine('set [\'string\' + ([ quaz()[2 + 2]]) + this + "ABC" ](k = 2){ }') expect(tokens[0]).toEqual value: 'set', scopes: ['source.js', 'meta.function.method.definition.js', 'keyword.operator.setter.js'] - expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.begin.bracket.square.js'] expect(tokens[3]).toEqual value: '\'', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] expect(tokens[4]).toEqual value: 'string', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js'] expect(tokens[5]).toEqual value: '\'', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] @@ -1155,7 +1155,7 @@ describe "Javascript grammar", -> expect(tokens[31]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] expect(tokens[32]).toEqual value: 'ABC', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js'] expect(tokens[33]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(tokens[35]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] + expect(tokens[35]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.end.bracket.square.js'] expect(tokens[36]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] expect(tokens[37]).toEqual value: 'k', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'variable.parameter.function.js'] expect(tokens[39]).toEqual value: '=', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'keyword.operator.assignment.js'] From 8fa17b5301d52efd9517e681067fa04fb278cfda Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 18 Oct 2016 02:41:41 +1100 Subject: [PATCH 141/420] Add specs for computed method names only --- spec/javascript-spec.coffee | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index e8b8d8df..97213381 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1070,6 +1070,29 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] it "tokenises ES6 methods with computed names", -> + {tokens} = grammar.tokenizeLine('[ foo ] () { }') + expect(tokens[0]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.begin.bracket.square.js'] + expect(tokens[2]).toEqual value: 'foo', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'variable.parameter.property.js'] + expect(tokens[4]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.end.bracket.square.js'] + expect(tokens[6]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] + expect(tokens[7]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.end.bracket.round.js'] + expect(tokens[9]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] + expect(tokens[11]).toEqual value: '}', scopes: ['source.js', 'punctuation.definition.function.body.end.bracket.curly.js'] + + {tokens} = grammar.tokenizeLine('[ "delet" + this ] (gun) { }') + expect(tokens[0]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.begin.bracket.square.js'] + expect(tokens[2]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[3]).toEqual value: 'delet', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js'] + expect(tokens[4]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(tokens[6]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] + expect(tokens[8]).toEqual value: 'this', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'variable.language.js'] + expect(tokens[10]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.end.bracket.square.js'] + expect(tokens[12]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] + expect(tokens[13]).toEqual value: 'gun', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'variable.parameter.function.js'] + expect(tokens[14]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.end.bracket.round.js'] + expect(tokens[16]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] + expect(tokens[18]).toEqual value: '}', scopes: ['source.js', 'punctuation.definition.function.body.end.bracket.curly.js'] + {tokens} = grammar.tokenizeLine('get [ foo ] () { }') expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'keyword.operator.getter.js'] expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.begin.bracket.square.js'] From 578ab0a510d209a325dc6fec27bcae093a6d0c94 Mon Sep 17 00:00:00 2001 From: DamnedScholar Date: Sun, 23 Oct 2016 16:48:27 -0500 Subject: [PATCH 142/420] Added test for innerHTML template match --- spec/javascript-spec.coffee | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 45c83805..e0668090 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -612,6 +612,21 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js'] expect(tokens[7]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] + describe "innerHTML attribute declarations with string template tags", -> + it "tokenizes them as strings", -> + {tokens} = grammar.tokenizeLine('text.innerHTML = `hey ${name}`') + expect(tokens[0]).toEqual value: 'text', scopes: [ 'source.js', 'variable.other.object.js' ] + expect(tokens[1]).toEqual value: '.', scopes: [ 'source.js', 'meta.delimiter.property.period.js' ] + expect(tokens[2]).toEqual value: 'innerHTML', scopes: [ 'source.js', 'variable.other.property.js' ] + expect(tokens[3]).toEqual value: '=', scopes: [ 'source.js', 'keyword.operator.assignment.js' ] + expect(tokens[4]).toEqual value: '`', scopes: [ 'source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js' ] + expect(tokens[5]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[6]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[7]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] + expect(tokens[8]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[9]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[10]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] + describe "ES6 tagged HTML string templates with expanded function name", -> it "tokenizes them as strings", -> {tokens} = grammar.tokenizeLine('escapeHTML`hey ${name}`') From f1cf9a61e8f7ef55dd85a8564928f1b36bef4d39 Mon Sep 17 00:00:00 2001 From: Wliu Date: Sun, 23 Oct 2016 23:29:35 -0400 Subject: [PATCH 143/420] Prepare 0.123.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7e32c4dd..7f0d8168 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.122.0", + "version": "0.123.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 925d776357e21fdf9381d62ba21b504db4a3e934 Mon Sep 17 00:00:00 2001 From: DamnedScholar Date: Mon, 24 Oct 2016 12:59:38 -0500 Subject: [PATCH 144/420] Regex tweaks --- grammars/javascript.cson | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index ae55d8f9..382a4c97 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1360,11 +1360,9 @@ ] } { - 'begin': '(?<=innerHTML)\\s*(\\+?=)\\s*(`)' + 'begin': '(?<=innerHTML\\s*(\\+?=)\\s*)(`)' 'beginCaptures': '1': - 'name': 'keyword.operator.assignment.js' - '2': 'name': 'punctuation.definition.string.begin.js' 'end': '`' 'endCaptures': From e7f64f1b85258d77c391c4f9c969e63865a26469 Mon Sep 17 00:00:00 2001 From: DamnedScholar Date: Mon, 24 Oct 2016 15:46:44 -0500 Subject: [PATCH 145/420] Regex reverted, updating tests --- grammars/javascript.cson | 2 +- spec/javascript-spec.coffee | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 382a4c97..65d649e8 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1360,7 +1360,7 @@ ] } { - 'begin': '(?<=innerHTML\\s*(\\+?=)\\s*)(`)' + 'begin': '(?<=innerHTML)\\s*(\\+?=)\\s*(`)' 'beginCaptures': '1': 'name': 'punctuation.definition.string.begin.js' diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index e0668090..c8364c30 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -618,14 +618,16 @@ describe "Javascript grammar", -> expect(tokens[0]).toEqual value: 'text', scopes: [ 'source.js', 'variable.other.object.js' ] expect(tokens[1]).toEqual value: '.', scopes: [ 'source.js', 'meta.delimiter.property.period.js' ] expect(tokens[2]).toEqual value: 'innerHTML', scopes: [ 'source.js', 'variable.other.property.js' ] - expect(tokens[3]).toEqual value: '=', scopes: [ 'source.js', 'keyword.operator.assignment.js' ] - expect(tokens[4]).toEqual value: '`', scopes: [ 'source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js' ] - expect(tokens[5]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[6]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[7]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] - expect(tokens[8]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[9]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[10]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] + expect(tokens[3]).toEqual value: ' ', scopes: [ 'source.js', 'string.quoted.template.html.js' ] + expect(tokens[4]).toEqual value: '=', scopes: [ 'source.js', 'string.quoted.template.html.js', 'keyword.operator.assignment.js' ] + expect(tokens[5]).toEqual value: ' ', scopes: [ 'source.js', 'string.quoted.template.html.js' ] + expect(tokens[6]).toEqual value: '`', scopes: [ 'source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js' ] + expect(tokens[7]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[8]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[9]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] + expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[11]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[12]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] describe "ES6 tagged HTML string templates with expanded function name", -> it "tokenizes them as strings", -> From a47ec1d6ed75f2c871cc49d6f5aba0bbb3a0040b Mon Sep 17 00:00:00 2001 From: DamnedScholar Date: Mon, 24 Oct 2016 16:37:26 -0500 Subject: [PATCH 146/420] Updated test --- grammars/javascript.cson | 2 ++ spec/javascript-spec.coffee | 15 +++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 65d649e8..ae55d8f9 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1363,6 +1363,8 @@ 'begin': '(?<=innerHTML)\\s*(\\+?=)\\s*(`)' 'beginCaptures': '1': + 'name': 'keyword.operator.assignment.js' + '2': 'name': 'punctuation.definition.string.begin.js' 'end': '`' 'endCaptures': diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index c8364c30..1fd66ea9 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -620,14 +620,13 @@ describe "Javascript grammar", -> expect(tokens[2]).toEqual value: 'innerHTML', scopes: [ 'source.js', 'variable.other.property.js' ] expect(tokens[3]).toEqual value: ' ', scopes: [ 'source.js', 'string.quoted.template.html.js' ] expect(tokens[4]).toEqual value: '=', scopes: [ 'source.js', 'string.quoted.template.html.js', 'keyword.operator.assignment.js' ] - expect(tokens[5]).toEqual value: ' ', scopes: [ 'source.js', 'string.quoted.template.html.js' ] - expect(tokens[6]).toEqual value: '`', scopes: [ 'source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js' ] - expect(tokens[7]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[8]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[9]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] - expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[11]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[12]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] + expect(tokens[5]).toEqual value: '`', scopes: [ 'source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js' ] + expect(tokens[6]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[7]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[8]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] + expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[10]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[11]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] describe "ES6 tagged HTML string templates with expanded function name", -> it "tokenizes them as strings", -> From b188911518fbc81c65d82e267fafc8ee93d4ddac Mon Sep 17 00:00:00 2001 From: DamnedScholar Date: Mon, 24 Oct 2016 16:49:26 -0500 Subject: [PATCH 147/420] Test updated --- spec/javascript-spec.coffee | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 1fd66ea9..c8364c30 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -620,13 +620,14 @@ describe "Javascript grammar", -> expect(tokens[2]).toEqual value: 'innerHTML', scopes: [ 'source.js', 'variable.other.property.js' ] expect(tokens[3]).toEqual value: ' ', scopes: [ 'source.js', 'string.quoted.template.html.js' ] expect(tokens[4]).toEqual value: '=', scopes: [ 'source.js', 'string.quoted.template.html.js', 'keyword.operator.assignment.js' ] - expect(tokens[5]).toEqual value: '`', scopes: [ 'source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js' ] - expect(tokens[6]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[7]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[8]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] - expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[10]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[11]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] + expect(tokens[5]).toEqual value: ' ', scopes: [ 'source.js', 'string.quoted.template.html.js' ] + expect(tokens[6]).toEqual value: '`', scopes: [ 'source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js' ] + expect(tokens[7]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[8]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[9]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] + expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[11]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[12]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] describe "ES6 tagged HTML string templates with expanded function name", -> it "tokenizes them as strings", -> From 17ba6640367d4291c6ae4ddcd1c1e139de286dbe Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sun, 30 Oct 2016 03:00:15 +1100 Subject: [PATCH 148/420] Fix #452: Wrong scopes for methods named "import" --- grammars/javascript.cson | 8 ++++---- spec/javascript-spec.coffee | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 4532c5d1..5c01c643 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -39,7 +39,7 @@ 'patterns': [ { # ES6 import - 'begin': '(? {tokens} = grammar.tokenizeLine('"func" : a => a') expect(tokens[8]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.json.js', 'storage.type.function.arrow.js'] + {tokens} = grammar.tokenizeLine('import (x) { return "Yeah"; }') + expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] + expect(tokens[11]).toEqual value: 'Yeah', scopes: ['source.js', 'string.quoted.double.js'] + + {tokens} = grammar.tokenizeLine('export (x) { return "Nah"; }') + expect(tokens[0]).toEqual value: 'export', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] + expect(tokens[11]).toEqual value: 'Nah', scopes: ['source.js', 'string.quoted.double.js'] + it "tokenizes generator functions", -> {tokens} = grammar.tokenizeLine('function* foo(){}') expect(tokens[0]).toEqual value: 'function', scopes: ['source.js', 'meta.function.js', 'storage.type.function.js'] From 20212928f799b848aee58ececf83611c2c5ab801 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sun, 30 Oct 2016 03:18:05 +1100 Subject: [PATCH 149/420] Highlight constants in property keys --- grammars/javascript.cson | 2 +- spec/javascript-spec.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 4532c5d1..db1f216d 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1167,7 +1167,7 @@ 'include': '#properties' } { - 'match': '((? it "tokenizes constants when they are object keys", -> {tokens} = grammar.tokenizeLine('FOO: 1') - expect(tokens[0]).toEqual value: 'FOO', scopes: ['source.js'] + expect(tokens[0]).toEqual value: 'FOO', scopes: ['source.js', 'constant.other.js'] expect(tokens[1]).toEqual value: ':', scopes: ['source.js', 'keyword.operator.assignment.js'] describe "ternary expressions", -> From 4808764e99768e6493073d1a2515fd7cb67c75b6 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sun, 30 Oct 2016 03:18:20 +1100 Subject: [PATCH 150/420] Fix misspelling of "JavaScript" --- spec/javascript-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 16a9dfbd..1e57ab78 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -8,7 +8,7 @@ buildTextEditor = (params) -> TextEditor ?= require('atom').TextEditor new TextEditor(params) -describe "Javascript grammar", -> +describe "JavaScript grammar", -> grammar = null beforeEach -> From fa7444135af2100abd9b372734b82c684111c00d Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sun, 30 Oct 2016 03:23:35 +1100 Subject: [PATCH 151/420] Move tests to their correct suite --- spec/javascript-spec.coffee | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index cd22c71e..b5760b4e 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1069,6 +1069,14 @@ describe "Javascript grammar", -> expect(tokens[5]).toEqual value: ')', scopes: ['source.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] expect(tokens[6]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + {tokens} = grammar.tokenizeLine('import (x) { return "Yeah"; }') + expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] + expect(tokens[11]).toEqual value: 'Yeah', scopes: ['source.js', 'string.quoted.double.js'] + + {tokens} = grammar.tokenizeLine('export (x) { return "Nah"; }') + expect(tokens[0]).toEqual value: 'export', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] + expect(tokens[11]).toEqual value: 'Nah', scopes: ['source.js', 'string.quoted.double.js'] + it "tokenises ES6 methods with computed names", -> {tokens} = grammar.tokenizeLine('[ foo ] () { }') expect(tokens[0]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.begin.bracket.square.js'] @@ -1249,14 +1257,6 @@ describe "Javascript grammar", -> {tokens} = grammar.tokenizeLine('"func" : a => a') expect(tokens[8]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.json.js', 'storage.type.function.arrow.js'] - {tokens} = grammar.tokenizeLine('import (x) { return "Yeah"; }') - expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] - expect(tokens[11]).toEqual value: 'Yeah', scopes: ['source.js', 'string.quoted.double.js'] - - {tokens} = grammar.tokenizeLine('export (x) { return "Nah"; }') - expect(tokens[0]).toEqual value: 'export', scopes: ['source.js', 'meta.function.method.definition.js', 'entity.name.function.js'] - expect(tokens[11]).toEqual value: 'Nah', scopes: ['source.js', 'string.quoted.double.js'] - it "tokenizes generator functions", -> {tokens} = grammar.tokenizeLine('function* foo(){}') expect(tokens[0]).toEqual value: 'function', scopes: ['source.js', 'meta.function.js', 'storage.type.function.js'] From b1571a02b6cc85cb87b1fa88c9789ab50cb033f8 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Tue, 11 Oct 2016 09:35:00 +0100 Subject: [PATCH 152/420] :bug: Add JSDoc support for function types --- grammars/javascript.cson | 188 +++++++++++++++++++++++---------------- 1 file changed, 109 insertions(+), 79 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 3e0d8bc1..6ab10027 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1886,72 +1886,87 @@ (?:(?<=@param)|(?<=@arg)|(?<=@argument)|(?<=@type)) \\s+ ({(?: - \\* | # {*} any type - \\? | # {?} unknown type - - (?: # Check for a prefix - \\? | # {?string} nullable type - ! | # {!string} non-nullable type - \\.{3} # {...string} variable number of parameters - )? + \\* | # {*} any type + \\? | # {?} unknown type (?: - \\( # Opening bracket of multiple types with parenthesis {(string|number)} - [a-zA-Z_$]+ + (?: # Check for a prefix + \\? | # {?string} nullable type + ! | # {!string} non-nullable type + \\.{3} # {...string} variable number of parameters + )? + + (?: (?: - (?: - [\\w$]* - (?:\\[\\])? # {(string[]|number)} type application, an array of strings or a number - ) | - \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) - ) + function\\( # {function(string, number)} function type + (?: + \\s* + [a-zA-Z_$] + (?:\\s*,\\s*[\\w$])* + \\s* + )* + \\) + )? | + (?: - [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback + \\( # Opening bracket of multiple types with parenthesis {(string|number)} + [a-zA-Z_$]+ + (?: + (?: + [\\w$]* + (?:\\[\\])? # {(string[]|number)} type application, an array of strings or a number + ) | + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) + ) + (?: + [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback + [a-zA-Z_$]+ + (?: + (?: + [\\w$]* + (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers + ) | + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) + ) + )* + \\) | [a-zA-Z_$]+ (?: (?: [\\w$]* - (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers + (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers ) | - \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) ) - )* - \\) | - [a-zA-Z_$]+ - (?: - (?: - [\\w$]* - (?:\\[\\])? # {string[]|number} type application, an array of strings or a number - ) | - \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) - ) - (?: - [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback - [a-zA-Z_$]+ - (?: - [\\w$]* | - \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) + (?: + [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback + [a-zA-Z_$]+ + (?: + [\\w$]* | + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) + ) + )* ) - )* + ) + # Check for suffix + (?:\\[\\])? # {string[]} type application, an array of strings + =? # {string=} optional parameter ) - # Check for suffix - (?:\\[\\])? # {string[]} type application, an array of strings - =? # {string=} optional parameter )}) \\s+ ( - \\[ # [foo] optional parameter + \\[ # [foo] optional parameter \\s* (?: [a-zA-Z_$][\\w$]* (?: - (?:\\[\\])? # Foo[].bar properties within an array - \\. # Foo.Bar namespaced parameter + (?:\\[\\])? # Foo[].bar properties within an array + \\. # Foo.Bar namespaced parameter [a-zA-Z_$][\\w$]* )* (?: \\s* - = # [foo=bar] Default parameter value + = # [foo=bar] Default parameter value \\s* [\\w$\\s]* )? @@ -1961,8 +1976,8 @@ (?: [a-zA-Z_$][\\w$]* (?: - (?:\\[\\])? # Foo[].bar properties within an array - \\. # Foo.Bar namespaced parameter + (?:\\[\\])? # Foo[].bar properties within an array + \\. # Foo.Bar namespaced parameter [a-zA-Z_$][\\w$]* )* )? @@ -1984,52 +1999,67 @@ { 'match': '''(?x) ({(?: - \\* | # {*} any type - \\? | # {?} unknown type - - (?: # Check for a prefix - \\? | # {?string} nullable type - ! | # {!string} non-nullable type - \\.{3} # {...string} variable number of parameters - )? + \\* | # {*} any type + \\? | # {?} unknown type (?: - \\( # Opening bracket of multiple types with parenthesis {(string|number)} - [a-zA-Z_$]+ + (?: # Check for a prefix + \\? | # {?string} nullable type + ! | # {!string} non-nullable type + \\.{3} # {...string} variable number of parameters + )? + + (?: (?: - [\\w$]* | - \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) - ) + function\\( # {function(string, number)} function type + (?: + \\s* + [a-zA-Z_$] + (?:\\s*,\\s*[\\w$])* + \\s* + )* + \\) + )? | + (?: - [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback + \\( # Opening bracket of multiple types with parenthesis {(string|number)} + [a-zA-Z_$]+ + (?: + [\\w$]* | + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) + ) + (?: + [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback + [a-zA-Z_$]+ + (?: + [\\w$]* | + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) + ) + )* + \\) | [a-zA-Z_$]+ (?: [\\w$]* | - \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) ) - )* - \\) | - [a-zA-Z_$]+ - (?: - [\\w$]* | - \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) - ) - (?: - [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback - [a-zA-Z_$]+ - (?: - [\\w$]* | - \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) + (?: + [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback + [a-zA-Z_$]+ + (?: + [\\w$]* | + \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) + ) + )* ) - )* + ) + # Check for suffix + (?:\\[\\])? # {string[]} type application, an array of strings + =? # {string=} optional parameter ) - # Check for suffix - (?:\\[\\])? # {string[]} type application, an array of strings - =? # {string=} optional parameter )}) \\s+ - (?:-\\s+)? # optional hyphen before the description - ((?:(?!\\*\\/).)*) # The type description + (?:-\\s+)? # optional hyphen before the description + ((?:(?!\\*\\/).)*) # The type description ''' 'captures': '0': From 7bfc3c3ffd0c7ae9e49a810352a80bb728facb29 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Thu, 13 Oct 2016 09:35:46 +0100 Subject: [PATCH 153/420] :white_check_mark: Add specs for JSDoc function type support --- spec/javascript-spec.coffee | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 322e8a22..683a19bd 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1974,6 +1974,21 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {function()} variable this is the description */') + expect(tokens[4]).toEqual value: '{function()}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(string)} variable this is the description */') + expect(tokens[4]).toEqual value: '{function(string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(string, number)} variable this is the description */') + expect(tokens[4]).toEqual value: '{function(string, number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {object} this is the description */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] @@ -1994,6 +2009,18 @@ describe "JavaScript grammar", -> {tokens} = grammar.tokenizeLine('/** @returns {(Something)} */') expect(tokens[4]).toEqual value: '{(Something)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {function()} this is the description */') + expect(tokens[4]).toEqual value: '{function()}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @return {function(string)} this is the description */') + expect(tokens[4]).toEqual value: '{function(string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @return {function(string, number)} this is the description */') + expect(tokens[4]).toEqual value: '{function(string, number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] From ef61005f07a8da88ea29974afc417a8752abe428 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Tue, 1 Nov 2016 14:18:15 +0000 Subject: [PATCH 154/420] :art: Refactor function type --- grammars/javascript.cson | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 6ab10027..352e20bf 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1858,7 +1858,7 @@ | tutorial ) ) - + \\s+ ([^\\s|}]+) # Namepath or URL @@ -1898,16 +1898,21 @@ (?: (?: - function\\( # {function(string, number)} function type + function # {function(string, number)} function type + \\s* + \\( + \\s* + (?: + [a-zA-Z_$][\\w$]* (?: - \\s* - [a-zA-Z_$] - (?:\\s*,\\s*[\\w$])* - \\s* + \\s*,\\s* + [a-zA-Z_$][\\w$]* )* + )? + \\s* \\) - )? | - + )? + | (?: \\( # Opening bracket of multiple types with parenthesis {(string|number)} [a-zA-Z_$]+ @@ -2011,16 +2016,21 @@ (?: (?: - function\\( # {function(string, number)} function type + function # {function(string, number)} function type + \\s* + \\( + \\s* + (?: + [a-zA-Z_$][\\w$]* (?: - \\s* - [a-zA-Z_$] - (?:\\s*,\\s*[\\w$])* - \\s* + \\s*,\\s* + [a-zA-Z_$][\\w$]* )* + )? + \\s* \\) - )? | - + )? + | (?: \\( # Opening bracket of multiple types with parenthesis {(string|number)} [a-zA-Z_$]+ From a63946bf54f7e0f8b460d0b55b61d771b4e09486 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Tue, 1 Nov 2016 14:19:43 +0000 Subject: [PATCH 155/420] :white_check_mark: Add more tests for function type --- spec/javascript-spec.coffee | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 683a19bd..2be5b6d6 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1979,6 +1979,16 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {function ()} variable this is the description */') + expect(tokens[4]).toEqual value: '{function ()}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function ( )} variable this is the description */') + expect(tokens[4]).toEqual value: '{function ( )}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {function(string)} variable this is the description */') expect(tokens[4]).toEqual value: '{function(string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] @@ -2013,6 +2023,14 @@ describe "JavaScript grammar", -> expect(tokens[4]).toEqual value: '{function()}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {function ()} this is the description */') + expect(tokens[4]).toEqual value: '{function ()}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @return {function ( )} this is the description */') + expect(tokens[4]).toEqual value: '{function ( )}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {function(string)} this is the description */') expect(tokens[4]).toEqual value: '{function(string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] From d64a27da9564f241af8f2f7bf63c32ca898ec1f2 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Fri, 23 Sep 2016 10:59:18 +0100 Subject: [PATCH 156/420] :bug: Add JSDoc support for function return type --- grammars/javascript.cson | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 352e20bf..2c2704e5 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1911,8 +1911,8 @@ )? \\s* \\) - )? - | + (?:\\s*:\\s*[a-zA-Z_$]+\\s*)? # {function(): string} function return type + )? | (?: \\( # Opening bracket of multiple types with parenthesis {(string|number)} [a-zA-Z_$]+ @@ -2029,8 +2029,8 @@ )? \\s* \\) - )? - | + (?:\\s*:\\s*[a-zA-Z_$]+\\s*)? # {function(): string} function return type + )? | (?: \\( # Opening bracket of multiple types with parenthesis {(string|number)} [a-zA-Z_$]+ From 76fda8f204a9b125448d34c8bd3ce46f3c6fa8cb Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Fri, 23 Sep 2016 11:02:25 +0100 Subject: [PATCH 157/420] :white_check_mark: Add specs for JSDoc function return type support --- spec/javascript-spec.coffee | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 2be5b6d6..0507ba93 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1999,6 +1999,17 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {function():number} variable this is the description */') + expect(tokens[4]).toEqual value: '{function():number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(string): number} variable this is the description */') + expect(tokens[4]).toEqual value: '{function(string): number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @return {object} this is the description */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] @@ -2039,6 +2050,14 @@ describe "JavaScript grammar", -> expect(tokens[4]).toEqual value: '{function(string, number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {function():number} this is the description */') + expect(tokens[4]).toEqual value: '{function():number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @return {function(string): number} this is the description */') + expect(tokens[4]).toEqual value: '{function(string): number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] From 6dc401534f012f10b416e8ae26c8e9ddfb13e9d1 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Tue, 1 Nov 2016 15:18:53 +0000 Subject: [PATCH 158/420] :art: Refactor for clarity --- grammars/javascript.cson | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 2c2704e5..78c82e1c 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1911,8 +1911,12 @@ )? \\s* \\) - (?:\\s*:\\s*[a-zA-Z_$]+\\s*)? # {function(): string} function return type - )? | + (?: # {function(): string} function return type + \\s*:\\s* + [a-zA-Z_$][\\w$]* + )? + )? + | (?: \\( # Opening bracket of multiple types with parenthesis {(string|number)} [a-zA-Z_$]+ @@ -2029,8 +2033,12 @@ )? \\s* \\) - (?:\\s*:\\s*[a-zA-Z_$]+\\s*)? # {function(): string} function return type - )? | + (?: # {function(): string} function return type + \\s*:\\s* + [a-zA-Z_$][\\w$]* + )? + )? + | (?: \\( # Opening bracket of multiple types with parenthesis {(string|number)} [a-zA-Z_$]+ From 2e551b88d6270f7c20ea99173e989069b3f9dd7a Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Tue, 1 Nov 2016 15:51:50 +0000 Subject: [PATCH 159/420] :white_check_mark: Add extra tests to spec --- spec/javascript-spec.coffee | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 0507ba93..392e78d4 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -2009,6 +2009,10 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {function(string) : number} variable this is the description */') + expect(tokens[4]).toEqual value: '{function(string) : number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] {tokens} = grammar.tokenizeLine('/** @return {object} this is the description */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] @@ -2058,6 +2062,10 @@ describe "JavaScript grammar", -> expect(tokens[4]).toEqual value: '{function(string): number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {function(string) : number} this is the description */') + expect(tokens[4]).toEqual value: '{function(string) : number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] From 8925933825c74dab66527f7f1cbabcb017a1c843 Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Tue, 1 Nov 2016 16:06:44 +0000 Subject: [PATCH 160/420] :memo: Update contributing docs link --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e70782fb..0fd0ad69 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1 +1 @@ -See the [Atom contributing guide](https://atom.io/docs/latest/contributing) +See the [Atom contributing guide](https://github.com/atom/atom/blob/master/CONTRIBUTING.md) From 25853e6c2ff713cb7e453d6f0d6a63d880690c68 Mon Sep 17 00:00:00 2001 From: DamnedScholar Date: Wed, 2 Nov 2016 20:45:02 -0500 Subject: [PATCH 161/420] Fixed scopes. --- grammars/javascript.cson | 32 ++++++++++++++++++++++---------- spec/javascript-spec.coffee | 6 +++--- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index ae55d8f9..5a4ee666 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1360,26 +1360,38 @@ ] } { - 'begin': '(?<=innerHTML)\\s*(\\+?=)\\s*(`)' + 'begin': '(?<=innerHTML)\\s*(\\+?=)\\s*(?=`)' 'beginCaptures': '1': 'name': 'keyword.operator.assignment.js' '2': 'name': 'punctuation.definition.string.begin.js' - 'end': '`' + 'end': '(?<=`)' 'endCaptures': '0': 'name': 'punctuation.definition.string.end.js' - 'name': 'string.quoted.template.html.js' + 'contentName': 'string.quoted.template.html.js' 'patterns': [ { - 'include': '#string_escapes' - } - { - 'include': '#interpolated_js' - } - { - 'include': 'text.html.basic' + 'begin': '`' + 'beginCaptures': + '0': + 'name': 'punctuation.definition.string.begin.js' + 'end': '`' + 'endCaptures': + '0': + 'name': 'punctuation.definition.string.end.js' + 'patterns': [ + { + 'include': '#string_escapes' + } + { + 'include': '#interpolated_js' + } + { + 'include': 'text.html.basic' + } + ] } ] } diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index c8364c30..1fdb63e9 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -618,9 +618,9 @@ describe "Javascript grammar", -> expect(tokens[0]).toEqual value: 'text', scopes: [ 'source.js', 'variable.other.object.js' ] expect(tokens[1]).toEqual value: '.', scopes: [ 'source.js', 'meta.delimiter.property.period.js' ] expect(tokens[2]).toEqual value: 'innerHTML', scopes: [ 'source.js', 'variable.other.property.js' ] - expect(tokens[3]).toEqual value: ' ', scopes: [ 'source.js', 'string.quoted.template.html.js' ] - expect(tokens[4]).toEqual value: '=', scopes: [ 'source.js', 'string.quoted.template.html.js', 'keyword.operator.assignment.js' ] - expect(tokens[5]).toEqual value: ' ', scopes: [ 'source.js', 'string.quoted.template.html.js' ] + expect(tokens[3]).toEqual value: ' ', scopes: [ 'source.js' ] + expect(tokens[4]).toEqual value: '=', scopes: [ 'source.js', 'keyword.operator.assignment.js' ] + expect(tokens[5]).toEqual value: ' ', scopes: [ 'source.js' ] expect(tokens[6]).toEqual value: '`', scopes: [ 'source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js' ] expect(tokens[7]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] expect(tokens[8]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] From d44275c3e73609d5b3d4d8865a34e792edc49c6e Mon Sep 17 00:00:00 2001 From: DamnedScholar Date: Wed, 2 Nov 2016 20:47:13 -0500 Subject: [PATCH 162/420] Removed unused capture name. --- grammars/javascript.cson | 2 -- 1 file changed, 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 5a4ee666..e3c3ac3e 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1364,8 +1364,6 @@ 'beginCaptures': '1': 'name': 'keyword.operator.assignment.js' - '2': - 'name': 'punctuation.definition.string.begin.js' 'end': '(?<=`)' 'endCaptures': '0': From 96c3bda0c5095e39a78303c6c4c6090e5ffcb09e Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Wed, 2 Nov 2016 22:21:33 -0400 Subject: [PATCH 163/420] :art: --- spec/javascript-spec.coffee | 38 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 1fdb63e9..86a36184 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -603,8 +603,8 @@ describe "Javascript grammar", -> describe "ES6 tagged HTML string templates", -> it "tokenizes them as strings", -> {tokens} = grammar.tokenizeLine('html`hey ${name}`') - expect(tokens[0]).toEqual value: 'html', scopes: [ 'source.js', 'string.quoted.template.html.js', 'entity.name.function.js' ] - expect(tokens[1]).toEqual value: '`', scopes: [ 'source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js' ] + expect(tokens[0]).toEqual value: 'html', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] expect(tokens[2]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] expect(tokens[3]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] expect(tokens[4]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] @@ -615,13 +615,13 @@ describe "Javascript grammar", -> describe "innerHTML attribute declarations with string template tags", -> it "tokenizes them as strings", -> {tokens} = grammar.tokenizeLine('text.innerHTML = `hey ${name}`') - expect(tokens[0]).toEqual value: 'text', scopes: [ 'source.js', 'variable.other.object.js' ] - expect(tokens[1]).toEqual value: '.', scopes: [ 'source.js', 'meta.delimiter.property.period.js' ] - expect(tokens[2]).toEqual value: 'innerHTML', scopes: [ 'source.js', 'variable.other.property.js' ] - expect(tokens[3]).toEqual value: ' ', scopes: [ 'source.js' ] - expect(tokens[4]).toEqual value: '=', scopes: [ 'source.js', 'keyword.operator.assignment.js' ] - expect(tokens[5]).toEqual value: ' ', scopes: [ 'source.js' ] - expect(tokens[6]).toEqual value: '`', scopes: [ 'source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js' ] + expect(tokens[0]).toEqual value: 'text', scopes: ['source.js', 'variable.other.object.js'] + expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.delimiter.property.period.js'] + expect(tokens[2]).toEqual value: 'innerHTML', scopes: ['source.js', 'variable.other.property.js'] + expect(tokens[3]).toEqual value: ' ', scopes: ['source.js'] + expect(tokens[4]).toEqual value: '=', scopes: ['source.js', 'keyword.operator.assignment.js'] + expect(tokens[5]).toEqual value: ' ', scopes: ['source.js'] + expect(tokens[6]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] expect(tokens[7]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] expect(tokens[8]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] expect(tokens[9]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] @@ -632,8 +632,8 @@ describe "Javascript grammar", -> describe "ES6 tagged HTML string templates with expanded function name", -> it "tokenizes them as strings", -> {tokens} = grammar.tokenizeLine('escapeHTML`hey ${name}`') - expect(tokens[0]).toEqual value: 'escapeHTML', scopes: [ 'source.js', 'string.quoted.template.html.js', 'entity.name.function.js' ] - expect(tokens[1]).toEqual value: '`', scopes: [ 'source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js' ] + expect(tokens[0]).toEqual value: 'escapeHTML', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] expect(tokens[2]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] expect(tokens[3]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] expect(tokens[4]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] @@ -644,9 +644,9 @@ describe "Javascript grammar", -> describe "ES6 tagged HTML string templates with expanded function name and white space", -> it "tokenizes them as strings", -> {tokens} = grammar.tokenizeLine('escapeHTML `hey ${name}`') - expect(tokens[0]).toEqual value: 'escapeHTML', scopes: [ 'source.js', 'string.quoted.template.html.js', 'entity.name.function.js' ] - expect(tokens[1]).toEqual value: ' ', scopes: [ 'source.js', 'string.quoted.template.html.js' ] - expect(tokens[2]).toEqual value: '`', scopes: [ 'source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js' ] + expect(tokens[0]).toEqual value: 'escapeHTML', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[2]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] expect(tokens[3]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] expect(tokens[4]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] expect(tokens[5]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] @@ -657,16 +657,16 @@ describe "Javascript grammar", -> describe "ES6 tagged Relay.QL string templates", -> it "tokenizes them as strings", -> {tokens} = grammar.tokenizeLine('Relay.QL`fragment on Foo { id }`') - expect(tokens[0]).toEqual value: 'Relay.QL', scopes: [ 'source.js', 'string.quoted.template.graphql.js', 'entity.name.function.js' ] - expect(tokens[1]).toEqual value: '`', scopes: [ 'source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.begin.js' ] + expect(tokens[0]).toEqual value: 'Relay.QL', scopes: ['source.js', 'string.quoted.template.graphql.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.begin.js'] expect(tokens[2]).toEqual value: 'fragment on Foo { id }', scopes: ['source.js', 'string.quoted.template.graphql.js'] expect(tokens[3]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.end.js'] describe "ES6 tagged Relay.QL string templates with interpolation", -> it "tokenizes them as strings", -> {tokens} = grammar.tokenizeLine('Relay.QL`fragment on Foo { ${myFragment} }`') - expect(tokens[0]).toEqual value: 'Relay.QL', scopes: [ 'source.js', 'string.quoted.template.graphql.js', 'entity.name.function.js' ] - expect(tokens[1]).toEqual value: '`', scopes: [ 'source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.begin.js' ] + expect(tokens[0]).toEqual value: 'Relay.QL', scopes: ['source.js', 'string.quoted.template.graphql.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.begin.js'] expect(tokens[2]).toEqual value: 'fragment on Foo { ', scopes: ['source.js', 'string.quoted.template.graphql.js'] expect(tokens[3]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.graphql.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] expect(tokens[4]).toEqual value: 'myFragment', scopes: ['source.js', 'string.quoted.template.graphql.js', 'source.js.embedded.source'] @@ -1539,7 +1539,7 @@ describe "Javascript grammar", -> expect(tokens[5]).toEqual value: 'x', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', scope] expect(tokens[6]).toEqual value: delim, scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', scope, 'punctuation.definition.string.end.js'] expect(tokens[8]).toEqual value: '+', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'keyword.operator.js'] - expect(tokens[9]).toEqual value: ' y ', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js' ] + expect(tokens[9]).toEqual value: ' y ', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js'] expect(tokens[10]).toEqual value: '+', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'keyword.operator.js'] expect(tokens[12]).toEqual value: delim, scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', scope, 'punctuation.definition.string.begin.js'] expect(tokens[13]).toEqual value: ':function()', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', scope] From bc403ba6bbda8447b6a9c11b90f9a01387d6ed84 Mon Sep 17 00:00:00 2001 From: Wliu Date: Thu, 3 Nov 2016 10:36:41 -0400 Subject: [PATCH 164/420] Properly test HTML template strings Closes #457 --- spec/javascript-spec.coffee | 131 +++++++++++++++++++++--------------- 1 file changed, 78 insertions(+), 53 deletions(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 53b3d14c..be271a7e 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -600,59 +600,84 @@ describe "JavaScript grammar", -> expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] expect(tokens[14]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.js', 'punctuation.definition.string.end.js'] - describe "ES6 tagged HTML string templates", -> - it "tokenizes them as strings", -> - {tokens} = grammar.tokenizeLine('html`hey ${name}`') - expect(tokens[0]).toEqual value: 'html', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] - expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] - expect(tokens[2]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[3]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[4]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] - expect(tokens[5]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[6]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[7]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] - - describe "innerHTML attribute declarations with string template tags", -> - it "tokenizes them as strings", -> - {tokens} = grammar.tokenizeLine('text.innerHTML = `hey ${name}`') - expect(tokens[0]).toEqual value: 'text', scopes: ['source.js', 'variable.other.object.js'] - expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.delimiter.property.period.js'] - expect(tokens[2]).toEqual value: 'innerHTML', scopes: ['source.js', 'variable.other.property.js'] - expect(tokens[3]).toEqual value: ' ', scopes: ['source.js'] - expect(tokens[4]).toEqual value: '=', scopes: ['source.js', 'keyword.operator.assignment.js'] - expect(tokens[5]).toEqual value: ' ', scopes: ['source.js'] - expect(tokens[6]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] - expect(tokens[7]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[8]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[9]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] - expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[11]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[12]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] - - describe "ES6 tagged HTML string templates with expanded function name", -> - it "tokenizes them as strings", -> - {tokens} = grammar.tokenizeLine('escapeHTML`hey ${name}`') - expect(tokens[0]).toEqual value: 'escapeHTML', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] - expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] - expect(tokens[2]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[3]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[4]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] - expect(tokens[5]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[6]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[7]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] - - describe "ES6 tagged HTML string templates with expanded function name and white space", -> - it "tokenizes them as strings", -> - {tokens} = grammar.tokenizeLine('escapeHTML `hey ${name}`') - expect(tokens[0]).toEqual value: 'escapeHTML', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] - expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[2]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] - expect(tokens[3]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[4]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[5]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] - expect(tokens[6]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[7]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[8]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] + describe "HTML template strings", -> + beforeEach -> + waitsForPromise -> + atom.packages.activatePackage("language-html") + + describe "ES6 tagged HTML string templates", -> + it "tokenizes them as strings", -> + {tokens} = grammar.tokenizeLine('html`hey ${name}`') + expect(tokens[0]).toEqual value: 'html', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] + expect(tokens[2]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[3]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] + expect(tokens[4]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] + expect(tokens[5]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[6]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[7]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] + expect(tokens[8]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[9]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[12]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] + + describe "innerHTML attribute declarations with string template tags", -> + it "tokenizes them as strings", -> + {tokens} = grammar.tokenizeLine('text.innerHTML = `hey ${name}`') + expect(tokens[0]).toEqual value: 'text', scopes: ['source.js', 'variable.other.object.js'] + expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.delimiter.property.period.js'] + expect(tokens[2]).toEqual value: 'innerHTML', scopes: ['source.js', 'variable.other.property.js'] + expect(tokens[3]).toEqual value: ' ', scopes: ['source.js'] + expect(tokens[4]).toEqual value: '=', scopes: ['source.js', 'keyword.operator.assignment.js'] + expect(tokens[5]).toEqual value: ' ', scopes: ['source.js'] + expect(tokens[6]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] + expect(tokens[7]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[8]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] + expect(tokens[9]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] + expect(tokens[10]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[11]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[12]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] + expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[14]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[17]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] + + describe "ES6 tagged HTML string templates with expanded function name", -> + it "tokenizes them as strings", -> + {tokens} = grammar.tokenizeLine('escapeHTML`hey ${name}`') + expect(tokens[0]).toEqual value: 'escapeHTML', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] + expect(tokens[2]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[3]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] + expect(tokens[4]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] + expect(tokens[5]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[6]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[7]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] + expect(tokens[8]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[9]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[12]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] + + describe "ES6 tagged HTML string templates with expanded function name and white space", -> + it "tokenizes them as strings", -> + {tokens} = grammar.tokenizeLine('escapeHTML `hey ${name}`') + expect(tokens[0]).toEqual value: 'escapeHTML', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[2]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] + expect(tokens[3]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[4]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] + expect(tokens[5]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] + expect(tokens[6]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[7]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[8]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] + expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[10]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[13]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] describe "ES6 tagged Relay.QL string templates", -> it "tokenizes them as strings", -> From 8f036c3db4057310e2ce942d9ee37754a89be716 Mon Sep 17 00:00:00 2001 From: Wliu Date: Thu, 3 Nov 2016 10:39:07 -0400 Subject: [PATCH 165/420] Remove some superfluous describes --- spec/javascript-spec.coffee | 142 ++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 73 deletions(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index be271a7e..a3a552ab 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -605,79 +605,75 @@ describe "JavaScript grammar", -> waitsForPromise -> atom.packages.activatePackage("language-html") - describe "ES6 tagged HTML string templates", -> - it "tokenizes them as strings", -> - {tokens} = grammar.tokenizeLine('html`hey ${name}`') - expect(tokens[0]).toEqual value: 'html', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] - expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] - expect(tokens[2]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[3]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] - expect(tokens[4]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] - expect(tokens[5]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] - expect(tokens[6]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[7]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] - expect(tokens[8]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[9]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] - expect(tokens[12]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] - - describe "innerHTML attribute declarations with string template tags", -> - it "tokenizes them as strings", -> - {tokens} = grammar.tokenizeLine('text.innerHTML = `hey ${name}`') - expect(tokens[0]).toEqual value: 'text', scopes: ['source.js', 'variable.other.object.js'] - expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.delimiter.property.period.js'] - expect(tokens[2]).toEqual value: 'innerHTML', scopes: ['source.js', 'variable.other.property.js'] - expect(tokens[3]).toEqual value: ' ', scopes: ['source.js'] - expect(tokens[4]).toEqual value: '=', scopes: ['source.js', 'keyword.operator.assignment.js'] - expect(tokens[5]).toEqual value: ' ', scopes: ['source.js'] - expect(tokens[6]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] - expect(tokens[7]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[8]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] - expect(tokens[9]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] - expect(tokens[10]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] - expect(tokens[11]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[12]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] - expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[14]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] - expect(tokens[17]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] - - describe "ES6 tagged HTML string templates with expanded function name", -> - it "tokenizes them as strings", -> - {tokens} = grammar.tokenizeLine('escapeHTML`hey ${name}`') - expect(tokens[0]).toEqual value: 'escapeHTML', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] - expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] - expect(tokens[2]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[3]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] - expect(tokens[4]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] - expect(tokens[5]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] - expect(tokens[6]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[7]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] - expect(tokens[8]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[9]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] - expect(tokens[12]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] - - describe "ES6 tagged HTML string templates with expanded function name and white space", -> - it "tokenizes them as strings", -> - {tokens} = grammar.tokenizeLine('escapeHTML `hey ${name}`') - expect(tokens[0]).toEqual value: 'escapeHTML', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] - expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[2]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] - expect(tokens[3]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[4]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] - expect(tokens[5]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] - expect(tokens[6]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] - expect(tokens[7]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[8]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] - expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[10]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] - expect(tokens[13]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] + it "tokenizes ES6 tagged HTML string templates", -> + {tokens} = grammar.tokenizeLine('html`hey ${name}`') + expect(tokens[0]).toEqual value: 'html', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] + expect(tokens[2]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[3]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] + expect(tokens[4]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] + expect(tokens[5]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[6]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[7]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] + expect(tokens[8]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[9]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[12]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] + + it "tokenizes innerHTML attribute declarations with string template tags", -> + {tokens} = grammar.tokenizeLine('text.innerHTML = `hey ${name}`') + expect(tokens[0]).toEqual value: 'text', scopes: ['source.js', 'variable.other.object.js'] + expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.delimiter.property.period.js'] + expect(tokens[2]).toEqual value: 'innerHTML', scopes: ['source.js', 'variable.other.property.js'] + expect(tokens[3]).toEqual value: ' ', scopes: ['source.js'] + expect(tokens[4]).toEqual value: '=', scopes: ['source.js', 'keyword.operator.assignment.js'] + expect(tokens[5]).toEqual value: ' ', scopes: ['source.js'] + expect(tokens[6]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] + expect(tokens[7]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[8]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] + expect(tokens[9]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] + expect(tokens[10]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[11]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[12]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] + expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[14]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[17]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] + + it "tokenizes ES6 tagged HTML string templates with expanded function name", -> + {tokens} = grammar.tokenizeLine('escapeHTML`hey ${name}`') + expect(tokens[0]).toEqual value: 'escapeHTML', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] + expect(tokens[2]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[3]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] + expect(tokens[4]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] + expect(tokens[5]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[6]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[7]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] + expect(tokens[8]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[9]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[12]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] + + it "tokenizes ES6 tagged HTML string templates with expanded function name and white space", -> + {tokens} = grammar.tokenizeLine('escapeHTML `hey ${name}`') + expect(tokens[0]).toEqual value: 'escapeHTML', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[2]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] + expect(tokens[3]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] + expect(tokens[4]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] + expect(tokens[5]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] + expect(tokens[6]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[7]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[8]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] + expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[10]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[13]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] describe "ES6 tagged Relay.QL string templates", -> it "tokenizes them as strings", -> From 91452e6b493f41f3c24635b7e3e62abb6250d8bd Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Mon, 14 Nov 2016 17:01:28 +0000 Subject: [PATCH 166/420] :bug: Add prefixes to function type for JSDoc --- grammars/javascript.cson | 92 ++++++++++++++++++++++++++++++++-------- 1 file changed, 74 insertions(+), 18 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 7fcfbe9b..1d9b4042 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1934,17 +1934,45 @@ (?: function # {function(string, number)} function type \\s* - \\( - \\s* (?: - [a-zA-Z_$][\\w$]* (?: - \\s*,\\s* - [a-zA-Z_$][\\w$]* - )* - )? - \\s* - \\) + \\( + \\s* + \\.{3}[a-zA-Z_$][\\w$]+ # {function(...string)} variable number of parameters + \\s* + \\) + ) + | + (?: + \\( + \\s* + (?: + (?: + \\? | # {function(?string)} nullable type + ! | # {function(!string)} non-nullable type + )? + [a-zA-Z_$][\\w$]+ + (?: + \\s*,\\s* + (?: + (?: + (?: + \\? | # {function(string, ?string)} nullable type + ! | # {function(string, !string)} non-nullable type + )? + [a-zA-Z_$][\\w$]+ + ) + | + (?: + \\.{3}[a-zA-Z_$][\\w$]+ # {function(string, ...string)} variable number of parameters + ) + ) + )* + )* + \\s* + \\) + ) + ) (?: # {function(): string} function return type \\s*:\\s* [a-zA-Z_$][\\w$]* @@ -2056,17 +2084,45 @@ (?: function # {function(string, number)} function type \\s* - \\( - \\s* (?: - [a-zA-Z_$][\\w$]* (?: - \\s*,\\s* - [a-zA-Z_$][\\w$]* - )* - )? - \\s* - \\) + \\( + \\s* + \\.{3}[a-zA-Z_$][\\w$]+ # {function(...string)} variable number of parameters + \\s* + \\) + ) + | + (?: + \\( + \\s* + (?: + (?: + \\? | # {function(?string)} nullable type + ! | # {function(!string)} non-nullable type + )? + [a-zA-Z_$][\\w$]+ + (?: + \\s*,\\s* + (?: + (?: + (?: + \\? | # {function(string, ?string)} nullable type + ! | # {function(string, !string)} non-nullable type + )? + [a-zA-Z_$][\\w$]+ + ) + | + (?: + \\.{3}[a-zA-Z_$][\\w$]+ # {function(string, ...string)} variable number of parameters + ) + ) + )* + )* + \\s* + \\) + ) + ) (?: # {function(): string} function return type \\s*:\\s* [a-zA-Z_$][\\w$]* From 01d21edba9c3f10cf969b6a5111878c9fc45d87f Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Tue, 15 Nov 2016 11:44:06 +0000 Subject: [PATCH 167/420] :bug: Add suffixes to function type for JSDoc --- grammars/javascript.cson | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 1d9b4042..c9a10252 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1952,6 +1952,7 @@ ! | # {function(!string)} non-nullable type )? [a-zA-Z_$][\\w$]+ + (?:\\[\\])? # {function(string[])} type application, an array of strings (?: \\s*,\\s* (?: @@ -1961,6 +1962,7 @@ ! | # {function(string, !string)} non-nullable type )? [a-zA-Z_$][\\w$]+ + (?:\\[\\])? # {function(string[])} type application, an array of strings ) | (?: @@ -1968,6 +1970,7 @@ ) ) )* + =? # {function(string=)} optional parameter )* \\s* \\) @@ -2102,6 +2105,7 @@ ! | # {function(!string)} non-nullable type )? [a-zA-Z_$][\\w$]+ + (?:\\[\\])? # {function(string[])} type application, an array of strings (?: \\s*,\\s* (?: @@ -2111,6 +2115,7 @@ ! | # {function(string, !string)} non-nullable type )? [a-zA-Z_$][\\w$]+ + (?:\\[\\])? # {function(string[])} type application, an array of strings ) | (?: @@ -2118,6 +2123,7 @@ ) ) )* + =? # {function(string=)} optional parameter )* \\s* \\) From e193c21be6b5b08ca323447e1d6a586047642fdc Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Tue, 15 Nov 2016 11:45:16 +0000 Subject: [PATCH 168/420] :white_check_mark: Add specs for prefixes/suffixes on function type params for JSDoc --- spec/javascript-spec.coffee | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 11245ce8..3af7032f 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -2037,6 +2037,36 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {function(...string)} variable this is the description */') + expect(tokens[4]).toEqual value: '{function(...string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(string, ...number)} variable this is the description */') + expect(tokens[4]).toEqual value: '{function(string, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(string, ...number)} variable this is the description */') + expect(tokens[4]).toEqual value: '{function(string, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(!string)} variable this is the description */') + expect(tokens[4]).toEqual value: '{function(!string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(?string, !number)} variable this is the description */') + expect(tokens[4]).toEqual value: '{function(?string, !number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(string[], number=)} variable this is the description */') + expect(tokens[4]).toEqual value: '{function(string[], number=)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {function():number} variable this is the description */') expect(tokens[4]).toEqual value: '{function():number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] @@ -2092,6 +2122,30 @@ describe "JavaScript grammar", -> expect(tokens[4]).toEqual value: '{function(string, number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {function(...string)} this is the description */') + expect(tokens[4]).toEqual value: '{function(...string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @return {function(string, ...number)} this is the description */') + expect(tokens[4]).toEqual value: '{function(string, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @return {function(string, ...number)} this is the description */') + expect(tokens[4]).toEqual value: '{function(string, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @return {function(!string)} this is the description */') + expect(tokens[4]).toEqual value: '{function(!string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @return {function(?string, !number)} this is the description */') + expect(tokens[4]).toEqual value: '{function(?string, !number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @return {function(string[], number=)} this is the description */') + expect(tokens[4]).toEqual value: '{function(string[], number=)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {function():number} this is the description */') expect(tokens[4]).toEqual value: '{function():number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] From 23a654c9a7b331a13bacd7aa1aef89411b30ce8f Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Fri, 18 Nov 2016 01:30:09 +0000 Subject: [PATCH 169/420] :bug: Only allow one spread --- grammars/javascript.cson | 84 +++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index c9a10252..394ff867 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1948,30 +1948,32 @@ \\s* (?: (?: - \\? | # {function(?string)} nullable type - ! | # {function(!string)} non-nullable type - )? - [a-zA-Z_$][\\w$]+ - (?:\\[\\])? # {function(string[])} type application, an array of strings - (?: - \\s*,\\s* (?: + \\? | # {function(?string)} nullable type + ! # {function(!string)} non-nullable type + )? + [a-zA-Z_$][\\w$]+ + (?:\\[\\])? # {function(string[])} type application, an array of strings + (?: + \\s*,\\s* (?: (?: - \\? | # {function(string, ?string)} nullable type - ! | # {function(string, !string)} non-nullable type - )? - [a-zA-Z_$][\\w$]+ - (?:\\[\\])? # {function(string[])} type application, an array of strings + (?: + \\? | # {function(string, ?string)} nullable type + ! # {function(string, !string)} non-nullable type + )? + [a-zA-Z_$][\\w$]+ + (?:\\[\\])? # {function(string[])} type application, an array of strings + ) ) - | - (?: - \\.{3}[a-zA-Z_$][\\w$]+ # {function(string, ...string)} variable number of parameters - ) - ) - )* - =? # {function(string=)} optional parameter - )* + )* + =? # {function(string=)} optional parameter + )+ + (?: + \\s*,\\s* + \\.{3}[a-zA-Z_$][\\w$]+ # {function(string, ...string)} variable number of parameters + )? + )? \\s* \\) ) @@ -2101,30 +2103,32 @@ \\s* (?: (?: - \\? | # {function(?string)} nullable type - ! | # {function(!string)} non-nullable type - )? - [a-zA-Z_$][\\w$]+ - (?:\\[\\])? # {function(string[])} type application, an array of strings - (?: - \\s*,\\s* (?: + \\? | # {function(?string)} nullable type + ! # {function(!string)} non-nullable type + )? + [a-zA-Z_$][\\w$]+ + (?:\\[\\])? # {function(string[])} type application, an array of strings + (?: + \\s*,\\s* (?: (?: - \\? | # {function(string, ?string)} nullable type - ! | # {function(string, !string)} non-nullable type - )? - [a-zA-Z_$][\\w$]+ - (?:\\[\\])? # {function(string[])} type application, an array of strings + (?: + \\? | # {function(string, ?string)} nullable type + ! # {function(string, !string)} non-nullable type + )? + [a-zA-Z_$][\\w$]+ + (?:\\[\\])? # {function(string[])} type application, an array of strings + ) ) - | - (?: - \\.{3}[a-zA-Z_$][\\w$]+ # {function(string, ...string)} variable number of parameters - ) - ) - )* - =? # {function(string=)} optional parameter - )* + )* + =? # {function(string=)} optional parameter + )+ + (?: + \\s*,\\s* + \\.{3}[a-zA-Z_$][\\w$]+ # {function(string, ...string)} variable number of parameters + )? + )? \\s* \\) ) From ec8a38939adbc9c4339ab48754cb378b9748cd7c Mon Sep 17 00:00:00 2001 From: Ben Griffith Date: Fri, 18 Nov 2016 12:24:36 +0000 Subject: [PATCH 170/420] Only allow optional params to trail --- grammars/javascript.cson | 134 +++++++++++++++++++++------------------ 1 file changed, 74 insertions(+), 60 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 394ff867..c5da5b6c 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1936,46 +1936,53 @@ \\s* (?: (?: - \\( - \\s* + \\(\\s* \\.{3}[a-zA-Z_$][\\w$]+ # {function(...string)} variable number of parameters - \\s* - \\) + \\s*\\) ) | (?: - \\( - \\s* + \\(\\s* (?: + (?:\\?|!)? # {function(?string)} or function(!string)} nullable/non-nullable type + [a-zA-Z_$][\\w$]+ + (?:\\[\\])? # {function(string[])} type application, an array of strings (?: (?: - \\? | # {function(?string)} nullable type - ! # {function(!string)} non-nullable type - )? - [a-zA-Z_$][\\w$]+ - (?:\\[\\])? # {function(string[])} type application, an array of strings + (?: + \\s*,\\s* + (?:\\?|!)? # {function(?string)} or function(!string)} nullable/non-nullable type + [a-zA-Z_$][\\w$]+ + (?:\\[\\])? # {function(string[])} type application, an array of strings + )* + (?: + \\s*,\\s* + \\.{3}[a-zA-Z_$][\\w$]+ # {function(string, ...string)} variable number of parameters + )? + ) + | (?: - \\s*,\\s* + =? # {function(string=)} optional parameter (?: - (?: - (?: - \\? | # {function(string, ?string)} nullable type - ! # {function(string, !string)} non-nullable type - )? - [a-zA-Z_$][\\w$]+ - (?:\\[\\])? # {function(string[])} type application, an array of strings - ) - ) - )* - =? # {function(string=)} optional parameter - )+ - (?: - \\s*,\\s* - \\.{3}[a-zA-Z_$][\\w$]+ # {function(string, ...string)} variable number of parameters - )? + (? Date: Fri, 18 Nov 2016 12:26:28 +0000 Subject: [PATCH 171/420] :bug: Tweak duplicated spec --- spec/javascript-spec.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 3af7032f..1a6a3b5c 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -2047,8 +2047,8 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - {tokens} = grammar.tokenizeLine('/** @param {function(string, ...number)} variable this is the description */') - expect(tokens[4]).toEqual value: '{function(string, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {function(string, number, ...number)} variable this is the description */') + expect(tokens[4]).toEqual value: '{function(string, number, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] @@ -2130,8 +2130,8 @@ describe "JavaScript grammar", -> expect(tokens[4]).toEqual value: '{function(string, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - {tokens} = grammar.tokenizeLine('/** @return {function(string, ...number)} this is the description */') - expect(tokens[4]).toEqual value: '{function(string, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {function(string, number, ...number)} this is the description */') + expect(tokens[4]).toEqual value: '{function(string, number, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] {tokens} = grammar.tokenizeLine('/** @return {function(!string)} this is the description */') From 1e411fd569dd1a67d84ff2c5a921324462f765bc Mon Sep 17 00:00:00 2001 From: Alhadis Date: Thu, 24 Nov 2016 05:07:20 +1100 Subject: [PATCH 172/420] Fix incorrect highlighting for multiline imports Resolves #460. --- grammars/javascript.cson | 79 +++++++-------- spec/javascript-spec.coffee | 194 +++++++++++++++++++++++++++++++++++- 2 files changed, 227 insertions(+), 46 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 7fcfbe9b..01bdd291 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -39,11 +39,11 @@ 'patterns': [ { # ES6 import - 'begin': '(? expect(tokens[4]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] expect(tokens[5]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + lines = grammar.tokenizeLines """ + import + \\x20{2} + "module-name" + ; + """ + expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[2][1]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(lines[2][2]).toEqual value: 'module-name', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js'] + expect(lines[2][3]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(lines[3][1]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + it "tokenizes default import", -> {tokens} = grammar.tokenizeLine('import defaultMember from "module-name";') expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] expect(tokens[2]).toEqual value: 'defaultMember', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] expect(tokens[4]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + lines = grammar.tokenizeLines """ + import + \\x20{2} + defaultMember + \\x20{2} + from + \\x20{2} + "module-name" + \\x20{2} + ; + """ + expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[2][1]).toEqual value: 'defaultMember', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] + expect(lines[4][1]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[6][1]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(lines[6][2]).toEqual value: 'module-name', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js'] + expect(lines[6][3]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(lines[8][1]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + it "tokenizes default named import", -> {tokens} = grammar.tokenizeLine('import { default as defaultMember } from "module-name";') expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] @@ -757,6 +788,31 @@ describe "JavaScript grammar", -> expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.end.js'] expect(tokens[12]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + lines = grammar.tokenizeLines """ + import + \\t + { + \\t + default + \\t + as + \\t + defaultMember + \\t + } from "module-name"; + """ + expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[2][0]).toEqual value: '{', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.begin.js'] + expect(lines[4][0]).toEqual value: 'default', scopes: ['source.js', 'meta.import.js', 'variable.language.default.js'] + expect(lines[6][0]).toEqual value: 'as', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[8][0]).toEqual value: 'defaultMember', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] + expect(lines[10][0]).toEqual value: '}', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.end.js'] + expect(lines[10][2]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[10][4]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(lines[10][5]).toEqual value: 'module-name', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js'] + expect(lines[10][6]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(lines[10][7]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + it "tokenizes named import", -> {tokens} = grammar.tokenizeLine('import { member } from "module-name";') expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] @@ -776,6 +832,55 @@ describe "JavaScript grammar", -> expect(tokens[14]).toEqual value: '}', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.end.js'] expect(tokens[16]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + lines = grammar.tokenizeLines """ + import + { + \\t + member + \\t + } + \\t + from + \\t + "module-name"; + """ + expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[1][0]).toEqual value: '{', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.begin.js'] + expect(lines[3][0]).toEqual value: ' ', scopes: ['source.js', 'meta.import.js'] + expect(lines[3][1]).toEqual value: 'member', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] + expect(lines[5][0]).toEqual value: '}', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.end.js'] + expect(lines[7][0]).toEqual value: ' ', scopes: ['source.js', 'meta.import.js'] + expect(lines[7][1]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[9][0]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(lines[9][1]).toEqual value: 'module-name', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js'] + expect(lines[9][2]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(lines[9][3]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + + lines = grammar.tokenizeLines """ + import + { + member1 + , + member2 + as + alias2 + } + from "module-name"; + """ + expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[1][0]).toEqual value: '{', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.begin.js'] + expect(lines[2][0]).toEqual value: 'member1', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] + expect(lines[3][0]).toEqual value: ',', scopes: ['source.js', 'meta.import.js', 'meta.delimiter.object.comma.js'] + expect(lines[4][0]).toEqual value: 'member2', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] + expect(lines[5][0]).toEqual value: 'as', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[6][0]).toEqual value: 'alias2', scopes: ['source.js', 'meta.import.js', 'variable.other.module-alias.js'] + expect(lines[7][0]).toEqual value: '}', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.end.js'] + expect(lines[8][0]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[8][2]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(lines[8][3]).toEqual value: 'module-name', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js'] + expect(lines[8][4]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(lines[8][5]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + it "tokenizes entire module import", -> {tokens} = grammar.tokenizeLine('import * as name from "module-name";') expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] @@ -784,6 +889,20 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: 'name', scopes: ['source.js', 'meta.import.js', 'variable.other.module-alias.js'] expect(tokens[8]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + lines = grammar.tokenizeLines """ + import + * + as + name + from + "module-name"; + """ + expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[1][0]).toEqual value: '*', scopes: ['source.js', 'meta.import.js', 'variable.language.import-all.js'] + expect(lines[2][0]).toEqual value: 'as', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[3][0]).toEqual value: 'name', scopes: ['source.js', 'meta.import.js', 'variable.other.module-alias.js'] + expect(lines[4][0]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + it "tokenizes `import defaultMember, { member } from 'module-name';`", -> {tokens} = grammar.tokenizeLine('import defaultMember, { member } from "module-name";') expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] @@ -794,6 +913,27 @@ describe "JavaScript grammar", -> expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.end.js'] expect(tokens[11]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + lines = grammar.tokenizeLines """ + import + defaultMember, + { + member + } + from + "module-name"; + """ + expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[1][0]).toEqual value: 'defaultMember', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] + expect(lines[1][1]).toEqual value: ',', scopes: ['source.js', 'meta.import.js', 'meta.delimiter.object.comma.js'] + expect(lines[2][0]).toEqual value: '{', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.begin.js'] + expect(lines[3][0]).toEqual value: 'member', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] + expect(lines[4][0]).toEqual value: '}', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.end.js'] + expect(lines[5][0]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[6][0]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(lines[6][1]).toEqual value: 'module-name', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js'] + expect(lines[6][2]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(lines[6][3]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + it "tokenizes `import defaultMember, * as alias from 'module-name';", -> {tokens} = grammar.tokenizeLine('import defaultMember, * as alias from "module-name";') expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] @@ -804,7 +944,28 @@ describe "JavaScript grammar", -> expect(tokens[9]).toEqual value: 'alias', scopes: ['source.js', 'meta.import.js', 'variable.other.module-alias.js'] expect(tokens[11]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - it "tokenizes comments in statement", -> + lines = grammar.tokenizeLines """ + import + defaultMember, + * + as + alias + from + "module-name"; + """ + expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[1][0]).toEqual value: 'defaultMember', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] + expect(lines[1][1]).toEqual value: ',', scopes: ['source.js', 'meta.import.js', 'meta.delimiter.object.comma.js'] + expect(lines[2][0]).toEqual value: '*', scopes: ['source.js', 'meta.import.js', 'variable.language.import-all.js'] + expect(lines[3][0]).toEqual value: 'as', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[4][0]).toEqual value: 'alias', scopes: ['source.js', 'meta.import.js', 'variable.other.module-alias.js'] + expect(lines[5][0]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[6][0]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(lines[6][1]).toEqual value: 'module-name', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js'] + expect(lines[6][2]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(lines[6][3]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + + it "tokenizes comments in import statements", -> lines = grammar.tokenizeLines ''' import /* comment */ { member1, // comment @@ -821,6 +982,37 @@ describe "JavaScript grammar", -> expect(lines[2][2]).toEqual value: ' comment ', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] expect(lines[2][3]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + {tokens} = grammar.tokenizeLine('import name as/* Comment */alias;') + expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(tokens[2]).toEqual value: 'name', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] + expect(tokens[4]).toEqual value: 'as', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(tokens[5]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[6]).toEqual value: ' Comment ', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] + expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[8]).toEqual value: 'alias', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] + expect(tokens[9]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + + lines = grammar.tokenizeLines """ + import/* + ======== + */name/* + ==*/as/* + Comment */alias; + """ + expect(lines[0][1]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[1][0]).toEqual value: '========', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] + expect(lines[2][0]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[2][1]).toEqual value: 'name', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] + expect(lines[2][2]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[3][0]).toEqual value: '==', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] + expect(lines[3][1]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[3][2]).toEqual value: 'as', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + expect(lines[3][3]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[4][0]).toEqual value: 'Comment ', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] + expect(lines[4][1]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[4][2]).toEqual value: 'alias', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] + expect(lines[4][3]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + describe "ES6 export", -> it "tokenizes named export", -> {tokens} = grammar.tokenizeLine('export var x = 0;') From 423633af9cf72dac464151fbe061d4a0a1ac6242 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Thu, 24 Nov 2016 05:15:34 +1100 Subject: [PATCH 173/420] Delete redundant .coffeelintignore file --- .coffeelintignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .coffeelintignore diff --git a/.coffeelintignore b/.coffeelintignore deleted file mode 100644 index 1db51fed..00000000 --- a/.coffeelintignore +++ /dev/null @@ -1 +0,0 @@ -spec/fixtures From 1e47b5499880ab31c76a9c020d42b2778c689c11 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 26 Nov 2016 21:32:25 +1100 Subject: [PATCH 174/420] Apply revisions requested in QA --- grammars/javascript.cson | 2 +- spec/javascript-spec.coffee | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 01bdd291..5bfd7b6d 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -122,7 +122,7 @@ 'name': 'keyword.control.js' } { - 'match': '\\b([a-zA-Z_$][\\w$]*)\\b(?=.*(?:$|\\bfrom\\b))' + 'match': '\\b([a-zA-Z_$][\\w$]*)\\b' 'name': 'variable.other.module.js' } { diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index ff8b70d1..245c780f 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -761,13 +761,13 @@ describe "JavaScript grammar", -> lines = grammar.tokenizeLines """ import - \\x20{2} + \\x20 defaultMember - \\x20{2} + \\x20 from - \\x20{2} + \\x20 "module-name" - \\x20{2} + \\x20 ; """ expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] @@ -790,22 +790,22 @@ describe "JavaScript grammar", -> lines = grammar.tokenizeLines """ import - \\t + \t { - \\t + \t default - \\t + \t as - \\t + \t defaultMember - \\t + \t } from "module-name"; """ expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] expect(lines[2][0]).toEqual value: '{', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.begin.js'] expect(lines[4][0]).toEqual value: 'default', scopes: ['source.js', 'meta.import.js', 'variable.language.default.js'] expect(lines[6][0]).toEqual value: 'as', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[8][0]).toEqual value: 'defaultMember', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] + expect(lines[8][0]).toEqual value: 'defaultMember', scopes: ['source.js', 'meta.import.js', 'variable.other.module-alias.js'] expect(lines[10][0]).toEqual value: '}', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.end.js'] expect(lines[10][2]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] expect(lines[10][4]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] From cc626a0d0aa21628c85418bfa073573eeacff942 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Sat, 26 Nov 2016 20:43:34 -0500 Subject: [PATCH 175/420] Revert "Return control to language-html when is detected when embedded" --- grammars/embedded javascript.cson | 10 ---------- grammars/javascript.cson | 19 ++++++++++--------- spec/javascript-spec.coffee | 13 ------------- 3 files changed, 10 insertions(+), 32 deletions(-) delete mode 100644 grammars/embedded javascript.cson diff --git a/grammars/embedded javascript.cson b/grammars/embedded javascript.cson deleted file mode 100644 index 6cd2575b..00000000 --- a/grammars/embedded javascript.cson +++ /dev/null @@ -1,10 +0,0 @@ -'scopeName': 'source.js.embedded.html' -'name': 'Embedded JavaScript' -'injectionSelector': 'L:source.js.embedded.html, L:source.js.embedded.xml' -'patterns': [ - { - # Break out as soon as a tag is encountered, - # even if it's in a string or comment - 'match': '(?=)' - } -] diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 7fcfbe9b..841a74f4 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1,5 +1,4 @@ 'scopeName': 'source.js' -'name': 'JavaScript' 'fileTypes': [ 'js' '_js' @@ -36,6 +35,7 @@ (?=\\s|:|$) ) ''' +'name': 'JavaScript' 'patterns': [ { # ES6 import @@ -865,6 +865,15 @@ { 'include': '#comments' } + { + 'match': '()' + 'captures': + '0': + 'name': 'punctuation.definition.comment.html.js' + '2': + 'name': 'punctuation.definition.comment.html.js' + 'name': 'comment.block.html.js' + } { 'match': '(?' - 'beginCaptures': - '0': - 'name': 'punctuation.definition.comment.html.js' - 'end': '$' - 'name': 'comment.line.deprecated.html.js' - } ] 'switch_statement': 'patterns': [ diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 11245ce8..e23d7ef1 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -2168,19 +2168,6 @@ describe "JavaScript grammar", -> expect(tokens[7]).toEqual value: ', p2 ', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js'] expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.definition.comment.js'] - it "tokenizes deprecated HTML-style comments correctly", -> - {tokens} = grammar.tokenizeLine(' test') - expect(tokens[0]).toEqual value: '-->', scopes: ['source.js', 'comment.line.deprecated.html.js', 'punctuation.definition.comment.html.js'] - expect(tokens[1]).toEqual value: ' test', scopes: ['source.js', 'comment.line.deprecated.html.js'] - - {tokens} = grammar.tokenizeLine(' console.log()') - expect(tokens[0]).toEqual value: ' console.log()', scopes: ['source.js', 'comment.line.deprecated.html.js'] - describe "console", -> it "tokenizes the console keyword", -> {tokens} = grammar.tokenizeLine('console;') From eadf9cf9900c2a81b9fd9237b77a74af80f7fc9c Mon Sep 17 00:00:00 2001 From: Wliu Date: Sat, 26 Nov 2016 20:43:55 -0500 Subject: [PATCH 176/420] Prepare 0.124.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7f0d8168..620e06f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.123.0", + "version": "0.124.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From f4f72f053f5d446707ca144f14aa0b64b3356270 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sun, 27 Nov 2016 12:59:40 +1100 Subject: [PATCH 177/420] Remove redundant backslashes CSON-based grammars are poisonous to the mind and must die. --- spec/javascript-spec.coffee | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 245c780f..86e4ec6a 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -743,7 +743,7 @@ describe "JavaScript grammar", -> lines = grammar.tokenizeLines """ import - \\x20{2} + \x20 "module-name" ; """ @@ -761,13 +761,13 @@ describe "JavaScript grammar", -> lines = grammar.tokenizeLines """ import - \\x20 + \x20 defaultMember - \\x20 + \x20 from - \\x20 + \x20 "module-name" - \\x20 + \x20 ; """ expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] @@ -835,13 +835,13 @@ describe "JavaScript grammar", -> lines = grammar.tokenizeLines """ import { - \\t + \t member - \\t + \t } - \\t + \t from - \\t + \t "module-name"; """ expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] From 4689326711aec7c8563f48e64f94141a1e0e3599 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Mon, 5 Dec 2016 03:28:56 +1100 Subject: [PATCH 178/420] Highlight quoted defaults in JSDoc @param tags --- grammars/javascript.cson | 6 +++++- spec/javascript-spec.coffee | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 841a74f4..28a18b37 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -2020,7 +2020,11 @@ \\s* = # [foo=bar] Default parameter value \\s* - [\\w$\\s]* + (?: + [\\w$\\s]* | # [foo=bar] Unquoted + "[^"]*" | # [foo="bar"] Double-quoted + '[^']*' # [foo='bar'] Single-quoted + ) )? ) \\s* diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index e23d7ef1..322f91e1 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1841,6 +1841,21 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: '[ variable = default value ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} [variable="default value"] this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[variable="default value"]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {object} [variable = "default value"] this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[variable = "default value"]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {object} [ variable = " default value " ] this is the description */') + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[ variable = " default value " ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} parameter.property this is the description */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'parameter.property', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] From da0741ed6e37e617b6d3db0b97681ac62ab03aa8 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Mon, 5 Dec 2016 03:48:26 +1100 Subject: [PATCH 179/420] Highlight JSDoc {@link tags} in param descriptions --- grammars/javascript.cson | 10 ++++++++++ spec/javascript-spec.coffee | 28 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 28a18b37..8b4aa329 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -2051,6 +2051,11 @@ 'name': 'variable.other.jsdoc' '3': 'name': 'other.description.jsdoc' + 'patterns': [ + { + 'include': '#docblock' + } + ] } { 'match': '''(?x) @@ -2133,6 +2138,11 @@ 'name': 'entity.name.type.instance.jsdoc' '2': 'name': 'other.description.jsdoc' + 'patterns': [ + { + 'include': '#docblock' + } + ] } ] 'comments': diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 322f91e1..fcf65333 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1856,6 +1856,34 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: '[ variable = " default value " ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a {@link linked} description */') + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is a ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + expect(tokens[9]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[10]).toEqual value: '@link', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[12]).toEqual value: 'linked', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[14]).toEqual value: ' description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a {@link linked#description}. */') + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is a ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + expect(tokens[9]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[10]).toEqual value: '@link', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[12]).toEqual value: 'linked#description', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[14]).toEqual value: '. ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a [description with a]{@link example}. */') + expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is a ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + expect(tokens[9]).toEqual value: '[description with a]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'constant.other.description.jsdoc'] + expect(tokens[10]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[11]).toEqual value: '@link', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[13]).toEqual value: 'example', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[14]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[15]).toEqual value: '. ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} parameter.property this is the description */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'parameter.property', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] From 25896c7d2eeca3013f3d268c56aaee8d10224f7b Mon Sep 17 00:00:00 2001 From: Alhadis Date: Mon, 5 Dec 2016 04:15:57 +1100 Subject: [PATCH 180/420] Allow ligatures in "double-not" operators --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 841a74f4..75a912ea 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1307,7 +1307,7 @@ 'name': 'keyword.operator.comparison.js' } { - 'match': '&&|!|\\|\\|' + 'match': '&&|!!|!|\\|\\|' 'name': 'keyword.operator.logical.js' } { From d25b510d789a2db02a5c7535b8261ae8153d6621 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 6 Dec 2016 07:45:26 +1100 Subject: [PATCH 181/420] Add tests for single-quoted default JSDoc values --- spec/javascript-spec.coffee | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index fcf65333..18750dc5 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1856,6 +1856,21 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: '[ variable = " default value " ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine("/** @param {object} [variable='default value'] this is the description */") + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: "[variable='default value']", scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine("/** @param {object} [variable = 'default value'] this is the description */") + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: "[variable = 'default value']", scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine("/** @param {object} [ variable = ' default value ' ] this is the description */") + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: "[ variable = ' default value ' ]", scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a {@link linked} description */') expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is a ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] From 2492d8f95118fb2c96ad38add953b82181cb273d Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 17 Dec 2016 05:48:32 +1100 Subject: [PATCH 182/420] Add JSDoc highlighting to variable/mixed type lists Examples: - @param {...*} args - @param {...?} args --- grammars/javascript.cson | 2 ++ spec/javascript-spec.coffee | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 4a4ec578..55c11836 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1926,6 +1926,7 @@ \\? | # {?string} nullable type ! | # {!string} non-nullable type \\.{3} # {...string} variable number of parameters + [*?]? # {...*) Variable number of mixed types )? (?: @@ -2097,6 +2098,7 @@ \\? | # {?string} nullable type ! | # {!string} non-nullable type \\.{3} # {...string} variable number of parameters + [*?]? # {...*) Variable number of mixed types )? (?: diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 539381df..9d01ad03 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -2182,6 +2182,16 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {...*} remainder */') + expect(tokens[2]).toEqual value: '@param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + expect(tokens[4]).toEqual value: '{...*}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'remainder', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {...?} remainder */') + expect(tokens[2]).toEqual value: '@param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + expect(tokens[4]).toEqual value: '{...?}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'remainder', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {number=} variable this is the description */') expect(tokens[4]).toEqual value: '{number=}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] From df7195c83da57845da8c12208b3d1ed7c7e30829 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 17 Dec 2016 18:36:56 +1100 Subject: [PATCH 183/420] Add JSDoc highlighting to typed-array return values Examples: - @return {(String[]|Number[])} - @return {(String|String[])} --- grammars/javascript.cson | 15 ++++++++++++--- spec/javascript-spec.coffee | 8 ++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 55c11836..a37787da 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -2166,21 +2166,30 @@ \\( # Opening bracket of multiple types with parenthesis {(string|number)} [a-zA-Z_$]+ (?: - [\\w$]* | + (?: + [\\w$]* + (?:\\[\\])? # {(string[]|number)} type application, an array of strings or a number + ) | \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) ) (?: [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback [a-zA-Z_$]+ (?: - [\\w$]* | + (?: + [\\w$]* + (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers + ) | \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) ) )* \\) | [a-zA-Z_$]+ (?: - [\\w$]* | + (?: + [\\w$]* + (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers + ) | \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) ) (?: diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 9d01ad03..516287e2 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -2349,6 +2349,14 @@ describe "JavaScript grammar", -> {tokens} = grammar.tokenizeLine('/** @return {Some|Thing} Something to return */') expect(tokens[4]).toEqual value: '{Some|Thing}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {(String[]|Number[])} Description */') + expect(tokens[4]).toEqual value: '{(String[]|Number[])}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'Description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {(Number|Number[])} Numbers */') + expect(tokens[4]).toEqual value: '{(Number|Number[])}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: 'Numbers', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @return {object} */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] From 4dc424fd1b58c672bd9feda1a025e9638fd7f0f9 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 17 Dec 2016 19:00:03 +1100 Subject: [PATCH 184/420] Add JSDoc support for arrays/objects as default values Examples: - @param {Object} [first={a: "b"}] - An object - @param {Array} [second=[1,2,3]] - An array --- grammars/javascript.cson | 4 +++- spec/javascript-spec.coffee | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index a37787da..4975881e 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -2053,7 +2053,9 @@ (?: [\\w$\\s]* | # [foo=bar] Unquoted "[^"]*" | # [foo="bar"] Double-quoted - '[^']*' # [foo='bar'] Single-quoted + '[^']*' | # [foo='bar'] Single-quoted + {[^{}]*} | # [foo={a:1}] Object literal + \\[ [^\\]\\[]* \\] # [foo=[1,2]] Array literal ) )? ) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 516287e2..38ffc24e 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -2063,6 +2063,54 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: "[ variable = ' default value ' ]", scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {Object} [variable={a: "b"}] - An object */') + expect(tokens[4]).toEqual value: '{Object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[variable={a: "b"}]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] + expect(tokens[8]).toEqual value: 'An object ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {Object} [ variable = { a : "b" } ] - An object */') + expect(tokens[4]).toEqual value: '{Object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[ variable = { a : "b" } ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] + expect(tokens[8]).toEqual value: 'An object ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {Array} [variable=[1,2,3]] - An array */') + expect(tokens[4]).toEqual value: '{Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[variable=[1,2,3]]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] + expect(tokens[8]).toEqual value: 'An array ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {Array} [ variable = [ 1 , 2 , 3 ] ] - An array */') + expect(tokens[4]).toEqual value: '{Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[ variable = [ 1 , 2 , 3 ] ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] + expect(tokens[8]).toEqual value: 'An array ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {Object} [variable={}] - Empty object */') + expect(tokens[4]).toEqual value: '{Object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[variable={}]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] + expect(tokens[8]).toEqual value: 'Empty object ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {Object} [ variable = { } ] - Empty object */') + expect(tokens[4]).toEqual value: '{Object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[ variable = { } ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] + expect(tokens[8]).toEqual value: 'Empty object ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {Array} [variable=[]] - Empty array */') + expect(tokens[4]).toEqual value: '{Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[variable=[]]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] + expect(tokens[8]).toEqual value: 'Empty array ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {Array} [ variable = [ ] ] - Empty array */') + expect(tokens[4]).toEqual value: '{Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[ variable = [ ] ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] + expect(tokens[8]).toEqual value: 'Empty array ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a {@link linked} description */') expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is a ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] From e6048d98399ba7e7bad61ad538ddd6acaeb7c6e4 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 17 Dec 2016 19:13:05 +1100 Subject: [PATCH 185/420] Retain keyword highlighting after spread operator Fixes missing highlighting in: - [...this]; - [...super]; - [...arguments]; --- grammars/javascript.cson | 2 +- spec/javascript-spec.coffee | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 4975881e..c83d4c34 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -286,7 +286,7 @@ ] } { - 'match': '(? expect(tokens[1]).toEqual value: '...', scopes: ['source.js', 'keyword.operator.spread.js'] expect(tokens[2]).toEqual value: 'iterableObj', scopes: ['source.js'] + {tokens} = grammar.tokenizeLine('...arguments') + expect(tokens[0]).toEqual value: '...', scopes: ['source.js', 'keyword.operator.spread.js'] + expect(tokens[1]).toEqual value: 'arguments', scopes: ['source.js', 'variable.language.js'] + + {tokens} = grammar.tokenizeLine('...super') + expect(tokens[0]).toEqual value: '...', scopes: ['source.js', 'keyword.operator.spread.js'] + expect(tokens[1]).toEqual value: 'super', scopes: ['source.js', 'variable.language.js'] + + {tokens} = grammar.tokenizeLine('...this') + expect(tokens[0]).toEqual value: '...', scopes: ['source.js', 'keyword.operator.spread.js'] + expect(tokens[1]).toEqual value: 'this', scopes: ['source.js', 'variable.language.js'] + describe "increment, decrement", -> it "tokenizes increment", -> {tokens} = grammar.tokenizeLine('i++') From 2bd094993ae18cbc6e7365113a4c3f5bff08fc70 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sun, 18 Dec 2016 03:52:35 +1100 Subject: [PATCH 186/420] Apply revision requests --- grammars/javascript.cson | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index c83d4c34..9d94d148 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1926,7 +1926,7 @@ \\? | # {?string} nullable type ! | # {!string} non-nullable type \\.{3} # {...string} variable number of parameters - [*?]? # {...*) Variable number of mixed types + [*?]? # {...*} Variable number of mixed types )? (?: @@ -2055,7 +2055,7 @@ "[^"]*" | # [foo="bar"] Double-quoted '[^']*' | # [foo='bar'] Single-quoted {[^{}]*} | # [foo={a:1}] Object literal - \\[ [^\\]\\[]* \\] # [foo=[1,2]] Array literal + \\[ [^\\[\\]]* \\] # [foo=[1,2]] Array literal ) )? ) @@ -2100,7 +2100,7 @@ \\? | # {?string} nullable type ! | # {!string} non-nullable type \\.{3} # {...string} variable number of parameters - [*?]? # {...*) Variable number of mixed types + [*?]? # {...*} Variable number of mixed types )? (?: From ba6ca759c535f9d5fa412df21eb0cc0a1cda51a2 Mon Sep 17 00:00:00 2001 From: Lee Dohm Date: Thu, 22 Dec 2016 10:36:42 -0800 Subject: [PATCH 187/420] Update issue and PR templates --- ISSUE_TEMPLATE.md | 40 ++++++++++++++++++++++++++++++++++++++++ PULL_REQUEST_TEMPLATE.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 ISSUE_TEMPLATE.md create mode 100644 PULL_REQUEST_TEMPLATE.md diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..b60bb86c --- /dev/null +++ b/ISSUE_TEMPLATE.md @@ -0,0 +1,40 @@ + + +### Prerequisites + +* [ ] Put an X between the brackets on this line if you have done all of the following: + * Reproduced the problem in Safe Mode: http://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode + * Followed all applicable steps in the debugging guide: http://flight-manual.atom.io/hacking-atom/sections/debugging/ + * Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq + * Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom + * Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages + +### Description + +[Description of the issue] + +### Steps to Reproduce + +1. [First Step] +2. [Second Step] +3. [and so on...] + +**Expected behavior:** [What you expect to happen] + +**Actual behavior:** [What actually happens] + +**Reproduces how often:** [What percentage of the time does it reproduce?] + +### Versions + +You can get this information from copy and pasting the output of `atom --version` and `apm --version` from the command line. Also, please include the OS and what version of the OS you're running. + +### Additional Information + +Any additional information, configuration or data that might be necessary to reproduce the issue. diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..2750afc8 --- /dev/null +++ b/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,28 @@ +### Requirements + +* Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion. +* All new code requires tests to ensure against regressions + +### Description of the Change + + + +## Alternate Designs + + + +### Benefits + + + +### Possible Drawbacks + + + +### Applicable Issues + + From d63557588ec1f9f4e882e39468e5328761e625bb Mon Sep 17 00:00:00 2001 From: Lee Dohm Date: Mon, 26 Dec 2016 10:01:41 -0800 Subject: [PATCH 188/420] :memo: Update issue and PR templates --- PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index 2750afc8..cdaa94a8 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -11,7 +11,7 @@ We must be able to understand the design of your change from this description. I --> -## Alternate Designs +### Alternate Designs From d906172e586ebbd5e8e17087742d279f90d5bd2f Mon Sep 17 00:00:00 2001 From: AlexKvazos Date: Fri, 30 Dec 2016 19:08:02 -0600 Subject: [PATCH 189/420] Add ternary operator snippet --- snippets/language-javascript.cson | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snippets/language-javascript.cson b/snippets/language-javascript.cson index 61533fb5..5c5e4118 100644 --- a/snippets/language-javascript.cson +++ b/snippets/language-javascript.cson @@ -11,6 +11,9 @@ 'do': 'prefix': 'do' 'body': 'do {\n\t$2\n} while (${1:true});' + 'condition ? true : false': + 'prefix': 'tern' + 'body': '${1:condition} ? (${2:true}) : (${3:false})' 'if': 'prefix': 'if' 'body': 'if (${1:true}) {\n\t$2\n}' From d64c8888bfc8e5f4dec48d1a5d9bba52274d260a Mon Sep 17 00:00:00 2001 From: AlexKvazos Date: Fri, 30 Dec 2016 19:15:53 -0600 Subject: [PATCH 190/420] Remove parentheses from ternary operator snippet --- snippets/language-javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/language-javascript.cson b/snippets/language-javascript.cson index 5c5e4118..fb5949e2 100644 --- a/snippets/language-javascript.cson +++ b/snippets/language-javascript.cson @@ -13,7 +13,7 @@ 'body': 'do {\n\t$2\n} while (${1:true});' 'condition ? true : false': 'prefix': 'tern' - 'body': '${1:condition} ? (${2:true}) : (${3:false})' + 'body': '${1:condition} ? ${2:true} : ${3:false}' 'if': 'prefix': 'if' 'body': 'if (${1:true}) {\n\t$2\n}' From 31b8154a2fe540c5c02063f70ac9bcf227265ac1 Mon Sep 17 00:00:00 2001 From: Wliu Date: Fri, 30 Dec 2016 21:22:30 -0500 Subject: [PATCH 191/420] Prepare 0.125.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 620e06f0..73bfbd29 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.124.0", + "version": "0.125.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 2445663dfb9ef43ba1998a45a8e0dd241c70c21d Mon Sep 17 00:00:00 2001 From: Steven Tang Date: Mon, 2 Jan 2017 09:28:02 -0700 Subject: [PATCH 192/420] const = storage.type.js Changed const from storage.modifier.js to storage.type.js Based on https://github.com/atom/language-javascript/issues/471 --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 9d94d148..8a1589ea 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -879,7 +879,7 @@ 'begin': '(? Date: Mon, 2 Jan 2017 10:05:33 -0700 Subject: [PATCH 193/420] Update javascript.cson --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 8a1589ea..e1aebc3f 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -879,7 +879,7 @@ 'begin': '(? Date: Mon, 2 Jan 2017 10:43:43 -0700 Subject: [PATCH 194/420] Update javascript-spec.coffee --- spec/javascript-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 54984398..b1713885 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -453,7 +453,7 @@ describe "JavaScript grammar", -> it "tokenizes variables declared using `const` as constants", -> {tokens} = grammar.tokenizeLine('const myCoolVar = 42;') - expect(tokens[0]).toEqual value: 'const', scopes: ['source.js', 'storage.modifier.js'] + expect(tokens[0]).toEqual value: 'const', scopes: ['source.js', 'storage.type.const.js'] expect(tokens[1]).toEqual value: ' ', scopes: ['source.js'] expect(tokens[2]).toEqual value: 'myCoolVar', scopes: ['source.js', 'constant.other.js'] expect(tokens[3]).toEqual value: ' ', scopes: ['source.js'] From a96dd63f8f2dd5c649c3e8e4cc0637b8f58d5bf3 Mon Sep 17 00:00:00 2001 From: Steven Tang Date: Mon, 2 Jan 2017 10:55:40 -0700 Subject: [PATCH 195/420] Add files via upload --- spec/javascript-spec.coffee | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index b1713885..3c71c1d4 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -468,7 +468,7 @@ describe "JavaScript grammar", -> c if(a) """ - expect(lines[0][0]).toEqual value: 'const', scopes: ['source.js', 'storage.modifier.js'] + expect(lines[0][0]).toEqual value: 'const', scopes: ['source.js', 'storage.type.const.js'] expect(lines[0][1]).toEqual value: ' ', scopes: ['source.js'] expect(lines[0][2]).toEqual value: 'a', scopes: ['source.js', 'constant.other.js'] expect(lines[0][3]).toEqual value: ',', scopes: ['source.js', 'meta.delimiter.object.comma.js'] @@ -487,7 +487,7 @@ describe "JavaScript grammar", -> c, } = foo """ - expect(lines[0][0]).toEqual value: 'const', scopes: ['source.js', 'storage.modifier.js'] + expect(lines[0][0]).toEqual value: 'const', scopes: ['source.js', 'storage.type.const.js'] expect(lines[0][1]).toEqual value: ' ', scopes: ['source.js'] expect(lines[0][2]).toEqual value: '{', scopes: ['source.js', 'meta.brace.curly.js'] expect(lines[1][0]).toEqual value: ' ', scopes: ['source.js'] @@ -505,14 +505,14 @@ describe "JavaScript grammar", -> {tokens} = grammar.tokenizeLine('(const hi);') expect(tokens[0]).toEqual value: '(', scopes: ['source.js', 'meta.brace.round.js'] - expect(tokens[1]).toEqual value: 'const', scopes: ['source.js', 'storage.modifier.js'] + expect(tokens[1]).toEqual value: 'const', scopes: ['source.js', 'storage.type.const.js'] expect(tokens[2]).toEqual value: ' ', scopes: ['source.js'] expect(tokens[3]).toEqual value: 'hi', scopes: ['source.js', 'constant.other.js'] expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'meta.brace.round.js'] expect(tokens[5]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] {tokens} = grammar.tokenizeLine('const {first:f,second,...rest} = obj;') - expect(tokens[0]).toEqual value: 'const', scopes: ['source.js', 'storage.modifier.js'] + expect(tokens[0]).toEqual value: 'const', scopes: ['source.js', 'storage.type.const.js'] expect(tokens[1]).toEqual value: ' ', scopes: ['source.js'] expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'meta.brace.curly.js'] expect(tokens[3]).toEqual value: 'first', scopes: ['source.js'] @@ -530,7 +530,7 @@ describe "JavaScript grammar", -> expect(tokens[15]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] {tokens} = grammar.tokenizeLine('const c = /regex/;') - expect(tokens[0]).toEqual value: 'const', scopes: ['source.js', 'storage.modifier.js'] + expect(tokens[0]).toEqual value: 'const', scopes: ['source.js', 'storage.type.const.js'] expect(tokens[1]).toEqual value: ' ', scopes: ['source.js'] expect(tokens[2]).toEqual value: 'c', scopes: ['source.js', 'constant.other.js'] expect(tokens[3]).toEqual value: ' ', scopes: ['source.js'] @@ -546,7 +546,7 @@ describe "JavaScript grammar", -> expect(tokens[0]).toEqual value: 'for', scopes: ['source.js', 'keyword.control.js'] expect(tokens[1]).toEqual value: ' ', scopes: ['source.js'] expect(tokens[2]).toEqual value: '(', scopes: ['source.js', 'meta.brace.round.js'] - expect(tokens[3]).toEqual value: 'const', scopes: ['source.js', 'storage.modifier.js'] + expect(tokens[3]).toEqual value: 'const', scopes: ['source.js', 'storage.type.const.js'] expect(tokens[4]).toEqual value: ' ', scopes: ['source.js'] expect(tokens[5]).toEqual value: 'elem', scopes: ['source.js', 'constant.other.js'] expect(tokens[6]).toEqual value: ' ', scopes: ['source.js'] @@ -561,12 +561,12 @@ describe "JavaScript grammar", -> expect(tokens[8]).toEqual value: ' object', scopes: ['source.js'] {tokens} = grammar.tokenizeLine 'const index = 0;' - expect(tokens[0]).toEqual value: 'const', scopes: ['source.js', 'storage.modifier.js'] + expect(tokens[0]).toEqual value: 'const', scopes: ['source.js', 'storage.type.const.js'] expect(tokens[2]).toEqual value: 'index', scopes: ['source.js', 'constant.other.js'] expect(tokens[4]).toEqual value: '=', scopes: ['source.js', 'keyword.operator.assignment.js'] {tokens} = grammar.tokenizeLine 'const offset = 0;' - expect(tokens[0]).toEqual value: 'const', scopes: ['source.js', 'storage.modifier.js'] + expect(tokens[0]).toEqual value: 'const', scopes: ['source.js', 'storage.type.const.js'] expect(tokens[2]).toEqual value: 'offset', scopes: ['source.js', 'constant.other.js'] expect(tokens[4]).toEqual value: '=', scopes: ['source.js', 'keyword.operator.assignment.js'] @@ -1041,7 +1041,7 @@ describe "JavaScript grammar", -> {tokens} = grammar.tokenizeLine('export const CONSTANT = 0;') expect(tokens[0]).toEqual value: 'export', scopes: ['source.js', 'meta.export.js', 'keyword.control.js'] - expect(tokens[2]).toEqual value: 'const', scopes: ['source.js', 'storage.modifier.js'] + expect(tokens[2]).toEqual value: 'const', scopes: ['source.js', 'storage.type.const.js'] expect(tokens[4]).toEqual value: 'CONSTANT', scopes: ['source.js', 'constant.other.js'] expect(tokens[6]).toEqual value: '=', scopes: ['source.js', 'keyword.operator.assignment.js'] @@ -2493,7 +2493,7 @@ describe "JavaScript grammar", -> it "tokenizes comments inside constant definitions", -> {tokens} = grammar.tokenizeLine('const a, // comment') - expect(tokens[0]).toEqual value: 'const', scopes: ['source.js', 'storage.modifier.js'] + expect(tokens[0]).toEqual value: 'const', scopes: ['source.js', 'storage.type.const.js'] expect(tokens[2]).toEqual value: 'a', scopes: ['source.js', 'constant.other.js'] expect(tokens[3]).toEqual value: ',', scopes: ['source.js', 'meta.delimiter.object.comma.js'] expect(tokens[5]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] From e346176a60236100be789c6c8526ae91c5aa8880 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Mon, 2 Jan 2017 15:42:21 -0500 Subject: [PATCH 196/420] Revert "Fix #460: Incorrect highlighting for multiline imports" --- grammars/javascript.cson | 79 ++++++++------- spec/javascript-spec.coffee | 194 +----------------------------------- 2 files changed, 46 insertions(+), 227 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index e1aebc3f..af62caa2 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -39,11 +39,11 @@ 'patterns': [ { # ES6 import - 'begin': '(? expect(tokens[4]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] expect(tokens[5]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] - lines = grammar.tokenizeLines """ - import - \x20 - "module-name" - ; - """ - expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[2][1]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(lines[2][2]).toEqual value: 'module-name', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js'] - expect(lines[2][3]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(lines[3][1]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] - it "tokenizes default import", -> {tokens} = grammar.tokenizeLine('import defaultMember from "module-name";') expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] expect(tokens[2]).toEqual value: 'defaultMember', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] expect(tokens[4]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - lines = grammar.tokenizeLines """ - import - \x20 - defaultMember - \x20 - from - \x20 - "module-name" - \x20 - ; - """ - expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[2][1]).toEqual value: 'defaultMember', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] - expect(lines[4][1]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[6][1]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(lines[6][2]).toEqual value: 'module-name', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js'] - expect(lines[6][3]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(lines[8][1]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] - it "tokenizes default named import", -> {tokens} = grammar.tokenizeLine('import { default as defaultMember } from "module-name";') expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] @@ -800,31 +769,6 @@ describe "JavaScript grammar", -> expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.end.js'] expect(tokens[12]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - lines = grammar.tokenizeLines """ - import - \t - { - \t - default - \t - as - \t - defaultMember - \t - } from "module-name"; - """ - expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[2][0]).toEqual value: '{', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.begin.js'] - expect(lines[4][0]).toEqual value: 'default', scopes: ['source.js', 'meta.import.js', 'variable.language.default.js'] - expect(lines[6][0]).toEqual value: 'as', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[8][0]).toEqual value: 'defaultMember', scopes: ['source.js', 'meta.import.js', 'variable.other.module-alias.js'] - expect(lines[10][0]).toEqual value: '}', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.end.js'] - expect(lines[10][2]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[10][4]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(lines[10][5]).toEqual value: 'module-name', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js'] - expect(lines[10][6]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(lines[10][7]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] - it "tokenizes named import", -> {tokens} = grammar.tokenizeLine('import { member } from "module-name";') expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] @@ -844,55 +788,6 @@ describe "JavaScript grammar", -> expect(tokens[14]).toEqual value: '}', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.end.js'] expect(tokens[16]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - lines = grammar.tokenizeLines """ - import - { - \t - member - \t - } - \t - from - \t - "module-name"; - """ - expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[1][0]).toEqual value: '{', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.begin.js'] - expect(lines[3][0]).toEqual value: ' ', scopes: ['source.js', 'meta.import.js'] - expect(lines[3][1]).toEqual value: 'member', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] - expect(lines[5][0]).toEqual value: '}', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.end.js'] - expect(lines[7][0]).toEqual value: ' ', scopes: ['source.js', 'meta.import.js'] - expect(lines[7][1]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[9][0]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(lines[9][1]).toEqual value: 'module-name', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js'] - expect(lines[9][2]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(lines[9][3]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] - - lines = grammar.tokenizeLines """ - import - { - member1 - , - member2 - as - alias2 - } - from "module-name"; - """ - expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[1][0]).toEqual value: '{', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.begin.js'] - expect(lines[2][0]).toEqual value: 'member1', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] - expect(lines[3][0]).toEqual value: ',', scopes: ['source.js', 'meta.import.js', 'meta.delimiter.object.comma.js'] - expect(lines[4][0]).toEqual value: 'member2', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] - expect(lines[5][0]).toEqual value: 'as', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[6][0]).toEqual value: 'alias2', scopes: ['source.js', 'meta.import.js', 'variable.other.module-alias.js'] - expect(lines[7][0]).toEqual value: '}', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.end.js'] - expect(lines[8][0]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[8][2]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(lines[8][3]).toEqual value: 'module-name', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js'] - expect(lines[8][4]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(lines[8][5]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] - it "tokenizes entire module import", -> {tokens} = grammar.tokenizeLine('import * as name from "module-name";') expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] @@ -901,20 +796,6 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: 'name', scopes: ['source.js', 'meta.import.js', 'variable.other.module-alias.js'] expect(tokens[8]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - lines = grammar.tokenizeLines """ - import - * - as - name - from - "module-name"; - """ - expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[1][0]).toEqual value: '*', scopes: ['source.js', 'meta.import.js', 'variable.language.import-all.js'] - expect(lines[2][0]).toEqual value: 'as', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[3][0]).toEqual value: 'name', scopes: ['source.js', 'meta.import.js', 'variable.other.module-alias.js'] - expect(lines[4][0]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - it "tokenizes `import defaultMember, { member } from 'module-name';`", -> {tokens} = grammar.tokenizeLine('import defaultMember, { member } from "module-name";') expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] @@ -925,27 +806,6 @@ describe "JavaScript grammar", -> expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.end.js'] expect(tokens[11]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - lines = grammar.tokenizeLines """ - import - defaultMember, - { - member - } - from - "module-name"; - """ - expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[1][0]).toEqual value: 'defaultMember', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] - expect(lines[1][1]).toEqual value: ',', scopes: ['source.js', 'meta.import.js', 'meta.delimiter.object.comma.js'] - expect(lines[2][0]).toEqual value: '{', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.begin.js'] - expect(lines[3][0]).toEqual value: 'member', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] - expect(lines[4][0]).toEqual value: '}', scopes: ['source.js', 'meta.import.js', 'punctuation.definition.modules.end.js'] - expect(lines[5][0]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[6][0]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(lines[6][1]).toEqual value: 'module-name', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js'] - expect(lines[6][2]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(lines[6][3]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] - it "tokenizes `import defaultMember, * as alias from 'module-name';", -> {tokens} = grammar.tokenizeLine('import defaultMember, * as alias from "module-name";') expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] @@ -956,28 +816,7 @@ describe "JavaScript grammar", -> expect(tokens[9]).toEqual value: 'alias', scopes: ['source.js', 'meta.import.js', 'variable.other.module-alias.js'] expect(tokens[11]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - lines = grammar.tokenizeLines """ - import - defaultMember, - * - as - alias - from - "module-name"; - """ - expect(lines[0][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[1][0]).toEqual value: 'defaultMember', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] - expect(lines[1][1]).toEqual value: ',', scopes: ['source.js', 'meta.import.js', 'meta.delimiter.object.comma.js'] - expect(lines[2][0]).toEqual value: '*', scopes: ['source.js', 'meta.import.js', 'variable.language.import-all.js'] - expect(lines[3][0]).toEqual value: 'as', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[4][0]).toEqual value: 'alias', scopes: ['source.js', 'meta.import.js', 'variable.other.module-alias.js'] - expect(lines[5][0]).toEqual value: 'from', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[6][0]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(lines[6][1]).toEqual value: 'module-name', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js'] - expect(lines[6][2]).toEqual value: '"', scopes: ['source.js', 'meta.import.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(lines[6][3]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] - - it "tokenizes comments in import statements", -> + it "tokenizes comments in statement", -> lines = grammar.tokenizeLines ''' import /* comment */ { member1, // comment @@ -994,37 +833,6 @@ describe "JavaScript grammar", -> expect(lines[2][2]).toEqual value: ' comment ', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] expect(lines[2][3]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] - {tokens} = grammar.tokenizeLine('import name as/* Comment */alias;') - expect(tokens[0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(tokens[2]).toEqual value: 'name', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] - expect(tokens[4]).toEqual value: 'as', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(tokens[5]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(tokens[6]).toEqual value: ' Comment ', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] - expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(tokens[8]).toEqual value: 'alias', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] - expect(tokens[9]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] - - lines = grammar.tokenizeLines """ - import/* - ======== - */name/* - ==*/as/* - Comment */alias; - """ - expect(lines[0][1]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(lines[1][0]).toEqual value: '========', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] - expect(lines[2][0]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(lines[2][1]).toEqual value: 'name', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] - expect(lines[2][2]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(lines[3][0]).toEqual value: '==', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] - expect(lines[3][1]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(lines[3][2]).toEqual value: 'as', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] - expect(lines[3][3]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(lines[4][0]).toEqual value: 'Comment ', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] - expect(lines[4][1]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(lines[4][2]).toEqual value: 'alias', scopes: ['source.js', 'meta.import.js', 'variable.other.module.js'] - expect(lines[4][3]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] - describe "ES6 export", -> it "tokenizes named export", -> {tokens} = grammar.tokenizeLine('export var x = 0;') From 31ec605571246ec78825fae937b5b51559e79452 Mon Sep 17 00:00:00 2001 From: Wliu Date: Mon, 2 Jan 2017 15:45:55 -0500 Subject: [PATCH 197/420] Prepare 0.125.1 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 73bfbd29..3ffa86aa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.125.0", + "version": "0.125.1", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 37220031be0c3bb256eb11b96b61a8d0042c3e88 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 14 Jan 2017 19:49:29 +1100 Subject: [PATCH 198/420] Add support for namespaced default values E.g., @param {Object} [name=Default.value] --- grammars/javascript.cson | 8 ++++---- spec/javascript-spec.coffee | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index af62caa2..6e097a90 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -2062,10 +2062,10 @@ = # [foo=bar] Default parameter value \\s* (?: - [\\w$\\s]* | # [foo=bar] Unquoted - "[^"]*" | # [foo="bar"] Double-quoted - '[^']*' | # [foo='bar'] Single-quoted - {[^{}]*} | # [foo={a:1}] Object literal + [\\w$.\\s]* | # [foo=bar] Unquoted + "[^"]*" | # [foo="bar"] Double-quoted + '[^']*' | # [foo='bar'] Single-quoted + {[^{}]*} | # [foo={a:1}] Object literal \\[ [^\\[\\]]* \\] # [foo=[1,2]] Array literal ) )? diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 0c424205..bd046fba 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1853,6 +1853,11 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: '[ variable = default value ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine '/** @param {object} [variable=default.value] this is the description */' + expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] + expect(tokens[6]).toEqual value: '[variable=default.value]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] + expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + {tokens} = grammar.tokenizeLine('/** @param {object} [variable="default value"] this is the description */') expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] expect(tokens[6]).toEqual value: '[variable="default value"]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] From a0ef65d2e08debaaa7d762d511fbf4411faa5502 Mon Sep 17 00:00:00 2001 From: Frederik Date: Mon, 16 Jan 2017 10:03:09 +0100 Subject: [PATCH 199/420] Add SJS (server-side JavaScript) to filetypes --- grammars/javascript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 6e097a90..2663fdeb 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -13,6 +13,7 @@ 'jspre' 'pac' 'pjs' + 'sjs' 'xsjs' 'xsjslib' ] From 6563b9b464bc998b14d0cd862feecc950cb87440 Mon Sep 17 00:00:00 2001 From: Wliu Date: Fri, 27 Jan 2017 13:44:47 -0500 Subject: [PATCH 200/420] Simplify single-line comment handling Fixes #485 --- grammars/javascript.cson | 19 +++++-------------- spec/javascript-spec.coffee | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 2663fdeb..8c31be89 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -2269,21 +2269,12 @@ 'name': 'comment.block.js' } { - 'begin': '(^[ \\t]+)?(?=//)' + 'begin': '//' 'beginCaptures': - '1': - 'name': 'punctuation.whitespace.comment.leading.js' - 'end': '(?!\\G)' - 'patterns': [ - { - 'begin': '//' - 'beginCaptures': - '0': - 'name': 'punctuation.definition.comment.js' - 'end': '\\n' - 'name': 'comment.line.double-slash.js' - } - ] + '0': + 'name': 'punctuation.definition.comment.js' + 'end': '$' + 'name': 'comment.line.double-slash.js' } ] 'switch_statement': diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index bd046fba..bf7fe994 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -833,6 +833,14 @@ describe "JavaScript grammar", -> expect(lines[2][2]).toEqual value: ' comment ', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] expect(lines[2][3]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + # https://github.com/atom/language-javascript/issues/485 + lines = grammar.tokenizeLines ''' + import a from 'a'; // + import b from 'b'; + ''' + expect(lines[0][11]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] + expect(lines[1][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] + describe "ES6 export", -> it "tokenizes named export", -> {tokens} = grammar.tokenizeLine('export var x = 0;') @@ -1715,6 +1723,14 @@ describe "JavaScript grammar", -> expect(tokens[15]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] describe "comments", -> + it "tokenizes // comments", -> + {tokens} = grammar.tokenizeLine '//' + expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] + + {tokens} = grammar.tokenizeLine '// stuff' + expect(tokens[0]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] + expect(tokens[1]).toEqual value: ' stuff', scopes: ['source.js', 'comment.line.double-slash.js'] + it "tokenizes /* */ comments", -> {tokens} = grammar.tokenizeLine('/**/') expect(tokens[0]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] From a87481e741eaef0170181cf8f531ce04a35a92f6 Mon Sep 17 00:00:00 2001 From: Wliu Date: Fri, 27 Jan 2017 16:26:27 -0500 Subject: [PATCH 201/420] Fix broken spec --- spec/javascript-spec.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index bf7fe994..a44a08e4 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -835,10 +835,10 @@ describe "JavaScript grammar", -> # https://github.com/atom/language-javascript/issues/485 lines = grammar.tokenizeLines ''' - import a from 'a'; // - import b from 'b'; + import a from 'a' // + import b from 'b' ''' - expect(lines[0][11]).toEqual value: '//', scopes: ['source.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] + expect(lines[0][10]).toEqual value: '//', scopes: ['source.js', 'meta.import.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] expect(lines[1][0]).toEqual value: 'import', scopes: ['source.js', 'meta.import.js', 'keyword.control.js'] describe "ES6 export", -> From fa19adc14c5188ab421f717cfec257509cd42623 Mon Sep 17 00:00:00 2001 From: surefire Date: Sun, 29 Jan 2017 01:25:48 +0300 Subject: [PATCH 202/420] Add support tagged SQL template strings --- grammars/javascript.cson | 24 ++++++++++++++++++++++++ spec/javascript-spec.coffee | 19 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 8c31be89..3cf4e8a7 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1456,6 +1456,30 @@ } ] } + { + 'begin': '(sql|SQL|Sql)\\s*(`)' + 'beginCaptures': + '1': + 'name': 'entity.name.function.js' + '2': + 'name': 'punctuation.definition.string.begin.js' + 'end': '`' + 'endCaptures': + '0': + 'name': 'punctuation.definition.string.end.js' + 'name': 'string.quoted.template.sql.js' + 'patterns': [ + { + 'include': '#string_escapes' + } + { + 'include': '#interpolated_js' + } + { + 'include': 'source.sql' + } + ] + } { 'begin': '`' 'beginCaptures': diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index a44a08e4..0d167cb4 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -707,6 +707,25 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: ' }', scopes: ['source.js', 'string.quoted.template.graphql.js'] expect(tokens[7]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.end.js'] + describe "ES6 tagged SQL string templates", -> + it "tokenizes them as strings", -> + {tokens} = grammar.tokenizeLine('SQL`SELECT foo FROM bar WHERE id = :id`') + expect(tokens[0]).toEqual value: 'SQL', scopes: ['source.js', 'string.quoted.template.sql.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.sql.js', 'punctuation.definition.string.begin.js'] + expect(tokens[2]).toEqual value: 'SELECT foo FROM bar WHERE id = :id', scopes: ['source.js', 'string.quoted.template.sql.js'] + expect(tokens[3]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.sql.js', 'punctuation.definition.string.end.js'] + + describe "ES6 tagged SQL string templates with interpolation", -> + it "tokenizes them as strings", -> + {tokens} = grammar.tokenizeLine('SQL`SELECT foo FROM bar WHERE id = ${id}`') + expect(tokens[0]).toEqual value: 'SQL', scopes: ['source.js', 'string.quoted.template.sql.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.sql.js', 'punctuation.definition.string.begin.js'] + expect(tokens[2]).toEqual value: 'SELECT foo FROM bar WHERE id = ', scopes: ['source.js', 'string.quoted.template.sql.js'] + expect(tokens[3]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.sql.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[4]).toEqual value: 'id', scopes: ['source.js', 'string.quoted.template.sql.js', 'source.js.embedded.source'] + expect(tokens[5]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.sql.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[6]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.sql.js', 'punctuation.definition.string.end.js'] + describe "ES6 class", -> it "tokenizes class", -> {tokens} = grammar.tokenizeLine('class MyClass') From 4146e0f3a160fc3ac0b80714af144e9ca8ea5329 Mon Sep 17 00:00:00 2001 From: Wliu Date: Mon, 6 Feb 2017 11:44:36 -0500 Subject: [PATCH 203/420] Prepare 0.126.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3ffa86aa..0666ee01 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.125.1", + "version": "0.126.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 123c4c8950cdd3311d85416f07e857e728c95fce Mon Sep 17 00:00:00 2001 From: Alhadis Date: Mon, 27 Feb 2017 11:40:39 +1100 Subject: [PATCH 204/420] Avoid testing for nested braces in computed keys Resolves #493. --- grammars/javascript.cson | 4 +- spec/javascript-spec.coffee | 84 ------------------------------------- 2 files changed, 2 insertions(+), 86 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 3cf4e8a7..23c6413b 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -472,12 +472,12 @@ ( \\b(get|set) # Property getter/setter: get foo(){} (?:\\s+|(?=\\[)) # Followed by whitespace or square bracket - )? + )?+ ( # Method name \\b[a-zA-Z_$][\\w$]* # Fixed name | \\[ # Computed property key - .*?[^\\[\\]\\s].*? # Contains at least one non-brace character + [^\\[\\]]++ # Contains at least one non-brace character \\] ) \\s*\\(\\s* # Start of arguments list diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 0d167cb4..8e4498e4 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1188,90 +1188,6 @@ describe "JavaScript grammar", -> expect(tokens[11]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'punctuation.definition.function.body.end.bracket.curly.js'] - {tokens} = grammar.tokenizeLine('get [ "Win" + bar[2] + quaz() ](){ }') - expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'keyword.operator.getter.js'] - expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.begin.bracket.square.js'] - expect(tokens[4]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[5]).toEqual value: 'Win', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js'] - expect(tokens[6]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(tokens[8]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] - expect(tokens[10]).toEqual value: 'bar', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'variable.parameter.property.js'] - expect(tokens[11]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] - expect(tokens[12]).toEqual value: '2', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'constant.numeric.decimal.js'] - expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] - expect(tokens[15]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] - expect(tokens[17]).toEqual value: 'quaz', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'entity.name.function.js'] - expect(tokens[18]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] - expect(tokens[19]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] - expect(tokens[21]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.end.bracket.square.js'] - expect(tokens[22]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] - expect(tokens[23]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.end.bracket.round.js'] - expect(tokens[24]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] - expect(tokens[26]).toEqual value: '}', scopes: ['source.js', 'punctuation.definition.function.body.end.bracket.curly.js'] - - {tokens} = grammar.tokenizeLine('get [\'string\' [ quaz()[2 + 2]] + this + "ABC" ](){ },') - expect(tokens[0]).toEqual value: 'get', scopes: ['source.js', 'meta.function.method.definition.js', 'keyword.operator.getter.js'] - expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.begin.bracket.square.js'] - expect(tokens[3]).toEqual value: '\'', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] - expect(tokens[4]).toEqual value: 'string', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js'] - expect(tokens[5]).toEqual value: '\'', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] - expect(tokens[7]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] - expect(tokens[9]).toEqual value: 'quaz', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'entity.name.function.js'] - expect(tokens[10]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] - expect(tokens[11]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] - expect(tokens[12]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] - expect(tokens[13]).toEqual value: '2', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'constant.numeric.decimal.js'] - expect(tokens[15]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] - expect(tokens[17]).toEqual value: '2', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'constant.numeric.decimal.js'] - expect(tokens[18]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] - expect(tokens[19]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] - expect(tokens[21]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] - expect(tokens[23]).toEqual value: 'this', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'variable.language.js'] - expect(tokens[25]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] - expect(tokens[27]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[28]).toEqual value: 'ABC', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js'] - expect(tokens[29]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(tokens[31]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.end.bracket.square.js'] - expect(tokens[32]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] - expect(tokens[33]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.end.bracket.round.js'] - expect(tokens[34]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] - expect(tokens[36]).toEqual value: '}', scopes: ['source.js', 'punctuation.definition.function.body.end.bracket.curly.js'] - expect(tokens[37]).toEqual value: ',', scopes: ['source.js', 'meta.delimiter.object.comma.js'] - - {tokens} = grammar.tokenizeLine('set [\'string\' + ([ quaz()[2 + 2]]) + this + "ABC" ](k = 2){ }') - expect(tokens[0]).toEqual value: 'set', scopes: ['source.js', 'meta.function.method.definition.js', 'keyword.operator.setter.js'] - expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.begin.bracket.square.js'] - expect(tokens[3]).toEqual value: '\'', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js', 'punctuation.definition.string.begin.js'] - expect(tokens[4]).toEqual value: 'string', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js'] - expect(tokens[5]).toEqual value: '\'', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.single.js', 'punctuation.definition.string.end.js'] - expect(tokens[7]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] - expect(tokens[9]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.round.js'] - expect(tokens[10]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] - expect(tokens[12]).toEqual value: 'quaz', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'entity.name.function.js'] - expect(tokens[13]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] - expect(tokens[14]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] - expect(tokens[15]).toEqual value: '[', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] - expect(tokens[16]).toEqual value: '2', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'constant.numeric.decimal.js'] - expect(tokens[18]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] - expect(tokens[20]).toEqual value: '2', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'constant.numeric.decimal.js'] - expect(tokens[21]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] - expect(tokens[22]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.square.js'] - expect(tokens[23]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'meta.brace.round.js'] - expect(tokens[25]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] - expect(tokens[27]).toEqual value: 'this', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'variable.language.js'] - expect(tokens[29]).toEqual value: '+', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'keyword.operator.js'] - expect(tokens[31]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[32]).toEqual value: 'ABC', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js'] - expect(tokens[33]).toEqual value: '"', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(tokens[35]).toEqual value: ']', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.computed-key.js', 'punctuation.definition.computed-key.end.bracket.square.js'] - expect(tokens[36]).toEqual value: '(', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.begin.bracket.round.js'] - expect(tokens[37]).toEqual value: 'k', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'variable.parameter.function.js'] - expect(tokens[39]).toEqual value: '=', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'keyword.operator.assignment.js'] - expect(tokens[41]).toEqual value: '2', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'constant.numeric.decimal.js'] - expect(tokens[42]).toEqual value: ')', scopes: ['source.js', 'meta.function.method.definition.js', 'meta.parameters.js', 'punctuation.definition.parameters.end.bracket.round.js'] - expect(tokens[43]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] - expect(tokens[45]).toEqual value: '}', scopes: ['source.js', 'punctuation.definition.function.body.end.bracket.curly.js'] - it "tokenizes constructors", -> {tokens} = grammar.tokenizeLine('constructor(p1, p2) { this.p1 = p1; }') expect(tokens[0]).toEqual value: 'constructor', scopes: ['source.js', 'meta.function.js', 'entity.name.function.constructor.js'] From 2eb3d6cf101a6044ec168405b2dbbb30f3c73982 Mon Sep 17 00:00:00 2001 From: Wliu Date: Mon, 27 Feb 2017 11:11:49 -0500 Subject: [PATCH 205/420] Prepare 0.126.1 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0666ee01..e2edc106 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.126.0", + "version": "0.126.1", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From ddc0238793c53205b3a5510448d400422293394d Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 28 Feb 2017 22:45:30 +1100 Subject: [PATCH 206/420] Torch old JSDoc patterns and refine scope-names See https://gist.github.com/infininight/9392d1e4408d507a4691e3daba9b3ec9 --- grammars/javascript.cson | 394 ++------------------------------------- 1 file changed, 12 insertions(+), 382 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 23c6413b..b94d9bef 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1883,401 +1883,31 @@ ] } ] - 'docblock': + 'comments': 'patterns': [ { - 'match': '''(?x) (? # {Array} or {Object} type application (optional .) - ) - (?: - [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback - [a-zA-Z_$]+ - (?: - (?: - [\\w$]* - (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers - ) | - \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) - ) - )* - \\) | - [a-zA-Z_$]+ - (?: - (?: - [\\w$]* - (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers - ) | - \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) - ) - (?: - [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback - [a-zA-Z_$]+ - (?: - [\\w$]* | - \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) - ) - )* - ) - ) - # Check for suffix - (?:\\[\\])? # {string[]} type application, an array of strings - =? # {string=} optional parameter - ) - )}) - \\s+ - ( - \\[ # [foo] optional parameter - \\s* - (?: - [a-zA-Z_$][\\w$]* - (?: - (?:\\[\\])? # Foo[].bar properties within an array - \\. # Foo.Bar namespaced parameter - [a-zA-Z_$][\\w$]* - )* - (?: - \\s* - = # [foo=bar] Default parameter value - \\s* - (?: - [\\w$.\\s]* | # [foo=bar] Unquoted - "[^"]*" | # [foo="bar"] Double-quoted - '[^']*' | # [foo='bar'] Single-quoted - {[^{}]*} | # [foo={a:1}] Object literal - \\[ [^\\[\\]]* \\] # [foo=[1,2]] Array literal - ) - )? - ) - \\s* - \\] | - (?: - [a-zA-Z_$][\\w$]* - (?: - (?:\\[\\])? # Foo[].bar properties within an array - \\. # Foo.Bar namespaced parameter - [a-zA-Z_$][\\w$]* - )* - )? - ) - \\s+ - (?:-\\s+)? # optional hyphen before the description - ((?:(?!\\*\\/).)*) # The type description - ''' - 'captures': - '0': - 'name': 'other.meta.jsdoc' - '1': - 'name': 'entity.name.type.instance.jsdoc' - '2': - 'name': 'variable.other.jsdoc' - '3': - 'name': 'other.description.jsdoc' - 'patterns': [ - { - 'include': '#docblock' - } - ] - } - { - 'match': '''(?x) - ({(?: - \\* | # {*} any type - \\? | # {?} unknown type - - (?: - (?: # Check for a prefix - \\? | # {?string} nullable type - ! | # {!string} non-nullable type - \\.{3} # {...string} variable number of parameters - [*?]? # {...*} Variable number of mixed types - )? - - (?: - (?: - function # {function(string, number)} function type - \\s* - (?: - (?: - \\(\\s* - \\.{3}[a-zA-Z_$][\\w$]+ # {function(...string)} variable number of parameters - \\s*\\) - ) - | - (?: - \\(\\s* - (?: - (?:\\?|!)? # {function(?string)} or function(!string)} nullable/non-nullable type - [a-zA-Z_$][\\w$]+ - (?:\\[\\])? # {function(string[])} type application, an array of strings - (?: - (?: - (?: - \\s*,\\s* - (?:\\?|!)? # {function(?string)} or function(!string)} nullable/non-nullable type - [a-zA-Z_$][\\w$]+ - (?:\\[\\])? # {function(string[])} type application, an array of strings - )* - (?: - \\s*,\\s* - \\.{3}[a-zA-Z_$][\\w$]+ # {function(string, ...string)} variable number of parameters - )? - ) - | - (?: - =? # {function(string=)} optional parameter - (?: - (? # {Array} or {Object} type application (optional .) - ) - (?: - [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback - [a-zA-Z_$]+ - (?: - (?: - [\\w$]* - (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers - ) | - \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) - ) - )* - \\) | - [a-zA-Z_$]+ - (?: - (?: - [\\w$]* - (?:\\[\\])? # {(string|number[])} type application, a string or an array of numbers - ) | - \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) - ) - (?: - [\\.|~] # {Foo.bar} namespaced, {string|number} multiple, {Foo~bar} class-specific callback - [a-zA-Z_$]+ - (?: - [\\w$]* | - \\.?<[\\w$]+(?:,\\s+[\\w$]+)*> # {Array} or {Object} type application (optional .) - ) - )* - ) - ) - # Check for suffix - (?:\\[\\])? # {string[]} type application, an array of strings - =? # {string=} optional parameter - ) - )}) - \\s+ - (?:-\\s+)? # optional hyphen before the description - ((?:(?!\\*\\/).)*) # The type description - ''' 'captures': - '0': - 'name': 'other.meta.jsdoc' '1': - 'name': 'entity.name.type.instance.jsdoc' + 'name': 'punctuation.section.begin.comment.js' '2': - 'name': 'other.description.jsdoc' - 'patterns': [ - { - 'include': '#docblock' - } - ] + 'name': 'punctuation.section.end.comment.js' + 'match': '(/\\*)(\\*/)' + 'name': 'comment.block.empty.js' } - ] - 'comments': - 'patterns': [ { - 'begin': '/\\*\\*(?!/)' + 'begin': '/\\*\\*' 'beginCaptures': '0': - 'name': 'punctuation.definition.comment.js' + 'name': 'punctuation.section.begin.comment.js' + 'contentName': 'source.js.embedded.source' 'end': '\\*/' 'endCaptures': '0': - 'name': 'punctuation.definition.comment.js' + 'name': 'punctuation.section.end.comment.js' 'name': 'comment.block.documentation.js' 'patterns': [ { - 'include': '#docblock' + 'include': 'source.jsdoc' } ] } @@ -2285,11 +1915,11 @@ 'begin': '/\\*' 'beginCaptures': '0': - 'name': 'punctuation.definition.comment.js' + 'name': 'punctuation.section.begin.comment.js' 'end': '\\*/' 'endCaptures': '0': - 'name': 'punctuation.definition.comment.js' + 'name': 'punctuation.section.end.comment.js' 'name': 'comment.block.js' } { From 91753756badad142b7eec4b5c8640418fb4c8e50 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 28 Feb 2017 23:15:06 +1100 Subject: [PATCH 207/420] Remove mention of "embedded" scope in JSDoc blocks This could risk triggering incorrect highlighting if a theme colours the contents of interpolated `${ literal }` sequences. --- grammars/javascript.cson | 1 - 1 file changed, 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index b94d9bef..baa68a9e 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1899,7 +1899,6 @@ 'beginCaptures': '0': 'name': 'punctuation.section.begin.comment.js' - 'contentName': 'source.js.embedded.source' 'end': '\\*/' 'endCaptures': '0': From d160eced76c17ba60c28b4e6ce4643ea38b87d21 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 4 Mar 2017 00:40:12 +1100 Subject: [PATCH 208/420] Add JSDoc grammar --- grammars/jsdoc.cson | 474 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 474 insertions(+) create mode 100644 grammars/jsdoc.cson diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson new file mode 100644 index 00000000..5a942318 --- /dev/null +++ b/grammars/jsdoc.cson @@ -0,0 +1,474 @@ +'scopeName': 'source.jsdoc' +'name': 'JSDoc' +'patterns': [ + { + # @access private|protected|public + 'captures': + '1': + 'name': 'storage.type.class.jsdoc' + '2': + 'name': 'punctuation.definition.block.tag.jsdoc' + '3': + 'name': 'constant.language.access-type.jsdoc' + 'match': '''(?x) + ((@)access) + \\s+ + (private|protected|public) + \\b + ''' + } + { + # @author name [] + 'match': '''(?x) + ((@)author) + \\s+ + ( + [^@\\s<>*/] + (?:[^@<>*/]|\\*[^/])*+ + ) + (?: + \\s* + (<) + ([^>\\s]++) + (>) + )? + ''' + 'captures': + '1': + 'name': 'storage.type.class.jsdoc' + '2': + 'name': 'punctuation.definition.block.tag.jsdoc' + '3': + 'name': 'entity.name.type.instance.jsdoc' + '4': + 'name': 'punctuation.definition.begin.jsdoc' + '5': + 'name': 'constant.other.email.link.underline.jsdoc' + '6': + 'name': 'punctuation.definition.end.jsdoc' + } + { + # @borrows as + 'match': '''(?x) + ((@)borrows) \\s+ + ((?:[^@\\s*/]|\\*[^/])++) # + \\s++ (as) \\s++ # as + ((?:[^@\\s*/]|\\*[^/])++) # + ''' + 'captures': + '1': + 'name': 'storage.type.class.jsdoc' + '2': + 'name': 'punctuation.definition.block.tag.jsdoc' + '3': + 'name': 'entity.name.type.instance.jsdoc' + '4': + 'name': 'keyword.operator.control.jsdoc' + '5': + 'name': 'entity.name.type.instance.jsdoc' + } + { + # @example text(); + 'name': 'meta.example.jsdoc' + 'begin': '((@)example)\\s+' + 'end': '(?=@|\\*/)' + 'beginCaptures': + '1': + 'name': 'storage.type.class.jsdoc' + '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(>)' + 'beginCaptures': + '0': + 'name': 'entity.name.tag.inline.jsdoc' + '1': + 'name': 'punctuation.definition.bracket.angle.begin.jsdoc' + '2': + 'name': 'punctuation.definition.bracket.angle.end.jsdoc' + 'contentName': 'constant.other.description.jsdoc' + 'end': '()|(?=\\*/)' + 'endCaptures': + '0': + 'name': 'entity.name.tag.inline.jsdoc' + '1': + 'name': 'punctuation.definition.bracket.angle.begin.jsdoc' + '2': + 'name': 'punctuation.definition.bracket.angle.end.jsdoc' + } + { + # Highlighted JavaScript example + 'match': '[^\\s@*](?:[^*]|\\*[^/])*+' + 'captures': + '0': + 'name': 'source.embedded.js' + 'patterns': [ + { + 'include': 'source.js' + } + ] + } + ] + } + { + # @kind type + 'captures': + '1': + 'name': 'storage.type.class.jsdoc' + '2': + 'name': 'punctuation.definition.block.tag.jsdoc' + '3': + 'name': 'constant.language.symbol-type.jsdoc' + 'match': '''(?x) + ((@)kind) + \\s+ + (class|constant|event|external|file|function|member|mixin|module|namespace|typedef) + \\b + ''' + } + { + # @see namepathOrURL + 'captures': + '1': + 'name': 'storage.type.class.jsdoc' + '2': + 'name': 'punctuation.definition.block.tag.jsdoc' + '3': + 'name': 'variable.other.link.underline.jsdoc' + '4': + 'name': 'entity.name.type.instance.jsdoc' + 'match': '''(?x) + ((@)see) + \\s+ + (?: + # URL + ( + (?=https?://) + (?:[^\\s*]|\\*[/])+ + ) + | + # JSDoc namepath + ( + (?!https?://) + (?:[^@\\s*/]|\\*[^/])++ + ) + ) + ''' + } + { + # @template Foo,Bar + 'captures': + '1': + 'name': 'storage.type.class.jsdoc' + '2': + 'name': 'punctuation.definition.block.tag.jsdoc' + '3': + 'name': 'variable.other.jsdoc' + 'match': '''(?x) + ((@)template) + \\s+ + # One or more valid identifiers + ( + [A-Za-z_$] # First character: non-numeric word character + [\\w$.\\[\\]]* # Rest of identifier + (?: # Possible list of additional identifiers + \\s* , \\s* + [A-Za-z_$] + [\\w$.\\[\\]]* + )* + ) + ''' + } + { + # Tags followed by an identifier token + # - @ identifier + 'captures': + '1': + 'name': 'storage.type.class.jsdoc' + '2': + 'name': 'punctuation.definition.block.tag.jsdoc' + '3': + 'name': 'variable.other.jsdoc' + 'match': '''(?x) + ( + (@) + (?:arg|argument|const|constant|member|namespace|param|var) + ) + \\s+ + ( + [A-Za-z_$] + [\\w$.\\[\\]]* + ) + ''' + } + { + # Tags followed by a type expression, then a namepath + # - @ {type} namepath + 'begin': '((@)typedef)\\s+(?={)' + 'beginCaptures': + '1': + 'name': 'storage.type.class.jsdoc' + '2': + 'name': 'punctuation.definition.block.tag.jsdoc' + 'end': '(?=\\s|\\*/|[^{}\\[\\]A-Za-z_$])' + 'patterns': [ + { + 'include': '#type' + } + { + 'name': 'entity.name.type.instance.jsdoc' + 'match': '(?:[^@\\s*/]|\\*[^/])++' + } + ] + } + { + # Tags followed by a type expression, then an identifier + # - @ {type} identifier + 'begin': '((@)(?:arg|argument|const|constant|member|namespace|param|prop|property|var))\\s+(?={)' + 'beginCaptures': + '1': 'name': 'storage.type.class.jsdoc' + '2': 'name': 'punctuation.definition.block.tag.jsdoc' + 'end': '(?=\\s|\\*/|[^{}\\[\\]A-Za-z_$])' + 'patterns': [ + { + 'include': '#type' + } + { + 'match': '([A-Za-z_$][\\w$.\\[\\]]*)' + 'name': 'variable.other.jsdoc' + } + { + 'name': 'variable.other.jsdoc' + 'begin': '\\[' + 'end': '\\]|(?=\\*/)' + 'patterns': [ + { + 'include': '#brackets' + } + { + 'include': '#quotes' + } + ] + } + ] + } + { + # Tags followed by a type expression + # - @ {type} + 'begin': '((@)(?:define|enum|exception|implements|modifies|namespace|private|protected|returns?|suppress|throws|type))\\s+(?={)' + 'beginCaptures': + '1': + 'name': 'storage.type.class.jsdoc' + '2': + 'name': 'punctuation.definition.block.tag.jsdoc' + 'end': '(?=\\s|\\*/|[^{}\\[\\]A-Za-z_$])' + 'patterns': [ + { + 'include': '#type' + } + ] + } + { + # Tags followed by a namepath + # - @ namepath + 'captures': + '1': + 'name': 'storage.type.class.jsdoc' + '2': + 'name': 'punctuation.definition.block.tag.jsdoc' + '3': + 'name': 'entity.name.type.instance.jsdoc' + 'match': '''(?x) + ( + (@) + (?:alias|augments|callback|constructs|emits|event|fires|exports? + |extends|external|function|func|host|lends|listens|interface|memberof!? + |method|module|mixes|mixin|name|requires|see|this|typedef|uses) + ) + \\s+ + ( + (?: + [^{}@\\s*] | \\*[^/] + )+ + ) + ''' + } + { + # Tags followed by a quoted arbitrary value + # - @ "Quoted value" + 'begin': '((@)(?:default(?:value)?|license|version))\\s+([\'"])' + 'beginCaptures': + '1': + 'name': 'storage.type.class.jsdoc' + '2': + 'name': 'punctuation.definition.block.tag.jsdoc' + '3': + 'name': 'variable.other.jsdoc' + 'contentName': 'variable.other.jsdoc' + 'end': '\\3|(?=$|\\*/)' + 'endCaptures': + '0': + 'name': 'variable.other.jsdoc' + } + { + # Tags followed by an arbitrary value + # - @ value + 'captures': + '1': + 'name': 'storage.type.class.jsdoc' + '2': + 'name': 'punctuation.definition.block.tag.jsdoc' + '3': + 'name': 'variable.other.jsdoc' + 'match': '((@)(?:default(?:value)?|license|tutorial|variation|version))\\s+([^\\s*]+)' + } + { + # Tags without arguments, or a tag without expected arguments. Because JSDoc permits + # tags to be spread across lines, we should at least highlight the opening tag for + # stuff like this: + # + # /** + # * @param + # * {type} + # * name + 'captures': + '1': + 'name': 'punctuation.definition.block.tag.jsdoc' + 'match': '''(?x) (@) + (?:abstract|access|alias|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) + \\b + ''' + 'name': 'storage.type.class.jsdoc' + } + { + # Description preceding {@inline tag} + 'captures': + '1': + 'name': 'punctuation.definition.bracket.square.begin.jsdoc' + '2': + 'name': 'punctuation.definition.bracket.square.end.jsdoc' + 'match': '(\\[)[^\\]]+(\\])(?={@(?:link|linkcode|linkplain|tutorial))' + 'name': 'constant.other.description.jsdoc' + } + { + # {@link|tutorial …} + 'begin': '({@)(?:link|linkcode|linkplain|tutorial)\\s*' + 'beginCaptures': + '0': + 'name': 'storage.type.class.jsdoc' + '1': + 'name': 'punctuation.definition.inline.tag.begin.jsdoc' + 'end': '}|(?=\\*/)' + 'endCaptures': + '0': + 'name': 'punctuation.definition.inline.tag.end.jsdoc' + 'name': 'entity.name.type.instance.jsdoc' + 'patterns': [ + { + 'captures': + '1': + 'name': 'variable.other.link.underline.jsdoc' + '2': + 'name': 'punctuation.separator.pipe.jsdoc' + 'match': '\\G((?=https?://)(?:[^|}\\s*]|\\*[/])+)(\\|)?' + } + { + 'captures': + '1': + 'name': 'variable.other.description.jsdoc' + '2': + 'name': 'punctuation.separator.pipe.jsdoc' + 'match': '\\G((?:[^{}@\\s|*]|\\*[^/])+)(\\|)?' + } + ] + } +] + +'repository': + + # Balanced brackets (square or curly) + 'brackets': + 'patterns': [ + { + 'begin': '{' + 'end': '}|(?=\\*/)' + 'patterns': [ + { + 'include': '#brackets' + } + ] + } + { + 'begin': '\\[' + 'end': '\\]|(?=\\*/)' + 'patterns': [ + { + 'include': '#brackets' + } + ] + } + ] + + # Balanced quotes + 'quotes': + 'patterns': [ + { + 'begin': "'" + 'end': "'|(?=\\*/)" + 'patterns': [ + { + 'include': '#quotes' + } + ] + } + { + 'begin': '"' + 'end': '"|(?=\\*/)' + 'patterns': [ + { + 'include': '#quotes' + } + ] + } + ] + + # {type} + 'type': + 'patterns': [ + { + # {unclosed + 'match': '\\G{[^}]+$' + 'name': 'invalid.illegal.type.jsdoc' + } + { + 'begin': '\\G{' + 'beginCaptures': + '0': + 'name': 'punctuation.definition.bracket.curly.begin.jsdoc' + 'end': '}\\s*|(?=\\*/)' + 'endCaptures': + '0': + 'name': 'punctuation.definition.bracket.curly.end.jsdoc' + 'name': 'entity.name.type.instance.jsdoc' + 'patterns': [ + { + 'include': '#brackets' + } + ] + } + ] From f3d508ed859d996e9246cd219730ceca909f7e38 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 4 Mar 2017 01:14:39 +1100 Subject: [PATCH 209/420] Remove {type} scope from trailing whitespace --- grammars/jsdoc.cson | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index 5a942318..be490dd8 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -456,15 +456,19 @@ 'name': 'invalid.illegal.type.jsdoc' } { - 'begin': '\\G{' + 'begin': '\\G({)' 'beginCaptures': '0': + 'name': 'entity.name.type.instance.jsdoc' + '1': 'name': 'punctuation.definition.bracket.curly.begin.jsdoc' - 'end': '}\\s*|(?=\\*/)' + 'contentName': 'entity.name.type.instance.jsdoc' + 'end': '((}))\\s*|(?=\\*/)' 'endCaptures': - '0': + '1': + 'name': 'entity.name.type.instance.jsdoc' + '2': 'name': 'punctuation.definition.bracket.curly.end.jsdoc' - 'name': 'entity.name.type.instance.jsdoc' 'patterns': [ { 'include': '#brackets' From 07439aec5ec129cb356e97c95cec616a4e323c21 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 4 Mar 2017 02:40:10 +1100 Subject: [PATCH 210/420] Fix specs and matching of empty /**/ tokens --- grammars/javascript.cson | 4 +- spec/javascript-spec.coffee | 624 ++------------------- spec/jsdoc-spec.coffee | 1020 +++++++++++++++++++++++++++++++++++ 3 files changed, 1052 insertions(+), 596 deletions(-) create mode 100644 spec/jsdoc-spec.coffee diff --git a/grammars/javascript.cson b/grammars/javascript.cson index baa68a9e..9e10cc5e 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1891,8 +1891,8 @@ 'name': 'punctuation.section.begin.comment.js' '2': 'name': 'punctuation.section.end.comment.js' - 'match': '(/\\*)(\\*/)' - 'name': 'comment.block.empty.js' + 'match': '(/\\*)(\\*/)' + 'name': 'comment.block.empty.js' } { 'begin': '/\\*\\*' diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 8e4498e4..dcc46f90 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -843,14 +843,14 @@ describe "JavaScript grammar", -> member2 } from "module-name"; ''' - expect(lines[0][2]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[0][2]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] expect(lines[0][3]).toEqual value: ' comment ', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] - expect(lines[0][4]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[0][4]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.section.end.comment.js'] expect(lines[1][4]).toEqual value: '//', scopes: ['source.js', 'meta.import.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] expect(lines[1][5]).toEqual value: ' comment', scopes: ['source.js', 'meta.import.js', 'comment.line.double-slash.js'] - expect(lines[2][1]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[2][1]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] expect(lines[2][2]).toEqual value: ' comment ', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] - expect(lines[2][3]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[2][3]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.section.end.comment.js'] # https://github.com/atom/language-javascript/issues/485 lines = grammar.tokenizeLines ''' @@ -966,17 +966,17 @@ describe "JavaScript grammar", -> ''' expect(lines[1][4]).toEqual value: '//', scopes: ['source.js', 'meta.export.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] expect(lines[1][5]).toEqual value: ' comment', scopes: ['source.js', 'meta.export.js', 'comment.line.double-slash.js'] - expect(lines[2][1]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[2][1]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] expect(lines[2][2]).toEqual value: ' comment ', scopes: ['source.js', 'meta.export.js', 'comment.block.js'] - expect(lines[2][3]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[2][3]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.section.end.comment.js'] {tokens} = grammar.tokenizeLine('export {member1, /* comment */ member2} /* comment */ from "module";') - expect(tokens[6]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[6]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] expect(tokens[7]).toEqual value: ' comment ', scopes: ['source.js', 'meta.export.js', 'comment.block.js'] - expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(tokens[13]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.section.end.comment.js'] + expect(tokens[13]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] expect(tokens[14]).toEqual value: ' comment ', scopes: ['source.js', 'meta.export.js', 'comment.block.js'] - expect(tokens[15]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[15]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.section.end.comment.js'] it "tokenizes default class export", -> {tokens} = grammar.tokenizeLine('export default class {}') @@ -1668,587 +1668,23 @@ describe "JavaScript grammar", -> it "tokenizes /* */ comments", -> {tokens} = grammar.tokenizeLine('/**/') - expect(tokens[0]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(tokens[1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/*', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.section.begin.comment.js'] + expect(tokens[1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.section.end.comment.js'] {tokens} = grammar.tokenizeLine('/* foo */') - expect(tokens[0]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] expect(tokens[1]).toEqual value: ' foo ', scopes: ['source.js', 'comment.block.js'] - expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.section.end.comment.js'] it "tokenizes /** */ comments", -> {tokens} = grammar.tokenizeLine('/***/') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - expect(tokens[1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] {tokens} = grammar.tokenizeLine('/** foo */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] expect(tokens[1]).toEqual value: ' foo ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - - {tokens} = grammar.tokenizeLine('/** @mixins */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - expect(tokens[2]).toEqual value: '@mixins', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] - expect(tokens[3]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[4]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - - it "tokenizes JSDoc comment documentation", -> - {tokens} = grammar.tokenizeLine('/** @const {object} */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @define {object} */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** Text {@link target} text */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[3]).toEqual value: '@link', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[5]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[6]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: ' text ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - - {tokens} = grammar.tokenizeLine('/** Text {@linkplain target|Description text} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[3]).toEqual value: '@linkplain', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[5]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[6]).toEqual value: '|Description text}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - - {tokens} = grammar.tokenizeLine('/** Text {@linkcode target Description text} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[3]).toEqual value: '@linkcode', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[5]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[6]).toEqual value: ' Description text}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - - {tokens} = grammar.tokenizeLine('/** Text [Description text]{@link target} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[2]).toEqual value: '[Description text]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'constant.other.description.jsdoc'] - expect(tokens[3]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[4]).toEqual value: '@link', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[5]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - - {tokens} = grammar.tokenizeLine('/** Text [Description text]{@tutorial target|Description} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - expect(tokens[1]).toEqual value: ' Text [Description text]', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[3]).toEqual value: '@tutorial', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[5]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[6]).toEqual value: '|Description}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - - {tokens} = grammar.tokenizeLine('/** @param {object} */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} variable */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} variable this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @arg {object} variable this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @argument {object} variable this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is the description */') - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} $variable this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '$variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [variable] this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[variable]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [ variable ] this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[ variable ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [variable=default value] this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[variable=default value]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [variable = default value] this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[variable = default value]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [ variable = default value ] this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[ variable = default value ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine '/** @param {object} [variable=default.value] this is the description */' - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[variable=default.value]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [variable="default value"] this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[variable="default value"]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [variable = "default value"] this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[variable = "default value"]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [ variable = " default value " ] this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[ variable = " default value " ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine("/** @param {object} [variable='default value'] this is the description */") - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: "[variable='default value']", scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine("/** @param {object} [variable = 'default value'] this is the description */") - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: "[variable = 'default value']", scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine("/** @param {object} [ variable = ' default value ' ] this is the description */") - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: "[ variable = ' default value ' ]", scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Object} [variable={a: "b"}] - An object */') - expect(tokens[4]).toEqual value: '{Object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[variable={a: "b"}]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] - expect(tokens[8]).toEqual value: 'An object ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Object} [ variable = { a : "b" } ] - An object */') - expect(tokens[4]).toEqual value: '{Object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[ variable = { a : "b" } ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] - expect(tokens[8]).toEqual value: 'An object ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Array} [variable=[1,2,3]] - An array */') - expect(tokens[4]).toEqual value: '{Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[variable=[1,2,3]]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] - expect(tokens[8]).toEqual value: 'An array ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Array} [ variable = [ 1 , 2 , 3 ] ] - An array */') - expect(tokens[4]).toEqual value: '{Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[ variable = [ 1 , 2 , 3 ] ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] - expect(tokens[8]).toEqual value: 'An array ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Object} [variable={}] - Empty object */') - expect(tokens[4]).toEqual value: '{Object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[variable={}]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] - expect(tokens[8]).toEqual value: 'Empty object ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Object} [ variable = { } ] - Empty object */') - expect(tokens[4]).toEqual value: '{Object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[ variable = { } ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] - expect(tokens[8]).toEqual value: 'Empty object ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Array} [variable=[]] - Empty array */') - expect(tokens[4]).toEqual value: '{Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[variable=[]]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] - expect(tokens[8]).toEqual value: 'Empty array ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Array} [ variable = [ ] ] - Empty array */') - expect(tokens[4]).toEqual value: '{Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[ variable = [ ] ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[7]).toEqual value: ' - ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc'] - expect(tokens[8]).toEqual value: 'Empty array ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a {@link linked} description */') - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is a ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - expect(tokens[9]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[10]).toEqual value: '@link', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[12]).toEqual value: 'linked', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[14]).toEqual value: ' description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a {@link linked#description}. */') - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is a ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - expect(tokens[9]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[10]).toEqual value: '@link', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[12]).toEqual value: 'linked#description', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[14]).toEqual value: '. ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a [description with a]{@link example}. */') - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is a ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - expect(tokens[9]).toEqual value: '[description with a]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'constant.other.description.jsdoc'] - expect(tokens[10]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[11]).toEqual value: '@link', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[13]).toEqual value: 'example', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[14]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[15]).toEqual value: '. ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} parameter.property this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'parameter.property', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [parameter.property] this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[parameter.property]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [ parameter.property ] this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[ parameter.property ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [parameter.property=default value] this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[parameter.property=default value]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [parameter.property = default value] this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[parameter.property = default value]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {object} [ parameter.property = default value ] this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: '[ parameter.property = default value ]', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {*} variable this is the description */') - expect(tokens[4]).toEqual value: '{*}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {?} variable this is the description */') - expect(tokens[4]).toEqual value: '{?}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {myNamespace.MyClass} variable this is the description */') - expect(tokens[4]).toEqual value: '{myNamespace.MyClass}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @type {function|string} variable this is the description */') - expect(tokens[4]).toEqual value: '{function|string}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {string[]|number} variable this is the description */') - expect(tokens[4]).toEqual value: '{string[]|number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {string|number[]} variable this is the description */') - expect(tokens[4]).toEqual value: '{string|number[]}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {(number|function)} variable this is the description */') - expect(tokens[2]).toEqual value: '@param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] - expect(tokens[4]).toEqual value: '{(number|function)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {(string[]|number)} variable this is the description */') - expect(tokens[4]).toEqual value: '{(string[]|number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {(string|number[])} variable this is the description */') - expect(tokens[4]).toEqual value: '{(string|number[])}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {?number} variable this is the description */') - expect(tokens[4]).toEqual value: '{?number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {!number} variable this is the description */') - expect(tokens[4]).toEqual value: '{!number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {...number} variable this is the description */') - expect(tokens[4]).toEqual value: '{...number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {...*} remainder */') - expect(tokens[2]).toEqual value: '@param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] - expect(tokens[4]).toEqual value: '{...*}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'remainder', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {...?} remainder */') - expect(tokens[2]).toEqual value: '@param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] - expect(tokens[4]).toEqual value: '{...?}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'remainder', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {number=} variable this is the description */') - expect(tokens[4]).toEqual value: '{number=}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {number[]} variable this is the description */') - expect(tokens[4]).toEqual value: '{number[]}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Foo[].bar} variable this is the description */') - expect(tokens[4]).toEqual value: '{Foo[].bar}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Array} variable this is the description */') - expect(tokens[4]).toEqual value: '{Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Array.} variable this is the description */') - expect(tokens[4]).toEqual value: '{Array.}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Array|Array} variable this is the description */') - expect(tokens[4]).toEqual value: '{Array|Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Array.|Array.} variable this is the description */') - expect(tokens[4]).toEqual value: '{Array.|Array.}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {(Array|Array)} variable this is the description */') - expect(tokens[4]).toEqual value: '{(Array|Array)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {(Array.|Array.)} variable this is the description */') - expect(tokens[4]).toEqual value: '{(Array.|Array.)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Object} variable this is the description */') - expect(tokens[4]).toEqual value: '{Object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Object.} variable this is the description */') - expect(tokens[4]).toEqual value: '{Object.}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Object|Array} variable this is the description */') - expect(tokens[4]).toEqual value: '{Object|Array}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Object.|Array.} variable this is the description */') - expect(tokens[4]).toEqual value: '{Object.|Array.}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {(Array|Object)} variable this is the description */') - expect(tokens[4]).toEqual value: '{(Array|Object)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {(Array.|Object.)} variable this is the description */') - expect(tokens[4]).toEqual value: '{(Array.|Object.)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {Foo~cb} variable this is the description */') - expect(tokens[4]).toEqual value: '{Foo~cb}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {function()} variable this is the description */') - expect(tokens[4]).toEqual value: '{function()}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {function ()} variable this is the description */') - expect(tokens[4]).toEqual value: '{function ()}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {function ( )} variable this is the description */') - expect(tokens[4]).toEqual value: '{function ( )}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {function(string)} variable this is the description */') - expect(tokens[4]).toEqual value: '{function(string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {function(string, number)} variable this is the description */') - expect(tokens[4]).toEqual value: '{function(string, number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {function(...string)} variable this is the description */') - expect(tokens[4]).toEqual value: '{function(...string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {function(string, ...number)} variable this is the description */') - expect(tokens[4]).toEqual value: '{function(string, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {function(string, number, ...number)} variable this is the description */') - expect(tokens[4]).toEqual value: '{function(string, number, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {function(!string)} variable this is the description */') - expect(tokens[4]).toEqual value: '{function(!string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {function(?string, !number)} variable this is the description */') - expect(tokens[4]).toEqual value: '{function(?string, !number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {function(string[], number=)} variable this is the description */') - expect(tokens[4]).toEqual value: '{function(string[], number=)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {function():number} variable this is the description */') - expect(tokens[4]).toEqual value: '{function():number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {function(string): number} variable this is the description */') - expect(tokens[4]).toEqual value: '{function(string): number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {function(string) : number} variable this is the description */') - expect(tokens[4]).toEqual value: '{function(string) : number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - expect(tokens[8]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {object} this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {Some|Thing} Something to return */') - expect(tokens[4]).toEqual value: '{Some|Thing}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {(String[]|Number[])} Description */') - expect(tokens[4]).toEqual value: '{(String[]|Number[])}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'Description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @param {(Number|Number[])} Numbers */') - expect(tokens[4]).toEqual value: '{(Number|Number[])}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'Numbers', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'variable.other.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {object} */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @returns {object} this is the description */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @returns {object} */') - expect(tokens[4]).toEqual value: '{object}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @returns {(Something)} */') - expect(tokens[4]).toEqual value: '{(Something)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {function()} this is the description */') - expect(tokens[4]).toEqual value: '{function()}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {function ()} this is the description */') - expect(tokens[4]).toEqual value: '{function ()}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {function ( )} this is the description */') - expect(tokens[4]).toEqual value: '{function ( )}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {function(string)} this is the description */') - expect(tokens[4]).toEqual value: '{function(string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {function(string, number)} this is the description */') - expect(tokens[4]).toEqual value: '{function(string, number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {function(...string)} this is the description */') - expect(tokens[4]).toEqual value: '{function(...string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {function(string, ...number)} this is the description */') - expect(tokens[4]).toEqual value: '{function(string, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {function(string, number, ...number)} this is the description */') - expect(tokens[4]).toEqual value: '{function(string, number, ...number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {function(!string)} this is the description */') - expect(tokens[4]).toEqual value: '{function(!string)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {function(?string, !number)} this is the description */') - expect(tokens[4]).toEqual value: '{function(?string, !number)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {function(string[], number=)} this is the description */') - expect(tokens[4]).toEqual value: '{function(string[], number=)}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {function():number} this is the description */') - expect(tokens[4]).toEqual value: '{function():number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {function(string): number} this is the description */') - expect(tokens[4]).toEqual value: '{function(string): number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] - - {tokens} = grammar.tokenizeLine('/** @return {function(string) : number} this is the description */') - expect(tokens[4]).toEqual value: '{function(string) : number}', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'entity.name.type.instance.jsdoc'] - expect(tokens[6]).toEqual value: 'this is the description ', scopes: ['source.js', 'comment.block.documentation.js', 'other.meta.jsdoc', 'other.description.jsdoc'] + expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') @@ -2266,25 +1702,25 @@ describe "JavaScript grammar", -> it "tokenizes comments inside function declarations", -> {tokens} = grammar.tokenizeLine('function /* */ foo() /* */ {}') expect(tokens[0]).toEqual value: 'function', scopes: ['source.js', 'meta.function.js', 'storage.type.function.js'] - expect(tokens[2]).toEqual value: '/*', scopes: ['source.js', 'meta.function.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(tokens[4]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[2]).toEqual value: '/*', scopes: ['source.js', 'meta.function.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] + expect(tokens[4]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'comment.block.js', 'punctuation.section.end.comment.js'] expect(tokens[6]).toEqual value: 'foo', scopes: ['source.js', 'meta.function.js', 'entity.name.function.js'] - expect(tokens[10]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(tokens[12]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[10]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] + expect(tokens[12]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.section.end.comment.js'] {tokens} = grammar.tokenizeLine('x => /* */ {}') expect(tokens[0]).toEqual value: 'x', scopes: ['source.js', 'meta.function.arrow.js', 'meta.parameters.js', 'variable.parameter.function.js'] expect(tokens[2]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.js', 'storage.type.function.arrow.js'] - expect(tokens[4]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(tokens[6]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[4]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] + expect(tokens[6]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.section.end.comment.js'] expect(tokens[8]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] {tokens} = grammar.tokenizeLine('.foo = x => /* */ {}') expect(tokens[1]).toEqual value: 'foo', scopes: ['source.js', 'meta.function.arrow.js', 'entity.name.function.js'] expect(tokens[5]).toEqual value: 'x', scopes: ['source.js', 'meta.function.arrow.js', 'meta.parameters.js', 'variable.parameter.function.js'] expect(tokens[7]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.js', 'storage.type.function.arrow.js'] - expect(tokens[9]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[9]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.section.end.comment.js'] expect(tokens[13]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] lines = grammar.tokenizeLines ''' @@ -2310,9 +1746,9 @@ describe "JavaScript grammar", -> it "tokenizes comments inside function parameters correctly", -> {tokens} = grammar.tokenizeLine('function test(p1 /*, p2 */) {}') - expect(tokens[6]).toEqual value: '/*', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[6]).toEqual value: '/*', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] expect(tokens[7]).toEqual value: ', p2 ', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js'] - expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.section.end.comment.js'] describe "console", -> it "tokenizes the console keyword", -> @@ -2337,8 +1773,8 @@ describe "JavaScript grammar", -> {tokens} = grammar.tokenizeLine('console/**/.log()') expect(tokens[0]).toEqual value: 'console', scopes: ['source.js', 'entity.name.type.object.console.js'] - expect(tokens[1]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[1]).toEqual value: '/*', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.section.begin.comment.js'] + expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.section.end.comment.js'] expect(tokens[3]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] expect(tokens[4]).toEqual value: 'log', scopes: ['source.js', 'meta.method-call.js', 'support.function.console.js'] expect(tokens[5]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee new file mode 100644 index 00000000..27100078 --- /dev/null +++ b/spec/jsdoc-spec.coffee @@ -0,0 +1,1020 @@ +describe "JSDoc", -> + grammar = null + + beforeEach -> + waitsForPromise -> + atom.packages.activatePackage("language-javascript") + + runs -> + grammar = atom.grammars.grammarForScopeName("source.js") + + it "tokenises simple tags", -> + {tokens} = grammar.tokenizeLine('/** @mixins */') + 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: 'mixins', 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: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @global @static */') + 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: 'global', 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: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(tokens[6]).toEqual value: 'static', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + 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'] + + describe "inline tags", -> + it "tokenises tags without descriptions", -> + {tokens} = grammar.tokenizeLine('/** Text {@link target} text */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[2]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] + expect(tokens[3]).toEqual value: 'link ', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[4]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[5]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.inline.tag.end.jsdoc'] + expect(tokens[6]).toEqual value: ' text ', 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 tags with an embedded trailing description", -> + {tokens} = grammar.tokenizeLine('/** Text {@linkplain target|Description text} */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[2]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] + expect(tokens[3]).toEqual value: 'link', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[4]).toEqual value: 'plain', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[5]).toEqual value: ' target|Description text', 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.inline.tag.end.jsdoc'] + expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** Text {@linkcode target Description text} */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[2]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] + expect(tokens[3]).toEqual value: 'link', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[4]).toEqual value: 'code', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[5]).toEqual value: ' target Description text', 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.inline.tag.end.jsdoc'] + expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + it "tokenises tags with a preceding description", -> + {tokens} = grammar.tokenizeLine('/** Text [Description text]{@link target} */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.begin.jsdoc'] + expect(tokens[3]).toEqual value: 'Description text', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc'] + expect(tokens[4]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.end.jsdoc'] + expect(tokens[5]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'link ', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[7]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[8]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.inline.tag.end.jsdoc'] + expect(tokens[10]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** Text [Description text]{@tutorial target|Description} */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.begin.jsdoc'] + expect(tokens[3]).toEqual value: 'Description text', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc'] + expect(tokens[4]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.end.jsdoc'] + expect(tokens[5]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] + expect(tokens[6]).toEqual value: 'tutorial ', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[7]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[8]).toEqual value: '|', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.separator.pipe.jsdoc'] + expect(tokens[9]).toEqual value: 'Description', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.inline.tag.end.jsdoc'] + expect(tokens[12]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + it "tokenises inline tags which follow block tags", -> + {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a {@link linked} 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' - this is a ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[11]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] + expect(tokens[12]).toEqual value: 'link ', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[13]).toEqual value: 'linked', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[14]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.inline.tag.end.jsdoc'] + expect(tokens[15]).toEqual value: ' description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[16]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a {@link linked#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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' - this is a ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[11]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] + expect(tokens[12]).toEqual value: 'link ', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[13]).toEqual value: 'linked#description', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[14]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.inline.tag.end.jsdoc'] + expect(tokens[15]).toEqual value: '. ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a [description with a]{@link example}. */') + 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' - this is a ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[11]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.begin.jsdoc'] + expect(tokens[12]).toEqual value: 'description with a', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc'] + expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.end.jsdoc'] + expect(tokens[14]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] + expect(tokens[15]).toEqual value: 'link ', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[16]).toEqual value: 'example', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[17]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.inline.tag.end.jsdoc'] + expect(tokens[18]).toEqual value: '. ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + describe "block tags", -> + 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'] + 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: 'const', 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: '{', 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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @define {object} */') + 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: 'define', 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'] + + it "tokenises unnamed @param tags", -> + {tokens} = grammar.tokenizeLine('/** @param {object} */') + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + it "tokenises @param tags", -> + {tokens} = grammar.tokenizeLine('/** @param {object} variable */') + 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + it "tokenises @param tags with a description", -> + {tokens} = grammar.tokenizeLine('/** @param {object} variable this is the 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @arg {object} variable this is the 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: 'arg', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @argument {object} variable this is the 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: 'argument', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is the 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' - this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @param {object} $variable this is the 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: '$variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + it "tokenises @param tags marked optional", -> + {tokens} = grammar.tokenizeLine('/** @param {object} [variable] this is the 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: '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'] + expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[13]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @param {object} [ variable ] this is the description */') + expect(tokens[3]).toEqual value: 'param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.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'] + 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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'variable=default value', 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'] + expect(tokens[12]).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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'variable = default value', 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'] + expect(tokens[12]).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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' variable = default value ', 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'] + expect(tokens[12]).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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: 'variable=default.value', 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'] + expect(tokens[12]).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'] + expect(tokens[12]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + 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', 'variable.other.jsdoc'] + expect(tokens[15]).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'] + expect(tokens[12]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + 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', 'variable.other.jsdoc'] + expect(tokens[15]).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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] + 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'] + expect(tokens[12]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + 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'] + expect(tokens[12]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + 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', 'variable.other.jsdoc'] + expect(tokens[15]).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'] + expect(tokens[12]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + 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', 'variable.other.jsdoc'] + expect(tokens[15]).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'] + expect(tokens[12]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + 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 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'] + expect(tokens[12]).toEqual value: 'a: "b"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + 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', 'variable.other.jsdoc'] + expect(tokens[15]).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'] + expect(tokens[12]).toEqual value: ' a : "b" ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[16]).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'] + expect(tokens[12]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[14]).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'] + expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[16]).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'] + expect(tokens[12]).toEqual value: '1,2,3', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + 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', 'variable.other.jsdoc'] + expect(tokens[15]).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'] + expect(tokens[12]).toEqual value: ' 1 , 2 , 3 ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[16]).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'] + expect(tokens[12]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[14]).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'] + expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + 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'] + + 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'] + 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: 'parameter.property', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {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'] + 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: 'parameter.property', 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'] + expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {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'] + 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: ' parameter.property ', 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'] + expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {object} [parameter.property=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: 'parameter.property=default value', 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'] + expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {object} [parameter.property = 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: 'parameter.property = default value', 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'] + expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {object} [ parameter.property = 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: ' parameter.property = default value ', 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'] + expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + it "tokenises @param tags with wildcard types", -> + {tokens} = grammar.tokenizeLine('/** @param {*} variable 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: '*', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {?} variable 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: '?', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + it "tokenises @param tags with qualified types", -> + {tokens} = grammar.tokenizeLine('/** @param {myNamespace.MyClass} variable this is the 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: 'myNamespace.MyClass', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Foo~cb} variable this is the 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: 'Foo~cb', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + it "tokenises @param tags with multiple types", -> + {tokens} = grammar.tokenizeLine('/** @param {function|string} variable 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: 'function|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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {string[]|number} variable this is the 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: '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'] + expect(tokens[8]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[9]).toEqual value: '|number', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[12]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {string|number[]} variable 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: 'string|number', 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'] + expect(tokens[8]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[11]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {(number|function)} variable this is the description */') + 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: '(number|function)', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {(string[]|number)} variable this is the 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: '(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'] + expect(tokens[8]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[9]).toEqual value: '|number)', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[12]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[14]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @param {(string|number[])} variable 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: '(string|number', 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'] + expect(tokens[8]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[9]).toEqual value: ')', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[12]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + it "tokenises @param tags marked nullable or non-nullable", -> + {tokens} = grammar.tokenizeLine('/** @param {?number} variable this is the description */') + 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: '?number', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {!number} variable this is the description */') + 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: '!number', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + it "tokenises @param tags marked as variable-length", -> + {tokens} = grammar.tokenizeLine('/** @param {...number} variable this is the description */') + 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: '...number', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {...*} remainder */') + 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: '...*', 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: 'remainder', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @param {...?} remainder */') + 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: '...?', 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: 'remainder', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + it "tokenises @param tags using Google Closure Compiler syntax", -> + {tokens} = grammar.tokenizeLine('/** @param {number=} variable 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: 'number=', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {number[]} variable this is the description */') + 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: 'number', 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'] + expect(tokens[8]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[11]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {Foo[].bar} variable this is the 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: 'Foo', 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'] + expect(tokens[8]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[9]).toEqual value: '.bar', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[12]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[14]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Array} variable this is the description */') + 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: '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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {Array.} variable this is the description */') + 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: '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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Array|Array} variable this is the description */') + 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: 'Array|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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Array.|Array.} variable this is the description */') + 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: 'Array.|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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {(Array|Array)} variable this is the description */') + 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: '(Array|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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {(Array.|Array.)} variable this is the description */') + 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: '(Array.|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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Object} variable this is the description */') + 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Object.} variable this is the description */') + 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Object|Array} variable this is the description */') + 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|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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Object.|Array.} variable this is the description */') + 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.|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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + {tokens} = grammar.tokenizeLine('/** @param {(Array|Object)} variable this is the description */') + 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: '(Array|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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {(Array.|Object.)} variable this is the description */') + 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: '(Array.|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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function()} variable this is the description */') + 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: 'function()', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function ()} variable this is the description */') + 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: 'function ()', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function ( )} variable 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: 'function ( )', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(string)} variable this is the description */') + 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: 'function(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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(string, number)} variable 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: 'function(string, number)', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(...string)} variable 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: 'function(...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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(string, ...number)} variable 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: 'function(string, ...number)', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(string, number, ...number)} variable 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: 'function(string, number, ...number)', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(!string)} variable 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: 'function(!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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(?string, !number)} variable 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: 'function(?string, !number)', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(string[], number=)} variable 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: 'function(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'] + expect(tokens[8]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[9]).toEqual value: ', number=)', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[12]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function():number} variable 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: 'function():number', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(string): number} variable 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: 'function(string): number', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @param {function(string) : number} variable this is the description */') + 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: 'function(string) : number', 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + + it "tokenises @return tags without descriptions", -> + {tokens} = grammar.tokenizeLine('/** @return {object} */') + 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: 'return', 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', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @returns {object} */') + 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: 'returns', 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', 'punctuation.section.end.comment.js'] + + it "tokenises @return tags with trailing descriptions", -> + {tokens} = grammar.tokenizeLine('/** @returns {object} this is the 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: 'returns', 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: 'this', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[10]).toEqual value: ' is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @return {object} this is the 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: 'return', 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: 'this', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[10]).toEqual value: ' is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @returns {(Something)} */') + expect(tokens[3]).toEqual value: 'returns', 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: '(Something)', 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'] + + it "tokenises @return tags with multiple types", -> + {tokens} = grammar.tokenizeLine('/** @return {Some|Thing} Something to return */') + expect(tokens[3]).toEqual value: 'return', 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: 'Some|Thing', 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'] + + {tokens} = grammar.tokenizeLine('/** @return {(String[]|Number[])} 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: 'return', 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'] + expect(tokens[8]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[9]).toEqual value: '|Number', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[10]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[11]).toEqual value: ']', 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'] + expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[15]).toEqual value: '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'] + + it "tokenises function-type @return tags", -> + {tokens} = grammar.tokenizeLine('/** @return {function()} this is the description */') + 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: 'return', 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: 'function()', 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'] + + {tokens} = grammar.tokenizeLine('/** @return {function ()} 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: 'function ()', 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'] + + {tokens} = grammar.tokenizeLine('/** @return {function ( )} 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: 'function ( )', 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'] + + {tokens} = grammar.tokenizeLine('/** @return {function(string)} 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: 'function(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'] + + {tokens} = grammar.tokenizeLine('/** @return {function(string, number)} 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: 'function(string, number)', 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'] + + {tokens} = grammar.tokenizeLine('/** @return {function(...string)} 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: 'function(...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'] + + {tokens} = grammar.tokenizeLine('/** @return {function(string, ...number)} 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: 'function(string, ...number)', 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'] + + {tokens} = grammar.tokenizeLine('/** @return {function(string, number, ...number)} 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: 'function(string, number, ...number)', 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'] + + {tokens} = grammar.tokenizeLine('/** @return {function(!string)} 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: 'function(!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'] + + {tokens} = grammar.tokenizeLine('/** @return {function(?string, !number)} 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: 'function(?string, !number)', 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'] + + {tokens} = grammar.tokenizeLine('/** @return {function(string[], number=)} this is the description */') + expect(tokens[3]).toEqual value: 'return', 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: 'function(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'] + expect(tokens[8]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[9]).toEqual value: ', number=)', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + + {tokens} = grammar.tokenizeLine('/** @return {function():number} this is the description */') + expect(tokens[3]).toEqual value: 'return', 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: 'function():number', 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'] + + {tokens} = grammar.tokenizeLine('/** @return {function(string): number} this is the description */') + expect(tokens[3]).toEqual value: 'return', 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: 'function(string): number', 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'] + + {tokens} = grammar.tokenizeLine('/** @return {function(string) : number} 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: 'function(string) : number', 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'] From 4012f6e44dc046e641953da9c4dbb41d67cdea92 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 4 Mar 2017 02:54:51 +1100 Subject: [PATCH 211/420] Fix spec-title and add tests for early cutoff --- grammars/jsdoc.cson | 2 +- spec/jsdoc-spec.coffee | 82 ++++++++++++++++++++++++++++++++---------- 2 files changed, 65 insertions(+), 19 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index be490dd8..329cbd27 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -452,7 +452,7 @@ 'patterns': [ { # {unclosed - 'match': '\\G{[^}]+$' + 'match': '\\G{(?:[^}*]|\\*[^/}])+$' 'name': 'invalid.illegal.type.jsdoc' } { diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index 27100078..cf79a9a8 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -1,4 +1,4 @@ -describe "JSDoc", -> +describe "JSDoc grammar", -> grammar = null beforeEach -> @@ -8,23 +8,6 @@ describe "JSDoc", -> runs -> grammar = atom.grammars.grammarForScopeName("source.js") - it "tokenises simple tags", -> - {tokens} = grammar.tokenizeLine('/** @mixins */') - 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: 'mixins', 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: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] - - {tokens} = grammar.tokenizeLine('/** @global @static */') - 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: 'global', 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: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] - expect(tokens[6]).toEqual value: 'static', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] - 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'] describe "inline tags", -> it "tokenises tags without descriptions", -> @@ -132,6 +115,24 @@ describe "JSDoc", -> expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] describe "block tags", -> + it "tokenises simple tags", -> + {tokens} = grammar.tokenizeLine('/** @mixins */') + 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: 'mixins', 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: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @global @static */') + 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: 'global', 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: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(tokens[6]).toEqual value: 'static', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + 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 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'] @@ -1018,3 +1019,48 @@ describe "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: 'function(string) : number', 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'] + + describe "when the containing comment ends unexpectedly", -> + it "terminates any unclosed tags", -> + {tokens} = grammar.tokenizeLine('/** @param {String */ aa') + 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', 'punctuation.section.end.comment.js'] + expect(tokens[8]).toEqual value: ' aa', scopes: ['source.js'] + + {tokens} = grammar.tokenizeLine('/** @param {*} [name={value: {a:[{*/}}]}] */') + 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: '*', 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: 'name=', 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'] + expect(tokens[12]).toEqual value: 'value: ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[14]).toEqual value: 'a:', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + 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', 'variable.other.jsdoc'] + expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[18]).toEqual value: '}}', scopes: ['source.js'] + expect(tokens[19]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] + expect(tokens[20]).toEqual value: '}', scopes: ['source.js'] + expect(tokens[21]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] + expect(tokens[23]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] + expect(tokens[24]).toEqual value: '/', scopes: ['source.js', 'keyword.operator.js'] + + {tokens} = grammar.tokenizeLine('/** @param {string="Foo*/oo"} bar') + 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="Foo', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[8]).toEqual value: 'oo', scopes: ['source.js'] + expect(tokens[9]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(tokens[10]).toEqual value: '} bar', scopes: ['source.js', 'string.quoted.double.js', 'invalid.illegal.string.js'] From 7274c6cedc572d34c59cc7875f32b3e09f96212a Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 4 Mar 2017 03:02:48 +1100 Subject: [PATCH 212/420] Add specs for embedded JavaScript in @example tags --- spec/jsdoc-spec.coffee | 193 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 176 insertions(+), 17 deletions(-) diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index cf79a9a8..e004eaa1 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -115,23 +115,23 @@ describe "JSDoc grammar", -> expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] describe "block tags", -> - it "tokenises simple tags", -> - {tokens} = grammar.tokenizeLine('/** @mixins */') - 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: 'mixins', 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: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] - - {tokens} = grammar.tokenizeLine('/** @global @static */') - 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: 'global', 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: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] - expect(tokens[6]).toEqual value: 'static', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] - 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 simple tags", -> + {tokens} = grammar.tokenizeLine('/** @mixins */') + 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: 'mixins', 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: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + {tokens} = grammar.tokenizeLine('/** @global @static */') + 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: 'global', 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: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] + expect(tokens[6]).toEqual value: 'static', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] + 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 tags with type expressions", -> {tokens} = grammar.tokenizeLine('/** @const {object} */') @@ -1020,6 +1020,132 @@ describe "JSDoc grammar", -> expect(tokens[6]).toEqual value: 'function(string) : number', 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'] + describe "highlighted JavaScript examples", -> + it "highlights JavaScript after an @example tag", -> + lines = grammar.tokenizeLines """ + /** + * @example foo("bar"); + */ + """ + 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: 'foo', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'entity.name.function.js'] + expect(lines[1][5]).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[1][6]).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[1][7]).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[1][8]).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[1][9]).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[1][10]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] + expect(lines[2][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + lines = grammar.tokenizeLines """ + /** + * @example + * foo("bar"); + */ + """ + 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][3]).toEqual value: '', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.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][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + lines = grammar.tokenizeLines """ + /** + * @example foo("bar"); + * foo(foo("bar")); // Comment + * 4 + 50; + */ + """ + 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: 'foo', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'entity.name.function.js'] + expect(lines[1][5]).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[1][6]).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[1][7]).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[1][8]).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[1][9]).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[1][10]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] + 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: 'foo', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.function-call.js', 'entity.name.function.js'] + expect(lines[2][4]).toEqual value: '(', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.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', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(lines[2][6]).toEqual value: 'bar', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js'] + expect(lines[2][7]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(lines[2][8]).toEqual value: ')', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(lines[2][9]).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][10]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] + expect(lines[2][12]).toEqual value: '//', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] + expect(lines[2][13]).toEqual value: ' Comment', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.line.double-slash.js'] + expect(lines[3][0]).toEqual value: ' * ', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc'] + expect(lines[3][1]).toEqual value: '4', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] + expect(lines[3][3]).toEqual value: '+', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'keyword.operator.js'] + expect(lines[3][5]).toEqual value: '50', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] + 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 "when the containing comment ends unexpectedly", -> it "terminates any unclosed tags", -> {tokens} = grammar.tokenizeLine('/** @param {String */ aa') @@ -1064,3 +1190,36 @@ describe "JSDoc grammar", -> expect(tokens[8]).toEqual value: 'oo', scopes: ['source.js'] expect(tokens[9]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] expect(tokens[10]).toEqual value: '} bar', scopes: ['source.js', 'string.quoted.double.js', 'invalid.illegal.string.js'] + + it "terminates any embedded JavaScript code", -> + lines = grammar.tokenizeLines """ + /** + * @example + * foo("bar"); /* Comment */ + * @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][3]).toEqual value: '', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.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[2][9]).toEqual value: '/*', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] + expect(lines[2][10]).toEqual value: ' Comment ', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.block.js'] + expect(lines[2][11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(lines[3][1]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] + expect(lines[3][2]).toEqual value: ' @', scopes: ['source.js'] + expect(lines[3][3]).toEqual value: 'return', scopes: ['source.js', 'keyword.control.js'] + expect(lines[3][5]).toEqual value: '{', scopes: ['source.js', 'meta.brace.curly.js'] + expect(lines[3][6]).toEqual value: 'String', scopes: ['source.js', 'support.class.js'] + expect(lines[3][7]).toEqual value: '}', scopes: ['source.js', 'meta.brace.curly.js'] + expect(lines[4][1]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] + expect(lines[4][2]).toEqual value: '/', scopes: ['source.js', 'keyword.operator.js'] From 0aa448d9b867eb640e7ab16d0db83b570e00cc8b Mon Sep 17 00:00:00 2001 From: Alhadis Date: Thu, 9 Mar 2017 19:40:42 +1100 Subject: [PATCH 213/420] Apply revisions requested in review --- grammars/jsdoc.cson | 51 ++++++++++++-------- spec/jsdoc-spec.coffee | 106 ++++++++++++++++++++++------------------- 2 files changed, 88 insertions(+), 69 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index 329cbd27..5e564fe0 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -41,19 +41,19 @@ '3': 'name': 'entity.name.type.instance.jsdoc' '4': - 'name': 'punctuation.definition.begin.jsdoc' + 'name': 'punctuation.definition.bracket.angle.begin.jsdoc' '5': 'name': 'constant.other.email.link.underline.jsdoc' '6': - 'name': 'punctuation.definition.end.jsdoc' + 'name': 'punctuation.definition.bracket.angle.end.jsdoc' } { # @borrows as 'match': '''(?x) ((@)borrows) \\s+ - ((?:[^@\\s*/]|\\*[^/])++) # - \\s++ (as) \\s++ # as - ((?:[^@\\s*/]|\\*[^/])++) # + ((?:[^@\\s*/]|\\*[^/])+) # + \\s++ (as) \\s+ # as + ((?:[^@\\s*/]|\\*[^/])+) # ''' 'captures': '1': @@ -150,13 +150,13 @@ # URL ( (?=https?://) - (?:[^\\s*]|\\*[/])+ + (?:[^\\s*]|\\*[^/])+ ) | # JSDoc namepath ( (?!https?://) - (?:[^@\\s*/]|\\*[^/])++ + (?:[^@\\s*/]|\\*[^/])+ ) ) ''' @@ -170,6 +170,12 @@ 'name': 'punctuation.definition.block.tag.jsdoc' '3': 'name': 'variable.other.jsdoc' + 'patterns': [ + { + 'match': ',' + 'name': 'punctuation.delimiter.object.comma.jsdoc' + } + ] 'match': '''(?x) ((@)template) \\s+ @@ -232,8 +238,10 @@ # - @ {type} identifier 'begin': '((@)(?:arg|argument|const|constant|member|namespace|param|prop|property|var))\\s+(?={)' 'beginCaptures': - '1': 'name': 'storage.type.class.jsdoc' - '2': 'name': 'punctuation.definition.block.tag.jsdoc' + '1': + 'name': 'storage.type.class.jsdoc' + '2': + 'name': 'punctuation.definition.block.tag.jsdoc' 'end': '(?=\\s|\\*/|[^{}\\[\\]A-Za-z_$])' 'patterns': [ { @@ -302,7 +310,7 @@ { # Tags followed by a quoted arbitrary value # - @ "Quoted value" - 'begin': '((@)(?:default(?:value)?|license|version))\\s+([\'"])' + 'begin': '((@)(?:default(?:value)?|license|version))\\s+(([\'"]))' 'beginCaptures': '1': 'name': 'storage.type.class.jsdoc' @@ -310,11 +318,15 @@ 'name': 'punctuation.definition.block.tag.jsdoc' '3': 'name': 'variable.other.jsdoc' + '4': + 'name': 'punctuation.definition.string.begin.jsdoc' 'contentName': 'variable.other.jsdoc' - 'end': '\\3|(?=$|\\*/)' + 'end': '(\\3)|(?=$|\\*/)' 'endCaptures': '0': 'name': 'variable.other.jsdoc' + '1': + 'name': 'punctuation.definition.string.end.jsdoc' } { # Tags followed by an arbitrary value @@ -366,17 +378,19 @@ 'name': 'constant.other.description.jsdoc' } { - # {@link|tutorial …} - 'begin': '({@)(?:link|linkcode|linkplain|tutorial)\\s*' + # {@link|@tutorial …} + 'begin': '({)((@)(?:link(?:code|plain)?|tutorial))\\s*' 'beginCaptures': - '0': - 'name': 'storage.type.class.jsdoc' '1': - 'name': 'punctuation.definition.inline.tag.begin.jsdoc' + 'name': 'punctuation.definition.bracket.curly.begin.jsdoc' + '2': + 'name': 'storage.type.class.jsdoc' + '3': + 'name': 'punctuation.definition.inline.tag.jsdoc' 'end': '}|(?=\\*/)' 'endCaptures': '0': - 'name': 'punctuation.definition.inline.tag.end.jsdoc' + 'name': 'punctuation.definition.bracket.curly.end.jsdoc' 'name': 'entity.name.type.instance.jsdoc' 'patterns': [ { @@ -400,7 +414,6 @@ ] 'repository': - # Balanced brackets (square or curly) 'brackets': 'patterns': [ @@ -423,7 +436,6 @@ ] } ] - # Balanced quotes 'quotes': 'patterns': [ @@ -446,7 +458,6 @@ ] } ] - # {type} 'type': 'patterns': [ diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index e004eaa1..d6feaac1 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -8,39 +8,42 @@ describe "JSDoc grammar", -> runs -> grammar = atom.grammars.grammarForScopeName("source.js") - describe "inline tags", -> it "tokenises tags without descriptions", -> {tokens} = grammar.tokenizeLine('/** Text {@link target} text */') expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[2]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] - expect(tokens[3]).toEqual value: 'link ', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[4]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[5]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.inline.tag.end.jsdoc'] - expect(tokens[6]).toEqual value: ' text ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[3]).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[4]).toEqual value: 'link', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[6]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.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[8]).toEqual value: ' text ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] it "tokenises tags with an embedded trailing description", -> {tokens} = grammar.tokenizeLine('/** Text {@linkplain target|Description text} */') expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[2]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] - expect(tokens[3]).toEqual value: 'link', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[4]).toEqual value: 'plain', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[5]).toEqual value: ' target|Description text', 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.inline.tag.end.jsdoc'] - expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[3]).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[4]).toEqual value: 'linkplain', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[6]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[7]).toEqual value: '|', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.separator.pipe.jsdoc'] + expect(tokens[8]).toEqual value: 'Description text', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] {tokens} = grammar.tokenizeLine('/** Text {@linkcode target Description text} */') expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[2]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] - expect(tokens[3]).toEqual value: 'link', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[4]).toEqual value: 'code', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[5]).toEqual value: ' target Description text', 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.inline.tag.end.jsdoc'] - expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[3]).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[4]).toEqual value: 'linkcode', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[6]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[7]).toEqual value: ' Description text', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] + expect(tokens[8]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[10]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] it "tokenises tags with a preceding description", -> {tokens} = grammar.tokenizeLine('/** Text [Description text]{@link target} */') @@ -49,11 +52,12 @@ describe "JSDoc grammar", -> expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.begin.jsdoc'] expect(tokens[3]).toEqual value: 'Description text', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc'] expect(tokens[4]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.end.jsdoc'] - expect(tokens[5]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'link ', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[7]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[8]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.inline.tag.end.jsdoc'] - expect(tokens[10]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + 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: 'target', 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.definition.bracket.curly.end.jsdoc'] + expect(tokens[12]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] {tokens} = grammar.tokenizeLine('/** Text [Description text]{@tutorial target|Description} */') expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] @@ -61,13 +65,14 @@ describe "JSDoc grammar", -> expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.begin.jsdoc'] expect(tokens[3]).toEqual value: 'Description text', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc'] expect(tokens[4]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.end.jsdoc'] - expect(tokens[5]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] - expect(tokens[6]).toEqual value: 'tutorial ', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[7]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[8]).toEqual value: '|', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.separator.pipe.jsdoc'] - expect(tokens[9]).toEqual value: 'Description', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.inline.tag.end.jsdoc'] - expect(tokens[12]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + 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: 'tutorial', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[9]).toEqual value: 'target', 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'] it "tokenises inline tags which follow block tags", -> {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a {@link linked} description */') @@ -79,12 +84,13 @@ describe "JSDoc grammar", -> 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' - this is a ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] - expect(tokens[12]).toEqual value: 'link ', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[13]).toEqual value: 'linked', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[14]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.inline.tag.end.jsdoc'] - expect(tokens[15]).toEqual value: ' description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[16]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[11]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[12]).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[13]).toEqual value: 'link', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[15]).toEqual value: 'linked', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[16]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.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'] {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a {@link linked#description}. */') expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] @@ -92,11 +98,13 @@ describe "JSDoc grammar", -> 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' - this is a ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] - expect(tokens[12]).toEqual value: 'link ', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[13]).toEqual value: 'linked#description', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[14]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.inline.tag.end.jsdoc'] - expect(tokens[15]).toEqual value: '. ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[11]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[12]).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[13]).toEqual value: 'link', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[15]).toEqual value: 'linked#description', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[16]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[17]).toEqual value: '. ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[18]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a [description with a]{@link example}. */') expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] @@ -107,12 +115,13 @@ describe "JSDoc grammar", -> expect(tokens[11]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.begin.jsdoc'] expect(tokens[12]).toEqual value: 'description with a', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc'] expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.end.jsdoc'] - expect(tokens[14]).toEqual value: '{@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.begin.jsdoc'] - expect(tokens[15]).toEqual value: 'link ', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[16]).toEqual value: 'example', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[17]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.inline.tag.end.jsdoc'] - expect(tokens[18]).toEqual value: '. ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[14]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[15]).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[16]).toEqual value: 'link', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[18]).toEqual value: 'example', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[19]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[20]).toEqual value: '. ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[21]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] describe "block tags", -> it "tokenises simple tags", -> @@ -521,7 +530,6 @@ describe "JSDoc grammar", -> 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - {tokens} = grammar.tokenizeLine('/** @param {?} variable 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: '?', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] From 35083333c9964319922925643c91a905844e1c9c Mon Sep 17 00:00:00 2001 From: Alhadis Date: Thu, 9 Mar 2017 23:40:06 +1100 Subject: [PATCH 214/420] Use JavaScript grammar to highlight default values --- grammars/jsdoc.cson | 13 ++ spec/jsdoc-spec.coffee | 304 +++++++++++++++++++++++++---------------- 2 files changed, 199 insertions(+), 118 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index 5e564fe0..6525563f 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -256,6 +256,19 @@ 'begin': '\\[' 'end': '\\]|(?=\\*/)' 'patterns': [ + { + 'match': '(=)((?:[^\\]*]|\\*[^/])*)' + 'captures': + '1': + 'name': 'keyword.operator.assignment.jsdoc' + '2': + 'name': 'source.embedded.js' + 'patterns': [ + { + 'include': 'source.js' + } + ] + } { 'include': '#brackets' } diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index d6feaac1..233cc8ac 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -266,41 +266,47 @@ describe "JSDoc grammar", -> 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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: 'variable=default value', 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'] - expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + 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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: 'variable = default value', 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'] - expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + 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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: ' variable = default value ', 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'] - expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + 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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[10]).toEqual value: 'variable=default.value', 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'] - expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + 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 */') @@ -308,73 +314,78 @@ describe "JSDoc grammar", -> 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'] - expect(tokens[12]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - 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', 'variable.other.jsdoc'] - expect(tokens[15]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + 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'] - expect(tokens[12]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - 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', 'variable.other.jsdoc'] - expect(tokens[15]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + 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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] 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'] - expect(tokens[12]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[13]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - 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'] + 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'] - expect(tokens[12]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - 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', 'variable.other.jsdoc'] - expect(tokens[15]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + 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'] - expect(tokens[12]).toEqual value: 'default value', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - 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', 'variable.other.jsdoc'] - expect(tokens[15]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + 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'] - expect(tokens[12]).toEqual value: ' default value ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[13]).toEqual value: "'", scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - 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'] + 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 */') @@ -382,46 +393,58 @@ describe "JSDoc grammar", -> 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'] - expect(tokens[12]).toEqual value: 'a: "b"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - 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', 'variable.other.jsdoc'] - expect(tokens[15]).toEqual value: ' - An object ', scopes: ['source.js', 'comment.block.documentation.js'] + 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'] - expect(tokens[12]).toEqual value: ' a : "b" ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[16]).toEqual value: ' - An object ', scopes: ['source.js', 'comment.block.documentation.js'] + 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'] - expect(tokens[12]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[14]).toEqual value: ' - Empty object ', scopes: ['source.js', 'comment.block.documentation.js'] + 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'] - expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[16]).toEqual value: ' - Empty object ', scopes: ['source.js', 'comment.block.documentation.js'] + 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 */') @@ -429,46 +452,56 @@ describe "JSDoc grammar", -> 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'] - expect(tokens[12]).toEqual value: '1,2,3', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - 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', 'variable.other.jsdoc'] - expect(tokens[15]).toEqual value: ' - An array ', scopes: ['source.js', 'comment.block.documentation.js'] + 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'] - expect(tokens[12]).toEqual value: ' 1 , 2 , 3 ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[16]).toEqual value: ' - An array ', scopes: ['source.js', 'comment.block.documentation.js'] + 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'] - expect(tokens[12]).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: ' - Empty array ', scopes: ['source.js', 'comment.block.documentation.js'] + 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'] - expect(tokens[13]).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'] + expect(tokens[16]).toEqual value: ' ] - Empty array ', scopes: ['source.js', 'comment.block.documentation.js'] it "tokenises @param tags with accessor-style names", -> {tokens} = grammar.tokenizeLine('/** @param {object} parameter.property this is the description */') @@ -501,27 +534,33 @@ describe "JSDoc grammar", -> 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: 'parameter.property=default value', 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'] - expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[10]).toEqual value: 'parameter.property', 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} [parameter.property = 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: 'parameter.property = default value', 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'] - expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[10]).toEqual value: 'parameter.property ', 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} [ parameter.property = 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: ' parameter.property = default value ', 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'] - expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[10]).toEqual value: ' parameter.property ', 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'] it "tokenises @param tags with wildcard types", -> {tokens} = grammar.tokenizeLine('/** @param {*} variable this is the description */') @@ -1173,20 +1212,23 @@ describe "JSDoc grammar", -> expect(tokens[6]).toEqual value: '*', 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: 'name=', 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'] - expect(tokens[12]).toEqual value: 'value: ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[13]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[14]).toEqual value: 'a:', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - 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', 'variable.other.jsdoc'] - expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] - expect(tokens[18]).toEqual value: '}}', scopes: ['source.js'] - expect(tokens[19]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] - expect(tokens[20]).toEqual value: '}', scopes: ['source.js'] - expect(tokens[21]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] - expect(tokens[23]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] - expect(tokens[24]).toEqual value: '/', scopes: ['source.js', 'keyword.operator.js'] + expect(tokens[10]).toEqual value: 'name', 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: 'value', 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.curly.js'] + expect(tokens[17]).toEqual value: 'a', 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', 'keyword.operator.assignment.js'] + expect(tokens[19]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[20]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] + expect(tokens[21]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[22]).toEqual value: '}}', scopes: ['source.js'] + expect(tokens[23]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] + expect(tokens[24]).toEqual value: '}', scopes: ['source.js'] + expect(tokens[25]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] + expect(tokens[27]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] + expect(tokens[28]).toEqual value: '/', scopes: ['source.js', 'keyword.operator.js'] {tokens} = grammar.tokenizeLine('/** @param {string="Foo*/oo"} bar') expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] @@ -1231,3 +1273,29 @@ describe "JSDoc grammar", -> expect(lines[3][7]).toEqual value: '}', scopes: ['source.js', 'meta.brace.curly.js'] expect(lines[4][1]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] expect(lines[4][2]).toEqual value: '/', scopes: ['source.js', 'keyword.operator.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Something} [value={key: [value, ["22"}] */ 20;') + 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: 'Something', 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: 'value', 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: 'key', 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: '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[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[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 c422015b30890972d5290233f31969271a16f923 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Fri, 10 Mar 2017 02:38:50 +1100 Subject: [PATCH 215/420] Remove needlessly possessive quantifiers --- grammars/jsdoc.cson | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index 6525563f..f7ac8894 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -24,12 +24,12 @@ \\s+ ( [^@\\s<>*/] - (?:[^@<>*/]|\\*[^/])*+ + (?:[^@<>*/]|\\*[^/])* ) (?: \\s* (<) - ([^>\\s]++) + ([^>\\s]+) (>) )? ''' @@ -52,7 +52,7 @@ 'match': '''(?x) ((@)borrows) \\s+ ((?:[^@\\s*/]|\\*[^/])+) # - \\s++ (as) \\s+ # as + \\s+ (as) \\s+ # as ((?:[^@\\s*/]|\\*[^/])+) # ''' 'captures': @@ -104,7 +104,7 @@ } { # Highlighted JavaScript example - 'match': '[^\\s@*](?:[^*]|\\*[^/])*+' + 'match': '[^\\s@*](?:[^*]|\\*[^/])*' 'captures': '0': 'name': 'source.embedded.js' @@ -229,7 +229,7 @@ } { 'name': 'entity.name.type.instance.jsdoc' - 'match': '(?:[^@\\s*/]|\\*[^/])++' + 'match': '(?:[^@\\s*/]|\\*[^/])+' } ] } From 70a6c530b8fdc678086e2883e348fb909c9e4b77 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Fri, 10 Mar 2017 02:51:46 +1100 Subject: [PATCH 216/420] Highlight {@inline tags} in default @param values --- grammars/jsdoc.cson | 93 +++++++++++++++++++++++------------------- spec/jsdoc-spec.coffee | 19 +++++++++ 2 files changed, 70 insertions(+), 42 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index f7ac8894..1cb84a2a 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -264,6 +264,9 @@ '2': 'name': 'source.embedded.js' 'patterns': [ + { + 'include': '#inline-tags' + } { 'include': 'source.js' } @@ -381,48 +384,7 @@ 'name': 'storage.type.class.jsdoc' } { - # Description preceding {@inline tag} - 'captures': - '1': - 'name': 'punctuation.definition.bracket.square.begin.jsdoc' - '2': - 'name': 'punctuation.definition.bracket.square.end.jsdoc' - 'match': '(\\[)[^\\]]+(\\])(?={@(?:link|linkcode|linkplain|tutorial))' - 'name': 'constant.other.description.jsdoc' - } - { - # {@link|@tutorial …} - 'begin': '({)((@)(?:link(?:code|plain)?|tutorial))\\s*' - 'beginCaptures': - '1': - 'name': 'punctuation.definition.bracket.curly.begin.jsdoc' - '2': - 'name': 'storage.type.class.jsdoc' - '3': - 'name': 'punctuation.definition.inline.tag.jsdoc' - 'end': '}|(?=\\*/)' - 'endCaptures': - '0': - 'name': 'punctuation.definition.bracket.curly.end.jsdoc' - 'name': 'entity.name.type.instance.jsdoc' - 'patterns': [ - { - 'captures': - '1': - 'name': 'variable.other.link.underline.jsdoc' - '2': - 'name': 'punctuation.separator.pipe.jsdoc' - 'match': '\\G((?=https?://)(?:[^|}\\s*]|\\*[/])+)(\\|)?' - } - { - 'captures': - '1': - 'name': 'variable.other.description.jsdoc' - '2': - 'name': 'punctuation.separator.pipe.jsdoc' - 'match': '\\G((?:[^{}@\\s|*]|\\*[^/])+)(\\|)?' - } - ] + 'include': '#inline-tags' } ] @@ -449,6 +411,53 @@ ] } ] + 'inline-tags': + 'patterns': [ + { + # Description preceding {@inline tag} + 'captures': + '1': + 'name': 'punctuation.definition.bracket.square.begin.jsdoc' + '2': + 'name': 'punctuation.definition.bracket.square.end.jsdoc' + 'match': '(\\[)[^\\]]+(\\])(?={@(?:link|linkcode|linkplain|tutorial))' + 'name': 'constant.other.description.jsdoc' + } + { + # {@link|@tutorial …} + 'begin': '({)((@)(?:link(?:code|plain)?|tutorial))\\s*' + 'beginCaptures': + '1': + 'name': 'punctuation.definition.bracket.curly.begin.jsdoc' + '2': + 'name': 'storage.type.class.jsdoc' + '3': + 'name': 'punctuation.definition.inline.tag.jsdoc' + 'end': '}|(?=\\*/)' + 'endCaptures': + '0': + 'name': 'punctuation.definition.bracket.curly.end.jsdoc' + 'name': 'entity.name.type.instance.jsdoc' + 'patterns': [ + { + 'captures': + '1': + 'name': 'variable.other.link.underline.jsdoc' + '2': + 'name': 'punctuation.separator.pipe.jsdoc' + 'match': '\\G((?=https?://)(?:[^|}\\s*]|\\*[/])+)(\\|)?' + } + { + 'captures': + '1': + 'name': 'variable.other.description.jsdoc' + '2': + 'name': 'punctuation.separator.pipe.jsdoc' + 'match': '\\G((?:[^{}@\\s|*]|\\*[^/])+)(\\|)?' + } + ] + } + ] # Balanced quotes 'quotes': 'patterns': [ diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index 233cc8ac..6163992d 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -123,6 +123,25 @@ describe "JSDoc grammar", -> expect(tokens[20]).toEqual value: '. ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[21]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + it "tokenises inline tags within default @param values", -> + {tokens} = grammar.tokenizeLine('/** @param {EntityType} [typeHint={@link EntityType.FILE}] */') + 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: 'EntityType', 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: 'typeHint', 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', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[13]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.jsdoc'] + expect(tokens[14]).toEqual value: 'link', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[16]).toEqual value: 'EntityType.FILE', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[17]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[18]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[20]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + describe "block tags", -> it "tokenises simple tags", -> {tokens} = grammar.tokenizeLine('/** @mixins */') From 785d630155c270d1cefe2030c09d53798f768f99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arandi=20L=C3=B3pez?= Date: Fri, 24 Mar 2017 16:11:07 -0600 Subject: [PATCH 217/420] return snippet --- snippets/language-javascript.cson | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snippets/language-javascript.cson b/snippets/language-javascript.cson index fb5949e2..8f523430 100644 --- a/snippets/language-javascript.cson +++ b/snippets/language-javascript.cson @@ -119,3 +119,6 @@ 'export module': 'prefix': 'expmod' 'body': 'module.exports = ${1:name};' + 'return': + 'prefix': 'ret' + 'body': 'return $1;$0' From c438e377a59131690b4269deac7b26d98a8d2f85 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Fri, 10 Mar 2017 23:13:09 +1100 Subject: [PATCH 218/420] =?UTF-8?q?Fix=20tokenisation=20of=20"@see=20{@lin?= =?UTF-8?q?k=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 1cb84a2a..4f7e44dc 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 6163992d..bf3c6728 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 31d2a5f3d321761a1b2d1ec85ed3d507f76b5812 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Tue, 14 Mar 2017 21:24:44 +1100 Subject: [PATCH 219/420] 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 4f7e44dc..e3141798 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 @@ -377,16 +377,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 43eaf17b80529175f5f5ca0ac19723c280c9dcd1 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Mon, 8 May 2017 01:11:28 -0400 Subject: [PATCH 220/420] Remove embedded JavaScript highlighting in JSDoc --- grammars/jsdoc.cson | 64 ++----- spec/jsdoc-spec.coffee | 397 +++++++++-------------------------------- 2 files changed, 91 insertions(+), 370 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index e3141798..92ec1c62 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -102,18 +102,6 @@ '2': 'name': 'punctuation.definition.bracket.angle.end.jsdoc' } - { - # Highlighted JavaScript example - 'match': '[^\\s@*](?:[^*]|\\*[^/])*' - 'captures': - '0': - 'name': 'source.embedded.js' - 'patterns': [ - { - 'include': 'source.js' - } - ] - } ] } { @@ -262,29 +250,19 @@ { 'name': 'variable.other.jsdoc' 'begin': '\\[' - 'end': '\\]|(?=\\*/)' + 'end': '\\](?=\\s*([\\w-]|$|\\*/))|(?=\\*/)' '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' - } - { - 'include': '#quotes' + 'end': '(?=(\\]\\s*([\\w-]|$|\\*/))|\\*/)' + 'patterns': [ + { + 'include': '#inline-tags' + } + ] } ] } @@ -466,28 +444,6 @@ ] } ] - # Balanced quotes - 'quotes': - 'patterns': [ - { - 'begin': "'" - 'end': "'|(?=\\*/)" - 'patterns': [ - { - 'include': '#quotes' - } - ] - } - { - 'begin': '"' - 'end': '"|(?=\\*/)' - 'patterns': [ - { - 'include': '#quotes' - } - ] - } - ] # {type} 'type': 'patterns': [ diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index bf3c6728..333fb87c 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -134,11 +134,11 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'typeHint', 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', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[13]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.jsdoc'] - expect(tokens[14]).toEqual value: 'link', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[16]).toEqual value: 'EntityType.FILE', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[17]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[12]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[13]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.jsdoc'] + expect(tokens[14]).toEqual value: 'link', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[16]).toEqual value: 'EntityType.FILE', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[17]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] expect(tokens[18]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[20]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] @@ -332,8 +332,8 @@ describe "JSDoc grammar", -> 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[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'] 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'] @@ -343,8 +343,8 @@ describe "JSDoc grammar", -> 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[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'] 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'] @@ -354,8 +354,8 @@ describe "JSDoc grammar", -> 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[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'] 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'] @@ -365,12 +365,10 @@ describe "JSDoc grammar", -> 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'] + 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'] + 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'] it "tokenises @param tags with quoted default values", -> {tokens} = grammar.tokenizeLine('/** @param {object} [variable="default value"] this is the description */') @@ -379,12 +377,10 @@ describe "JSDoc grammar", -> 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'] + 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'] + 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'] @@ -392,12 +388,10 @@ describe "JSDoc grammar", -> 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'] + 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'] + 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'] @@ -405,12 +399,10 @@ describe "JSDoc grammar", -> 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'] + 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'] + 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'] @@ -418,12 +410,10 @@ describe "JSDoc grammar", -> 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'] + 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'] + 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'] @@ -431,12 +421,10 @@ describe "JSDoc grammar", -> 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'] + 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'] + 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'] @@ -444,12 +432,10 @@ describe "JSDoc grammar", -> 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'] + 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'] + 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'] it "tokenises @param tags with objects as default values", -> {tokens} = grammar.tokenizeLine('/** @param {Object} [variable={a: "b"}] - An object */') @@ -458,16 +444,9 @@ describe "JSDoc grammar", -> 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'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] + expect(tokens[12]).toEqual value: '{a: "b"}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[14]).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'] @@ -475,16 +454,10 @@ describe "JSDoc grammar", -> 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'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] + expect(tokens[12]).toEqual value: ' { a : "b" } ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[14]).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'] @@ -492,11 +465,9 @@ describe "JSDoc grammar", -> 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'] + 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'] + expect(tokens[14]).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'] @@ -504,11 +475,9 @@ describe "JSDoc grammar", -> 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'] + 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'] + expect(tokens[14]).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 */') @@ -517,16 +486,10 @@ describe "JSDoc grammar", -> 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'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] + expect(tokens[12]).toEqual value: '[1,2,3]', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[14]).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'] @@ -534,15 +497,10 @@ describe "JSDoc grammar", -> 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'] + expect(tokens[11]).toEqual value: '=', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'keyword.operator.assignment.jsdoc'] + expect(tokens[12]).toEqual value: ' [ 1 , 2 , 3 ] ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[14]).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'] @@ -550,11 +508,10 @@ describe "JSDoc grammar", -> 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[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'] 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'] + expect(tokens[14]).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'] @@ -562,10 +519,10 @@ describe "JSDoc grammar", -> 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'] + 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'] + expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[14]).toEqual value: ' - Empty array ', scopes: ['source.js', 'comment.block.documentation.js'] it "tokenises @param tags with accessor-style names", -> {tokens} = grammar.tokenizeLine('/** @param {object} parameter.property this is the description */') @@ -599,8 +556,8 @@ describe "JSDoc grammar", -> 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: 'parameter.property', 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[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'] 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'] @@ -610,8 +567,8 @@ describe "JSDoc grammar", -> 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: 'parameter.property ', 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[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'] 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'] @@ -621,8 +578,8 @@ describe "JSDoc grammar", -> 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: ' parameter.property ', 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[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'] 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'] @@ -1131,132 +1088,6 @@ describe "JSDoc grammar", -> expect(tokens[6]).toEqual value: 'function(string) : number', 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'] - describe "highlighted JavaScript examples", -> - it "highlights JavaScript after an @example tag", -> - lines = grammar.tokenizeLines """ - /** - * @example foo("bar"); - */ - """ - 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: 'foo', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'entity.name.function.js'] - expect(lines[1][5]).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[1][6]).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[1][7]).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[1][8]).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[1][9]).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[1][10]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] - expect(lines[2][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] - - lines = grammar.tokenizeLines """ - /** - * @example - * foo("bar"); - */ - """ - 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][3]).toEqual value: '', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.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][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] - - lines = grammar.tokenizeLines """ - /** - * @example foo("bar"); - * foo(foo("bar")); // Comment - * 4 + 50; - */ - """ - 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: 'foo', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'entity.name.function.js'] - expect(lines[1][5]).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[1][6]).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[1][7]).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[1][8]).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[1][9]).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[1][10]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] - 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: 'foo', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.function-call.js', 'entity.name.function.js'] - expect(lines[2][4]).toEqual value: '(', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.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', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(lines[2][6]).toEqual value: 'bar', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js'] - expect(lines[2][7]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] - expect(lines[2][8]).toEqual value: ')', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] - expect(lines[2][9]).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][10]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] - expect(lines[2][12]).toEqual value: '//', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] - expect(lines[2][13]).toEqual value: ' Comment', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.line.double-slash.js'] - expect(lines[3][0]).toEqual value: ' * ', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc'] - expect(lines[3][1]).toEqual value: '4', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] - expect(lines[3][3]).toEqual value: '+', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'keyword.operator.js'] - expect(lines[3][5]).toEqual value: '50', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] - 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 "when the containing comment ends unexpectedly", -> it "terminates any unclosed tags", -> {tokens} = grammar.tokenizeLine('/** @param {String */ aa') @@ -1278,21 +1109,14 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: 'name', 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: 'value', 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.curly.js'] - expect(tokens[17]).toEqual value: 'a', 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', 'keyword.operator.assignment.js'] - expect(tokens[19]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] - expect(tokens[20]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] - expect(tokens[21]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] - expect(tokens[22]).toEqual value: '}}', scopes: ['source.js'] - expect(tokens[23]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] - expect(tokens[24]).toEqual value: '}', scopes: ['source.js'] - expect(tokens[25]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] - expect(tokens[27]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] - expect(tokens[28]).toEqual value: '/', scopes: ['source.js', 'keyword.operator.js'] + expect(tokens[12]).toEqual value: '{value: {a:[{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[14]).toEqual value: '}}', scopes: ['source.js'] + expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] + expect(tokens[16]).toEqual value: '}', scopes: ['source.js'] + expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] + expect(tokens[19]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] + expect(tokens[20]).toEqual value: '/', scopes: ['source.js', 'keyword.operator.js'] {tokens} = grammar.tokenizeLine('/** @param {string="Foo*/oo"} bar') expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] @@ -1304,62 +1128,3 @@ describe "JSDoc grammar", -> expect(tokens[8]).toEqual value: 'oo', scopes: ['source.js'] expect(tokens[9]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] expect(tokens[10]).toEqual value: '} bar', scopes: ['source.js', 'string.quoted.double.js', 'invalid.illegal.string.js'] - - it "terminates any embedded JavaScript code", -> - lines = grammar.tokenizeLines """ - /** - * @example - * foo("bar"); /* Comment */ - * @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][3]).toEqual value: '', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.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[2][9]).toEqual value: '/*', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] - expect(lines[2][10]).toEqual value: ' Comment ', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.block.js'] - expect(lines[2][11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] - expect(lines[3][1]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] - expect(lines[3][2]).toEqual value: ' @', scopes: ['source.js'] - expect(lines[3][3]).toEqual value: 'return', scopes: ['source.js', 'keyword.control.js'] - expect(lines[3][5]).toEqual value: '{', scopes: ['source.js', 'meta.brace.curly.js'] - expect(lines[3][6]).toEqual value: 'String', scopes: ['source.js', 'support.class.js'] - expect(lines[3][7]).toEqual value: '}', scopes: ['source.js', 'meta.brace.curly.js'] - expect(lines[4][1]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] - expect(lines[4][2]).toEqual value: '/', scopes: ['source.js', 'keyword.operator.js'] - - {tokens} = grammar.tokenizeLine('/** @param {Something} [value={key: [value, ["22"}] */ 20;') - 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: 'Something', 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: 'value', 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: 'key', 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: '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[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[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 ea43f155e426e16b1f55b90d675950e51fb27700 Mon Sep 17 00:00:00 2001 From: Steven Tang Date: Tue, 23 May 2017 06:59:34 -0600 Subject: [PATCH 221/420] Add stringify to support.function.js --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 9e10cc5e..76b7c415 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1679,7 +1679,7 @@ contextual|confirm|compile|clear|captureEvents|call|createStyleSheet|createPopup| createEventObject|to(GMTString|UTCString|String|Source|UpperCase|LowerCase|LocaleString)| test|taint|taintEnabled|indexOf|italics|disableExternalCapture|dump|detachEvent|unshift| - untaint|unwatch|updateCommands|join|javaEnabled|pop|push|plugins.refresh|paddings|parse| + untaint|unwatch|updateCommands|join|javaEnabled|pop|push|plugins.refresh|paddings|parse|stringify| print|prompt|preference|enableExternalCapture|exec|execScript|valueOf|UTC|find|file| fileModifiedDate|fileSize|fileCreatedDate|fileUpdatedDate|fixed|fontsize|fontcolor| forward|fromCharCode|watch|link|load|lastIndexOf|anchor|attachEvent|atob|apply|alert| From d171982014c27255b4d057d98dfc5fef573fec9f Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Tue, 23 May 2017 22:37:06 -0400 Subject: [PATCH 222/420] Welcome back JavaScript --- grammars/jsdoc.cson | 61 ++- spec/jsdoc-spec.coffee | 865 ++++++++++++++++++++++++++++++----------- 2 files changed, 682 insertions(+), 244 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index 92ec1c62..13dc82da 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -102,6 +102,18 @@ '2': 'name': 'punctuation.definition.bracket.angle.end.jsdoc' } + { + # Highlighted JavaScript example + 'match': '[^\\s@*](?:[^*]|\\*[^/])*' + 'captures': + '0': + 'name': 'source.embedded.js' + 'patterns': [ + { + 'include': 'source.js' + } + ] + } ] } { @@ -248,23 +260,50 @@ 'name': 'variable.other.jsdoc' } { + # Optional value 'name': 'variable.other.jsdoc' - 'begin': '\\[' - 'end': '\\](?=\\s*([\\w-]|$|\\*/))|(?=\\*/)' - 'patterns': [ - { - 'begin': '=' - 'beginCaptures': - '0': - 'name': 'keyword.operator.assignment.jsdoc' - 'end': '(?=(\\]\\s*([\\w-]|$|\\*/))|\\*/)' + 'match': '''(?x) + (\\[)\\s* + [\\w$]+ + (?: + (?:\\[\\])? # Foo[].bar properties within an array + \\. # Foo.Bar namespaced parameter + [\\w$]+ + )* + (?: + \\s* + (=) # [foo=bar] Default parameter value + \\s* + ( + (?: + "(?:(?:\\*(?!/))|(?:\\\\(?!"))|[^*\\\\])*?" | # [foo="bar"] Double-quoted + '(?:(?:\\*(?!/))|(?:\\\\(?!'))|[^*\\\\])*?' | # [foo='bar'] Single-quoted + \\[ (?:(?:\\*(?!/))|[^*])*? \\] | # [foo=[1,2]] Array literal + (?:(?:\\*(?!/))|[^*])*? # Everything else, but stop the match early at */ + )* + ) + )? + \\s*(?:(\\])((?:[^*\\s]|\\*[^\\s/])+)?|(?=\\*/)) + ''' + 'captures': + '1': + 'name': 'punctuation.definition.optional-value.begin.bracket.square.jsdoc' + '2': + 'name': 'keyword.operator.assignment.jsdoc' + '3': + 'name': 'source.embedded.js' 'patterns': [ { 'include': '#inline-tags' } + { + 'include': 'source.js' + } ] - } - ] + '4': + 'name': 'punctuation.definition.optional-value.end.bracket.square.jsdoc' + '5': + 'name': 'invalid.illegal.syntax.jsdoc' } ] } diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index 333fb87c..f05cd289 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -131,15 +131,15 @@ describe "JSDoc grammar", -> 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: 'EntityType', 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[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.begin.bracket.square.jsdoc'] expect(tokens[10]).toEqual value: 'typeHint', 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', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] - expect(tokens[13]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.jsdoc'] - expect(tokens[14]).toEqual value: 'link', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] - expect(tokens[16]).toEqual value: 'EntityType.FILE', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] - expect(tokens[17]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[18]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[12]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] + expect(tokens[13]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.jsdoc'] + expect(tokens[14]).toEqual value: 'link', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc'] + expect(tokens[16]).toEqual value: 'EntityType.FILE', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] + expect(tokens[17]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] + expect(tokens[18]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] expect(tokens[20]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] describe "block tags", -> @@ -312,217 +312,421 @@ describe "JSDoc grammar", -> 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[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.begin.bracket.square.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'] + expect(tokens[11]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[13]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] {tokens} = grammar.tokenizeLine('/** @param {object} [ variable ] this is the description */') expect(tokens[3]).toEqual value: 'param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] - expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.begin.bracket.square.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'] + expect(tokens[11]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.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'] - 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'] - 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'] - 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'] - 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'] - - 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: '"default value"', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - 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'] - 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'] - 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'] - 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'] - 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'] - 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'] - - 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: '{a: "b"}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[14]).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[12]).toEqual value: ' { a : "b" } ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[14]).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'] - expect(tokens[14]).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[12]).toEqual value: ' { } ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[14]).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: '[1,2,3]', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[14]).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[12]).toEqual value: ' [ 1 , 2 , 3 ] ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[14]).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'] - expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[14]).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[12]).toEqual value: ' [ ] ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[14]).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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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: 'default value', 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', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] + expect(tokens[15]).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', 'punctuation.definition.optional-value.begin.bracket.square.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'] + expect(tokens[13]).toEqual value: 'default value', 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'] + expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] + expect(tokens[16]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] + + it "tokenises 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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] + expect(tokens[28]).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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] + expect(tokens[18]).toEqual value: ' - Empty array ', scopes: ['source.js', 'comment.block.documentation.js'] + + it "tokenizes 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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'meta.brace.curly.js'] + expect(tokens[36]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'meta.brace.curly.js'] + expect(tokens[36]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.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'] + + 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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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'] + + 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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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', 'punctuation.definition.optional-value.begin.bracket.square.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', 'punctuation.definition.optional-value.end.bracket.square.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 */') @@ -536,52 +740,55 @@ describe "JSDoc grammar", -> 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[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.begin.bracket.square.jsdoc'] expect(tokens[10]).toEqual value: 'parameter.property', 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'] + expect(tokens[11]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] {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'] 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[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.begin.bracket.square.jsdoc'] expect(tokens[10]).toEqual value: ' parameter.property ', 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'] + expect(tokens[11]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] {tokens} = grammar.tokenizeLine('/** @param {object} [parameter.property=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[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.begin.bracket.square.jsdoc'] expect(tokens[10]).toEqual value: 'parameter.property', 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'] - expect(tokens[13]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.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', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] expect(tokens[14]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] {tokens} = grammar.tokenizeLine('/** @param {object} [parameter.property = 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[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.begin.bracket.square.jsdoc'] expect(tokens[10]).toEqual value: 'parameter.property ', 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'] - 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'] + expect(tokens[12]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: 'default value', 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', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] + expect(tokens[15]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] {tokens} = grammar.tokenizeLine('/** @param {object} [ parameter.property = 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[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.begin.bracket.square.jsdoc'] expect(tokens[10]).toEqual value: ' parameter.property ', 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'] - 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'] + expect(tokens[12]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] + expect(tokens[13]).toEqual value: 'default value', 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'] + expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] + expect(tokens[16]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] it "tokenises @param tags with wildcard types", -> {tokens} = grammar.tokenizeLine('/** @param {*} variable this is the description */') @@ -1088,6 +1295,132 @@ describe "JSDoc grammar", -> expect(tokens[6]).toEqual value: 'function(string) : number', 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'] + describe "highlighted JavaScript examples", -> + it "highlights JavaScript after an @example tag", -> + lines = grammar.tokenizeLines """ + /** + * @example foo("bar"); + */ + """ + 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: 'foo', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'entity.name.function.js'] + expect(lines[1][5]).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[1][6]).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[1][7]).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[1][8]).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[1][9]).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[1][10]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] + expect(lines[2][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + lines = grammar.tokenizeLines """ + /** + * @example + * foo("bar"); + */ + """ + 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][3]).toEqual value: '', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.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][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + + lines = grammar.tokenizeLines """ + /** + * @example foo("bar"); + * foo(foo("bar")); // Comment + * 4 + 50; + */ + """ + 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: 'foo', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'entity.name.function.js'] + expect(lines[1][5]).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[1][6]).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[1][7]).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[1][8]).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[1][9]).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[1][10]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] + 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: 'foo', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.function-call.js', 'entity.name.function.js'] + expect(lines[2][4]).toEqual value: '(', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.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', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] + expect(lines[2][6]).toEqual value: 'bar', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js'] + expect(lines[2][7]).toEqual value: '"', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.function-call.js', 'meta.arguments.js', 'string.quoted.double.js', 'punctuation.definition.string.end.js'] + expect(lines[2][8]).toEqual value: ')', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'meta.function-call.js', 'meta.arguments.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(lines[2][9]).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][10]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] + expect(lines[2][12]).toEqual value: '//', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] + expect(lines[2][13]).toEqual value: ' Comment', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.line.double-slash.js'] + expect(lines[3][0]).toEqual value: ' * ', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc'] + expect(lines[3][1]).toEqual value: '4', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] + expect(lines[3][3]).toEqual value: '+', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'keyword.operator.js'] + expect(lines[3][5]).toEqual value: '50', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] + 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 "when the containing comment ends unexpectedly", -> it "terminates any unclosed tags", -> {tokens} = grammar.tokenizeLine('/** @param {String */ aa') @@ -1106,17 +1439,24 @@ describe "JSDoc grammar", -> 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'] 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[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.begin.bracket.square.jsdoc'] expect(tokens[10]).toEqual value: 'name', 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: '{value: {a:[{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[13]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] - expect(tokens[14]).toEqual value: '}}', scopes: ['source.js'] - expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] - expect(tokens[16]).toEqual value: '}', scopes: ['source.js'] - expect(tokens[17]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] - expect(tokens[19]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] - expect(tokens[20]).toEqual value: '/', scopes: ['source.js', 'keyword.operator.js'] + 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: 'value', 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.curly.js'] + expect(tokens[17]).toEqual value: 'a', 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', 'keyword.operator.assignment.js'] + expect(tokens[19]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] + expect(tokens[20]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] + expect(tokens[21]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[22]).toEqual value: '}}', scopes: ['source.js'] + expect(tokens[23]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] + expect(tokens[24]).toEqual value: '}', scopes: ['source.js'] + expect(tokens[25]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] + expect(tokens[27]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] + expect(tokens[28]).toEqual value: '/', scopes: ['source.js', 'keyword.operator.js'] {tokens} = grammar.tokenizeLine('/** @param {string="Foo*/oo"} bar') expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] @@ -1128,3 +1468,62 @@ describe "JSDoc grammar", -> expect(tokens[8]).toEqual value: 'oo', scopes: ['source.js'] expect(tokens[9]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] expect(tokens[10]).toEqual value: '} bar', scopes: ['source.js', 'string.quoted.double.js', 'invalid.illegal.string.js'] + + it "terminates any embedded JavaScript code", -> + lines = grammar.tokenizeLines """ + /** + * @example + * foo("bar"); /* Comment */ + * @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][3]).toEqual value: '', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.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[2][9]).toEqual value: '/*', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] + expect(lines[2][10]).toEqual value: ' Comment ', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.block.js'] + expect(lines[2][11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(lines[3][1]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] + expect(lines[3][2]).toEqual value: ' @', scopes: ['source.js'] + expect(lines[3][3]).toEqual value: 'return', scopes: ['source.js', 'keyword.control.js'] + expect(lines[3][5]).toEqual value: '{', scopes: ['source.js', 'meta.brace.curly.js'] + expect(lines[3][6]).toEqual value: 'String', scopes: ['source.js', 'support.class.js'] + expect(lines[3][7]).toEqual value: '}', scopes: ['source.js', 'meta.brace.curly.js'] + expect(lines[4][1]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] + expect(lines[4][2]).toEqual value: '/', scopes: ['source.js', 'keyword.operator.js'] + + {tokens} = grammar.tokenizeLine('/** @param {Something} [value={key: [value, ["22"}] */ 20;') + 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: 'Something', 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', 'punctuation.definition.optional-value.begin.bracket.square.jsdoc'] + expect(tokens[10]).toEqual value: 'value', 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: 'key', 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: '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[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'] + expect(tokens[30]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] From 23fac44f72d341b32ccddb66ca3ca94d9de4c55c Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Tue, 23 May 2017 23:36:40 -0400 Subject: [PATCH 223/420] :memo: --- grammars/jsdoc.cson | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index 13dc82da..7f16fb5d 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -275,11 +275,12 @@ (=) # [foo=bar] Default parameter value \\s* ( + # The inner regexes are to stop the match early at */ and to not stop at escaped quotes (?: "(?:(?:\\*(?!/))|(?:\\\\(?!"))|[^*\\\\])*?" | # [foo="bar"] Double-quoted '(?:(?:\\*(?!/))|(?:\\\\(?!'))|[^*\\\\])*?' | # [foo='bar'] Single-quoted \\[ (?:(?:\\*(?!/))|[^*])*? \\] | # [foo=[1,2]] Array literal - (?:(?:\\*(?!/))|[^*])*? # Everything else, but stop the match early at */ + (?:(?:\\*(?!/))|[^*])*? # Everything else )* ) )? From c24bb4ed1ea370e0eb5263f3b5fd57da7c1c5c62 Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Sat, 24 Jun 2017 17:42:12 +0200 Subject: [PATCH 224/420] Avoid using the ambiguous \h shorthand character Depending on the regular expression engine used, \h does not always mean the same. With a PCRE engine, it matches white spaces, whereas, with a Oniguruma engine, it matches hexademical digit characters. Atom uses an Oniguruma engine, but github.com relies on a PCRE engine. --- grammars/javascript.cson | 2 +- grammars/regular expressions (javascript).cson | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 76b7c415..3132323f 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1524,7 +1524,7 @@ 'name': 'punctuation.definition.unicode-escape.end.bracket.curly.js' } { - 'match': '\\\\(x\\h{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)' + 'match': '\\\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)' 'name': 'constant.character.escape.js' } ] diff --git a/grammars/regular expressions (javascript).cson b/grammars/regular expressions (javascript).cson index 16b7c969..92368e8f 100644 --- a/grammars/regular expressions (javascript).cson +++ b/grammars/regular expressions (javascript).cson @@ -14,7 +14,7 @@ 'name': 'constant.character.character-class.regexp' } { - 'match': '\\\\([0-7]{3}|x\\h\\h|u\\h\\h\\h\\h)' + 'match': '\\\\([0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4})' 'name': 'constant.character.numeric.regexp' } { @@ -107,7 +107,7 @@ 'name': 'constant.character.control.regexp' '6': 'name': 'constant.character.escape.backslash.regexp' - 'match': '(?:.|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x\\h\\h|u\\h\\h\\h\\h))|(\\\\c[A-Z])|(\\\\.))' + 'match': '(?:.|(\\\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\\\c[A-Z])|(\\\\.))' 'name': 'constant.other.character-class.range.regexp' } { From d3a74971ac1b534d401925c3317a6c80888bb7f2 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Wed, 12 Jul 2017 23:17:38 -0400 Subject: [PATCH 225/420] Prepare 0.127.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e2edc106..ac7b70b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.126.1", + "version": "0.127.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 2cf0b2b755ca961f702635e4c464a7334bf27e88 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Thu, 13 Jul 2017 23:38:38 -0400 Subject: [PATCH 226/420] Temporarily revert comment scope changes --- grammars/javascript.cson | 12 +-- spec/javascript-spec.coffee | 60 +++++------ spec/jsdoc-spec.coffee | 200 ++++++++++++++++++------------------ 3 files changed, 136 insertions(+), 136 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 3132323f..af68a0a4 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1888,9 +1888,9 @@ { 'captures': '1': - 'name': 'punctuation.section.begin.comment.js' + 'name': 'punctuation.definition.comment.js' '2': - 'name': 'punctuation.section.end.comment.js' + 'name': 'punctuation.definition.comment.js' 'match': '(/\\*)(\\*/)' 'name': 'comment.block.empty.js' } @@ -1898,11 +1898,11 @@ 'begin': '/\\*\\*' 'beginCaptures': '0': - 'name': 'punctuation.section.begin.comment.js' + 'name': 'punctuation.definition.comment.js' 'end': '\\*/' 'endCaptures': '0': - 'name': 'punctuation.section.end.comment.js' + 'name': 'punctuation.definition.comment.js' 'name': 'comment.block.documentation.js' 'patterns': [ { @@ -1914,11 +1914,11 @@ 'begin': '/\\*' 'beginCaptures': '0': - 'name': 'punctuation.section.begin.comment.js' + 'name': 'punctuation.definition.comment.js' 'end': '\\*/' 'endCaptures': '0': - 'name': 'punctuation.section.end.comment.js' + 'name': 'punctuation.definition.comment.js' 'name': 'comment.block.js' } { diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index dcc46f90..8a4fedca 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -843,14 +843,14 @@ describe "JavaScript grammar", -> member2 } from "module-name"; ''' - expect(lines[0][2]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] + expect(lines[0][2]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] expect(lines[0][3]).toEqual value: ' comment ', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] - expect(lines[0][4]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.section.end.comment.js'] + expect(lines[0][4]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] expect(lines[1][4]).toEqual value: '//', scopes: ['source.js', 'meta.import.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] expect(lines[1][5]).toEqual value: ' comment', scopes: ['source.js', 'meta.import.js', 'comment.line.double-slash.js'] - expect(lines[2][1]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] + expect(lines[2][1]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] expect(lines[2][2]).toEqual value: ' comment ', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] - expect(lines[2][3]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.section.end.comment.js'] + expect(lines[2][3]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] # https://github.com/atom/language-javascript/issues/485 lines = grammar.tokenizeLines ''' @@ -966,17 +966,17 @@ describe "JavaScript grammar", -> ''' expect(lines[1][4]).toEqual value: '//', scopes: ['source.js', 'meta.export.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] expect(lines[1][5]).toEqual value: ' comment', scopes: ['source.js', 'meta.export.js', 'comment.line.double-slash.js'] - expect(lines[2][1]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] + expect(lines[2][1]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] expect(lines[2][2]).toEqual value: ' comment ', scopes: ['source.js', 'meta.export.js', 'comment.block.js'] - expect(lines[2][3]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.section.end.comment.js'] + expect(lines[2][3]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('export {member1, /* comment */ member2} /* comment */ from "module";') - expect(tokens[6]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] + expect(tokens[6]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] expect(tokens[7]).toEqual value: ' comment ', scopes: ['source.js', 'meta.export.js', 'comment.block.js'] - expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.section.end.comment.js'] - expect(tokens[13]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] + expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[13]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] expect(tokens[14]).toEqual value: ' comment ', scopes: ['source.js', 'meta.export.js', 'comment.block.js'] - expect(tokens[15]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.section.end.comment.js'] + expect(tokens[15]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] it "tokenizes default class export", -> {tokens} = grammar.tokenizeLine('export default class {}') @@ -1668,23 +1668,23 @@ describe "JavaScript grammar", -> it "tokenizes /* */ comments", -> {tokens} = grammar.tokenizeLine('/**/') - expect(tokens[0]).toEqual value: '/*', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.section.begin.comment.js'] - expect(tokens[1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.section.end.comment.js'] + expect(tokens[0]).toEqual value: '/*', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.definition.comment.js'] + expect(tokens[1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/* foo */') - expect(tokens[0]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] expect(tokens[1]).toEqual value: ' foo ', scopes: ['source.js', 'comment.block.js'] - expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.section.end.comment.js'] + expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] it "tokenizes /** */ comments", -> {tokens} = grammar.tokenizeLine('/***/') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] - expect(tokens[1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** foo */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] expect(tokens[1]).toEqual value: ' foo ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') @@ -1702,25 +1702,25 @@ describe "JavaScript grammar", -> it "tokenizes comments inside function declarations", -> {tokens} = grammar.tokenizeLine('function /* */ foo() /* */ {}') expect(tokens[0]).toEqual value: 'function', scopes: ['source.js', 'meta.function.js', 'storage.type.function.js'] - expect(tokens[2]).toEqual value: '/*', scopes: ['source.js', 'meta.function.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] - expect(tokens[4]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'comment.block.js', 'punctuation.section.end.comment.js'] + expect(tokens[2]).toEqual value: '/*', scopes: ['source.js', 'meta.function.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[4]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'comment.block.js', 'punctuation.definition.comment.js'] expect(tokens[6]).toEqual value: 'foo', scopes: ['source.js', 'meta.function.js', 'entity.name.function.js'] - expect(tokens[10]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] - expect(tokens[12]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.section.end.comment.js'] + expect(tokens[10]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[12]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('x => /* */ {}') expect(tokens[0]).toEqual value: 'x', scopes: ['source.js', 'meta.function.arrow.js', 'meta.parameters.js', 'variable.parameter.function.js'] expect(tokens[2]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.js', 'storage.type.function.arrow.js'] - expect(tokens[4]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] - expect(tokens[6]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.section.end.comment.js'] + expect(tokens[4]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[6]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] expect(tokens[8]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] {tokens} = grammar.tokenizeLine('.foo = x => /* */ {}') expect(tokens[1]).toEqual value: 'foo', scopes: ['source.js', 'meta.function.arrow.js', 'entity.name.function.js'] expect(tokens[5]).toEqual value: 'x', scopes: ['source.js', 'meta.function.arrow.js', 'meta.parameters.js', 'variable.parameter.function.js'] expect(tokens[7]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.js', 'storage.type.function.arrow.js'] - expect(tokens[9]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.section.end.comment.js'] + expect(tokens[9]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] expect(tokens[13]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] lines = grammar.tokenizeLines ''' @@ -1746,9 +1746,9 @@ describe "JavaScript grammar", -> it "tokenizes comments inside function parameters correctly", -> {tokens} = grammar.tokenizeLine('function test(p1 /*, p2 */) {}') - expect(tokens[6]).toEqual value: '/*', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] + expect(tokens[6]).toEqual value: '/*', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.definition.comment.js'] expect(tokens[7]).toEqual value: ', p2 ', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js'] - expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.section.end.comment.js'] + expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.definition.comment.js'] describe "console", -> it "tokenizes the console keyword", -> @@ -1773,8 +1773,8 @@ describe "JavaScript grammar", -> {tokens} = grammar.tokenizeLine('console/**/.log()') expect(tokens[0]).toEqual value: 'console', scopes: ['source.js', 'entity.name.type.object.console.js'] - expect(tokens[1]).toEqual value: '/*', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.section.begin.comment.js'] - expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.section.end.comment.js'] + expect(tokens[1]).toEqual value: '/*', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.definition.comment.js'] + expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.definition.comment.js'] expect(tokens[3]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] expect(tokens[4]).toEqual value: 'log', scopes: ['source.js', 'meta.method-call.js', 'support.function.console.js'] expect(tokens[5]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index f05cd289..a80d22c2 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -11,7 +11,7 @@ describe "JSDoc grammar", -> describe "inline tags", -> it "tokenises tags without descriptions", -> {tokens} = grammar.tokenizeLine('/** Text {@link target} text */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] expect(tokens[3]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.jsdoc'] @@ -19,11 +19,11 @@ describe "JSDoc grammar", -> expect(tokens[6]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.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[8]).toEqual value: ' text ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] it "tokenises tags with an embedded trailing description", -> {tokens} = grammar.tokenizeLine('/** Text {@linkplain target|Description text} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] expect(tokens[3]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.jsdoc'] @@ -32,10 +32,10 @@ describe "JSDoc grammar", -> expect(tokens[7]).toEqual value: '|', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.separator.pipe.jsdoc'] expect(tokens[8]).toEqual value: 'Description text', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** Text {@linkcode target Description text} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] expect(tokens[3]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.jsdoc'] @@ -43,11 +43,11 @@ describe "JSDoc grammar", -> expect(tokens[6]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] expect(tokens[7]).toEqual value: ' Description text', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] expect(tokens[8]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[10]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[10]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] it "tokenises tags with a preceding description", -> {tokens} = grammar.tokenizeLine('/** Text [Description text]{@link target} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.begin.jsdoc'] expect(tokens[3]).toEqual value: 'Description text', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc'] @@ -57,10 +57,10 @@ describe "JSDoc grammar", -> 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: 'target', 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.definition.bracket.curly.end.jsdoc'] - expect(tokens[12]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[12]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** Text [Description text]{@tutorial target|Description} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.begin.jsdoc'] expect(tokens[3]).toEqual value: 'Description text', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc'] @@ -72,11 +72,11 @@ describe "JSDoc grammar", -> 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'] + expect(tokens[14]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] it "tokenises inline tags which follow block tags", -> {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a {@link linked} description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -90,7 +90,7 @@ describe "JSDoc grammar", -> expect(tokens[15]).toEqual value: 'linked', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] expect(tokens[16]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.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'] + expect(tokens[18]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a {@link linked#description}. */') expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] @@ -104,7 +104,7 @@ describe "JSDoc grammar", -> expect(tokens[15]).toEqual value: 'linked#description', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] expect(tokens[16]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] expect(tokens[17]).toEqual value: '. ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[18]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[18]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a [description with a]{@link example}. */') expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] @@ -121,11 +121,11 @@ describe "JSDoc grammar", -> expect(tokens[18]).toEqual value: 'example', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] expect(tokens[19]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] expect(tokens[20]).toEqual value: '. ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[21]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[21]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] it "tokenises inline tags within default @param values", -> {tokens} = grammar.tokenizeLine('/** @param {EntityType} [typeHint={@link EntityType.FILE}] */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -140,49 +140,49 @@ describe "JSDoc grammar", -> expect(tokens[16]).toEqual value: 'EntityType.FILE', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] expect(tokens[17]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] expect(tokens[18]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] - expect(tokens[20]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[20]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] describe "block tags", -> it "tokenises simple tags", -> {tokens} = grammar.tokenizeLine('/** @mixins */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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: 'mixins', 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: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[5]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @global @static */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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: 'global', 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: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] expect(tokens[6]).toEqual value: 'static', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] 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'] + expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] + expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] + expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -192,10 +192,10 @@ describe "JSDoc grammar", -> 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'] + expect(tokens[14]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -204,11 +204,11 @@ describe "JSDoc grammar", -> 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'] + expect(tokens[13]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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: 'const', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] expect(tokens[4]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -216,7 +216,7 @@ describe "JSDoc grammar", -> 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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @define {object} */') expect(tokens[2]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] @@ -227,7 +227,7 @@ describe "JSDoc grammar", -> it "tokenises unnamed @param tags", -> {tokens} = grammar.tokenizeLine('/** @param {object} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.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'] @@ -235,22 +235,22 @@ describe "JSDoc grammar", -> 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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] it "tokenises @param tags", -> {tokens} = grammar.tokenizeLine('/** @param {object} variable */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] it "tokenises @param tags with a description", -> {tokens} = grammar.tokenizeLine('/** @param {object} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -258,10 +258,10 @@ describe "JSDoc grammar", -> 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @arg {object} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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: 'arg', 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'] @@ -269,10 +269,10 @@ describe "JSDoc grammar", -> 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @argument {object} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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: 'argument', 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'] @@ -280,10 +280,10 @@ describe "JSDoc grammar", -> 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -291,10 +291,10 @@ describe "JSDoc grammar", -> 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' - this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @param {object} $variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -302,11 +302,11 @@ describe "JSDoc grammar", -> 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: '$variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] it "tokenises @param tags marked optional", -> {tokens} = grammar.tokenizeLine('/** @param {object} [variable] this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -316,7 +316,7 @@ describe "JSDoc grammar", -> 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', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[13]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[13]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @param {object} [ variable ] this is the description */') expect(tokens[3]).toEqual value: 'param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] @@ -574,7 +574,7 @@ describe "JSDoc grammar", -> it "tokenizes 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[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -605,11 +605,11 @@ describe "JSDoc grammar", -> 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', 'punctuation.definition.optional-value.end.bracket.square.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'] + expect(tokens[38]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -641,11 +641,11 @@ describe "JSDoc grammar", -> expect(tokens[36]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.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'] + expect(tokens[39]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -659,10 +659,10 @@ describe "JSDoc grammar", -> 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', 'punctuation.definition.optional-value.end.bracket.square.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'] + expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -676,7 +676,7 @@ describe "JSDoc grammar", -> 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', 'punctuation.definition.optional-value.end.bracket.square.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'] + expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -689,11 +689,11 @@ describe "JSDoc grammar", -> expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.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'] + expect(tokens[18]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -708,10 +708,10 @@ describe "JSDoc grammar", -> 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', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] - expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -726,7 +726,7 @@ describe "JSDoc grammar", -> 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', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] - expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] it "tokenises @param tags with accessor-style names", -> {tokens} = grammar.tokenizeLine('/** @param {object} parameter.property this is the description */') @@ -806,7 +806,7 @@ describe "JSDoc grammar", -> it "tokenises @param tags with qualified types", -> {tokens} = grammar.tokenizeLine('/** @param {myNamespace.MyClass} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -814,10 +814,10 @@ describe "JSDoc grammar", -> 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @param {Foo~cb} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -825,7 +825,7 @@ describe "JSDoc grammar", -> 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] it "tokenises @param tags with multiple types", -> {tokens} = grammar.tokenizeLine('/** @param {function|string} variable this is the description */') @@ -836,7 +836,7 @@ describe "JSDoc grammar", -> expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] {tokens} = grammar.tokenizeLine('/** @param {string[]|number} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -865,7 +865,7 @@ describe "JSDoc grammar", -> expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] {tokens} = grammar.tokenizeLine('/** @param {(string[]|number)} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -876,7 +876,7 @@ describe "JSDoc grammar", -> expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] expect(tokens[12]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[13]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[14]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[14]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @param {(string|number[])} variable 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'] @@ -914,24 +914,24 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] {tokens} = grammar.tokenizeLine('/** @param {...*} remainder */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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: '...*', 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: 'remainder', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @param {...?} remainder */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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: '...?', 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: 'remainder', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] it "tokenises @param tags using Google Closure Compiler syntax", -> {tokens} = grammar.tokenizeLine('/** @param {number=} variable this is the description */') @@ -950,7 +950,7 @@ describe "JSDoc grammar", -> expect(tokens[11]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] {tokens} = grammar.tokenizeLine('/** @param {Foo[].bar} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -961,7 +961,7 @@ describe "JSDoc grammar", -> expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] expect(tokens[12]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[13]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[14]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[14]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @param {Array} variable this is the description */') expect(tokens[3]).toEqual value: 'param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] @@ -1147,26 +1147,26 @@ describe "JSDoc grammar", -> it "tokenises @return tags without descriptions", -> {tokens} = grammar.tokenizeLine('/** @return {object} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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: 'return', 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', 'punctuation.section.end.comment.js'] + expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @returns {object} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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: 'returns', 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', 'punctuation.section.end.comment.js'] + expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] it "tokenises @return tags with trailing descriptions", -> {tokens} = grammar.tokenizeLine('/** @returns {object} this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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: 'returns', 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'] @@ -1174,10 +1174,10 @@ describe "JSDoc grammar", -> 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: 'this', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[10]).toEqual value: ' is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @return {object} this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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: 'return', 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'] @@ -1185,7 +1185,7 @@ describe "JSDoc grammar", -> 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: 'this', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[10]).toEqual value: ' is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] {tokens} = grammar.tokenizeLine('/** @returns {(Something)} */') expect(tokens[3]).toEqual value: 'returns', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] @@ -1201,7 +1201,7 @@ describe "JSDoc grammar", -> expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] {tokens} = grammar.tokenizeLine('/** @return {(String[]|Number[])} Description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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: 'return', 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'] @@ -1214,7 +1214,7 @@ describe "JSDoc grammar", -> expect(tokens[12]).toEqual value: ')', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] expect(tokens[15]).toEqual value: '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'] + expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] it "tokenises function-type @return tags", -> {tokens} = grammar.tokenizeLine('/** @return {function()} this is the description */') @@ -1312,7 +1312,7 @@ describe "JSDoc grammar", -> expect(lines[1][8]).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[1][9]).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[1][10]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] - expect(lines[2][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(lines[2][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] lines = grammar.tokenizeLines """ /** @@ -1332,7 +1332,7 @@ describe "JSDoc grammar", -> 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][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(lines[3][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] lines = grammar.tokenizeLines """ /** @@ -1369,11 +1369,11 @@ describe "JSDoc grammar", -> expect(lines[3][3]).toEqual value: '+', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'keyword.operator.js'] expect(lines[3][5]).toEqual value: '50', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] 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'] + expect(lines[4][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -1383,7 +1383,7 @@ describe "JSDoc grammar", -> 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'] + expect(tokens[13]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] lines = grammar.tokenizeLines """ /** @@ -1392,7 +1392,7 @@ describe "JSDoc grammar", -> * @return {String} */ """ - expect(lines[0][0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(lines[0][0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -1418,22 +1418,22 @@ describe "JSDoc grammar", -> 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'] + expect(lines[4][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] describe "when the containing comment ends unexpectedly", -> it "terminates any unclosed tags", -> {tokens} = grammar.tokenizeLine('/** @param {String */ aa') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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', 'punctuation.section.end.comment.js'] + expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] expect(tokens[8]).toEqual value: ' aa', scopes: ['source.js'] {tokens} = grammar.tokenizeLine('/** @param {*} [name={value: {a:[{*/}}]}] */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -1450,7 +1450,7 @@ describe "JSDoc grammar", -> expect(tokens[18]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] expect(tokens[19]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] expect(tokens[20]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] - expect(tokens[21]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[21]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] expect(tokens[22]).toEqual value: '}}', scopes: ['source.js'] expect(tokens[23]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] expect(tokens[24]).toEqual value: '}', scopes: ['source.js'] @@ -1459,12 +1459,12 @@ describe "JSDoc grammar", -> expect(tokens[28]).toEqual value: '/', scopes: ['source.js', 'keyword.operator.js'] {tokens} = grammar.tokenizeLine('/** @param {string="Foo*/oo"} bar') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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="Foo', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] expect(tokens[8]).toEqual value: 'oo', scopes: ['source.js'] expect(tokens[9]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] expect(tokens[10]).toEqual value: '} bar', scopes: ['source.js', 'string.quoted.double.js', 'invalid.illegal.string.js'] @@ -1477,7 +1477,7 @@ describe "JSDoc grammar", -> * @return {String} */ """ - expect(lines[0][0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(lines[0][0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -1490,9 +1490,9 @@ describe "JSDoc grammar", -> 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[2][9]).toEqual value: '/*', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.block.js', 'punctuation.section.begin.comment.js'] + expect(lines[2][9]).toEqual value: '/*', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.block.js', 'punctuation.definition.comment.js'] expect(lines[2][10]).toEqual value: ' Comment ', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.block.js'] - expect(lines[2][11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.end.comment.js'] + expect(lines[2][11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] expect(lines[3][1]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] expect(lines[3][2]).toEqual value: ' @', scopes: ['source.js'] expect(lines[3][3]).toEqual value: 'return', scopes: ['source.js', 'keyword.control.js'] @@ -1503,7 +1503,7 @@ describe "JSDoc grammar", -> expect(lines[4][2]).toEqual value: '/', scopes: ['source.js', 'keyword.operator.js'] {tokens} = grammar.tokenizeLine('/** @param {Something} [value={key: [value, ["22"}] */ 20;') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.section.begin.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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'] @@ -1524,6 +1524,6 @@ describe "JSDoc grammar", -> 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', '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[27]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.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 28de7f5ea78db5bd9284b6fae8b3f4c68f4938b9 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Thu, 13 Jul 2017 23:40:07 -0400 Subject: [PATCH 227/420] Prepare 0.127.1 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ac7b70b4..9d1d38e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.127.0", + "version": "0.127.1", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From a298dbc4a4b265964ff7433ee4758d8d4aa3044e Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Fri, 14 Jul 2017 11:08:49 -0400 Subject: [PATCH 228/420] Use 'punctuation.definition.comment.begin/end.js' --- grammars/javascript.cson | 12 +-- spec/javascript-spec.coffee | 60 +++++------ spec/jsdoc-spec.coffee | 200 ++++++++++++++++++------------------ 3 files changed, 136 insertions(+), 136 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index af68a0a4..085b8e57 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1888,9 +1888,9 @@ { 'captures': '1': - 'name': 'punctuation.definition.comment.js' + 'name': 'punctuation.definition.comment.begin.js' '2': - 'name': 'punctuation.definition.comment.js' + 'name': 'punctuation.definition.comment.end.js' 'match': '(/\\*)(\\*/)' 'name': 'comment.block.empty.js' } @@ -1898,11 +1898,11 @@ 'begin': '/\\*\\*' 'beginCaptures': '0': - 'name': 'punctuation.definition.comment.js' + 'name': 'punctuation.definition.comment.begin.js' 'end': '\\*/' 'endCaptures': '0': - 'name': 'punctuation.definition.comment.js' + 'name': 'punctuation.definition.comment.end.js' 'name': 'comment.block.documentation.js' 'patterns': [ { @@ -1914,11 +1914,11 @@ 'begin': '/\\*' 'beginCaptures': '0': - 'name': 'punctuation.definition.comment.js' + 'name': 'punctuation.definition.comment.begin.js' 'end': '\\*/' 'endCaptures': '0': - 'name': 'punctuation.definition.comment.js' + 'name': 'punctuation.definition.comment.end.js' 'name': 'comment.block.js' } { diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 8a4fedca..7b938fc3 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -843,14 +843,14 @@ describe "JavaScript grammar", -> member2 } from "module-name"; ''' - expect(lines[0][2]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[0][2]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.begin.js'] expect(lines[0][3]).toEqual value: ' comment ', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] - expect(lines[0][4]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[0][4]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.end.js'] expect(lines[1][4]).toEqual value: '//', scopes: ['source.js', 'meta.import.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] expect(lines[1][5]).toEqual value: ' comment', scopes: ['source.js', 'meta.import.js', 'comment.line.double-slash.js'] - expect(lines[2][1]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[2][1]).toEqual value: '/*', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.begin.js'] expect(lines[2][2]).toEqual value: ' comment ', scopes: ['source.js', 'meta.import.js', 'comment.block.js'] - expect(lines[2][3]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[2][3]).toEqual value: '*/', scopes: ['source.js', 'meta.import.js', 'comment.block.js', 'punctuation.definition.comment.end.js'] # https://github.com/atom/language-javascript/issues/485 lines = grammar.tokenizeLines ''' @@ -966,17 +966,17 @@ describe "JavaScript grammar", -> ''' expect(lines[1][4]).toEqual value: '//', scopes: ['source.js', 'meta.export.js', 'comment.line.double-slash.js', 'punctuation.definition.comment.js'] expect(lines[1][5]).toEqual value: ' comment', scopes: ['source.js', 'meta.export.js', 'comment.line.double-slash.js'] - expect(lines[2][1]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[2][1]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.begin.js'] expect(lines[2][2]).toEqual value: ' comment ', scopes: ['source.js', 'meta.export.js', 'comment.block.js'] - expect(lines[2][3]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[2][3]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('export {member1, /* comment */ member2} /* comment */ from "module";') - expect(tokens[6]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[6]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.begin.js'] expect(tokens[7]).toEqual value: ' comment ', scopes: ['source.js', 'meta.export.js', 'comment.block.js'] - expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(tokens[13]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.end.js'] + expect(tokens[13]).toEqual value: '/*', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.begin.js'] expect(tokens[14]).toEqual value: ' comment ', scopes: ['source.js', 'meta.export.js', 'comment.block.js'] - expect(tokens[15]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[15]).toEqual value: '*/', scopes: ['source.js', 'meta.export.js', 'comment.block.js', 'punctuation.definition.comment.end.js'] it "tokenizes default class export", -> {tokens} = grammar.tokenizeLine('export default class {}') @@ -1668,23 +1668,23 @@ describe "JavaScript grammar", -> it "tokenizes /* */ comments", -> {tokens} = grammar.tokenizeLine('/**/') - expect(tokens[0]).toEqual value: '/*', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.definition.comment.js'] - expect(tokens[1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/*', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.definition.comment.begin.js'] + expect(tokens[1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/* foo */') - expect(tokens[0]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.begin.js'] expect(tokens[1]).toEqual value: ' foo ', scopes: ['source.js', 'comment.block.js'] - expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.end.js'] it "tokenizes /** */ comments", -> {tokens} = grammar.tokenizeLine('/***/') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] - expect(tokens[1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.js'] + expect(tokens[1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** foo */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.js'] expect(tokens[1]).toEqual value: ' foo ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] it "tokenizes // comments", -> {tokens} = grammar.tokenizeLine('// comment') @@ -1702,25 +1702,25 @@ describe "JavaScript grammar", -> it "tokenizes comments inside function declarations", -> {tokens} = grammar.tokenizeLine('function /* */ foo() /* */ {}') expect(tokens[0]).toEqual value: 'function', scopes: ['source.js', 'meta.function.js', 'storage.type.function.js'] - expect(tokens[2]).toEqual value: '/*', scopes: ['source.js', 'meta.function.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(tokens[4]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[2]).toEqual value: '/*', scopes: ['source.js', 'meta.function.js', 'comment.block.js', 'punctuation.definition.comment.begin.js'] + expect(tokens[4]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'comment.block.js', 'punctuation.definition.comment.end.js'] expect(tokens[6]).toEqual value: 'foo', scopes: ['source.js', 'meta.function.js', 'entity.name.function.js'] - expect(tokens[10]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(tokens[12]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[10]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.begin.js'] + expect(tokens[12]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('x => /* */ {}') expect(tokens[0]).toEqual value: 'x', scopes: ['source.js', 'meta.function.arrow.js', 'meta.parameters.js', 'variable.parameter.function.js'] expect(tokens[2]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.js', 'storage.type.function.arrow.js'] - expect(tokens[4]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(tokens[6]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[4]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.begin.js'] + expect(tokens[6]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.end.js'] expect(tokens[8]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] {tokens} = grammar.tokenizeLine('.foo = x => /* */ {}') expect(tokens[1]).toEqual value: 'foo', scopes: ['source.js', 'meta.function.arrow.js', 'entity.name.function.js'] expect(tokens[5]).toEqual value: 'x', scopes: ['source.js', 'meta.function.arrow.js', 'meta.parameters.js', 'variable.parameter.function.js'] expect(tokens[7]).toEqual value: '=>', scopes: ['source.js', 'meta.function.arrow.js', 'storage.type.function.arrow.js'] - expect(tokens[9]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[9]).toEqual value: '/*', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.begin.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.js', 'punctuation.definition.comment.end.js'] expect(tokens[13]).toEqual value: '{', scopes: ['source.js', 'punctuation.definition.function.body.begin.bracket.curly.js'] lines = grammar.tokenizeLines ''' @@ -1746,9 +1746,9 @@ describe "JavaScript grammar", -> it "tokenizes comments inside function parameters correctly", -> {tokens} = grammar.tokenizeLine('function test(p1 /*, p2 */) {}') - expect(tokens[6]).toEqual value: '/*', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[6]).toEqual value: '/*', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.definition.comment.begin.js'] expect(tokens[7]).toEqual value: ', p2 ', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js'] - expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'meta.function.js', 'meta.parameters.js', 'comment.block.js', 'punctuation.definition.comment.end.js'] describe "console", -> it "tokenizes the console keyword", -> @@ -1773,8 +1773,8 @@ describe "JavaScript grammar", -> {tokens} = grammar.tokenizeLine('console/**/.log()') expect(tokens[0]).toEqual value: 'console', scopes: ['source.js', 'entity.name.type.object.console.js'] - expect(tokens[1]).toEqual value: '/*', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.definition.comment.js'] - expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.definition.comment.js'] + expect(tokens[1]).toEqual value: '/*', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.definition.comment.begin.js'] + expect(tokens[2]).toEqual value: '*/', scopes: ['source.js', 'comment.block.empty.js', 'punctuation.definition.comment.end.js'] expect(tokens[3]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] expect(tokens[4]).toEqual value: 'log', scopes: ['source.js', 'meta.method-call.js', 'support.function.console.js'] expect(tokens[5]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index a80d22c2..c904f5c3 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -11,7 +11,7 @@ describe "JSDoc grammar", -> describe "inline tags", -> it "tokenises tags without descriptions", -> {tokens} = grammar.tokenizeLine('/** Text {@link target} text */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.js'] expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] expect(tokens[3]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.jsdoc'] @@ -19,11 +19,11 @@ describe "JSDoc grammar", -> expect(tokens[6]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.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[8]).toEqual value: ' text ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] it "tokenises tags with an embedded trailing description", -> {tokens} = grammar.tokenizeLine('/** Text {@linkplain target|Description text} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.js'] expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] expect(tokens[3]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.jsdoc'] @@ -32,10 +32,10 @@ describe "JSDoc grammar", -> expect(tokens[7]).toEqual value: '|', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.separator.pipe.jsdoc'] expect(tokens[8]).toEqual value: 'Description text', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** Text {@linkcode target Description text} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.js'] expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[2]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] expect(tokens[3]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'storage.type.class.jsdoc', 'punctuation.definition.inline.tag.jsdoc'] @@ -43,11 +43,11 @@ describe "JSDoc grammar", -> expect(tokens[6]).toEqual value: 'target', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] expect(tokens[7]).toEqual value: ' Description text', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] expect(tokens[8]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] - expect(tokens[10]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[10]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] it "tokenises tags with a preceding description", -> {tokens} = grammar.tokenizeLine('/** Text [Description text]{@link target} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.js'] expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.begin.jsdoc'] expect(tokens[3]).toEqual value: 'Description text', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc'] @@ -57,10 +57,10 @@ describe "JSDoc grammar", -> 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: 'target', 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.definition.bracket.curly.end.jsdoc'] - expect(tokens[12]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[12]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** Text [Description text]{@tutorial target|Description} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.js'] expect(tokens[1]).toEqual value: ' Text ', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[2]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc', 'punctuation.definition.bracket.square.begin.jsdoc'] expect(tokens[3]).toEqual value: 'Description text', scopes: ['source.js', 'comment.block.documentation.js', 'constant.other.description.jsdoc'] @@ -72,11 +72,11 @@ describe "JSDoc grammar", -> 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.definition.comment.js'] + expect(tokens[14]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] it "tokenises inline tags which follow block tags", -> {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a {@link linked} description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -90,7 +90,7 @@ describe "JSDoc grammar", -> expect(tokens[15]).toEqual value: 'linked', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] expect(tokens[16]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.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.definition.comment.js'] + expect(tokens[18]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a {@link linked#description}. */') expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] @@ -104,7 +104,7 @@ describe "JSDoc grammar", -> expect(tokens[15]).toEqual value: 'linked#description', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] expect(tokens[16]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] expect(tokens[17]).toEqual value: '. ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[18]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[18]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is a [description with a]{@link example}. */') expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.begin.jsdoc'] @@ -121,11 +121,11 @@ describe "JSDoc grammar", -> expect(tokens[18]).toEqual value: 'example', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] expect(tokens[19]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] expect(tokens[20]).toEqual value: '. ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[21]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[21]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] it "tokenises inline tags within default @param values", -> {tokens} = grammar.tokenizeLine('/** @param {EntityType} [typeHint={@link EntityType.FILE}] */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -140,49 +140,49 @@ describe "JSDoc grammar", -> expect(tokens[16]).toEqual value: 'EntityType.FILE', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'variable.other.description.jsdoc'] expect(tokens[17]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] expect(tokens[18]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] - expect(tokens[20]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[20]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] describe "block tags", -> it "tokenises simple tags", -> {tokens} = grammar.tokenizeLine('/** @mixins */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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: 'mixins', 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: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[5]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @global @static */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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: 'global', 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: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] expect(tokens[6]).toEqual value: 'static', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] 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.definition.comment.js'] + expect(tokens[8]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.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.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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.definition.comment.js'] + expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @see http://atom.io/ */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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.definition.comment.js'] + expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.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.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -192,10 +192,10 @@ describe "JSDoc grammar", -> 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.definition.comment.js'] + expect(tokens[14]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @see [Description]{@link name#path} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -204,11 +204,11 @@ describe "JSDoc grammar", -> 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.definition.comment.js'] + expect(tokens[13]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.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.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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: 'const', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] expect(tokens[4]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] @@ -216,7 +216,7 @@ describe "JSDoc grammar", -> 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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @define {object} */') expect(tokens[2]).toEqual value: '@', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc', 'punctuation.definition.block.tag.jsdoc'] @@ -227,7 +227,7 @@ describe "JSDoc grammar", -> it "tokenises unnamed @param tags", -> {tokens} = grammar.tokenizeLine('/** @param {object} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.js'] expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.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'] @@ -235,22 +235,22 @@ describe "JSDoc grammar", -> 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[8]).toEqual value: ' ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] it "tokenises @param tags", -> {tokens} = grammar.tokenizeLine('/** @param {object} variable */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] it "tokenises @param tags with a description", -> {tokens} = grammar.tokenizeLine('/** @param {object} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -258,10 +258,10 @@ describe "JSDoc grammar", -> 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @arg {object} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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: 'arg', 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'] @@ -269,10 +269,10 @@ describe "JSDoc grammar", -> 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @argument {object} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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: 'argument', 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'] @@ -280,10 +280,10 @@ describe "JSDoc grammar", -> 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @param {object} variable - this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -291,10 +291,10 @@ describe "JSDoc grammar", -> 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' - this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @param {object} $variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -302,11 +302,11 @@ describe "JSDoc grammar", -> 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: '$variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] it "tokenises @param tags marked optional", -> {tokens} = grammar.tokenizeLine('/** @param {object} [variable] this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -316,7 +316,7 @@ describe "JSDoc grammar", -> 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', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] expect(tokens[12]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[13]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[13]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @param {object} [ variable ] this is the description */') expect(tokens[3]).toEqual value: 'param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] @@ -574,7 +574,7 @@ describe "JSDoc grammar", -> it "tokenizes 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.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -605,11 +605,11 @@ describe "JSDoc grammar", -> 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', 'punctuation.definition.optional-value.end.bracket.square.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.definition.comment.js'] + expect(tokens[38]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.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.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -641,11 +641,11 @@ describe "JSDoc grammar", -> expect(tokens[36]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.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.definition.comment.js'] + expect(tokens[39]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.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.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -659,10 +659,10 @@ describe "JSDoc grammar", -> 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', 'punctuation.definition.optional-value.end.bracket.square.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.definition.comment.js'] + expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.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.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -676,7 +676,7 @@ describe "JSDoc grammar", -> 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', 'punctuation.definition.optional-value.end.bracket.square.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.definition.comment.js'] + expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.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'] @@ -689,11 +689,11 @@ describe "JSDoc grammar", -> expect(tokens[15]).toEqual value: ']', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'punctuation.definition.optional-value.end.bracket.square.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.definition.comment.js'] + expect(tokens[18]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.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.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -708,10 +708,10 @@ describe "JSDoc grammar", -> 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', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] - expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine("/** @param {String} [key='a[\\']z'] */") - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -726,7 +726,7 @@ describe "JSDoc grammar", -> 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', 'punctuation.definition.optional-value.end.bracket.square.jsdoc'] - expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[19]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] it "tokenises @param tags with accessor-style names", -> {tokens} = grammar.tokenizeLine('/** @param {object} parameter.property this is the description */') @@ -806,7 +806,7 @@ describe "JSDoc grammar", -> it "tokenises @param tags with qualified types", -> {tokens} = grammar.tokenizeLine('/** @param {myNamespace.MyClass} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -814,10 +814,10 @@ describe "JSDoc grammar", -> 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @param {Foo~cb} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -825,7 +825,7 @@ describe "JSDoc grammar", -> 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: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] it "tokenises @param tags with multiple types", -> {tokens} = grammar.tokenizeLine('/** @param {function|string} variable this is the description */') @@ -836,7 +836,7 @@ describe "JSDoc grammar", -> expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] {tokens} = grammar.tokenizeLine('/** @param {string[]|number} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -865,7 +865,7 @@ describe "JSDoc grammar", -> expect(tokens[10]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] {tokens} = grammar.tokenizeLine('/** @param {(string[]|number)} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -876,7 +876,7 @@ describe "JSDoc grammar", -> expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] expect(tokens[12]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[13]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[14]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[14]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @param {(string|number[])} variable 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'] @@ -914,24 +914,24 @@ describe "JSDoc grammar", -> expect(tokens[9]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] {tokens} = grammar.tokenizeLine('/** @param {...*} remainder */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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: '...*', 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: 'remainder', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @param {...?} remainder */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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: '...?', 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: 'remainder', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] it "tokenises @param tags using Google Closure Compiler syntax", -> {tokens} = grammar.tokenizeLine('/** @param {number=} variable this is the description */') @@ -950,7 +950,7 @@ describe "JSDoc grammar", -> expect(tokens[11]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] {tokens} = grammar.tokenizeLine('/** @param {Foo[].bar} variable this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -961,7 +961,7 @@ describe "JSDoc grammar", -> expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] expect(tokens[12]).toEqual value: 'variable', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc'] expect(tokens[13]).toEqual value: ' this is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[14]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[14]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @param {Array} variable this is the description */') expect(tokens[3]).toEqual value: 'param', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] @@ -1147,26 +1147,26 @@ describe "JSDoc grammar", -> it "tokenises @return tags without descriptions", -> {tokens} = grammar.tokenizeLine('/** @return {object} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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: 'return', 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', 'punctuation.definition.comment.js'] + expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @returns {object} */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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: 'returns', 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', 'punctuation.definition.comment.js'] + expect(tokens[9]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] it "tokenises @return tags with trailing descriptions", -> {tokens} = grammar.tokenizeLine('/** @returns {object} this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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: 'returns', 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'] @@ -1174,10 +1174,10 @@ describe "JSDoc grammar", -> 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: 'this', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[10]).toEqual value: ' is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @return {object} this is the description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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: 'return', 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'] @@ -1185,7 +1185,7 @@ describe "JSDoc grammar", -> 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: 'this', scopes: ['source.js', 'comment.block.documentation.js'] expect(tokens[10]).toEqual value: ' is the description ', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] {tokens} = grammar.tokenizeLine('/** @returns {(Something)} */') expect(tokens[3]).toEqual value: 'returns', scopes: ['source.js', 'comment.block.documentation.js', 'storage.type.class.jsdoc'] @@ -1201,7 +1201,7 @@ describe "JSDoc grammar", -> expect(tokens[7]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] {tokens} = grammar.tokenizeLine('/** @return {(String[]|Number[])} Description */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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: 'return', 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'] @@ -1214,7 +1214,7 @@ describe "JSDoc grammar", -> expect(tokens[12]).toEqual value: ')', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc', 'punctuation.definition.bracket.curly.end.jsdoc'] expect(tokens[15]).toEqual value: 'Description', scopes: ['source.js', 'comment.block.documentation.js'] - expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[17]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] it "tokenises function-type @return tags", -> {tokens} = grammar.tokenizeLine('/** @return {function()} this is the description */') @@ -1312,7 +1312,7 @@ describe "JSDoc grammar", -> expect(lines[1][8]).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[1][9]).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[1][10]).toEqual value: ';', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'punctuation.terminator.statement.js'] - expect(lines[2][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(lines[2][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] lines = grammar.tokenizeLines """ /** @@ -1332,7 +1332,7 @@ describe "JSDoc grammar", -> 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][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(lines[3][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] lines = grammar.tokenizeLines """ /** @@ -1369,11 +1369,11 @@ describe "JSDoc grammar", -> expect(lines[3][3]).toEqual value: '+', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'keyword.operator.js'] expect(lines[3][5]).toEqual value: '50', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'constant.numeric.decimal.js'] 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.definition.comment.js'] + expect(lines[4][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.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.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -1383,7 +1383,7 @@ describe "JSDoc grammar", -> 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.definition.comment.js'] + expect(tokens[13]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] lines = grammar.tokenizeLines """ /** @@ -1392,7 +1392,7 @@ describe "JSDoc grammar", -> * @return {String} */ """ - expect(lines[0][0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(lines[0][0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -1418,22 +1418,22 @@ describe "JSDoc grammar", -> 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.definition.comment.js'] + expect(lines[4][1]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] describe "when the containing comment ends unexpectedly", -> it "terminates any unclosed tags", -> {tokens} = grammar.tokenizeLine('/** @param {String */ aa') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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', 'punctuation.definition.comment.js'] + expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] expect(tokens[8]).toEqual value: ' aa', scopes: ['source.js'] {tokens} = grammar.tokenizeLine('/** @param {*} [name={value: {a:[{*/}}]}] */') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -1450,7 +1450,7 @@ describe "JSDoc grammar", -> expect(tokens[18]).toEqual value: ':', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'keyword.operator.assignment.js'] expect(tokens[19]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.square.js'] expect(tokens[20]).toEqual value: '{', scopes: ['source.js', 'comment.block.documentation.js', 'variable.other.jsdoc', 'source.embedded.js', 'meta.brace.curly.js'] - expect(tokens[21]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[21]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] expect(tokens[22]).toEqual value: '}}', scopes: ['source.js'] expect(tokens[23]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] expect(tokens[24]).toEqual value: '}', scopes: ['source.js'] @@ -1459,12 +1459,12 @@ describe "JSDoc grammar", -> expect(tokens[28]).toEqual value: '/', scopes: ['source.js', 'keyword.operator.js'] {tokens} = grammar.tokenizeLine('/** @param {string="Foo*/oo"} bar') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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="Foo', scopes: ['source.js', 'comment.block.documentation.js', 'entity.name.type.instance.jsdoc'] - expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] expect(tokens[8]).toEqual value: 'oo', scopes: ['source.js'] expect(tokens[9]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] expect(tokens[10]).toEqual value: '} bar', scopes: ['source.js', 'string.quoted.double.js', 'invalid.illegal.string.js'] @@ -1477,7 +1477,7 @@ describe "JSDoc grammar", -> * @return {String} */ """ - expect(lines[0][0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(lines[0][0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -1490,9 +1490,9 @@ describe "JSDoc grammar", -> 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[2][9]).toEqual value: '/*', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.block.js', 'punctuation.definition.comment.js'] + expect(lines[2][9]).toEqual value: '/*', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.block.js', 'punctuation.definition.comment.begin.js'] expect(lines[2][10]).toEqual value: ' Comment ', scopes: ['source.js', 'comment.block.documentation.js', 'meta.example.jsdoc', 'source.embedded.js', 'comment.block.js'] - expect(lines[2][11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(lines[2][11]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] expect(lines[3][1]).toEqual value: '*', scopes: ['source.js', 'keyword.operator.js'] expect(lines[3][2]).toEqual value: ' @', scopes: ['source.js'] expect(lines[3][3]).toEqual value: 'return', scopes: ['source.js', 'keyword.control.js'] @@ -1503,7 +1503,7 @@ describe "JSDoc grammar", -> expect(lines[4][2]).toEqual value: '/', scopes: ['source.js', 'keyword.operator.js'] {tokens} = grammar.tokenizeLine('/** @param {Something} [value={key: [value, ["22"}] */ 20;') - expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[0]).toEqual value: '/**', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.begin.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'] @@ -1524,6 +1524,6 @@ describe "JSDoc grammar", -> 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', 'source.embedded.js', 'meta.brace.square.js'] - expect(tokens[27]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.js'] + expect(tokens[27]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.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 43317ef4bd2edfb82f8ae7a642196e23a072900c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D1=82=D0=B2=D0=B5=D0=B9?= Date: Tue, 18 Jul 2017 21:20:27 +0300 Subject: [PATCH 229/420] Add 'dir' snippet --- snippets/language-javascript.cson | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snippets/language-javascript.cson b/snippets/language-javascript.cson index 8f523430..c8064854 100644 --- a/snippets/language-javascript.cson +++ b/snippets/language-javascript.cson @@ -74,6 +74,9 @@ 'log': 'prefix': 'log' 'body': 'console.log($1);$0' + 'dir': + 'prefix': 'dir' + 'body': 'console.dir($1);$0' 'warn': 'prefix': 'warn' 'body': 'console.warn($1);$0' From b01b9b6e445428438d259b336596058d30f28751 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Wed, 9 Aug 2017 11:16:54 -0400 Subject: [PATCH 230/420] Prepare 0.127.2 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9d1d38e5..29abca32 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.127.1", + "version": "0.127.2", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 09cf8a1d567712d109a83f9ac4796717505dccdc Mon Sep 17 00:00:00 2001 From: aemino Date: Fri, 11 Aug 2017 09:41:16 -0700 Subject: [PATCH 231/420] Add .mjs as a supported file type At this point, the Node.js CTC has [settled on](https://github.com/nodejs/node-eps/blob/master/002-es-modules.md#32-determining-if-source-is-an-es-module) the `.mjs` extension for ES6 module files. In addition, the [`@std/esm`](https://www.npmjs.com/package/@std/esm) package has been released, which allows inline, spec-compliant usage of ES6 modules in Node.js. In an effort to push the migration from `.js` to `.mjs`, the module defaults to only affecting files with the `.mjs` extension. --- grammars/javascript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 085b8e57..122de25e 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -4,6 +4,7 @@ '_js' 'es' 'es6' + 'mjs' 'gs' 'htc' 'jscad' From 0daf8d8333996374836447e17b31c637e39d8a81 Mon Sep 17 00:00:00 2001 From: aemino Date: Fri, 11 Aug 2017 10:36:46 -0700 Subject: [PATCH 232/420] Alphabetize --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 122de25e..8883c3e9 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -4,7 +4,6 @@ '_js' 'es' 'es6' - 'mjs' 'gs' 'htc' 'jscad' @@ -12,6 +11,7 @@ 'jsm' 'json5' 'jspre' + 'mjs' 'pac' 'pjs' 'sjs' From 9f65f4f2dfd6316a6e6a5f4b04d5c0d18c85c69e Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Mon, 28 Aug 2017 16:08:38 -0400 Subject: [PATCH 233/420] Prepare 0.127.3 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 29abca32..319b956b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.127.2", + "version": "0.127.3", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 7c0699f2e753cb5d8aff676d5bff684bb59b1c04 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Thu, 21 Sep 2017 15:59:32 +1000 Subject: [PATCH 234/420] Add `@polymer` and `@polymerBehavior` JSDoc tags These tags are used for marking objects with Polymer-specific semantics. Used by Closure Compiler when executed with `--polymer_pass=2`. Source: https://git.io/v5jo4 --- grammars/jsdoc.cson | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index 7f16fb5d..481c3e37 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -401,10 +401,10 @@ |exports?|extends|extension(?:_?for)?|external|externs|file|fileoverview|final|fires|for|func |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) + |name|namespace|noalias|nocollapse|nocompile|nosideeffects|override|overview|package|param + |polymer(?:Behavior)?|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 6685c1a9c60c60681e865f622f7fea4a8fa58e63 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Thu, 21 Sep 2017 16:13:00 +1000 Subject: [PATCH 235/420] Allow curly brackets to be used in some JSDoc tags Closure Compiler permits or requires curly brackets around {Type} tokens that follow certain JSDoc tags. Specifically: /** * @export {SomeType} * @extends {goog.ds.BasicNodeList} * @lends {objectName} * @modifies {this} * @this {Widget} */ See: https://github.com/google/closure-compiler/wiki --- grammars/jsdoc.cson | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index 481c3e37..b505ae2d 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -311,7 +311,14 @@ { # Tags followed by a type expression # - @ {type} - 'begin': '((@)(?:define|enum|exception|implements|modifies|namespace|private|protected|returns?|suppress|throws|type))\\s+(?={)' + 'begin': '''(?x) + ( + (@) + (?:define|enum|exception|export|extends|lends|implements|modifies + |namespace|private|protected|returns?|suppress|this|throws|type) + ) + \\s+(?={) + ''' 'beginCaptures': '1': 'name': 'storage.type.class.jsdoc' From 1524164e55879f23a6429941422906fd5bfcebb9 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Thu, 21 Sep 2017 16:31:28 +1000 Subject: [PATCH 236/420] Add support for JSDoc 3.5.0 tags This adds support for the @generator, @yield, and @hideconstructor tags: class CompleteExample { /** @hideconstructor */ constructor() { } /** * Generate numbers in the Fibonacci sequence. * @generator * @yields {Number} The next number in the Fibonacci sequence. */ * fibonacci(){ yield 41.999999999; } } See: * http://usejsdoc.org/tags-generator.html * http://usejsdoc.org/tags-yields.html * http://usejsdoc.org/tags-hideconstructor.html --- grammars/jsdoc.cson | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index b505ae2d..84868d07 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -315,7 +315,8 @@ ( (@) (?:define|enum|exception|export|extends|lends|implements|modifies - |namespace|private|protected|returns?|suppress|this|throws|type) + |namespace|private|protected|returns?|suppress|this|throws|type + |yields?) ) \\s+(?={) ''' @@ -406,12 +407,13 @@ |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 - |internal|kind|lends|license|listens|main|member|memberof!?|method|mixes|mixins?|modifies|module - |name|namespace|noalias|nocollapse|nocompile|nosideeffects|override|overview|package|param - |polymer(?:Behavior)?|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|generator|global|hideconstructor|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|polymer(?:Behavior)?|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|yields?) \\b ''' 'name': 'storage.type.class.jsdoc' From 0ea510870f5d3dde5d4f4a00e6a7dbfeaecad97e Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Thu, 21 Sep 2017 20:34:29 +0200 Subject: [PATCH 237/420] Use Trusty on Travis --- .travis.yml | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index a6b772f1..47ee9a1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,41 @@ -language: objective-c +### Project specific config ### +language: generic + +env: + global: + - APM_TEST_PACKAGES="" + - ATOM_LINT_WITH_BUNDLED_NODE="true" + + matrix: + - ATOM_CHANNEL=stable + - ATOM_CHANNEL=beta + +### Generic setup follows ### +script: + - curl -s -O https://raw.githubusercontent.com/atom/ci/master/build-package.sh + - chmod u+x build-package.sh + - ./build-package.sh notifications: email: on_success: never on_failure: change -script: 'curl -s https://raw.githubusercontent.com/atom/ci/master/build-package.sh | sh' - branches: only: - master + +git: + depth: 10 + +sudo: false + +dist: trusty + +addons: + apt: + packages: + - build-essential + - fakeroot + - git + - libsecret-1-dev From d939cc51bc3e18659f229e327925cb37ab17d123 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Thu, 21 Sep 2017 20:13:17 +0200 Subject: [PATCH 238/420] Adjust specs for language-html changes --- spec/javascript-spec.coffee | 57 +++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 7b938fc3..583d680b 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -613,6 +613,15 @@ describe "JavaScript grammar", -> expect(tokens[14]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.js', 'punctuation.definition.string.end.js'] describe "HTML template strings", -> + # TODO: Remove after Atom 1.21 is released + [tagScope, entityScope] = [] + if parseFloat(atom.getVersion()) <= 1.21 + tagScope = 'meta.tag.inline.any.html' + entityScope = 'entity.name.tag.inline.any.html' + else + tagScope = 'meta.tag.inline.b.html' + entityScope = 'entity.name.tag.inline.b.html' + beforeEach -> waitsForPromise -> atom.packages.activatePackage("language-html") @@ -622,15 +631,15 @@ describe "JavaScript grammar", -> expect(tokens[0]).toEqual value: 'html', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] expect(tokens[2]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[3]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] - expect(tokens[4]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] - expect(tokens[5]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[3]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, 'punctuation.definition.tag.begin.html'] + expect(tokens[4]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, entityScope] + expect(tokens[5]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, 'punctuation.definition.tag.end.html'] expect(tokens[6]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] expect(tokens[7]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] expect(tokens[8]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[9]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[9]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, 'punctuation.definition.tag.end.html'] expect(tokens[12]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] it "tokenizes innerHTML attribute declarations with string template tags", -> @@ -643,15 +652,15 @@ describe "JavaScript grammar", -> expect(tokens[5]).toEqual value: ' ', scopes: ['source.js'] expect(tokens[6]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] expect(tokens[7]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[8]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] - expect(tokens[9]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] - expect(tokens[10]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[8]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, 'punctuation.definition.tag.begin.html'] + expect(tokens[9]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, entityScope] + expect(tokens[10]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, 'punctuation.definition.tag.end.html'] expect(tokens[11]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] expect(tokens[12]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] expect(tokens[13]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[14]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[14]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, 'punctuation.definition.tag.end.html'] expect(tokens[17]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] it "tokenizes ES6 tagged HTML string templates with expanded function name", -> @@ -659,15 +668,15 @@ describe "JavaScript grammar", -> expect(tokens[0]).toEqual value: 'escapeHTML', scopes: ['source.js', 'string.quoted.template.html.js', 'entity.name.function.js'] expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] expect(tokens[2]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[3]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] - expect(tokens[4]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] - expect(tokens[5]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[3]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, 'punctuation.definition.tag.begin.html'] + expect(tokens[4]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, entityScope] + expect(tokens[5]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, 'punctuation.definition.tag.end.html'] expect(tokens[6]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] expect(tokens[7]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] expect(tokens[8]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[9]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[9]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, 'punctuation.definition.tag.end.html'] expect(tokens[12]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] it "tokenizes ES6 tagged HTML string templates with expanded function name and white space", -> @@ -676,15 +685,15 @@ describe "JavaScript grammar", -> expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'string.quoted.template.html.js'] expect(tokens[2]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.begin.js'] expect(tokens[3]).toEqual value: 'hey ', scopes: ['source.js', 'string.quoted.template.html.js'] - expect(tokens[4]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.begin.html'] - expect(tokens[5]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'entity.name.tag.inline.any.html'] - expect(tokens[6]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[4]).toEqual value: '<', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, 'punctuation.definition.tag.begin.html'] + expect(tokens[5]).toEqual value: 'b', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, entityScope] + expect(tokens[6]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, 'punctuation.definition.tag.end.html'] expect(tokens[7]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] expect(tokens[8]).toEqual value: 'name', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source'] expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.html.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[10]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', 'meta.tag.inline.any.html', 'punctuation.definition.tag.end.html'] + expect(tokens[10]).toEqual value: '', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, 'punctuation.definition.tag.end.html'] expect(tokens[13]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] describe "ES6 tagged Relay.QL string templates", -> From 608611408bd375bd703cf55c52c511c185772fa3 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Thu, 21 Sep 2017 20:28:20 +0200 Subject: [PATCH 239/420] Fix catastrophic backtracking? --- grammars/jsdoc.cson | 4 ++-- spec/jsdoc-spec.coffee | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/grammars/jsdoc.cson b/grammars/jsdoc.cson index 84868d07..f199cacf 100644 --- a/grammars/jsdoc.cson +++ b/grammars/jsdoc.cson @@ -276,11 +276,11 @@ \\s* ( # The inner regexes are to stop the match early at */ and to not stop at escaped quotes - (?: + (?> "(?:(?:\\*(?!/))|(?:\\\\(?!"))|[^*\\\\])*?" | # [foo="bar"] Double-quoted '(?:(?:\\*(?!/))|(?:\\\\(?!'))|[^*\\\\])*?' | # [foo='bar'] Single-quoted \\[ (?:(?:\\*(?!/))|[^*])*? \\] | # [foo=[1,2]] Array literal - (?:(?:\\*(?!/))|[^*])*? # Everything else + (?:(?:\\*(?!/))|\\s(?!\\s*\\])|\\[.*?(?:\\]|(?=\\*/))|[^*\\s\\[\\]])* # Everything else (sorry) )* ) )? diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index c904f5c3..5aa50985 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -1527,3 +1527,9 @@ describe "JSDoc grammar", -> expect(tokens[27]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.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'] + + describe "when the line ends without a closing bracket", -> + it "does not attempt to match the optional value (regression)", -> + {tokens} = grammar.tokenizeLine('/** @param {array} [bar = "x" REMOVE THE CLOSE BRACKET HERE.') + expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js'] + expect(tokens[11]).toEqual value: ' = "x" REMOVE THE CLOSE BRACKET HERE.', scopes: ['source.js', 'comment.block.documentation.js'] From 3d9a5fd65690fd959aad16fbc87bc4f47a21e009 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Thu, 21 Sep 2017 20:44:31 +0200 Subject: [PATCH 240/420] Prepare 0.127.4 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 319b956b..e5ad4c85 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.127.3", + "version": "0.127.4", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 6059880ceb7c63b65a0b116cc8ca9063524159b8 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Thu, 21 Sep 2017 22:04:17 +0200 Subject: [PATCH 241/420] Prepare 0.127.5 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e5ad4c85..afdddc6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.127.4", + "version": "0.127.5", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 85bbd31ebf179688bd665311cab79c959e1a9e04 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Mon, 25 Sep 2017 12:12:13 +1000 Subject: [PATCH 242/420] Hide RegExp-specific grammars from selection menu The presence of a `name` field is causing these two grammars to be shown in the grammar selection menu. Both are used internally to highlight the find-and-replace fields when using regexp-enabled seaching. References: atom/grammar-selector#34 --- grammars/regular expression replacement (javascript).cson | 2 -- grammars/regular expressions (javascript).cson | 2 -- 2 files changed, 4 deletions(-) diff --git a/grammars/regular expression replacement (javascript).cson b/grammars/regular expression replacement (javascript).cson index 596b8279..eeaa8d70 100644 --- a/grammars/regular expression replacement (javascript).cson +++ b/grammars/regular expression replacement (javascript).cson @@ -1,6 +1,4 @@ 'scopeName': 'source.js.regexp.replacement' -'name': 'Regular Expression Replacement (JavaScript)' -'fileTypes': [] 'patterns': [ { 'include': '#regexp-replacement' diff --git a/grammars/regular expressions (javascript).cson b/grammars/regular expressions (javascript).cson index 92368e8f..d9891feb 100644 --- a/grammars/regular expressions (javascript).cson +++ b/grammars/regular expressions (javascript).cson @@ -1,6 +1,4 @@ 'scopeName': 'source.js.regexp' -'name': 'Regular Expressions (JavaScript)' -'fileTypes': [] 'patterns': [ { 'include': '#regexp' From 98080a7a9f20e88a947fc740783f0959021fdb87 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Fri, 13 Oct 2017 08:44:31 +1100 Subject: [PATCH 243/420] Allow spreads to precede the `await` operator --- grammars/javascript.cson | 6 +++++- spec/javascript-spec.coffee | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 8883c3e9..85bb2857 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -951,7 +951,11 @@ 'name': 'meta.control.yield.js' } { - 'match': '(? expect(tokens[0]).toEqual value: "debugger", scopes: ['source.js', 'keyword.other.debugger.js'] expect(tokens[1]).toEqual value: ";", scopes: ['source.js', 'punctuation.terminator.statement.js'] + it "tokenises an `await` keyword after a spread operator", -> + {tokens} = grammar.tokenizeLine("...await stuff()") + expect(tokens[0]).toEqual value: '...', scopes: ['source.js', 'keyword.operator.spread.js'] + expect(tokens[1]).toEqual value: 'await', scopes: ['source.js', 'keyword.control.js'] + expect(tokens[3]).toEqual value: 'stuff', scopes: ['source.js', 'meta.function-call.js', 'entity.name.function.js'] + expect(tokens[4]).toEqual value: '(', scopes: ['source.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] + expect(tokens[5]).toEqual value: ')', scopes: ['source.js', 'meta.function-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + describe "built-in globals", -> it "tokenizes built-in classes", -> {tokens} = grammar.tokenizeLine('window') From 7bc149be65250b3f1a8dcfd700fbef12f0ede4b5 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Thu, 19 Oct 2017 23:51:52 +0200 Subject: [PATCH 244/420] `package` is a valid function name --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 85bb2857..11c8cc3d 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -467,7 +467,7 @@ (?= (?! (break|case|catch|continue|do|else|finally|for|function|if| - package|return|switch|throw|try|while|with) + return|switch|throw|try|while|with) [\\s\\(] ) ( From 58cb09d7732a4828f3d8f361cc63294daf1c5f14 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Wed, 25 Oct 2017 14:50:48 +0200 Subject: [PATCH 245/420] Prepare 0.127.6 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index afdddc6c..c31072f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.127.5", + "version": "0.127.6", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 57a0478a94a0c0cbd9e36cfdd7994604fc750984 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Fri, 10 Nov 2017 20:11:35 +0100 Subject: [PATCH 246/420] Allow more punctuation to precede regexes --- grammars/javascript.cson | 2 +- spec/javascript-spec.coffee | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 11c8cc3d..3962041a 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1130,7 +1130,7 @@ 'name': 'constant.language.js' } { - 'begin': '(?<=[\\[=(?:+,!]|^|return|=>|&&|\\|\\|)\\s*(/)(?![/*+?])(?=.*/)' + 'begin': '(?<=[\\[{=(?:+*,!~-]|^|return|=>|&&|\\|\\|)\\s*(/)(?![/*+?])(?=.*/)' 'beginCaptures': '1': 'name': 'punctuation.definition.string.begin.js' diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 6339e3d6..24b3a76e 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -216,6 +216,14 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] expect(tokens[7]).toEqual value: ']', scopes: ['source.js', 'meta.brace.square.js'] + it "tokenizes regular expressions inside curly brackets", -> + {tokens} = grammar.tokenizeLine('{/test/}') + expect(tokens[0]).toEqual value: '{', scopes: ['source.js', 'meta.brace.curly.js'] + expect(tokens[1]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] + expect(tokens[2]).toEqual value: 'test', scopes: ['source.js', 'string.regexp.js'] + expect(tokens[3]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] + expect(tokens[4]).toEqual value: '}', scopes: ['source.js', 'meta.brace.curly.js'] + it "tokenizes regular expressions inside arrow function expressions", -> {tokens} = grammar.tokenizeLine('getRegex = () => /^helloworld$/;') expect(tokens[9]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] From af8b923fec9632821a4d7c5229ae513bdd1aa35d Mon Sep 17 00:00:00 2001 From: Kepler Sticka-Jones Date: Sat, 11 Nov 2017 14:32:58 -0700 Subject: [PATCH 247/420] Add Jest Snapshot File Format --- grammars/javascript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 11c8cc3d..154de308 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -15,6 +15,7 @@ 'pac' 'pjs' 'sjs' + 'snap' 'xsjs' 'xsjslib' ] From 83536ba0fd522bfc070c5c170aa031092fec8c20 Mon Sep 17 00:00:00 2001 From: Justin Ratner Date: Sat, 18 Nov 2017 17:57:07 -0700 Subject: [PATCH 248/420] Add editor.nonWordCharacters --- settings/language-javascript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/settings/language-javascript.cson b/settings/language-javascript.cson index 8d1243e7..f7bc48f6 100644 --- a/settings/language-javascript.cson +++ b/settings/language-javascript.cson @@ -1,5 +1,6 @@ '.source.js': 'editor': + 'nonWordCharacters': '/\\()"\':,.;<>~!#@%^&*|+=[]{}`?-…' 'commentStart': '// ' 'foldEndPattern': '^\\s*\\}|^\\s*\\]|^\\s*\\)' 'increaseIndentPattern': '(?x) From 95200299fa9fb7c836eff291bfb85465781553dc Mon Sep 17 00:00:00 2001 From: Justin Ratner Date: Mon, 20 Nov 2017 12:17:19 -0700 Subject: [PATCH 249/420] Prepare 0.127.7 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c31072f5..f0b47eca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.127.6", + "version": "0.127.7", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 24b039f2593c2769ab6e6491698ce06f164f1709 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 29 Nov 2017 16:54:48 -0800 Subject: [PATCH 250/420] Add tree-sitter JavaScript grammar --- grammars/tree-sitter-javascript.cson | 131 +++++++++++++++++++++++++++ package.json | 3 + 2 files changed, 134 insertions(+) create mode 100644 grammars/tree-sitter-javascript.cson diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson new file mode 100644 index 00000000..dff1fa54 --- /dev/null +++ b/grammars/tree-sitter-javascript.cson @@ -0,0 +1,131 @@ +id: 'javascript' + +name: 'JavaScript' + +type: 'tree-sitter' + +parser: 'tree-sitter-javascript' + +folds: + delimiters: [ + ['{', '}'] + ['(', ')'] + ['[', ']'], + ['jsx_opening_element', 'jsx_closing_element'], + ['<', '>', {afterChildCount: 1}] + ], + + tokens: [ + ['comment', 2, 2] + ['template_string', 1, 1] + ] + +fileTypes: [ + 'js' +] + +firstLineMatch: '''(?x) + # Hashbang + ^\\#!.*(?:\\s|\\/|(?<=!)\\b) + (?:node|iojs|JavaScript) + (?:$|\\s) + | + # Modeline + (?i: + # Emacs + -\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*) + (?:js|javascript) + (?=[\\s;]|(?]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s*set?\\s))(?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:](?:filetype|ft|syntax)\\s*= + javascript + (?=\\s|:|$) + ) +''' + +comments: + start: '// ' + +scopes: + 'program': 'source.js' + + 'class > identifier': 'entity.name.type.class' + + 'property_identifier': 'variable.other.object.property' + + 'function > identifier': 'entity.name.function' + 'call_expression > identifier': 'entity.name.function' + + 'method_definition > property_identifier': 'entity.name.function' + 'call_expression > member_expression > property_identifier': 'entity.name.function' + + 'new_expression > call_expression > identifier': 'meta.class.instance.constructor' + + 'import_specifier > identifier': 'variable.other.module' + 'import_clause > identifier': 'variable.other.module' + + 'number': 'constant.numeric' + 'string': 'string.quoted' + 'regex': 'string.regexp' + 'template_string': 'string.quoted.template' + 'undefined': 'constant.language' + 'null': 'constant.language.null' + 'true': 'constant.language.boolean.true' + 'false': 'constant.language.boolean.false' + 'comment': 'comment.block' + + '"("': 'punctuation.definition.parameters.begin.bracket.round' + '")"': 'punctuation.definition.parameters.end.bracket.round' + '"{"': 'punctuation.definition.function.body.begin.bracket.curly' + '"}"': 'punctuation.definition.function.body.end.bracket.curly' + + '"var"': 'storage.type' + '"let"': 'storage.type' + '"class"': 'storage.type' + '"const"': 'storage.modifier' + '"static"': 'storage.modifier' + '"function"': 'storage.type' + + '"+"': 'keyword.operator' + '"-"': 'keyword.operator' + '"*"': 'keyword.operator' + '"/"': 'keyword.operator' + '"in"': 'keyword.operator.in' + '"instanceof"': 'keyword.operator.instanceof' + '"of"': 'keyword.operator.of' + '"new"': 'keyword.operator.new' + '"typeof"': 'keyword.operator.typeof' + + '"get"': 'keyword.operator.setter' + '"set"': 'keyword.operator.setter' + + '"."': 'meta.delimiter' + '","': 'meta.delimiter' + + '"if"': 'keyword.control' + '"do"': 'keyword.control' + '"else"': 'keyword.control' + '"while"': 'keyword.control' + '"for"': 'keyword.control' + '"return"': 'keyword.control' + '"break"': 'keyword.control' + '"continue"': 'keyword.control' + '"throw"': 'keyword.control' + '"try"': 'keyword.control' + '"catch"': 'keyword.control' + '"finally"': 'keyword.control' + '"switch"': 'keyword.control' + '"case"': 'keyword.control' + '"default"': 'keyword.control' + '"export"': 'keyword.control' + '"import"': 'keyword.control' + '"from"': 'keyword.control' + '"yield"': 'keyword.control' + '"async"': 'keyword.control' + '"await"': 'keyword.control' + + 'jsx_attribute': 'entity.other.attribute-name' + 'jsx_opening_element > identifier': 'entity.name.tag' + 'jsx_closing_element > identifier': 'entity.name.tag' + 'jsx_self_closing_element > identifier': 'entity.name.tag' diff --git a/package.json b/package.json index f0b47eca..dac832b1 100644 --- a/package.json +++ b/package.json @@ -17,5 +17,8 @@ }, "devDependencies": { "coffeelint": "^1.10.1" + }, + "dependencies": { + "tree-sitter-javascript": "^0.4.7" } } From 143ed6d508fe882adff0ffe817aa24fd0c350a97 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 29 Nov 2017 16:59:51 -0800 Subject: [PATCH 251/420] 0.128.0-0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dac832b1..0bb08a6f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.127.7", + "version": "0.128.0-0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 044b14e85e1a83d45cf29462b22811bf864a18ee Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 29 Nov 2017 17:18:35 -0800 Subject: [PATCH 252/420] Use visual studio 2015 on appveyor --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 2b0fde43..7d07d05d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,7 @@ version: "{build}" +image: Visual Studio 2015 + platform: x64 branches: From 4ade4044018e3d53e15da62b1e4b9a74bdd6b760 Mon Sep 17 00:00:00 2001 From: "/\\/es" <5124946+wesdawg@users.noreply.github.com> Date: Thu, 30 Nov 2017 10:25:42 -0500 Subject: [PATCH 253/420] Update javascript.cson Add JScript file extensions --- grammars/javascript.cson | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 154de308..1c77ac54 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -7,6 +7,8 @@ 'gs' 'htc' 'jscad' + 'jscript' + 'jse' 'jslib' 'jsm' 'json5' From d1198bf2aa6d2a918b2439d3b898deb8e814711d Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 30 Nov 2017 13:46:41 -0800 Subject: [PATCH 254/420] :art: --- grammars/tree-sitter-javascript.cson | 35 ++++++++++++---------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index dff1fa54..62677cf5 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -1,28 +1,9 @@ id: 'javascript' - name: 'JavaScript' - type: 'tree-sitter' - parser: 'tree-sitter-javascript' -folds: - delimiters: [ - ['{', '}'] - ['(', ')'] - ['[', ']'], - ['jsx_opening_element', 'jsx_closing_element'], - ['<', '>', {afterChildCount: 1}] - ], - - tokens: [ - ['comment', 2, 2] - ['template_string', 1, 1] - ] - -fileTypes: [ - 'js' -] +fileTypes: ['js', 'jsx'] firstLineMatch: '''(?x) # Hashbang @@ -44,6 +25,20 @@ firstLineMatch: '''(?x) ) ''' +folds: + delimiters: [ + ['{', '}'] + ['(', ')'] + ['[', ']'] + ['jsx_opening_element', 'jsx_closing_element'] + ['<', '>', {afterChildCount: 1}] + ] + + tokens: [ + ['comment', 2, 2] + ['template_string', 1, 1] + ] + comments: start: '// ' From 04c539e4ec3d72149ef0228b2f429096442f7bed Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 4 Dec 2017 11:57:19 -0800 Subject: [PATCH 255/420] Highlight template substitution delimiters --- grammars/tree-sitter-javascript.cson | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 62677cf5..d705fac6 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -70,6 +70,9 @@ scopes: 'false': 'constant.language.boolean.false' 'comment': 'comment.block' + 'template_substitution > "${"': 'punctuation.section.embedded' + 'template_substitution > "}"': 'punctuation.section.embedded' + '"("': 'punctuation.definition.parameters.begin.bracket.round' '")"': 'punctuation.definition.parameters.end.bracket.round' '"{"': 'punctuation.definition.function.body.begin.bracket.curly' From 51450bff8b6396f2578398c7b475d6c34eebce1f Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 4 Dec 2017 11:57:29 -0800 Subject: [PATCH 256/420] Update fold config syntax --- grammars/tree-sitter-javascript.cson | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index d705fac6..20176f98 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -34,9 +34,9 @@ folds: ['<', '>', {afterChildCount: 1}] ] - tokens: [ - ['comment', 2, 2] - ['template_string', 1, 1] + nodes: [ + 'comment', + 'template_string', ] comments: From 9dbcdf7ccbea9eebff0cd909f972b8d125da2e94 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 5 Dec 2017 13:14:54 -0800 Subject: [PATCH 257/420] Use new fold config API for tree-sitter grammar --- grammars/tree-sitter-javascript.cson | 40 +++++++++++++++++++--------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 20176f98..ea77d831 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -25,19 +25,33 @@ firstLineMatch: '''(?x) ) ''' -folds: - delimiters: [ - ['{', '}'] - ['(', ')'] - ['[', ']'] - ['jsx_opening_element', 'jsx_closing_element'] - ['<', '>', {afterChildCount: 1}] - ] - - nodes: [ - 'comment', - 'template_string', - ] +folds: [ + { + type: ['comment', 'template_string'] + } + { + type: 'jsx_element' + start: {index: 0} + end: {index: -1} + } + { + type: 'jsx_self_closing_element' + start: {index: 1} + end: {index: -2} + } + { + start: {index: 0, type: '{'} + end: {index: -1, type: '}'} + } + { + start: {index: 0, type: '['} + end: {index: -1, type: ']'} + } + { + start: {index: 0, type: '('} + end: {index: -1, type: ')'} + } +] comments: start: '// ' From 068e8049367e326ad0f1d37bab858b1d52c010d6 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 5 Dec 2017 14:08:25 -0800 Subject: [PATCH 258/420] Prepare 0.128.0-1 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0bb08a6f..d540c0f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.0-0", + "version": "0.128.0-1", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 1331fa94e3bad086649a6882d418b7479e95e88a Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 5 Dec 2017 14:11:34 -0800 Subject: [PATCH 259/420] Fix JSX attribute scope mapping --- grammars/tree-sitter-javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index ea77d831..c4d09bbb 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -137,7 +137,7 @@ scopes: '"async"': 'keyword.control' '"await"': 'keyword.control' - 'jsx_attribute': 'entity.other.attribute-name' + 'jsx_attribute > property_identifier': 'entity.other.attribute-name' 'jsx_opening_element > identifier': 'entity.name.tag' 'jsx_closing_element > identifier': 'entity.name.tag' 'jsx_self_closing_element > identifier': 'entity.name.tag' From ad2e5d19717aec7abd6ac6529034477ff2146dce Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 6 Dec 2017 11:15:49 -0800 Subject: [PATCH 260/420] Fix template string folding --- grammars/tree-sitter-javascript.cson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index c4d09bbb..a08882cf 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -27,10 +27,10 @@ firstLineMatch: '''(?x) folds: [ { - type: ['comment', 'template_string'] + type: 'comment' } { - type: 'jsx_element' + type: ['jsx_element', 'template_string'], start: {index: 0} end: {index: -1} } From b88bd7ec8e15ab558bf9ed5b0d3b1fadd18939d6 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 6 Dec 2017 12:38:10 -0800 Subject: [PATCH 261/420] Prepare 0.128.0-2 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d540c0f0..38b44e0f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.0-1", + "version": "0.128.0-2", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From b06e4dc2618db20aee33db71ef60380561961263 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 15 Dec 2017 16:30:18 -0800 Subject: [PATCH 262/420] Add legacy scope name property --- grammars/tree-sitter-javascript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index a08882cf..3edcd103 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -2,6 +2,7 @@ id: 'javascript' name: 'JavaScript' type: 'tree-sitter' parser: 'tree-sitter-javascript' +legacyScopeName: 'source.js' fileTypes: ['js', 'jsx'] From 4f85189a25116a9b79e10b7c48b1fc0d3b73baac Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 15 Dec 2017 16:30:46 -0800 Subject: [PATCH 263/420] Prepare 0.128.0-3 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 38b44e0f..7a45950f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.0-2", + "version": "0.128.0-3", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 202431f49ba12b710cad9922d6262cf3403698f8 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 26 Dec 2017 13:43:50 -0800 Subject: [PATCH 264/420] :arrow_up: tree-sitter-javascript --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7a45950f..1ae20d12 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,6 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.4.7" + "tree-sitter-javascript": "^0.5.0" } } From 2a21af1488237da7d8a57a054f8e5b9f4b1bfaf6 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 26 Dec 2017 13:43:57 -0800 Subject: [PATCH 265/420] Prepare 0.128.0-4 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1ae20d12..a3ce99f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.0-3", + "version": "0.128.0-4", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From db096f1cb01fea5f4d97488c77fc1cc0e9b9d2a1 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 8 Jan 2018 09:40:07 -0800 Subject: [PATCH 266/420] Prepare 0.128.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a3ce99f0..a27d1803 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.0-4", + "version": "0.128.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 8f5c01bbb1a1300013e5f6f9092274c28f25c146 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 11 Jan 2018 16:12:50 -0800 Subject: [PATCH 267/420] Add debugger and hash_bang_line scope mappings --- grammars/tree-sitter-javascript.cson | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 3edcd103..632862a3 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -84,6 +84,7 @@ scopes: 'true': 'constant.language.boolean.true' 'false': 'constant.language.boolean.false' 'comment': 'comment.block' + 'hash_bang_line': 'comment.block' 'template_substitution > "${"': 'punctuation.section.embedded' 'template_substitution > "}"': 'punctuation.section.embedded' @@ -137,6 +138,7 @@ scopes: '"yield"': 'keyword.control' '"async"': 'keyword.control' '"await"': 'keyword.control' + '"debugger"': 'keyword.control' 'jsx_attribute > property_identifier': 'entity.other.attribute-name' 'jsx_opening_element > identifier': 'entity.name.tag' From 4b1b2fcca09987ccd63c016bbed26be02ecdf6ff Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 11 Jan 2018 16:13:02 -0800 Subject: [PATCH 268/420] Prepare 0.128.1 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a27d1803..96ecbff6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.0", + "version": "0.128.1", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 4bf3e2b90146967b09f5a4397b31bf6161deb234 Mon Sep 17 00:00:00 2001 From: CentricStorm Date: Mon, 12 Feb 2018 22:12:09 +0000 Subject: [PATCH 269/420] Add regular expression lookbehind highlighting. --- .../regular expressions (javascript).cson | 10 ++++--- spec/javascript-spec.coffee | 26 +++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/grammars/regular expressions (javascript).cson b/grammars/regular expressions (javascript).cson index d9891feb..4ef8a8cc 100644 --- a/grammars/regular expressions (javascript).cson +++ b/grammars/regular expressions (javascript).cson @@ -43,14 +43,18 @@ 'name': 'keyword.operator.or.regexp' } { - 'begin': '(\\()((\\?=)|(\\?!))' + 'begin': '(\\()(?:(\\?=)|(\\?!)|(\\?<=)|(\\? expect(tokens[1]).toEqual value: 'test', scopes: ['source.js', 'string.regexp.js'] expect(tokens[2]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] + {tokens} = grammar.tokenizeLine('/(?<=foo)test(?=bar)/') + expect(tokens[0]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] + expect(tokens[1]).toEqual value: '(', scopes: ['source.js', 'string.regexp.js', 'meta.group.assertion.regexp', 'punctuation.definition.group.regexp'] + expect(tokens[2]).toEqual value: '?<=', scopes: ['source.js', 'string.regexp.js', 'meta.group.assertion.regexp', 'meta.assertion.look-behind.regexp'] + expect(tokens[3]).toEqual value: 'foo', scopes: ['source.js', 'string.regexp.js', 'meta.group.assertion.regexp'] + expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'string.regexp.js', 'meta.group.assertion.regexp', 'punctuation.definition.group.regexp'] + expect(tokens[5]).toEqual value: 'test', scopes: ['source.js', 'string.regexp.js'] + expect(tokens[6]).toEqual value: '(', scopes: ['source.js', 'string.regexp.js', 'meta.group.assertion.regexp', 'punctuation.definition.group.regexp'] + expect(tokens[7]).toEqual value: '?=', scopes: ['source.js', 'string.regexp.js', 'meta.group.assertion.regexp', 'meta.assertion.look-ahead.regexp'] + expect(tokens[8]).toEqual value: 'bar', scopes: ['source.js', 'string.regexp.js', 'meta.group.assertion.regexp'] + expect(tokens[9]).toEqual value: ')', scopes: ['source.js', 'string.regexp.js', 'meta.group.assertion.regexp', 'punctuation.definition.group.regexp'] + expect(tokens[10]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] + + {tokens} = grammar.tokenizeLine('/(? Date: Mon, 12 Feb 2018 21:46:20 -0800 Subject: [PATCH 270/420] :arrow_up: tree-sitter-javascript --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 96ecbff6..7a8068e2 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,6 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.5.0" + "tree-sitter-javascript": "^0.6.0" } } From 6fbb6dd45e0d42b833bc6b749734b80ee45dc76a Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 12 Feb 2018 21:50:07 -0800 Subject: [PATCH 271/420] Prepare 0.128.2 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7a8068e2..b0dca938 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.1", + "version": "0.128.2", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 09ce9ca87c0b44a5b1f95060bd7d5cb8aa67e6f8 Mon Sep 17 00:00:00 2001 From: CentricStorm Date: Tue, 13 Feb 2018 23:40:52 +0000 Subject: [PATCH 272/420] Add regular expression s flag highlighting. --- grammars/javascript.cson | 4 +++- spec/javascript-spec.coffee | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 1c77ac54..406b9bdd 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1137,10 +1137,12 @@ 'beginCaptures': '1': 'name': 'punctuation.definition.string.begin.js' - 'end': '(/)[gimuy]*' + 'end': '(/)([gimsuy]*)' 'endCaptures': '1': 'name': 'punctuation.definition.string.end.js' + '2': + 'name': 'meta.flag.regexp' 'name': 'string.regexp.js' 'patterns': [ { diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 273c9451..a73712fe 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -186,6 +186,22 @@ describe "JavaScript grammar", -> expect(tokens[1]).toEqual value: 'test', scopes: ['source.js', 'string.regexp.js'] expect(tokens[2]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] + {tokens} = grammar.tokenizeLine('/random/g') + expect(tokens[0]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] + expect(tokens[1]).toEqual value: 'random', scopes: ['source.js', 'string.regexp.js'] + expect(tokens[2]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] + expect(tokens[3]).toEqual value: 'g', scopes: ['source.js', 'string.regexp.js', 'meta.flag.regexp'] + + {tokens} = grammar.tokenizeLine('/rock(et)?/is') + expect(tokens[0]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] + expect(tokens[1]).toEqual value: 'rock', scopes: ['source.js', 'string.regexp.js'] + expect(tokens[2]).toEqual value: '(', scopes: ['source.js', 'string.regexp.js', 'meta.group.regexp', 'punctuation.definition.group.regexp'] + expect(tokens[3]).toEqual value: 'et', scopes: ['source.js', 'string.regexp.js', 'meta.group.regexp'] + expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'string.regexp.js', 'meta.group.regexp', 'punctuation.definition.group.regexp'] + expect(tokens[5]).toEqual value: '?', scopes: ['source.js', 'string.regexp.js', 'keyword.operator.quantifier.regexp'] + expect(tokens[6]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] + expect(tokens[7]).toEqual value: 'is', scopes: ['source.js', 'string.regexp.js', 'meta.flag.regexp'] + {tokens} = grammar.tokenizeLine('/(?<=foo)test(?=bar)/') expect(tokens[0]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] expect(tokens[1]).toEqual value: '(', scopes: ['source.js', 'string.regexp.js', 'meta.group.assertion.regexp', 'punctuation.definition.group.regexp'] From 4342f4705a808c6586ca2651f99cceb623b0a74a Mon Sep 17 00:00:00 2001 From: CentricStorm Date: Wed, 14 Feb 2018 23:52:38 +0000 Subject: [PATCH 273/420] Update Promise highlighting. --- grammars/javascript.cson | 37 +++++++++++++++++++++++++++++++++++-- spec/javascript-spec.coffee | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 406b9bdd..bec8a1ed 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -864,6 +864,39 @@ } ] } + { + # Promise + 'begin': '(? expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] expect(tokens[5]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + describe "promise", -> + it "tokenizes the promise object", -> + {tokens} = grammar.tokenizeLine('Promise;') + expect(tokens[0]).toEqual value: 'Promise', scopes: ['source.js', 'support.class.promise.js'] + expect(tokens[1]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + + it "tokenizes promise support functions", -> + {tokens} = grammar.tokenizeLine('Promise.race();') + expect(tokens[0]).toEqual value: 'Promise', scopes: ['source.js', 'support.class.promise.js'] + expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] + expect(tokens[2]).toEqual value: 'race', scopes: ['source.js', 'meta.method-call.js', 'support.function.promise.js'] + expect(tokens[3]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] + expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(tokens[5]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + + lines = grammar.tokenizeLines ''' + Promise + .resolve(); + ''' + expect(lines[0][0]).toEqual value: 'Promise', scopes: ['source.js', 'support.class.promise.js'] + expect(lines[1][0]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] + expect(lines[1][1]).toEqual value: 'resolve', scopes: ['source.js', 'meta.method-call.js', 'support.function.promise.js'] + expect(lines[1][2]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] + expect(lines[1][3]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(lines[1][4]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + + it "tokenizes promise custom functions", -> + {tokens} = grammar.tokenizeLine('Promise.anExtraFunction();') + expect(tokens[0]).toEqual value: 'Promise', scopes: ['source.js', 'support.class.promise.js'] + expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.method-call.js', 'meta.delimiter.method.period.js'] + expect(tokens[2]).toEqual value: 'anExtraFunction', scopes: ['source.js', 'meta.method-call.js', 'entity.name.function.js'] + expect(tokens[3]).toEqual value: '(', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.begin.bracket.round.js'] + expect(tokens[4]).toEqual value: ')', scopes: ['source.js', 'meta.method-call.js', 'meta.arguments.js', 'punctuation.definition.arguments.end.bracket.round.js'] + expect(tokens[5]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + describe "object literals", -> keywords = ['super', 'this', 'null', 'true', 'false', 'debugger', 'exports', '__filename'] From ececc1425a1131ed509695fb0a9db8f47eab49ff Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 15 Feb 2018 15:26:50 -0800 Subject: [PATCH 274/420] Fix highlighting for '=>' and some operators Refs #558 --- grammars/tree-sitter-javascript.cson | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 632862a3..929fefc9 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -99,12 +99,14 @@ scopes: '"class"': 'storage.type' '"const"': 'storage.modifier' '"static"': 'storage.modifier' - '"function"': 'storage.type' - - '"+"': 'keyword.operator' - '"-"': 'keyword.operator' - '"*"': 'keyword.operator' - '"/"': 'keyword.operator' + '"function"': 'storage.type.function' + '"=>"': 'storage.type.function' + + '"="': 'keyword.operator.js' + '"+"': 'keyword.operator.js' + '"-"': 'keyword.operator.js' + '"*"': 'keyword.operator.js' + '"/"': 'keyword.operator.js' '"in"': 'keyword.operator.in' '"instanceof"': 'keyword.operator.instanceof' '"of"': 'keyword.operator.of' From 95c2a54edb8e6db4c7a6e4d3e57c8692ba6cb3d3 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 16 Feb 2018 14:42:03 -0800 Subject: [PATCH 275/420] :arrow_up: tree-sitter-javascript --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b0dca938..a2264166 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,6 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.6.0" + "tree-sitter-javascript": "^0.6.2" } } From dfef3f519fc7e487537ac8be172f83587eb82ed5 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 16 Feb 2018 14:42:13 -0800 Subject: [PATCH 276/420] Prepare 0.128.3 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a2264166..89d02b1c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.2", + "version": "0.128.3", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From a76c047126c4f41e64cc9e5755975aa6d8b4099b Mon Sep 17 00:00:00 2001 From: CentricStorm Date: Tue, 20 Feb 2018 19:47:20 +0000 Subject: [PATCH 277/420] Add regular expression named capture group highlighting. --- .../regular expressions (javascript).cson | 4 +-- spec/javascript-spec.coffee | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/grammars/regular expressions (javascript).cson b/grammars/regular expressions (javascript).cson index 4ef8a8cc..1de6f54b 100644 --- a/grammars/regular expressions (javascript).cson +++ b/grammars/regular expressions (javascript).cson @@ -31,7 +31,7 @@ 'name': 'keyword.control.anchor.regexp' } { - 'match': '\\\\[1-9]\\d*' + 'match': '\\\\[1-9]\\d*|\\\\k<[a-zA-Z_$][\\w$]*>' 'name': 'keyword.other.back-reference.regexp' } { @@ -67,7 +67,7 @@ ] } { - 'begin': '\\((\\?:)?' + 'begin': '\\(((\\?:)|(\\?<[a-zA-Z_$][\\w$]*>))?' 'beginCaptures': '0': 'name': 'punctuation.definition.group.regexp' diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 417fc374..79be4db9 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -202,6 +202,32 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] expect(tokens[7]).toEqual value: 'is', scopes: ['source.js', 'string.regexp.js', 'meta.flag.regexp'] + {tokens} = grammar.tokenizeLine('/(foo)bar\\1/') + expect(tokens[0]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] + expect(tokens[1]).toEqual value: '(', scopes: ['source.js', 'string.regexp.js', 'meta.group.regexp', 'punctuation.definition.group.regexp'] + expect(tokens[2]).toEqual value: 'foo', scopes: ['source.js', 'string.regexp.js', 'meta.group.regexp'] + expect(tokens[3]).toEqual value: ')', scopes: ['source.js', 'string.regexp.js', 'meta.group.regexp', 'punctuation.definition.group.regexp'] + expect(tokens[4]).toEqual value: 'bar', scopes: ['source.js', 'string.regexp.js'] + expect(tokens[5]).toEqual value: '\\1', scopes: ['source.js', 'string.regexp.js', 'keyword.other.back-reference.regexp'] + expect(tokens[6]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] + + {tokens} = grammar.tokenizeLine('/(?foo)bar\\k/') + expect(tokens[0]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] + expect(tokens[1]).toEqual value: '(?', scopes: ['source.js', 'string.regexp.js', 'meta.group.regexp', 'punctuation.definition.group.regexp'] + expect(tokens[2]).toEqual value: 'foo', scopes: ['source.js', 'string.regexp.js', 'meta.group.regexp'] + expect(tokens[3]).toEqual value: ')', scopes: ['source.js', 'string.regexp.js', 'meta.group.regexp', 'punctuation.definition.group.regexp'] + expect(tokens[4]).toEqual value: 'bar', scopes: ['source.js', 'string.regexp.js'] + expect(tokens[5]).toEqual value: '\\k', scopes: ['source.js', 'string.regexp.js', 'keyword.other.back-reference.regexp'] + expect(tokens[6]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] + + {tokens} = grammar.tokenizeLine('/(?:foo)bar/') + expect(tokens[0]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] + expect(tokens[1]).toEqual value: '(?:', scopes: ['source.js', 'string.regexp.js', 'meta.group.regexp', 'punctuation.definition.group.regexp'] + expect(tokens[2]).toEqual value: 'foo', scopes: ['source.js', 'string.regexp.js', 'meta.group.regexp'] + expect(tokens[3]).toEqual value: ')', scopes: ['source.js', 'string.regexp.js', 'meta.group.regexp', 'punctuation.definition.group.regexp'] + expect(tokens[4]).toEqual value: 'bar', scopes: ['source.js', 'string.regexp.js'] + expect(tokens[5]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.end.js'] + {tokens} = grammar.tokenizeLine('/(?<=foo)test(?=bar)/') expect(tokens[0]).toEqual value: '/', scopes: ['source.js', 'string.regexp.js', 'punctuation.definition.string.begin.js'] expect(tokens[1]).toEqual value: '(', scopes: ['source.js', 'string.regexp.js', 'meta.group.assertion.regexp', 'punctuation.definition.group.regexp'] From c698b12e7fcf5bd523c6c837bc26d9c170e999a7 Mon Sep 17 00:00:00 2001 From: Mike McBride Date: Thu, 1 Mar 2018 08:48:47 -0700 Subject: [PATCH 278/420] add missing operators --- grammars/tree-sitter-javascript.cson | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 929fefc9..7912207d 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -106,7 +106,19 @@ scopes: '"+"': 'keyword.operator.js' '"-"': 'keyword.operator.js' '"*"': 'keyword.operator.js' - '"/"': 'keyword.operator.js' + '"=="': 'keyword.operator.js' + '"==="': 'keyword.operator.js' + '"!="': 'keyword.operator.js' + '"!=="': 'keyword.operator.js' + '">="': 'keyword.operator.js' + '"<="': 'keyword.operator.js' + '">"': 'keyword.operator.js' + '"<"': 'keyword.operator.js' + '":"': 'keyword.operator.js' + '"?"': 'keyword.operator.js' + '"&&"': 'keyword.operator.js' + '"||"': 'keyword.operator.js' + '"in"': 'keyword.operator.in' '"instanceof"': 'keyword.operator.instanceof' '"of"': 'keyword.operator.of' From 5c7147f55841a7cb65ffc2c82edc41686020180f Mon Sep 17 00:00:00 2001 From: Mike McBride Date: Thu, 1 Mar 2018 08:53:07 -0700 Subject: [PATCH 279/420] add % operator too --- grammars/tree-sitter-javascript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 7912207d..ca26150d 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -106,6 +106,7 @@ scopes: '"+"': 'keyword.operator.js' '"-"': 'keyword.operator.js' '"*"': 'keyword.operator.js' + '"%"': 'keyword.operator.js' '"=="': 'keyword.operator.js' '"==="': 'keyword.operator.js' '"!="': 'keyword.operator.js' From 9002aad03e40e04ed8f6589613330833a12226ca Mon Sep 17 00:00:00 2001 From: Kyle Thompson Date: Wed, 31 Jan 2018 12:55:56 -0500 Subject: [PATCH 280/420] add failing spec --- spec/javascript-spec.coffee | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 79be4db9..41d335be 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -1099,6 +1099,29 @@ describe "JavaScript grammar", -> expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'meta.export.js', 'punctuation.definition.modules.end.js'] expect(tokens[12]).toEqual value: 'from', scopes: ['source.js', 'meta.export.js', 'keyword.control.js'] + it "tokenizes multiline re-export", -> + lines = grammar.tokenizeLines ''' + export { + default as alias, + member1 as alias1, + member2, + } from "module-name"; + ''' + expect(lines[0][0]).toEqual value: 'export', scopes: ['source.js', 'meta.export.js', 'keyword.control.js'] + expect(lines[0][2]).toEqual value: '{', scopes: ['source.js', 'meta.export.js', 'punctuation.definition.modules.begin.js'] + expect(lines[1][1]).toEqual value: 'default', scopes: ['source.js', 'meta.export.js', 'variable.language.default.js'] + expect(lines[1][3]).toEqual value: 'as', scopes: ['source.js', 'meta.export.js', 'keyword.control.js'] + expect(lines[1][5]).toEqual value: 'alias', scopes: ['source.js', 'meta.export.js', 'variable.other.module-alias.js'] + expect(lines[1][6]).toEqual value: ',', scopes: ['source.js', 'meta.export.js', 'meta.delimiter.object.comma.js'] + expect(lines[2][1]).toEqual value: 'member1', scopes: ['source.js', 'meta.export.js', 'variable.other.module.js'] + expect(lines[2][3]).toEqual value: 'as', scopes: ['source.js', 'meta.export.js', 'keyword.control.js'] + expect(lines[2][5]).toEqual value: 'alias1', scopes: ['source.js', 'meta.export.js', 'variable.other.module-alias.js'] + expect(lines[2][6]).toEqual value: ',', scopes: ['source.js', 'meta.export.js', 'meta.delimiter.object.comma.js'] + expect(lines[3][1]).toEqual value: 'member2', scopes: ['source.js', 'meta.export.js', 'variable.other.module.js'] + expect(lines[3][2]).toEqual value: ',', scopes: ['source.js', 'meta.export.js', 'meta.delimiter.object.comma.js'] + expect(lines[4][0]).toEqual value: '}', scopes: ['source.js', 'meta.export.js', 'punctuation.definition.modules.end.js'] + expect(lines[4][2]).toEqual value: 'from', scopes: ['source.js', 'meta.export.js', 'keyword.control.js'] + describe "ES6 yield", -> it "tokenizes yield", -> {tokens} = grammar.tokenizeLine('yield next') From 334a3a82388ca946b0b7f5ed1ddc8bb7224d4e0c Mon Sep 17 00:00:00 2001 From: Kyle Thompson Date: Fri, 2 Mar 2018 21:27:43 -0500 Subject: [PATCH 281/420] fixes multiline re-export tokenization --- grammars/javascript.cson | 49 +--------------------------------------- 1 file changed, 1 insertion(+), 48 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index bec8a1ed..2cfb89f3 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -176,53 +176,6 @@ { 'include': '#numbers' } - { - # { member1 , member2 as alias2 , [...] } inside re-export - 'begin': '{(?=.*\\bfrom\\b)' - 'beginCaptures': - 0: - 'name': 'punctuation.definition.modules.begin.js' - 'end': '}' - 'endCaptures': - 0: - 'name': 'punctuation.definition.modules.end.js' - 'patterns': [ - { - # (default|name) as alias - 'match': '''(?x) - (?: \\b(default)\\b | \\b([a-zA-Z_$][\\w$]*)\\b) - \\s* - (\\b as \\b) - \\s* - (?: \\b(default)\\b | (\\*) | \\b([a-zA-Z_$][\\w$]*)\\b) - ''' - 'captures': - '1': - 'name': 'variable.language.default.js' - '2': - 'name': 'variable.other.module.js' - '3': - 'name': 'keyword.control.js' - '4': - 'name': 'variable.language.default.js' - '5': - 'name': 'invalid.illegal.js' - '6': - 'name': 'variable.other.module-alias.js' - } - { - 'match': ',' - 'name': 'meta.delimiter.object.comma.js' - } - { - 'include': '#comments' - } - { - 'match': '\\b([a-zA-Z_$][\\w$]*)\\b' - 'name': 'variable.other.module.js' - } - ] - } { # { member1 , member2 as alias2 , [...] } 'begin': '(?![a-zA-Z_$0-9]){' @@ -238,7 +191,7 @@ # name as (default|alias) 'captures': '1': - 'name': 'invalid.illegal.js' + 'name': 'variable.language.default.js' '2': 'name': 'variable.other.module.js' '3': From e85477eab1ca45e25d39c7dbb350e87dea263ed2 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Fri, 9 Mar 2018 12:59:31 -0500 Subject: [PATCH 282/420] Prepare 0.128.4 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 89d02b1c..d8bd4779 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.3", + "version": "0.128.4", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From c692e494e3bd66cee5a224bb41a46108a002de30 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 28 Mar 2018 14:47:57 -0700 Subject: [PATCH 283/420] :arrow_up: tree-sitter-javascript --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d8bd4779..0a0133ee 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,6 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.6.2" + "tree-sitter-javascript": "^0.11.0" } } From 57a8519aae8bdc2d26363c7edeca7045b58103fc Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 28 Mar 2018 14:48:08 -0700 Subject: [PATCH 284/420] Prepare 0.128.5 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0a0133ee..a0713df8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.4", + "version": "0.128.5", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 9ee5ae3dc96747e5e3ab2f37fa36b40a57dfa62f Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 17 Apr 2018 17:35:08 -0700 Subject: [PATCH 285/420] :arrow_up: tree-sitter-javascript --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a0713df8..7016be9f 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,6 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.11.0" + "tree-sitter-javascript": "^0.11.1" } } From e3501ba49da2fe69cc3f93f76a9b651e7d5d05ad Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 17 Apr 2018 17:35:19 -0700 Subject: [PATCH 286/420] Prepare 0.128.6 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7016be9f..6356cbb9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.5", + "version": "0.128.6", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From aa518c0c561e60163df6453a37bbfbbdab648b38 Mon Sep 17 00:00:00 2001 From: Mike McBride Date: Thu, 10 May 2018 10:01:48 -0500 Subject: [PATCH 287/420] add delete keyword to tree-sitter grammar --- grammars/tree-sitter-javascript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 929fefc9..1e7751a3 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -141,6 +141,7 @@ scopes: '"async"': 'keyword.control' '"await"': 'keyword.control' '"debugger"': 'keyword.control' + '"delete"': 'keyword.control' 'jsx_attribute > property_identifier': 'entity.other.attribute-name' 'jsx_opening_element > identifier': 'entity.name.tag' From 599316392a73a5dad739e0688cb715aefdf4ec68 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Fri, 11 May 2018 09:51:59 -0400 Subject: [PATCH 288/420] Prepare 0.128.7 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6356cbb9..f13dc5b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.6", + "version": "0.128.7", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From bd06b16a05f031ad13401fff468708de636fb4be Mon Sep 17 00:00:00 2001 From: Mike McBride Date: Mon, 21 May 2018 10:00:10 -0500 Subject: [PATCH 289/420] add operator highlighting for ++ and -- --- grammars/tree-sitter-javascript.cson | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 2802ab55..54c0cb3d 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -119,6 +119,8 @@ scopes: '"?"': 'keyword.operator.js' '"&&"': 'keyword.operator.js' '"||"': 'keyword.operator.js' + '"++"': 'keyword.operator.js' + '"--"': 'keyword.operator.js' '"in"': 'keyword.operator.in' '"instanceof"': 'keyword.operator.instanceof' From 5373ffeb45da4e1b9aadeb1c9e52dfdfb1745874 Mon Sep 17 00:00:00 2001 From: Mike McBride Date: Mon, 21 May 2018 22:07:45 -0500 Subject: [PATCH 290/420] add spread operator syntax --- grammars/tree-sitter-javascript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 54c0cb3d..1b619c6c 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -121,6 +121,7 @@ scopes: '"||"': 'keyword.operator.js' '"++"': 'keyword.operator.js' '"--"': 'keyword.operator.js' + '"..."': 'keyword.operator.js' '"in"': 'keyword.operator.in' '"instanceof"': 'keyword.operator.instanceof' From e1b7daa5b6d5b64b8f1967c8a5c50325ac1d9cff Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 18 Jun 2018 11:49:52 -0700 Subject: [PATCH 291/420] :arrow_up: tree-sitter-javascript --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f13dc5b7..4c11a273 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,6 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.11.1" + "tree-sitter-javascript": "^0.12.0" } } From 89b88911d0aa4a30798f56a59e6d9dc74119b072 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 18 Jun 2018 11:49:57 -0700 Subject: [PATCH 292/420] Prepare 0.128.8 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4c11a273..de98ec74 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.7", + "version": "0.128.8", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 36a66a39da2393308cc1e4a63135642ef69b3df8 Mon Sep 17 00:00:00 2001 From: Mike McBride Date: Mon, 25 Jun 2018 08:42:45 -0500 Subject: [PATCH 293/420] add / to operators list --- grammars/tree-sitter-javascript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 1b619c6c..af51391d 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -106,6 +106,7 @@ scopes: '"+"': 'keyword.operator.js' '"-"': 'keyword.operator.js' '"*"': 'keyword.operator.js' + '"/"': 'keyword.operator.js' '"%"': 'keyword.operator.js' '"=="': 'keyword.operator.js' '"==="': 'keyword.operator.js' From a7ec0935c50c833fc8017b9aac29cc7bf6240226 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 29 Jun 2018 12:17:22 -0700 Subject: [PATCH 294/420] :arrow_up: tree-sitter-javascript --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index de98ec74..11187155 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,6 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.12.0" + "tree-sitter-javascript": "^0.12.1" } } From b34c61a9bea71bb892aeac28cfbed954f5b62d0f Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 29 Jun 2018 12:31:55 -0700 Subject: [PATCH 295/420] Prepare 0.128.9 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 11187155..97d98c8a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.8", + "version": "0.128.9", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 4f7a5b06b0ab1c595ec96639fc7b1a061adc87f8 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 6 Jul 2018 11:56:55 -0700 Subject: [PATCH 296/420] Add styling to entire template substitutions Co-Authored-By: Ashi Krishnan --- grammars/tree-sitter-javascript.cson | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index af51391d..7bb165b6 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -88,6 +88,7 @@ scopes: 'template_substitution > "${"': 'punctuation.section.embedded' 'template_substitution > "}"': 'punctuation.section.embedded' + 'template_substitution': 'interpolation' '"("': 'punctuation.definition.parameters.begin.bracket.round' '")"': 'punctuation.definition.parameters.end.bracket.round' @@ -123,7 +124,7 @@ scopes: '"++"': 'keyword.operator.js' '"--"': 'keyword.operator.js' '"..."': 'keyword.operator.js' - + '"in"': 'keyword.operator.in' '"instanceof"': 'keyword.operator.instanceof' '"of"': 'keyword.operator.of' From f48b659d8afe011a66d2d9c1ba270fdd3c54eb09 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 6 Jul 2018 11:57:13 -0700 Subject: [PATCH 297/420] Allow JavaScript to be injected when using Tree-sitter Co-Authored-By: Ashi Krishnan --- grammars/tree-sitter-javascript.cson | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 7bb165b6..da477b00 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -6,6 +6,8 @@ legacyScopeName: 'source.js' fileTypes: ['js', 'jsx'] +injectionRegExp: 'js|javascript' + firstLineMatch: '''(?x) # Hashbang ^\\#!.*(?:\\s|\\/|(?<=!)\\b) From 5d75f660ff2c3c4cdbb3be4cf59577c372ac0a12 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 6 Jul 2018 11:57:43 -0700 Subject: [PATCH 298/420] Allow other languages to be injected into JS when using Tree-sitter Co-Authored-By: Ashi Krishnan --- lib/main.js | 39 +++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 40 insertions(+) create mode 100644 lib/main.js diff --git a/lib/main.js b/lib/main.js new file mode 100644 index 00000000..214cf5d2 --- /dev/null +++ b/lib/main.js @@ -0,0 +1,39 @@ +exports.activate = function() { + atom.grammars.addInjectionPoint('javascript', { + type: 'call_expression', + + language (callExpression) { + const {firstChild} = callExpression + if (firstChild.type === 'identifier') { + return firstChild.text + } + }, + + content (callExpression) { + const {lastChild} = callExpression + if (lastChild.type === 'template_string') { + return lastChild + } + } + }) + + atom.grammars.addInjectionPoint('javascript', { + type: 'assignment_expression', + + language (callExpression) { + const {firstChild} = callExpression + if (firstChild.type === 'member_expression') { + if (firstChild.lastChild.text === 'innerHTML') { + return 'html' + } + } + }, + + content (callExpression) { + const {lastChild} = callExpression + if (lastChild.type === 'template_string') { + return lastChild + } + } + }) +} diff --git a/package.json b/package.json index 97d98c8a..41a60960 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "atom": "*", "node": "*" }, + "main": "lib/main", "homepage": "http://atom.github.io/language-javascript", "repository": { "type": "git", From e939c23399df587201f9b6e1ba332fb27b4f03b1 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 6 Jul 2018 11:58:19 -0700 Subject: [PATCH 299/420] Check for the existence of the addInjectionPoint method Co-Authored-By: Ashi Krishnan --- lib/main.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/main.js b/lib/main.js index 214cf5d2..95f2f88f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,4 +1,6 @@ exports.activate = function() { + if (!atom.grammars.addInjectionPoint) return + atom.grammars.addInjectionPoint('javascript', { type: 'call_expression', From af6bea98476f1165b85659430d730eca478437c1 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 6 Jul 2018 11:59:28 -0700 Subject: [PATCH 300/420] Prepare 0.128.10-0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 41a60960..cf3bee01 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.9", + "version": "0.128.10-0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From a4b3f378b3b2ed3465811aecf2280c9437c8f4dc Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 16 Jul 2018 15:13:22 -0700 Subject: [PATCH 301/420] Prepare 0.128.10 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cf3bee01..e718ffae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.10-0", + "version": "0.128.10", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From a043a3921d7941c0fd4026c375506ef15ce6c4ba Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 16 Jul 2018 16:18:42 -0700 Subject: [PATCH 302/420] Use source.js scopes for Tree-sitter template substitutions This matches how they are styled with the text-mate grammar. --- grammars/tree-sitter-javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index da477b00..a0c083d9 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -90,7 +90,7 @@ scopes: 'template_substitution > "${"': 'punctuation.section.embedded' 'template_substitution > "}"': 'punctuation.section.embedded' - 'template_substitution': 'interpolation' + 'template_substitution': 'source.js' '"("': 'punctuation.definition.parameters.begin.bracket.round' '")"': 'punctuation.definition.parameters.end.bracket.round' From 3092347046a8f24d4c8cacfb8e0724dc5d424eac Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 16 Jul 2018 16:19:08 -0700 Subject: [PATCH 303/420] Prepare 0.128.11 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e718ffae..004e2b06 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.10", + "version": "0.128.11", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 9cdf0035515fae6171c56329ea5fa2bbdf9b9b6c Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 18 Jul 2018 16:17:01 -0700 Subject: [PATCH 304/420] :arrow_up: tree-sitter-javascript --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 004e2b06..95d43350 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,6 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.12.1" + "tree-sitter-javascript": "^0.13.0" } } From f31f64cf8a85be9dadae2d9b85343d9dce1710e1 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 18 Jul 2018 16:17:07 -0700 Subject: [PATCH 305/420] Prepare 0.129.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 95d43350..8b2bab66 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.128.11", + "version": "0.129.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 5e65fdfd41b9e02912050d1c45626425323ebbdd Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 20 Jul 2018 17:17:05 -0700 Subject: [PATCH 306/420] Use embedded.source class for code in template substitutions --- grammars/tree-sitter-javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index a0c083d9..bb04ab42 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -90,7 +90,7 @@ scopes: 'template_substitution > "${"': 'punctuation.section.embedded' 'template_substitution > "}"': 'punctuation.section.embedded' - 'template_substitution': 'source.js' + 'template_substitution': 'embedded.source' '"("': 'punctuation.definition.parameters.begin.bracket.round' '")"': 'punctuation.definition.parameters.end.bracket.round' From 5c627b28edbc212f113185c4d40526a3f2531f6d Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 20 Jul 2018 17:17:12 -0700 Subject: [PATCH 307/420] Prepare 0.129.1 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b2bab66..b5fc0e46 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.0", + "version": "0.129.1", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 9fe09b962fdf64625f265729e9dcbe8689c3bf1d Mon Sep 17 00:00:00 2001 From: Ashi Krishnan Date: Tue, 24 Jul 2018 14:37:31 -0400 Subject: [PATCH 308/420] Highlight special variables, CONSTANT_VARIABLES, and ClassNames differently. --- grammars/tree-sitter-javascript.cson | 40 ++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index bb04ab42..7b02b91a 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -62,18 +62,19 @@ comments: scopes: 'program': 'source.js' - 'class > identifier': 'entity.name.type.class' - 'property_identifier': 'variable.other.object.property' 'function > identifier': 'entity.name.function' - 'call_expression > identifier': 'entity.name.function' + + 'call_expression > identifier': [ + {match: '^require$', scopes: 'support.function'}, + {match: '^[A-Z]', scopes: 'meta.class'}, + 'entity.name.function' + ] 'method_definition > property_identifier': 'entity.name.function' 'call_expression > member_expression > property_identifier': 'entity.name.function' - 'new_expression > call_expression > identifier': 'meta.class.instance.constructor' - 'import_specifier > identifier': 'variable.other.module' 'import_clause > identifier': 'variable.other.module' @@ -97,6 +98,35 @@ scopes: '"{"': 'punctuation.definition.function.body.begin.bracket.curly' '"}"': 'punctuation.definition.function.body.end.bracket.curly' + 'identifier': [ + { + match: '^(global|module|exports|__filename|__dirname)$', + scopes: 'support.variable' + }, + { + exact: 'require', scopes: 'support.function' + } + { + match: '^[\$A-Z_]+$', + scopes: 'constant.other' + }, + { + match: '^[A-Z]', + scopes: 'meta.class' + }, + ] + + 'shorthand_property_identifier': [ + { + match: '^[\$A-Z_]+$', + scopes: 'constant.other' + }, + { + match: '^[A-Z]', + scopes: 'meta.class' + }, + ] + '"var"': 'storage.type' '"let"': 'storage.type' '"class"': 'storage.type' From f17feaa0d6e42a6c0ee3fc4046dfd36161c5e60a Mon Sep 17 00:00:00 2001 From: Stephan Schneider Date: Thu, 26 Jul 2018 15:37:57 +0200 Subject: [PATCH 309/420] Add 'n' suffix for BigInt numeric --- grammars/javascript.cson | 8 ++++---- spec/javascript-spec.coffee | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 147a7b80..003b36e8 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1244,15 +1244,15 @@ 'numbers': 'patterns': [ { - 'match': '\\b(? {tokens} = grammar.tokenizeLine('0X1D306') expect(tokens[0]).toEqual value: '0X1D306', scopes: ['source.js', 'constant.numeric.hex.js'] + {tokens} = grammar.tokenizeLine('0x1D306n') + expect(tokens[0]).toEqual value: '0x1D306n', scopes: ['source.js', 'constant.numeric.hex.js'] + + {tokens} = grammar.tokenizeLine('0X1D306n') + expect(tokens[0]).toEqual value: '0X1D306n', scopes: ['source.js', 'constant.numeric.hex.js'] + it "tokenizes binary literals", -> {tokens} = grammar.tokenizeLine('0b011101110111010001100110') expect(tokens[0]).toEqual value: '0b011101110111010001100110', scopes: ['source.js', 'constant.numeric.binary.js'] @@ -323,6 +329,12 @@ describe "JavaScript grammar", -> {tokens} = grammar.tokenizeLine('0B011101110111010001100110') expect(tokens[0]).toEqual value: '0B011101110111010001100110', scopes: ['source.js', 'constant.numeric.binary.js'] + {tokens} = grammar.tokenizeLine('0b011101110111010001100110n') + expect(tokens[0]).toEqual value: '0b011101110111010001100110n', scopes: ['source.js', 'constant.numeric.binary.js'] + + {tokens} = grammar.tokenizeLine('0B011101110111010001100110n') + expect(tokens[0]).toEqual value: '0B011101110111010001100110n', scopes: ['source.js', 'constant.numeric.binary.js'] + it "tokenizes octal literals", -> {tokens} = grammar.tokenizeLine('0o1411') expect(tokens[0]).toEqual value: '0o1411', scopes: ['source.js', 'constant.numeric.octal.js'] @@ -330,6 +342,12 @@ describe "JavaScript grammar", -> {tokens} = grammar.tokenizeLine('0O1411') expect(tokens[0]).toEqual value: '0O1411', scopes: ['source.js', 'constant.numeric.octal.js'] + {tokens} = grammar.tokenizeLine('0o1411n') + expect(tokens[0]).toEqual value: '0o1411n', scopes: ['source.js', 'constant.numeric.octal.js'] + + {tokens} = grammar.tokenizeLine('0O1411n') + expect(tokens[0]).toEqual value: '0O1411n', scopes: ['source.js', 'constant.numeric.octal.js'] + {tokens} = grammar.tokenizeLine('0010') expect(tokens[0]).toEqual value: '0010', scopes: ['source.js', 'constant.numeric.octal.js'] @@ -337,6 +355,9 @@ describe "JavaScript grammar", -> {tokens} = grammar.tokenizeLine('1234') expect(tokens[0]).toEqual value: '1234', scopes: ['source.js', 'constant.numeric.decimal.js'] + {tokens} = grammar.tokenizeLine('123456789n') + expect(tokens[0]).toEqual value: '123456789n', scopes: ['source.js', 'constant.numeric.decimal.js'] + {tokens} = grammar.tokenizeLine('5e-10') expect(tokens[0]).toEqual value: '5e-10', scopes: ['source.js', 'constant.numeric.decimal.js'] From 8650c4692a80bb4a733af19970d0797d0dfc100f Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 31 Jul 2018 14:04:27 -0700 Subject: [PATCH 310/420] :arrow_up: tree-sitter-javascript, highlight escape sequences --- grammars/tree-sitter-javascript.cson | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 7b02b91a..bfe4a587 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -81,6 +81,7 @@ scopes: 'number': 'constant.numeric' 'string': 'string.quoted' 'regex': 'string.regexp' + 'escape_sequence': 'constant.character.escape' 'template_string': 'string.quoted.template' 'undefined': 'constant.language' 'null': 'constant.language.null' diff --git a/package.json b/package.json index b5fc0e46..135afc40 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,6 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.13.0" + "tree-sitter-javascript": "^0.13.1" } } From 7337d9ce8358e265210016a78a717e644ad25713 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 31 Jul 2018 14:04:34 -0700 Subject: [PATCH 311/420] Prepare 0.129.2 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 135afc40..ee2b0638 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.1", + "version": "0.129.2", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 92f4c2fbd24801d9b30d92e350919c26392d83da Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 31 Jul 2018 20:07:08 -0700 Subject: [PATCH 312/420] Tweak scope mappings --- grammars/tree-sitter-javascript.cson | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index bfe4a587..6ae5ee36 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -75,9 +75,6 @@ scopes: 'method_definition > property_identifier': 'entity.name.function' 'call_expression > member_expression > property_identifier': 'entity.name.function' - 'import_specifier > identifier': 'variable.other.module' - 'import_clause > identifier': 'variable.other.module' - 'number': 'constant.numeric' 'string': 'string.quoted' 'regex': 'string.regexp' @@ -131,6 +128,7 @@ scopes: '"var"': 'storage.type' '"let"': 'storage.type' '"class"': 'storage.type' + '"extends"': 'storage.modifier' '"const"': 'storage.modifier' '"static"': 'storage.modifier' '"function"': 'storage.type.function' @@ -154,6 +152,8 @@ scopes: '"?"': 'keyword.operator.js' '"&&"': 'keyword.operator.js' '"||"': 'keyword.operator.js' + '"&"': 'keyword.operator.js' + '"|"': 'keyword.operator.js' '"++"': 'keyword.operator.js' '"--"': 'keyword.operator.js' '"..."': 'keyword.operator.js' From de49168945d8bdcbbd52890ef80ae5dc184fe345 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 31 Jul 2018 20:10:31 -0700 Subject: [PATCH 313/420] Prepare 0.129.3 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ee2b0638..5def8d1b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.2", + "version": "0.129.3", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 7ae3aa868f3937d6c38d3d0d5075dd263aad4ea3 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 1 Aug 2018 16:38:29 -0700 Subject: [PATCH 314/420] :arrow_up: tree-sitter-javascript --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5def8d1b..9571b3ef 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,6 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.13.1" + "tree-sitter-javascript": "^0.13.3" } } From 0c3de9c94bbbf0dbd090b0f84ec2ff35246ec46e Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 1 Aug 2018 16:38:42 -0700 Subject: [PATCH 315/420] Prepare 0.129.4 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9571b3ef..33c88f61 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.3", + "version": "0.129.4", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 61dea9fe346460c341ec3d404e772796629b69de Mon Sep 17 00:00:00 2001 From: Ashi Krishnan Date: Tue, 7 Aug 2018 15:15:42 -0400 Subject: [PATCH 316/420] Inject and highlight regular expressions with tree-sitter-regex Co-Authored-By: Max Brunsfeld --- grammars/tree-sitter-regex.cson | 21 +++++++++++++++++++++ lib/main.js | 13 +++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 grammars/tree-sitter-regex.cson diff --git a/grammars/tree-sitter-regex.cson b/grammars/tree-sitter-regex.cson new file mode 100644 index 00000000..ae201540 --- /dev/null +++ b/grammars/tree-sitter-regex.cson @@ -0,0 +1,21 @@ +id: 'regex' +name: 'Javascript RegExp' +type: 'tree-sitter' +parser: 'tree-sitter-regex' +legacyScopeName: 'source.js.regexp' +fileTypes: ['jsre'] +injectionRegExp: 'regex' + +comments: + start: '// ' + +scopes: + 'pattern': 'string.quoted', + 'group_name': 'variable.other.object.property' + 'atom_escape, class_escape': 'constant.character.character-class.regexp' + 'assertion': 'constant.character.character-class.regexp' + 'quantifier': 'storage.modifier' + 'character_class': 'string.regexp' + '"(", "(?", "(?:", "(?<"': 'punctuation.definition.parameters.begin.bracket.round' + '">", ")"': 'punctuation.definition.parameters.end.bracket.round' + '"=", "<=", "!", " Date: Tue, 7 Aug 2018 17:05:38 -0400 Subject: [PATCH 317/420] Update highlighting to reflect upstream parse tree simplification. (Also, ignore package-lock.json) Co-Authored-By: Max Brunsfeld --- .gitignore | 1 + grammars/tree-sitter-regex.cson | 6 +++--- package.json | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 3c3629e6..d5f19d89 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +package-lock.json diff --git a/grammars/tree-sitter-regex.cson b/grammars/tree-sitter-regex.cson index ae201540..7c98ead7 100644 --- a/grammars/tree-sitter-regex.cson +++ b/grammars/tree-sitter-regex.cson @@ -12,9 +12,9 @@ comments: scopes: 'pattern': 'string.quoted', 'group_name': 'variable.other.object.property' - 'atom_escape, class_escape': 'constant.character.character-class.regexp' - 'assertion': 'constant.character.character-class.regexp' - 'quantifier': 'storage.modifier' + 'identity_escape, control_letter_escape, control_escape, class_escape': 'constant.character.character-class.regexp' + 'start_assertion, end_assertion, boundary_assertion, non_boundary_assertion': 'constant.character.character-class.regexp' + 'count_quantifier, one_or_more, zero_or_more, optional': 'storage.modifier' 'character_class': 'string.regexp' '"(", "(?", "(?:", "(?<"': 'punctuation.definition.parameters.begin.bracket.round' '">", ")"': 'punctuation.definition.parameters.end.bracket.round' diff --git a/package.json b/package.json index 33c88f61..45aaef95 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.13.3" + "tree-sitter-javascript": "^0.13.3", + "tree-sitter-regex": "^0.13.0" } } From e717279ca66d79eac7daec47f666765830607c11 Mon Sep 17 00:00:00 2001 From: Ashi Krishnan Date: Tue, 7 Aug 2018 18:00:26 -0400 Subject: [PATCH 318/420] =?UTF-8?q?=E2=98=9D=F0=9F=8F=BEtree-sitter-javasc?= =?UTF-8?q?ript=20to=200.13.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Max Brunsfeld --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 45aaef95..cabd5552 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.13.3", + "tree-sitter-javascript": "^0.13.4", "tree-sitter-regex": "^0.13.0" } } From 6db1c8cd22e167382e3adea08b8c1fd5762201d7 Mon Sep 17 00:00:00 2001 From: Ashi Krishnan Date: Wed, 8 Aug 2018 13:52:57 -0400 Subject: [PATCH 319/420] Bump tree-sitter-javascript to a version that npm believes in. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cabd5552..e14ad556 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.13.4", + "tree-sitter-javascript": "^0.13.5", "tree-sitter-regex": "^0.13.0" } } From 3c96f5b84738fa79abf821ba2e1a52cd2ce18ca7 Mon Sep 17 00:00:00 2001 From: Ashi Krishnan Date: Wed, 8 Aug 2018 14:35:22 -0400 Subject: [PATCH 320/420] Remove comments field from regex grammar. --- grammars/tree-sitter-regex.cson | 3 --- 1 file changed, 3 deletions(-) diff --git a/grammars/tree-sitter-regex.cson b/grammars/tree-sitter-regex.cson index 7c98ead7..8391d4d1 100644 --- a/grammars/tree-sitter-regex.cson +++ b/grammars/tree-sitter-regex.cson @@ -6,9 +6,6 @@ legacyScopeName: 'source.js.regexp' fileTypes: ['jsre'] injectionRegExp: 'regex' -comments: - start: '// ' - scopes: 'pattern': 'string.quoted', 'group_name': 'variable.other.object.property' From 096b4b148e46151f72f2e98dcc33cda5311b4e31 Mon Sep 17 00:00:00 2001 From: Ashi Krishnan Date: Wed, 8 Aug 2018 15:09:51 -0400 Subject: [PATCH 321/420] Prepare 0.129.5 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e14ad556..e8d694d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.4", + "version": "0.129.5", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 46b57af3a1536df7f371356cb04cf5b25c07d80b Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 10 Aug 2018 14:29:08 -0700 Subject: [PATCH 322/420] Use new tree-sitter grammar regexes --- grammars/tree-sitter-javascript.cson | 30 +++++++++------------------- grammars/tree-sitter-regex.cson | 1 - 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 6ae5ee36..395a16d0 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -6,27 +6,15 @@ legacyScopeName: 'source.js' fileTypes: ['js', 'jsx'] -injectionRegExp: 'js|javascript' - -firstLineMatch: '''(?x) - # Hashbang - ^\\#!.*(?:\\s|\\/|(?<=!)\\b) - (?:node|iojs|JavaScript) - (?:$|\\s) - | - # Modeline - (?i: - # Emacs - -\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*) - (?:js|javascript) - (?=[\\s;]|(?]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s*set?\\s))(?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:](?:filetype|ft|syntax)\\s*= - javascript - (?=\\s|:|$) - ) -''' +injectionRegex: 'js|javascript' + +firstLineRegex: [ + # shebang line + '^#!.*\\b(node)\\r?\\n' + + # vim modeline + 'vim\\b.*\\bset\\b.*\\b(filetype|ft|syntax)=(js|javascript)' +] folds: [ { diff --git a/grammars/tree-sitter-regex.cson b/grammars/tree-sitter-regex.cson index 8391d4d1..aa966035 100644 --- a/grammars/tree-sitter-regex.cson +++ b/grammars/tree-sitter-regex.cson @@ -3,7 +3,6 @@ name: 'Javascript RegExp' type: 'tree-sitter' parser: 'tree-sitter-regex' legacyScopeName: 'source.js.regexp' -fileTypes: ['jsre'] injectionRegExp: 'regex' scopes: From 6b8e6adf276bfef5ed3729fe042dbcfdd72ef25b Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 10 Aug 2018 14:34:46 -0700 Subject: [PATCH 323/420] Prepare 0.129.6 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e8d694d2..56946f5b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.5", + "version": "0.129.6", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 93f2f2df796c98261384ac3b46eeeaa736a9c4e0 Mon Sep 17 00:00:00 2001 From: Ashi Krishnan Date: Thu, 16 Aug 2018 11:53:21 -0700 Subject: [PATCH 324/420] Match the textmate styling a little more closely. --- grammars/tree-sitter-javascript.cson | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 6ae5ee36..1e18470e 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -68,10 +68,11 @@ scopes: 'call_expression > identifier': [ {match: '^require$', scopes: 'support.function'}, - {match: '^[A-Z]', scopes: 'meta.class'}, 'entity.name.function' ] + 'new_expression > call_expression > identifier': 'entity.name.type.instance.meta.constructor' + 'method_definition > property_identifier': 'entity.name.function' 'call_expression > member_expression > property_identifier': 'entity.name.function' @@ -98,7 +99,7 @@ scopes: 'identifier': [ { - match: '^(global|module|exports|__filename|__dirname)$', + match: '^(global|module|exports|__filename|__dirname|window|document)$', scopes: 'support.variable' }, { From dd8a5d54413b7344d689ca237639c0a0766d32c8 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 20 Aug 2018 10:04:15 -0700 Subject: [PATCH 325/420] Replace id and legacyScopeName with scopeName --- grammars/tree-sitter-javascript.cson | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index d28ebac0..265caad4 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -1,8 +1,7 @@ -id: 'javascript' name: 'JavaScript' +scopeName: 'source.js' type: 'tree-sitter' parser: 'tree-sitter-javascript' -legacyScopeName: 'source.js' fileTypes: ['js', 'jsx'] From 69dd010088cf01fb1c21a78b909da2ef4192ed39 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 20 Aug 2018 10:12:39 -0700 Subject: [PATCH 326/420] Prepare 0.129.7-0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 56946f5b..69eda2cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.6", + "version": "0.129.7-0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 423939d37b53220a24d2d9719c13e2821e6c4c9e Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 20 Aug 2018 11:24:38 -0700 Subject: [PATCH 327/420] Use scopeName in regex grammar --- grammars/tree-sitter-regex.cson | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grammars/tree-sitter-regex.cson b/grammars/tree-sitter-regex.cson index aa966035..812bd378 100644 --- a/grammars/tree-sitter-regex.cson +++ b/grammars/tree-sitter-regex.cson @@ -1,9 +1,9 @@ -id: 'regex' name: 'Javascript RegExp' +scopeName: 'source.js.regexp' type: 'tree-sitter' parser: 'tree-sitter-regex' -legacyScopeName: 'source.js.regexp' -injectionRegExp: 'regex' + +injectionRegex: 'regex' scopes: 'pattern': 'string.quoted', From 5a6fef4b16d9ea9df07db1e3c8b2ee86455df599 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 20 Aug 2018 11:24:51 -0700 Subject: [PATCH 328/420] Prepare 0.129.7-1 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 69eda2cb..2c7b6bff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.7-0", + "version": "0.129.7-1", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From eed8e53872e0d5c7dcb16bd80e4323d937cf41b3 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 20 Aug 2018 13:18:15 -0700 Subject: [PATCH 329/420] Prepare 0.129.7 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2c7b6bff..87afd33a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.7-1", + "version": "0.129.7", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From f21122bed150e6172db265e9ae069a576ab22256 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 23 Aug 2018 17:54:42 -0700 Subject: [PATCH 330/420] Explicitly disable Tree-sitter in TextMate grammar specs --- spec/javascript-spec.coffee | 2 ++ spec/jsdoc-spec.coffee | 2 ++ spec/regular-expression-replacement-spec.coffee | 2 ++ 3 files changed, 6 insertions(+) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index b23d5bc0..746b286d 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -12,6 +12,8 @@ describe "JavaScript grammar", -> grammar = null beforeEach -> + atom.config.set('core.useTreeSitterParsers', false) + waitsForPromise -> atom.packages.activatePackage("language-javascript") diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index 5aa50985..695adee7 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -2,6 +2,8 @@ describe "JSDoc grammar", -> grammar = null beforeEach -> + atom.config.set('core.useTreeSitterParsers', false) + waitsForPromise -> atom.packages.activatePackage("language-javascript") diff --git a/spec/regular-expression-replacement-spec.coffee b/spec/regular-expression-replacement-spec.coffee index 5f2c682b..735aa823 100644 --- a/spec/regular-expression-replacement-spec.coffee +++ b/spec/regular-expression-replacement-spec.coffee @@ -2,6 +2,8 @@ describe "Regular Expression Replacement grammar", -> grammar = null beforeEach -> + atom.config.set('core.useTreeSitterParsers', false) + waitsForPromise -> atom.packages.activatePackage("language-javascript") From 8f9243969152bae7ddc5b09c5a506e9d33f96896 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 23 Aug 2018 17:54:48 -0700 Subject: [PATCH 331/420] Prepare 0.129.8 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 87afd33a..6567065d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.7", + "version": "0.129.8", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 85b1e6ec99d63b2a5741ee17eefb6d4313d3f038 Mon Sep 17 00:00:00 2001 From: Benjamin Gray Date: Sun, 26 Aug 2018 23:01:59 +1000 Subject: [PATCH 332/420] Colour generator functions too --- grammars/tree-sitter-javascript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 265caad4..30ac7934 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -52,6 +52,7 @@ scopes: 'property_identifier': 'variable.other.object.property' 'function > identifier': 'entity.name.function' + 'generator_function > identifier': 'entity.name.function' 'call_expression > identifier': [ {match: '^require$', scopes: 'support.function'}, From ea37ba47038b9e6f253a8a4b22cf7b611e79bf98 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 29 Aug 2018 12:24:59 -0700 Subject: [PATCH 333/420] Fix injection points to use new scope names --- lib/main.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/main.js b/lib/main.js index e6e20fd5..12772065 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,7 +1,7 @@ exports.activate = function() { if (!atom.grammars.addInjectionPoint) return - atom.grammars.addInjectionPoint('javascript', { + atom.grammars.addInjectionPoint('source.js', { type: 'call_expression', language (callExpression) { @@ -19,7 +19,7 @@ exports.activate = function() { } }) - atom.grammars.addInjectionPoint('javascript', { + atom.grammars.addInjectionPoint('source.js', { type: 'assignment_expression', language (callExpression) { @@ -39,16 +39,9 @@ exports.activate = function() { } }) - atom.grammars.addInjectionPoint('javascript', { + atom.grammars.addInjectionPoint('source.js', { type: 'regex_pattern', - - language (regex) { - return 'regex' - }, - - content (regex) { - return regex - } + language (regex) { return 'regex' }, + content (regex) { return regex } }) - } From df7a049ec5b6e866b1686c561ba8d8bb7c0de0c5 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 29 Aug 2018 12:25:05 -0700 Subject: [PATCH 334/420] Prepare 0.129.9 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6567065d..9292f035 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.8", + "version": "0.129.9", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From ca6de6d7e15269caaa3e07bcf8a3e5ad13442431 Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Tue, 25 Sep 2018 14:20:39 -0400 Subject: [PATCH 335/420] :memo: Update .github --- .github/no-response.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/no-response.yml diff --git a/.github/no-response.yml b/.github/no-response.yml new file mode 100644 index 00000000..3c6b33d4 --- /dev/null +++ b/.github/no-response.yml @@ -0,0 +1,15 @@ +# Configuration for probot-no-response - https://github.com/probot/no-response + +# Number of days of inactivity before an issue is closed for lack of response +daysUntilClose: 180 + +# Label requiring a response +responseRequiredLabel: more-information-needed + +# Comment to post when closing an issue for lack of response. Set to `false` to disable. +closeComment: > + This issue has been automatically closed because there has been no response + to our request for more information from the original author. With only the + information that is currently in the issue, we don't have enough information + to take action. Please reach out if you have or find the answers we need so + that we can investigate further. From 593bb261ce250469fceaaeb4c07506b9adae09c0 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 1 Oct 2018 09:41:05 -0700 Subject: [PATCH 336/420] Use `constant.other.property` scope for all-caps property names Refs #597 --- grammars/tree-sitter-javascript.cson | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 30ac7934..cbe0d7de 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -49,7 +49,14 @@ comments: scopes: 'program': 'source.js' - 'property_identifier': 'variable.other.object.property' + 'property_identifier': [ + { + match: '^[\$A-Z_]+$', + scopes: 'constant.other.property.js' + } + + 'variable.other.object.property' + ] 'function > identifier': 'entity.name.function' 'generator_function > identifier': 'entity.name.function' From ea9fdb570e179f321628f7f42bb87cac2bb15d9a Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 1 Oct 2018 09:49:57 -0700 Subject: [PATCH 337/420] :arrow_up: tree-sitter-javascript --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9292f035..1e64da7e 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.13.5", + "tree-sitter-javascript": "^0.13.7", "tree-sitter-regex": "^0.13.0" } } From fd5835edab933a385c704126b18fb56076ac3079 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 1 Oct 2018 09:50:02 -0700 Subject: [PATCH 338/420] Prepare 0.129.10 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1e64da7e..7471cd35 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.9", + "version": "0.129.10", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 4f9aa374c2d7ab4d3e29ec7764e2dee71d8dcd24 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 1 Oct 2018 09:52:49 -0700 Subject: [PATCH 339/420] :arrow_up: tree-sitter-regex --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7471cd35..72279645 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,6 @@ }, "dependencies": { "tree-sitter-javascript": "^0.13.7", - "tree-sitter-regex": "^0.13.0" + "tree-sitter-regex": "^0.13.1" } } From df1414869a1eb356c2e9a18564af2e7519d7a811 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 1 Oct 2018 09:52:54 -0700 Subject: [PATCH 340/420] Prepare 0.129.11 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 72279645..5afa4c40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.10", + "version": "0.129.11", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 51ae47d8253f7f3dfec1a7bb102d0b36606dc92c Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Tue, 2 Oct 2018 11:42:56 -0400 Subject: [PATCH 341/420] :memo: Update .github --- .github/no-response.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/no-response.yml b/.github/no-response.yml index 3c6b33d4..1c8799d1 100644 --- a/.github/no-response.yml +++ b/.github/no-response.yml @@ -1,7 +1,7 @@ # Configuration for probot-no-response - https://github.com/probot/no-response # Number of days of inactivity before an issue is closed for lack of response -daysUntilClose: 180 +daysUntilClose: 28 # Label requiring a response responseRequiredLabel: more-information-needed From b2d7f02fe6ad743020d6415cf1c814171bbfbb11 Mon Sep 17 00:00:00 2001 From: Indrek Ardel Date: Sun, 14 Oct 2018 17:07:43 +0300 Subject: [PATCH 342/420] Add support for gql template literal Closes #429 Co-Authored-By: Tony Xiao --- grammars/javascript.cson | 2 +- spec/javascript-spec.coffee | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 147a7b80..469fb4be 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1429,7 +1429,7 @@ ] } { - 'begin': '(Relay\\.QL)\\s*(`)' + 'begin': '(Relay\\.QL|gql)\\s*(`)' 'beginCaptures': '1': 'name': 'entity.name.function.js' diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 746b286d..47a2fc2c 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -802,6 +802,14 @@ describe "JavaScript grammar", -> expect(tokens[6]).toEqual value: ' }', scopes: ['source.js', 'string.quoted.template.graphql.js'] expect(tokens[7]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.end.js'] + describe "ES6 tagged gql string templates", -> + it "tokenizes them as strings", -> + {tokens} = grammar.tokenizeLine('gql`fragment on Foo { id }`') + expect(tokens[0]).toEqual value: 'gql', scopes: ['source.js', 'string.quoted.template.graphql.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.begin.js'] + expect(tokens[2]).toEqual value: 'fragment on Foo { id }', scopes: ['source.js', 'string.quoted.template.graphql.js'] + expect(tokens[3]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.graphql.js', 'punctuation.definition.string.end.js'] + describe "ES6 tagged SQL string templates", -> it "tokenizes them as strings", -> {tokens} = grammar.tokenizeLine('SQL`SELECT foo FROM bar WHERE id = :id`') From 6a90949ab193467a4df254d11856733d8bbb2221 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 25 Oct 2018 15:02:37 -0700 Subject: [PATCH 343/420] Fix some JSX scope mappings --- grammars/tree-sitter-javascript.cson | 80 ++++++++++++++++------------ 1 file changed, 47 insertions(+), 33 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index cbe0d7de..6de24373 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -58,6 +58,29 @@ scopes: 'variable.other.object.property' ] + 'shorthand_property_identifier': [ + { + match: '^[\$A-Z_]{2,}$', + scopes: 'constant.other' + } + ] + + ' + class > identifier, + new_expression > call_expression > identifier + ': 'meta.class' + + ' + jsx_opening_element > identifier, + jsx_closing_element > identifier, + call_expression > identifier + ': [ + { + match: '^[A-Z]', + scopes: 'meta.class' + }, + ] + 'function > identifier': 'entity.name.function' 'generator_function > identifier': 'entity.name.function' @@ -66,11 +89,27 @@ scopes: 'entity.name.function' ] - 'new_expression > call_expression > identifier': 'entity.name.type.instance.meta.constructor' - 'method_definition > property_identifier': 'entity.name.function' 'call_expression > member_expression > property_identifier': 'entity.name.function' + 'identifier': [ + { + match: '^(global|module|exports|__filename|__dirname|window|document)$', + scopes: 'support.variable' + }, + { + exact: 'require', scopes: 'support.function' + } + { + match: '^[\$A-Z_]{2,}$', + scopes: 'constant.other' + }, + { + match: '^[A-Z]', + scopes: 'meta.class' + }, + ] + 'number': 'constant.numeric' 'string': 'string.quoted' 'regex': 'string.regexp' @@ -83,8 +122,12 @@ scopes: 'comment': 'comment.block' 'hash_bang_line': 'comment.block' - 'template_substitution > "${"': 'punctuation.section.embedded' - 'template_substitution > "}"': 'punctuation.section.embedded' + ' + jsx_expression > "{", + jsx_expression > "}", + template_substitution > "${", + template_substitution > "}" + ': 'punctuation.section.embedded' 'template_substitution': 'embedded.source' '"("': 'punctuation.definition.parameters.begin.bracket.round' @@ -92,35 +135,6 @@ scopes: '"{"': 'punctuation.definition.function.body.begin.bracket.curly' '"}"': 'punctuation.definition.function.body.end.bracket.curly' - 'identifier': [ - { - match: '^(global|module|exports|__filename|__dirname|window|document)$', - scopes: 'support.variable' - }, - { - exact: 'require', scopes: 'support.function' - } - { - match: '^[\$A-Z_]+$', - scopes: 'constant.other' - }, - { - match: '^[A-Z]', - scopes: 'meta.class' - }, - ] - - 'shorthand_property_identifier': [ - { - match: '^[\$A-Z_]+$', - scopes: 'constant.other' - }, - { - match: '^[A-Z]', - scopes: 'meta.class' - }, - ] - '"var"': 'storage.type' '"let"': 'storage.type' '"class"': 'storage.type' From 3851d25c9aea522be2bfcaea19e307b19383a992 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 25 Oct 2018 15:47:13 -0700 Subject: [PATCH 344/420] Allow injection in template literals with member expression tags --- lib/main.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 12772065..8d538c2b 100644 --- a/lib/main.js +++ b/lib/main.js @@ -6,8 +6,13 @@ exports.activate = function() { language (callExpression) { const {firstChild} = callExpression - if (firstChild.type === 'identifier') { - return firstChild.text + switch (firstChild.type) { + case 'identifier': + return firstChild.text + case 'member_expression': + if (firstChild.startPosition.row === firstChild.endPosition.row) { + return firstChild.text + } } }, From 2f1246ea0f702bf9c5419bc87f2cb6e8e3bbe5d2 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 25 Oct 2018 15:48:31 -0700 Subject: [PATCH 345/420] :shirt: --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 8d538c2b..72569bf5 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,4 +1,4 @@ -exports.activate = function() { +exports.activate = function () { if (!atom.grammars.addInjectionPoint) return atom.grammars.addInjectionPoint('source.js', { From 72cdded78c02fda0dd47389e32fb45acdb0f4e8c Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 25 Oct 2018 16:01:00 -0700 Subject: [PATCH 346/420] Prepare 0.129.12 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5afa4c40..25dcf701 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.11", + "version": "0.129.12", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From a6ab0c62f524d83aab5c5ffc5caeb8224a72e060 Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Fri, 26 Oct 2018 20:51:34 +0200 Subject: [PATCH 347/420] Add missing operators to the tree-sitter grammar --- grammars/tree-sitter-javascript.cson | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 6de24373..7ca5481f 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -145,6 +145,18 @@ scopes: '"=>"': 'storage.type.function' '"="': 'keyword.operator.js' + '"+="': 'keyword.operator.js' + '"-="': 'keyword.operator.js' + '"*="': 'keyword.operator.js' + '"/="': 'keyword.operator.js' + '"%="': 'keyword.operator.js' + '"<<="': 'keyword.operator.js' + '">>="': 'keyword.operator.js' + '">>>="': 'keyword.operator.js' + '"&="': 'keyword.operator.js' + '"^="': 'keyword.operator.js' + '"|="': 'keyword.operator.js' + '"!"': 'keyword.operator.js' '"+"': 'keyword.operator.js' '"-"': 'keyword.operator.js' '"*"': 'keyword.operator.js' @@ -163,6 +175,11 @@ scopes: '"&&"': 'keyword.operator.js' '"||"': 'keyword.operator.js' '"&"': 'keyword.operator.js' + '"~"': 'keyword.operator.js' + '"^"': 'keyword.operator.js' + '">>"': 'keyword.operator.js' + '">>>"': 'keyword.operator.js' + '"<<"': 'keyword.operator.js' '"|"': 'keyword.operator.js' '"++"': 'keyword.operator.js' '"--"': 'keyword.operator.js' From 284f9c7b35708555e023f84ab8da093b8b19eefe Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Fri, 26 Oct 2018 21:16:47 +0200 Subject: [PATCH 348/420] Prepare 0.129.13 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 25dcf701..087c40c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.12", + "version": "0.129.13", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 9d367ce7c9bf54d719e749aec8596aafa7602d65 Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Sun, 28 Oct 2018 21:56:57 +0100 Subject: [PATCH 349/420] Scope super as support.function --- grammars/tree-sitter-javascript.cson | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 7ca5481f..ca9b700b 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -89,6 +89,8 @@ scopes: 'entity.name.function' ] + 'call_expression > super': 'support.function' + 'method_definition > property_identifier': 'entity.name.function' 'call_expression > member_expression > property_identifier': 'entity.name.function' From 61cc764bed9497faf3be5723bd4dd131956abab0 Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Sun, 28 Oct 2018 22:08:15 +0100 Subject: [PATCH 350/420] Prepare 0.129.14 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 087c40c3..4726066e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.13", + "version": "0.129.14", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From a2f66fc3aa684121d2af84b026396618f45475ed Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 30 Oct 2018 12:48:04 -0700 Subject: [PATCH 351/420] Allow CSS injection inside 'styled' tagged template literals --- lib/main.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 72569bf5..2da3f731 100644 --- a/lib/main.js +++ b/lib/main.js @@ -8,10 +8,10 @@ exports.activate = function () { const {firstChild} = callExpression switch (firstChild.type) { case 'identifier': - return firstChild.text + return languageStringForTemplateTag(firstChild.text) case 'member_expression': if (firstChild.startPosition.row === firstChild.endPosition.row) { - return firstChild.text + return languageStringForTemplateTag(firstChild.text) } } }, @@ -50,3 +50,13 @@ exports.activate = function () { content (regex) { return regex } }) } + +const STYLED_REGEX = /\bstyled\b/i + +function languageStringForTemplateTag (tag) { + if (STYLED_REGEX.test(tag)) { + return 'CSS' + } else { + return tag + } +} From 81d3af4577d8c06a96167c5dd2ad6857df9dceec Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 30 Oct 2018 12:57:23 -0700 Subject: [PATCH 352/420] Prepare 0.129.15 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4726066e..ff21188b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.14", + "version": "0.129.15", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From e04d8bcd2c0e8d22e8f27d62ffdfa0d164feb451 Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Thu, 1 Nov 2018 15:40:24 +0100 Subject: [PATCH 353/420] Add more scopes to the tree-sitter grammar --- grammars/tree-sitter-javascript.cson | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index ca9b700b..71fac84a 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -136,6 +136,9 @@ scopes: '")"': 'punctuation.definition.parameters.end.bracket.round' '"{"': 'punctuation.definition.function.body.begin.bracket.curly' '"}"': 'punctuation.definition.function.body.end.bracket.curly' + '";"': 'punctuation.terminator.statement.semicolon' + '"["': 'punctuation.definition.array.begin.bracket.square' + '"]"': 'punctuation.definition.array.end.bracket.square' '"var"': 'storage.type' '"let"': 'storage.type' @@ -199,6 +202,7 @@ scopes: '"."': 'meta.delimiter' '","': 'meta.delimiter' + '"as"': 'keyword.control' '"if"': 'keyword.control' '"do"': 'keyword.control' '"else"': 'keyword.control' From 9be2756d4b67eaf0297ebbd21ae13c1b680dbd7e Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Thu, 1 Nov 2018 17:46:25 +0100 Subject: [PATCH 354/420] Style arugments and super as variable.language --- grammars/tree-sitter-javascript.cson | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 71fac84a..e7d8f358 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -94,11 +94,16 @@ scopes: 'method_definition > property_identifier': 'entity.name.function' 'call_expression > member_expression > property_identifier': 'entity.name.function' + 'super': 'variable.language' + 'identifier': [ { match: '^(global|module|exports|__filename|__dirname|window|document)$', scopes: 'support.variable' }, + { + exact: 'arguments', + scopes:'variable.language'}, { exact: 'require', scopes: 'support.function' } From 2772c289a553da74dcd433d1081b110388e8bcbc Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Thu, 1 Nov 2018 19:27:04 +0100 Subject: [PATCH 355/420] :art: --- grammars/tree-sitter-javascript.cson | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index e7d8f358..8f23a3d6 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -103,10 +103,12 @@ scopes: }, { exact: 'arguments', - scopes:'variable.language'}, + scopes:'variable.language' + }, { - exact: 'require', scopes: 'support.function' - } + exact: 'require', + scopes: 'support.function' + }, { match: '^[\$A-Z_]{2,}$', scopes: 'constant.other' From 8c513eb0a96f54aac61612c0b944c72b8df6ffe4 Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Thu, 1 Nov 2018 19:40:36 +0100 Subject: [PATCH 356/420] Scope this as variable.language --- grammars/tree-sitter-javascript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 8f23a3d6..8dbaaed0 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -94,6 +94,7 @@ scopes: 'method_definition > property_identifier': 'entity.name.function' 'call_expression > member_expression > property_identifier': 'entity.name.function' + 'this': 'variable.language' 'super': 'variable.language' 'identifier': [ From b427615eddf4ab9c7ce4ad1a6a4f5ebc1291997e Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Thu, 1 Nov 2018 20:09:31 +0100 Subject: [PATCH 357/420] Add a more specific scope for a call to super --- grammars/tree-sitter-javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 8dbaaed0..b6a3d0e5 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -89,7 +89,7 @@ scopes: 'entity.name.function' ] - 'call_expression > super': 'support.function' + 'call_expression > super': 'support.function.super' 'method_definition > property_identifier': 'entity.name.function' 'call_expression > member_expression > property_identifier': 'entity.name.function' From 4216f3df82a98d145a7d6dc0147ce96febb3fcc6 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 1 Nov 2018 13:38:05 -0700 Subject: [PATCH 358/420] :arrow_up: tree-sitter-javascript For tree-sitter/tree-sitter-javascript#85 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ff21188b..a8528a92 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.13.7", + "tree-sitter-javascript": "^0.13.8", "tree-sitter-regex": "^0.13.1" } } From e615da4207d1028820ddc19b417389cf78c03ab2 Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Sat, 3 Nov 2018 09:17:21 +0100 Subject: [PATCH 359/420] Add arrow to the function to match textmate Refs https://github.com/atom/language-javascript/issues/566 --- grammars/tree-sitter-javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index b6a3d0e5..3fe576d3 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -155,7 +155,7 @@ scopes: '"const"': 'storage.modifier' '"static"': 'storage.modifier' '"function"': 'storage.type.function' - '"=>"': 'storage.type.function' + '"=>"': 'storage.type.function.arrow' '"="': 'keyword.operator.js' '"+="': 'keyword.operator.js' From 8b7f5b09a2243f29a758249b052a23ebd5da543c Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Wed, 7 Nov 2018 13:07:44 +0100 Subject: [PATCH 360/420] Self closing elements can also be meta.class --- grammars/tree-sitter-javascript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index ca9b700b..9398d69c 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -73,6 +73,7 @@ scopes: ' jsx_opening_element > identifier, jsx_closing_element > identifier, + jsx_self_closing_element > identifier, call_expression > identifier ': [ { From 9ebc7decef45b28022983d62b93c078d564ca471 Mon Sep 17 00:00:00 2001 From: CentricStorm Date: Wed, 7 Nov 2018 16:10:53 +0000 Subject: [PATCH 361/420] Distinguish between commas and periods. --- grammars/tree-sitter-javascript.cson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index ca9b700b..90319025 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -196,8 +196,8 @@ scopes: '"get"': 'keyword.operator.setter' '"set"': 'keyword.operator.setter' - '"."': 'meta.delimiter' - '","': 'meta.delimiter' + '"."': 'meta.delimiter.period' + '","': 'meta.delimiter.comma' '"if"': 'keyword.control' '"do"': 'keyword.control' From 92145cdb0cc19ea858caf20d57320164977669f5 Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Wed, 7 Nov 2018 20:23:28 +0100 Subject: [PATCH 362/420] Prepare 0.129.16 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a8528a92..169d3373 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.15", + "version": "0.129.16", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 478f98d7ab254d94506d260f696acb9448611792 Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Thu, 8 Nov 2018 20:39:15 +0100 Subject: [PATCH 363/420] Fold rules for switch_case If there is a break statement don't include that in the fold. If there isn't a break fold the entire case --- grammars/tree-sitter-javascript.cson | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 284983e5..1e1f5e80 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -41,6 +41,15 @@ folds: [ start: {index: 0, type: '('} end: {index: -1, type: ')'} } + { + type: 'switch_case' + start: {index: 0} + end: {type: 'break_statement', index: -1} + } + { + type: 'switch_case' + start: {index: 0} + } ] comments: From cab77b6babf538836db2bc6cdfff60ec960a6fbf Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 8 Nov 2018 13:28:57 -0800 Subject: [PATCH 364/420] Remove language.variable scope mappings for now --- grammars/tree-sitter-javascript.cson | 7 ------- 1 file changed, 7 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 3fe576d3..b67318a8 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -94,18 +94,11 @@ scopes: 'method_definition > property_identifier': 'entity.name.function' 'call_expression > member_expression > property_identifier': 'entity.name.function' - 'this': 'variable.language' - 'super': 'variable.language' - 'identifier': [ { match: '^(global|module|exports|__filename|__dirname|window|document)$', scopes: 'support.variable' }, - { - exact: 'arguments', - scopes:'variable.language' - }, { exact: 'require', scopes: 'support.function' From c0553a316620f166dfa364f9a0978c17ade3631d Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 8 Nov 2018 14:00:07 -0800 Subject: [PATCH 365/420] Prepare 0.129.17 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 169d3373..77d3d8c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.16", + "version": "0.129.17", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 5da20e88f88bedf261399a7c1d48c93b831dcf08 Mon Sep 17 00:00:00 2001 From: Benjamin Gray Date: Mon, 12 Nov 2018 00:57:53 +1100 Subject: [PATCH 366/420] Differentiate line and block comments --- grammars/tree-sitter-javascript.cson | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 67e81291..05d7b7b4 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -132,7 +132,13 @@ scopes: 'null': 'constant.language.null' 'true': 'constant.language.boolean.true' 'false': 'constant.language.boolean.false' - 'comment': 'comment.block' + 'comment': [ + { + match: "^//", + scopes: 'comment.line' + }, + 'comment.block' + ] 'hash_bang_line': 'comment.block' ' From a4f69240a3cb01d4c2f66d82d448c6d9067de194 Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Wed, 14 Nov 2018 21:08:38 +0100 Subject: [PATCH 367/420] Change scopes in comparison to language-babel Refs https://github.com/atom/language-javascript/issues/625 --- grammars/tree-sitter-javascript.cson | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 67e81291..e5c3ca81 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -67,6 +67,10 @@ scopes: 'variable.other.object.property' ] + 'member_expression > property_identifier': 'variable.other.object.property.unquoted' + + 'formal_parameters > identifier': 'formal-parameter.identifier' + 'shorthand_property_identifier': [ { match: '^[\$A-Z_]{2,}$', @@ -83,14 +87,15 @@ scopes: jsx_opening_element > identifier, jsx_closing_element > identifier, jsx_self_closing_element > identifier, - call_expression > identifier ': [ { match: '^[A-Z]', - scopes: 'meta.class' - }, + scopes: 'meta.class.component.jsx' + } ] + 'call_expression > identifier': {match: '^[A-Z]', scopes: 'meta.class'} + 'function > identifier': 'entity.name.function' 'generator_function > identifier': 'entity.name.function' @@ -106,9 +111,13 @@ scopes: 'identifier': [ { - match: '^(global|module|exports|__filename|__dirname|window|document)$', + match: '^(global|module|exports|__filename|__dirname)$', scopes: 'support.variable' }, + { + match: '^(window|event|document|performance|screen|navigator|console)$' + scopes: 'support.variable.dom' + }, { exact: 'require', scopes: 'support.function' @@ -199,7 +208,7 @@ scopes: '"|"': 'keyword.operator.js' '"++"': 'keyword.operator.js' '"--"': 'keyword.operator.js' - '"..."': 'keyword.operator.js' + '"..."': 'keyword.operator.spread.js' '"in"': 'keyword.operator.in' '"instanceof"': 'keyword.operator.instanceof' From e14dd5c53018d951dc86a36411fc3231089f4a2a Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 14 Nov 2018 15:21:39 -0800 Subject: [PATCH 368/420] Add JSDoc injection w/ tree-sitter-jsdoc --- grammars/tree-sitter-javascript.cson | 2 +- grammars/tree-sitter-jsdoc.cson | 11 +++++++++++ lib/main.js | 12 ++++++++++++ package.json | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 grammars/tree-sitter-jsdoc.cson diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 67e81291..4585ddb3 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -5,7 +5,7 @@ parser: 'tree-sitter-javascript' fileTypes: ['js', 'jsx'] -injectionRegex: 'js|javascript' +injectionRegex: '^js$|^JS$|javascript|JavaScript' firstLineRegex: [ # shebang line diff --git a/grammars/tree-sitter-jsdoc.cson b/grammars/tree-sitter-jsdoc.cson new file mode 100644 index 00000000..397fa6ae --- /dev/null +++ b/grammars/tree-sitter-jsdoc.cson @@ -0,0 +1,11 @@ +name: 'JSDoc' +scopeName: 'source.jsdoc' +type: 'tree-sitter' +parser: 'tree-sitter-jsdoc' + +injectionRegex: 'jsdoc' + +scopes: + '"@param", "@returns", "@alias", tag_name': 'keyword.control' + 'param_tag > identifier, alias_tag > identifier': 'variable.other.jsdoc' + 'type': 'support.type' diff --git a/lib/main.js b/lib/main.js index 2da3f731..da1e9faf 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,6 +49,18 @@ exports.activate = function () { language (regex) { return 'regex' }, content (regex) { return regex } }) + + for (const scopeName of ['source.js', 'source.flow', 'source.ts']) { + atom.grammars.addInjectionPoint(scopeName, { + type: 'comment', + language (comment) { + if (comment.text.startsWith('/**')) return 'jsdoc' + }, + content (comment) { + return comment + } + }) + } } const STYLED_REGEX = /\bstyled\b/i diff --git a/package.json b/package.json index 77d3d8c9..1c7e65b6 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ }, "dependencies": { "tree-sitter-javascript": "^0.13.8", + "tree-sitter-jsdoc": "^0.13.2", "tree-sitter-regex": "^0.13.1" } } From 5aa901be72548399b14ad2261935f913562c4832 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 15 Nov 2018 12:43:10 -0800 Subject: [PATCH 369/420] Add tree-sitter keyword to package.json --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 77d3d8c9..91f7924b 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,9 @@ "bugs": { "url": "https://github.com/atom/language-javascript/issues" }, + "keywords": [ + "tree-sitter" + ], "devDependencies": { "coffeelint": "^1.10.1" }, From b09a675accc4f4e8df160d2179c9e5855ad597b3 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 15 Nov 2018 14:59:44 -0800 Subject: [PATCH 370/420] :arrow_up: tree-sitter-jsdoc, generalize tag scopes --- grammars/tree-sitter-jsdoc.cson | 11 ++++++++--- package.json | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/grammars/tree-sitter-jsdoc.cson b/grammars/tree-sitter-jsdoc.cson index 397fa6ae..a9f8a679 100644 --- a/grammars/tree-sitter-jsdoc.cson +++ b/grammars/tree-sitter-jsdoc.cson @@ -3,9 +3,14 @@ scopeName: 'source.jsdoc' type: 'tree-sitter' parser: 'tree-sitter-jsdoc' -injectionRegex: 'jsdoc' +injectionRegex: '^jsdoc$' scopes: - '"@param", "@returns", "@alias", tag_name': 'keyword.control' - 'param_tag > identifier, alias_tag > identifier': 'variable.other.jsdoc' + 'tag_name': 'keyword.control' + 'identifier': 'variable.other.jsdoc' 'type': 'support.type' + 'path_expression > identifier': 'string' + '"."': 'meta.delimiter.period' + '":"': 'meta.delimiter.colon' + '"/"': 'meta.delimiter.slash' + '"#", "~"': 'meta.delimiter' diff --git a/package.json b/package.json index 1c7e65b6..42222f16 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ }, "dependencies": { "tree-sitter-javascript": "^0.13.8", - "tree-sitter-jsdoc": "^0.13.2", + "tree-sitter-jsdoc": "^0.13.3", "tree-sitter-regex": "^0.13.1" } } From 7a377722e3bee3ee62bf64591b2c1566e2043551 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 15 Nov 2018 15:27:38 -0800 Subject: [PATCH 371/420] :arrow_up: tree-sitter-jsdoc for CRLF fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 42222f16..5323ffb0 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ }, "dependencies": { "tree-sitter-javascript": "^0.13.8", - "tree-sitter-jsdoc": "^0.13.3", + "tree-sitter-jsdoc": "^0.13.4", "tree-sitter-regex": "^0.13.1" } } From 8682aceeba09e208a3ffc516f9986783f60d0131 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 15 Nov 2018 15:56:48 -0800 Subject: [PATCH 372/420] Prepare 0.129.18 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ce7e8c13..1d7c4b36 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.17", + "version": "0.129.18", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 9c6b4fca96dceb12a95e1bacda62001a21111e39 Mon Sep 17 00:00:00 2001 From: fd-rey Date: Wed, 21 Nov 2018 17:49:38 +0100 Subject: [PATCH 373/420] Fix for...of autocomplete, variable declaration Following the for...of reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of The variable declaration with "var" is missing. --- snippets/language-javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/language-javascript.cson b/snippets/language-javascript.cson index c8064854..7d5dfea2 100644 --- a/snippets/language-javascript.cson +++ b/snippets/language-javascript.cson @@ -34,7 +34,7 @@ 'body': 'for (var ${1:variable} in ${2:object}) {\n\t${3:if (${2:object}.hasOwnProperty(${1:variable})) {\n\t\t$4\n\t\\}}\n}' 'for of': 'prefix': 'forof' - 'body': 'for (${1:variable} of ${2:iterable}) {\n\t$3\n}' + 'body': 'for (var ${1:variable} of ${2:iterable}) {\n\t$3\n}' 'Function': 'prefix': 'fun' 'body': 'function ${1:functionName}($2) {\n\t$0\n}' From 7cb6cfd8192d50190b31ede3b67a0a9f58ceec2a Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Thu, 29 Nov 2018 17:49:24 +0100 Subject: [PATCH 374/420] Remove , so this rule actually works --- grammars/tree-sitter-javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 6b70a23c..5afaef54 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -86,7 +86,7 @@ scopes: ' jsx_opening_element > identifier, jsx_closing_element > identifier, - jsx_self_closing_element > identifier, + jsx_self_closing_element > identifier ': [ { match: '^[A-Z]', From a6332c080b839c8fcf9e571b56b98a5df713444e Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 19 Dec 2018 09:41:53 -0800 Subject: [PATCH 375/420] :arrow_up: tree-sitter-javascript, adjust scope mappings --- grammars/tree-sitter-javascript.cson | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 5afaef54..512598ba 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -80,7 +80,7 @@ scopes: ' class > identifier, - new_expression > call_expression > identifier + new_expression > identifier ': 'meta.class' ' diff --git a/package.json b/package.json index 1d7c4b36..7f92f7b5 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.13.8", + "tree-sitter-javascript": "^0.13.10", "tree-sitter-jsdoc": "^0.13.4", "tree-sitter-regex": "^0.13.1" } From 5d7da002d1958fc8d59c6d5116d33453fdf850ab Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 19 Dec 2018 09:48:33 -0800 Subject: [PATCH 376/420] Prepare 0.129.19-0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7f92f7b5..bd53e6bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.18", + "version": "0.129.19-0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 25863daee1a66142718349de0dc9139ddf825489 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 19 Dec 2018 10:54:51 -0800 Subject: [PATCH 377/420] Prepare 0.129.19 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bd53e6bb..98cb9144 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.19-0", + "version": "0.129.19", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 4f905c5480dd338535adbe020524380505de3ed8 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Fri, 25 Jan 2019 13:16:29 +0200 Subject: [PATCH 378/420] Add `css` template literal tag --- grammars/javascript.cson | 24 +++++++++++++++++ spec/javascript-spec.coffee | 51 +++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 469fb4be..dcb314ba 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1370,6 +1370,30 @@ } ] } + { + 'begin': '((\\w+)?(css|CSS|Css))\\s*(`)' + 'beginCaptures': + '1': + 'name': 'entity.name.function.js' + '4': + 'name': 'punctuation.definition.string.begin.js' + 'end': '`' + 'endCaptures': + '0': + 'name': 'punctuation.definition.string.end.js' + 'name': 'string.quoted.template.css.js' + 'patterns': [ + { + 'include': '#string_escapes' + } + { + 'include': '#interpolated_js' + } + { + 'include': 'source.css' + } + ] + } { 'begin': '((\\w+)?(html|HTML|Html))\\s*(`)' 'beginCaptures': diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 47a2fc2c..0f139375 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -782,6 +782,57 @@ describe "JavaScript grammar", -> expect(tokens[12]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, 'punctuation.definition.tag.end.html'] expect(tokens[13]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] + describe "CSS template strings", -> + beforeEach -> + waitsForPromise -> + atom.packages.activatePackage("language-css") + + it "tokenizes ES6 tagged CSS string templates", -> + {tokens} = grammar.tokenizeLine('css`:host{display:${display}}`') + expect(tokens[0]).toEqual value: 'css', scopes: ['source.js', 'string.quoted.template.css.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.definition.string.begin.js'] + expect(tokens[2]).toEqual value: ':', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.selector.css', 'entity.other.attribute-name.pseudo-class.css', 'punctuation.definition.entity.css'] + expect(tokens[3]).toEqual value: 'host', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.selector.css', 'entity.other.attribute-name.pseudo-class.css'] + expect(tokens[4]).toEqual value: '{', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.property-list.css', 'punctuation.section.property-list.begin.bracket.curly.css'] + expect(tokens[5]).toEqual value: 'display', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.property-list.css', 'meta.property-name.css', 'support.type.property-name.css'] + expect(tokens[6]).toEqual value: ':', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.property-list.css', 'punctuation.separator.key-value.css'] + expect(tokens[7]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[8]).toEqual value: 'display', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source'] + expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.section.property-list.end.bracket.curly.css'] + expect(tokens[11]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.definition.string.end.js'] + + it "tokenizes ES6 tagged CSS string templates with expanded function name", -> + {tokens} = grammar.tokenizeLine('escapeCSS`:host{display:${display}}`') + expect(tokens[0]).toEqual value: 'escapeCSS', scopes: ['source.js', 'string.quoted.template.css.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.definition.string.begin.js'] + expect(tokens[2]).toEqual value: ':', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.selector.css', 'entity.other.attribute-name.pseudo-class.css', 'punctuation.definition.entity.css'] + expect(tokens[3]).toEqual value: 'host', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.selector.css', 'entity.other.attribute-name.pseudo-class.css'] + expect(tokens[4]).toEqual value: '{', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.section.property-list.begin.bracket.curly.css'] + expect(tokens[5]).toEqual value: 'display', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.property-list.css', 'meta.property-name.css', 'support.type.property-name.css'] + expect(tokens[6]).toEqual value: ':', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.property-list.css', 'punctuation.separator.key-value.css'] + expect(tokens[7]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[8]).toEqual value: 'display', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source'] + expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.section.property-list.end.bracket.curly.css'] + expect(tokens[11]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.definition.string.end.js'] + + it "tokenizes ES6 tagged CSS string templates with expanded function name and white space", -> + {tokens} = grammar.tokenizeLine('escapeCSS `:host{display:${display}}`') + expect(tokens[0]).toEqual value: 'escapeCSS', scopes: ['source.js', 'string.quoted.template.css.js', 'entity.name.function.js'] + expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'string.quoted.template.css.js'] + expect(tokens[2]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.definition.string.begin.js'] + expect(tokens[3]).toEqual value: ':', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.selector.css', 'entity.other.attribute-name.pseudo-class.css', 'punctuation.definition.entity.css'] + expect(tokens[4]).toEqual value: 'host', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.selector.css', 'entity.other.attribute-name.pseudo-class.css'] + expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.section.property-list.begin.bracket.curly.css'] + expect(tokens[6]).toEqual value: 'display', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.property-list.css', 'meta.property-name.css', 'support.type.property-name.css'] + expect(tokens[7]).toEqual value: ':', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.property-list.css', 'punctuation.separator.key-value.css'] + expect(tokens[8]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[9]).toEqual value: 'display', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source'] + expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] + expect(tokens[11]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.section.property-list.end.bracket.curly.css'] + expect(tokens[12]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.definition.string.end.js'] + describe "ES6 tagged Relay.QL string templates", -> it "tokenizes them as strings", -> {tokens} = grammar.tokenizeLine('Relay.QL`fragment on Foo { id }`') From 1f1da30a976dc0dbaef78fd8fdc425351b7b97a2 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 6 Feb 2019 17:25:39 -0800 Subject: [PATCH 379/420] Allow tagged template injections to accept function parameters This change fixes #634 which reports that the Tree-Sitter JavaScript grammar does not correctly highlight tagged template injections which have function parameters, such as those used in the Styled Components library. The fix enables tagged template injections to be highlighted correctly when the template invocation includes function arguments. --- lib/main.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/main.js b/lib/main.js index da1e9faf..c5905c2f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -9,6 +9,8 @@ exports.activate = function () { switch (firstChild.type) { case 'identifier': return languageStringForTemplateTag(firstChild.text) + case 'call_expression': + return languageStringForTemplateTag(firstChild.children[0].text) case 'member_expression': if (firstChild.startPosition.row === firstChild.endPosition.row) { return languageStringForTemplateTag(firstChild.text) From 7bd0335c79bfebfc6511839d876c08d5cd7a215c Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Thu, 7 Feb 2019 08:07:25 +0200 Subject: [PATCH 380/420] Revert "Add `css` template literal tag" This reverts commit 4fc67fb98d66c239f639bf33171ec261c59e4c72. --- grammars/javascript.cson | 24 ----------------- spec/javascript-spec.coffee | 51 ------------------------------------- 2 files changed, 75 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index dcb314ba..469fb4be 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1370,30 +1370,6 @@ } ] } - { - 'begin': '((\\w+)?(css|CSS|Css))\\s*(`)' - 'beginCaptures': - '1': - 'name': 'entity.name.function.js' - '4': - 'name': 'punctuation.definition.string.begin.js' - 'end': '`' - 'endCaptures': - '0': - 'name': 'punctuation.definition.string.end.js' - 'name': 'string.quoted.template.css.js' - 'patterns': [ - { - 'include': '#string_escapes' - } - { - 'include': '#interpolated_js' - } - { - 'include': 'source.css' - } - ] - } { 'begin': '((\\w+)?(html|HTML|Html))\\s*(`)' 'beginCaptures': diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 0f139375..47a2fc2c 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -782,57 +782,6 @@ describe "JavaScript grammar", -> expect(tokens[12]).toEqual value: '>', scopes: ['source.js', 'string.quoted.template.html.js', tagScope, 'punctuation.definition.tag.end.html'] expect(tokens[13]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.html.js', 'punctuation.definition.string.end.js'] - describe "CSS template strings", -> - beforeEach -> - waitsForPromise -> - atom.packages.activatePackage("language-css") - - it "tokenizes ES6 tagged CSS string templates", -> - {tokens} = grammar.tokenizeLine('css`:host{display:${display}}`') - expect(tokens[0]).toEqual value: 'css', scopes: ['source.js', 'string.quoted.template.css.js', 'entity.name.function.js'] - expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.definition.string.begin.js'] - expect(tokens[2]).toEqual value: ':', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.selector.css', 'entity.other.attribute-name.pseudo-class.css', 'punctuation.definition.entity.css'] - expect(tokens[3]).toEqual value: 'host', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.selector.css', 'entity.other.attribute-name.pseudo-class.css'] - expect(tokens[4]).toEqual value: '{', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.property-list.css', 'punctuation.section.property-list.begin.bracket.curly.css'] - expect(tokens[5]).toEqual value: 'display', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.property-list.css', 'meta.property-name.css', 'support.type.property-name.css'] - expect(tokens[6]).toEqual value: ':', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.property-list.css', 'punctuation.separator.key-value.css'] - expect(tokens[7]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[8]).toEqual value: 'display', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source'] - expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.section.property-list.end.bracket.curly.css'] - expect(tokens[11]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.definition.string.end.js'] - - it "tokenizes ES6 tagged CSS string templates with expanded function name", -> - {tokens} = grammar.tokenizeLine('escapeCSS`:host{display:${display}}`') - expect(tokens[0]).toEqual value: 'escapeCSS', scopes: ['source.js', 'string.quoted.template.css.js', 'entity.name.function.js'] - expect(tokens[1]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.definition.string.begin.js'] - expect(tokens[2]).toEqual value: ':', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.selector.css', 'entity.other.attribute-name.pseudo-class.css', 'punctuation.definition.entity.css'] - expect(tokens[3]).toEqual value: 'host', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.selector.css', 'entity.other.attribute-name.pseudo-class.css'] - expect(tokens[4]).toEqual value: '{', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.section.property-list.begin.bracket.curly.css'] - expect(tokens[5]).toEqual value: 'display', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.property-list.css', 'meta.property-name.css', 'support.type.property-name.css'] - expect(tokens[6]).toEqual value: ':', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.property-list.css', 'punctuation.separator.key-value.css'] - expect(tokens[7]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[8]).toEqual value: 'display', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source'] - expect(tokens[9]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.section.property-list.end.bracket.curly.css'] - expect(tokens[11]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.definition.string.end.js'] - - it "tokenizes ES6 tagged CSS string templates with expanded function name and white space", -> - {tokens} = grammar.tokenizeLine('escapeCSS `:host{display:${display}}`') - expect(tokens[0]).toEqual value: 'escapeCSS', scopes: ['source.js', 'string.quoted.template.css.js', 'entity.name.function.js'] - expect(tokens[1]).toEqual value: ' ', scopes: ['source.js', 'string.quoted.template.css.js'] - expect(tokens[2]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.definition.string.begin.js'] - expect(tokens[3]).toEqual value: ':', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.selector.css', 'entity.other.attribute-name.pseudo-class.css', 'punctuation.definition.entity.css'] - expect(tokens[4]).toEqual value: 'host', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.selector.css', 'entity.other.attribute-name.pseudo-class.css'] - expect(tokens[5]).toEqual value: '{', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.section.property-list.begin.bracket.curly.css'] - expect(tokens[6]).toEqual value: 'display', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.property-list.css', 'meta.property-name.css', 'support.type.property-name.css'] - expect(tokens[7]).toEqual value: ':', scopes: ['source.js', 'string.quoted.template.css.js', 'meta.property-list.css', 'punctuation.separator.key-value.css'] - expect(tokens[8]).toEqual value: '${', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[9]).toEqual value: 'display', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source'] - expect(tokens[10]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.css.js', 'source.js.embedded.source', 'punctuation.section.embedded.js'] - expect(tokens[11]).toEqual value: '}', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.section.property-list.end.bracket.curly.css'] - expect(tokens[12]).toEqual value: '`', scopes: ['source.js', 'string.quoted.template.css.js', 'punctuation.definition.string.end.js'] - describe "ES6 tagged Relay.QL string templates", -> it "tokenizes them as strings", -> {tokens} = grammar.tokenizeLine('Relay.QL`fragment on Foo { id }`') From 14f286320ecd40730b82922076f74e7c99f70124 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Thu, 7 Feb 2019 08:15:12 +0200 Subject: [PATCH 381/420] Uses CSS language for `css` template tag --- lib/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index da1e9faf..7d51ca4c 100644 --- a/lib/main.js +++ b/lib/main.js @@ -63,10 +63,10 @@ exports.activate = function () { } } -const STYLED_REGEX = /\bstyled\b/i +const CSS_REGEX = /\bstyled\b|\bcss\b/i -function languageStringForTemplateTag (tag) { - if (STYLED_REGEX.test(tag)) { +function languageStringForTemplateTag(tag) { + if (CSS_REGEX.test(tag)) { return 'CSS' } else { return tag From 9a5263912971ed8b0d99c73594a094b5850298e9 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Thu, 7 Feb 2019 08:47:12 +0200 Subject: [PATCH 382/420] Lint main.js --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 7d51ca4c..419c634f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -65,7 +65,7 @@ exports.activate = function () { const CSS_REGEX = /\bstyled\b|\bcss\b/i -function languageStringForTemplateTag(tag) { +function languageStringForTemplateTag (tag) { if (CSS_REGEX.test(tag)) { return 'CSS' } else { From 76b5c69238229f1b1bb161892005df50e5831626 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Thu, 7 Feb 2019 08:47:23 +0200 Subject: [PATCH 383/420] Adds gql and sql tags --- lib/main.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/main.js b/lib/main.js index 419c634f..c30a5022 100644 --- a/lib/main.js +++ b/lib/main.js @@ -64,10 +64,16 @@ exports.activate = function () { } const CSS_REGEX = /\bstyled\b|\bcss\b/i +const GQL_REGEX = /\bgraphql\b|\bgql\b/i +const SQL_REGEX = /\bsql\b/i function languageStringForTemplateTag (tag) { if (CSS_REGEX.test(tag)) { return 'CSS' + } else if (GQL_REGEX.test(tag)) { + return 'GraphQL' + } else if (SQL_REGEX.test(tag)) { + return 'SQL' } else { return tag } From e5034e28f00e5401890516b7bce47fe3a9041c3c Mon Sep 17 00:00:00 2001 From: David Wilson Date: Thu, 7 Feb 2019 10:06:09 -0800 Subject: [PATCH 384/420] Prepare 0.129.20 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 98cb9144..13bc28f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.19", + "version": "0.129.20", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From e589d85a45369159b272abf32bf799adfb767fe6 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 5 Mar 2019 15:01:43 +0000 Subject: [PATCH 385/420] Remove invalid string highlighting GitHub Linguist currently uses this grammar for highlighting Javascript and JSX and the presence of an apostrophe within JSX caused the syntax to be highlighted in red. See https://github.com/github/linguist/issues/3044 for details. Fixes https://github.com/atom/language-javascript/issues/641 --- grammars/javascript.cson | 8 -------- 1 file changed, 8 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 469fb4be..fca11f9b 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1344,10 +1344,6 @@ { 'include': '#string_escapes' } - { - 'match': "[^']*[^\\n\\r'\\\\]$" - 'name': 'invalid.illegal.string.js' - } ] } { @@ -1364,10 +1360,6 @@ { 'include': '#string_escapes' } - { - 'match': '[^"]*[^\\n\\r"\\\\]$' - 'name': 'invalid.illegal.string.js' - } ] } { From 9cf582ae9c6e90c454f5a5d5e28dd2fb95738fbb Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 15 Mar 2019 10:17:00 +0000 Subject: [PATCH 386/420] Update tests to reflect invalid.illegal.string removal --- spec/javascript-spec.coffee | 1 - spec/jsdoc-spec.coffee | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 47a2fc2c..ff099acb 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -51,7 +51,6 @@ describe "JavaScript grammar", -> line3 """ + delim expect(lines[0][0]).toEqual value: delim, scopes: ['source.js', scope, 'punctuation.definition.string.begin.js'] - expect(lines[0][1]).toEqual value: 'line1', scopes: ['source.js', scope, 'invalid.illegal.string.js'] expect(lines[1][0]).toEqual value: 'line2\\', scopes: ['source.js', scope] expect(lines[2][0]).toEqual value: 'line3', scopes: ['source.js', scope] expect(lines[2][1]).toEqual value: delim, scopes: ['source.js', scope, 'punctuation.definition.string.end.js'] diff --git a/spec/jsdoc-spec.coffee b/spec/jsdoc-spec.coffee index 695adee7..8baf4e28 100644 --- a/spec/jsdoc-spec.coffee +++ b/spec/jsdoc-spec.coffee @@ -1469,7 +1469,7 @@ describe "JSDoc grammar", -> expect(tokens[7]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js'] expect(tokens[8]).toEqual value: 'oo', scopes: ['source.js'] expect(tokens[9]).toEqual value: '"', scopes: ['source.js', 'string.quoted.double.js', 'punctuation.definition.string.begin.js'] - expect(tokens[10]).toEqual value: '} bar', scopes: ['source.js', 'string.quoted.double.js', 'invalid.illegal.string.js'] + expect(tokens[10]).toEqual value: '} bar', scopes: ['source.js', 'string.quoted.double.js'] it "terminates any embedded JavaScript code", -> lines = grammar.tokenizeLines """ From f991b825d7cdd3c214d470bc37b528c81af9e95d Mon Sep 17 00:00:00 2001 From: Winston Liu <50Wliu@users.noreply.github.com> Date: Mon, 1 Apr 2019 00:34:46 -0400 Subject: [PATCH 387/420] Prepare 0.129.21 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 13bc28f3..3c09d48f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.20", + "version": "0.129.21", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 977311479e2cc44b2bef409a8b8ec5e2439dc6cc Mon Sep 17 00:00:00 2001 From: Linus Eriksson Date: Wed, 3 Apr 2019 11:39:51 +0200 Subject: [PATCH 388/420] Allow folding switch_default --- grammars/tree-sitter-javascript.cson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 943aca1b..cc87958a 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -42,12 +42,12 @@ folds: [ end: {index: -1, type: ')'} } { - type: 'switch_case' + type: ['switch_case', 'switch_default'] start: {index: 0} end: {type: 'break_statement', index: -1} } { - type: 'switch_case' + type: ['switch_case', 'switch_default'] start: {index: 0} } ] From d07be709933f131156fbf4308d5eb30cda6a578f Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 10 Apr 2019 16:12:13 -0600 Subject: [PATCH 389/420] Prepare 0.130.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3c09d48f..73d55a69 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.129.21", + "version": "0.130.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 7cbd956659520b3287764df4a06912ae497ecbcc Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 18 Jun 2019 16:46:56 -0700 Subject: [PATCH 390/420] :arrow_up: tree-sitter-{javascript,json,regex} --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 73d55a69..dce66c5d 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.13.10", - "tree-sitter-jsdoc": "^0.13.4", - "tree-sitter-regex": "^0.13.1" + "tree-sitter-javascript": "^0.15.0", + "tree-sitter-jsdoc": "^0.15.0", + "tree-sitter-regex": "^0.15.0" } } From 12b321be8fe054838a4e5130cd498aa8eeedb167 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 18 Jun 2019 16:47:09 -0700 Subject: [PATCH 391/420] Prepare 0.130.1 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dce66c5d..3647e288 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.130.0", + "version": "0.130.1", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 4076f4eb1e0c54834a87e429033d26171c596cf6 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 25 Jun 2019 16:09:44 +0200 Subject: [PATCH 392/420] Fix auto-indent when the previous line ends with a comment with a quote Co-Authored-By: Nathan Sobo --- settings/language-javascript.cson | 6 +++--- spec/javascript-spec.coffee | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/settings/language-javascript.cson b/settings/language-javascript.cson index f7bc48f6..37198cb0 100644 --- a/settings/language-javascript.cson +++ b/settings/language-javascript.cson @@ -4,9 +4,9 @@ 'commentStart': '// ' 'foldEndPattern': '^\\s*\\}|^\\s*\\]|^\\s*\\)' 'increaseIndentPattern': '(?x) - \\{ [^}"\']* $ - | \\[ [^\\]"\']* $ - | \\( [^)"\']* $ + \\{ [^}"\']*(//.*)? $ + | \\[ [^\\]"\']*(//.*)? $ + | \\( [^)"\']*(//.*)? $ ' 'decreaseIndentPattern': '(?x) ^ \\s* (\\s* /[*] .* [*]/ \\s*)* [}\\])] diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index ff099acb..0244ba55 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -2202,7 +2202,7 @@ describe "JavaScript grammar", -> it "indents non-allman-style curly braces", -> expectPreservedIndentation """ if (true) { - for (;;) { + for (;;) { // " while (true) { x(); } @@ -2226,7 +2226,7 @@ describe "JavaScript grammar", -> it "indents collection literals", -> expectPreservedIndentation """ - [ + [ // " { a: b, c: d @@ -2239,7 +2239,7 @@ describe "JavaScript grammar", -> it "indents function arguments", -> expectPreservedIndentation """ f( - g( + g( // " h, i ), From 5d677a20d23a6cdd0e9c7720bd4a26306b7d74ce Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 25 Jun 2019 16:52:30 +0200 Subject: [PATCH 393/420] Prepare 0.130.2 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3647e288..6ca9b05a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.130.1", + "version": "0.130.2", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 59c25d27a7ed53f086fe17eb84359fa8b01bf760 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 26 Jun 2019 14:33:10 -0600 Subject: [PATCH 394/420] Allow JS snippets to be used in Flow files Flow files are actually handled by `language-typescript`, but the JS snippets should all be applicable in that context. --- snippets/language-javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/language-javascript.cson b/snippets/language-javascript.cson index c8064854..0da1e337 100644 --- a/snippets/language-javascript.cson +++ b/snippets/language-javascript.cson @@ -1,4 +1,4 @@ -'.source.js': +'.source.js, .source.flow': 'Object Method': 'prefix': 'kf' 'body': '${1:methodName}: function (${2:attribute}) {\n\t$3\n}${4:,}' From 7bde3b12b8cc84661fcb6ab09ba693c2475b4d9c Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 26 Jun 2019 15:07:22 -0600 Subject: [PATCH 395/420] Prepare 0.131.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6ca9b05a..50ed1ee1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.130.2", + "version": "0.131.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From d66821651bd97279e03c4285269aea2f283a0017 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 26 Jun 2019 14:53:08 -0600 Subject: [PATCH 396/420] Prepare 0.132.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 50ed1ee1..7ee9f150 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.131.0", + "version": "0.132.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 45430f7367b89af535514b7d3466815e75827135 Mon Sep 17 00:00:00 2001 From: Caleb Evans Date: Tue, 16 Jul 2019 13:20:57 -0700 Subject: [PATCH 397/420] Restore colorization for function declaration names --- grammars/tree-sitter-javascript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index cc87958a..413deb92 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -97,6 +97,7 @@ scopes: 'call_expression > identifier': {match: '^[A-Z]', scopes: 'meta.class'} 'function > identifier': 'entity.name.function' + 'function_declaration > identifier': 'entity.name.function' 'generator_function > identifier': 'entity.name.function' 'call_expression > identifier': [ From 6371d90d25084eb67a26f135d548a528258359d1 Mon Sep 17 00:00:00 2001 From: Caleb Evans Date: Mon, 15 Jul 2019 18:50:48 -0700 Subject: [PATCH 398/420] Colorize arrow function parameters without parens --- grammars/tree-sitter-javascript.cson | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index cc87958a..48588bce 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -69,7 +69,7 @@ scopes: 'member_expression > property_identifier': 'variable.other.object.property.unquoted' - 'formal_parameters > identifier': 'formal-parameter.identifier' + 'formal_parameters > identifier': 'variable.parameter.function' 'shorthand_property_identifier': [ { @@ -95,6 +95,7 @@ scopes: ] 'call_expression > identifier': {match: '^[A-Z]', scopes: 'meta.class'} + 'arrow_function > identifier:nth-child(0)': 'variable.parameter.function' 'function > identifier': 'entity.name.function' 'generator_function > identifier': 'entity.name.function' From e74802362027c7cd62a66adbef58b0b1f5650491 Mon Sep 17 00:00:00 2001 From: Caleb Evans Date: Tue, 16 Jul 2019 19:20:21 -0700 Subject: [PATCH 399/420] Colorize rest parameters like other formal parameters --- grammars/tree-sitter-javascript.cson | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index cc87958a..6fb4146d 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -69,7 +69,8 @@ scopes: 'member_expression > property_identifier': 'variable.other.object.property.unquoted' - 'formal_parameters > identifier': 'formal-parameter.identifier' + 'formal_parameters > identifier': 'variable.parameter.function' + 'formal_parameters > rest_parameter > identifier': 'variable.parameter.function' 'shorthand_property_identifier': [ { From f1103e2e57b9d3d8fc0ddd3c70bb21323f10d21f Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Thu, 5 Sep 2019 11:14:37 -0400 Subject: [PATCH 400/420] Teach Tree-sitter grammar match TextMate scope used for rest params /xref https://github.com/atom/language-javascript/pull/654#issuecomment-522006555 --- grammars/tree-sitter-javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index 6fb4146d..9fb5d79e 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -70,7 +70,7 @@ scopes: 'member_expression > property_identifier': 'variable.other.object.property.unquoted' 'formal_parameters > identifier': 'variable.parameter.function' - 'formal_parameters > rest_parameter > identifier': 'variable.parameter.function' + 'formal_parameters > rest_parameter > identifier': 'variable.parameter.rest.function' 'shorthand_property_identifier': [ { From a37d7d231e44a247f4b75bd0cc2bc75c6e874796 Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Thu, 5 Sep 2019 11:30:35 -0400 Subject: [PATCH 401/420] Prepare v0.133.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7ee9f150..07ede25a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.132.0", + "version": "0.133.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 8513214d1c2046579152a95c411e4127f6939210 Mon Sep 17 00:00:00 2001 From: "Peder B. Sundt" Date: Thu, 31 Oct 2019 14:29:05 +0100 Subject: [PATCH 402/420] Add a 'forEach' snippet --- snippets/language-javascript.cson | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snippets/language-javascript.cson b/snippets/language-javascript.cson index 97820cc7..24fdbb61 100644 --- a/snippets/language-javascript.cson +++ b/snippets/language-javascript.cson @@ -35,6 +35,9 @@ 'for of': 'prefix': 'forof' 'body': 'for (var ${1:variable} of ${2:iterable}) {\n\t$3\n}' + 'forEach': + 'prefix' : 'foreach' + 'body' : 'forEach((${1:item}, ${2:i}) => {\n\t$3\n});\n' 'Function': 'prefix': 'fun' 'body': 'function ${1:functionName}($2) {\n\t$0\n}' From 2035549971a37f94c8ef5bc14daefc14c4bf9755 Mon Sep 17 00:00:00 2001 From: Darangi Date: Mon, 18 Nov 2019 14:45:49 +0100 Subject: [PATCH 403/420] Prepare v0.133.1 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 07ede25a..192529bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.133.0", + "version": "0.133.1", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 5233545511e59da3e90aa67fa9537d609f1f23c1 Mon Sep 17 00:00:00 2001 From: Mazen El-Kashef Date: Thu, 21 Nov 2019 10:37:57 -0500 Subject: [PATCH 404/420] Prepare v0.134.0 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 192529bf..7f80087d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.133.1", + "version": "0.134.0", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From f0e077cd3e1a946ddf4232deedb3b859fcea33c5 Mon Sep 17 00:00:00 2001 From: kenny Date: Sun, 1 Dec 2019 13:15:27 -0700 Subject: [PATCH 405/420] add cjs file extension to grammars cause node is kinda retarded, I have to use .cjs extensions, but atom doesn't recognise them as js language --- grammars/javascript.cson | 1 + 1 file changed, 1 insertion(+) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 3ec2e5ce..09b456cb 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -2,6 +2,7 @@ 'fileTypes': [ 'js' '_js' + 'cjs' 'es' 'es6' 'gs' From e5b67062d8f1cffe654c1c16ad632908d7628ef8 Mon Sep 17 00:00:00 2001 From: Darangi Date: Fri, 6 Dec 2019 18:31:51 +0100 Subject: [PATCH 406/420] :arrow_up:tree-sitter-javascript@0.15.2, :arrow_up:tree-sitter-jsdoc@0.15.2 and :arrow_up:tree-sitter-regex@0.15.1 --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7f80087d..064c761f 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.15.0", - "tree-sitter-jsdoc": "^0.15.0", - "tree-sitter-regex": "^0.15.0" + "tree-sitter-javascript": "^0.15.2", + "tree-sitter-jsdoc": "^0.15.2", + "tree-sitter-regex": "^0.15.1" } } From c3443f016c074c362d174cc50ee8ff26b8e36851 Mon Sep 17 00:00:00 2001 From: Darangi Date: Fri, 6 Dec 2019 18:32:07 +0100 Subject: [PATCH 407/420] Prepare v0.134.1 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 064c761f..62ca8ee8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.134.0", + "version": "0.134.1", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From d06e74f99222d40cd8957bd21fda03c051816ac6 Mon Sep 17 00:00:00 2001 From: aminya Date: Thu, 12 Nov 2020 07:35:08 -0600 Subject: [PATCH 408/420] GitHub Actions --- .github/workflows/ci.yml | 51 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 41 -------------------------------- README.md | 4 ++-- appveyor.yml | 31 ++++-------------------- 4 files changed, 57 insertions(+), 70 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..16f1825b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,51 @@ +name: ci +on: + - pull_request + - push + +jobs: + Test: + if: "!contains(github.event.head_commit.message, '[skip ci]')" + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + atom_channel: + - stable + - nightly + steps: + - uses: actions/checkout@v2 + - name: Cache + uses: actions/cache@v2 + with: + path: | + 'node_modules' + 'C:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/v140' + key: ${{ runner.os }}-${{ matrix.atom_channel }}-${{ hashFiles('package.json') }} + + - uses: UziTech/action-setup-atom@v1 + with: + channel: ${{ matrix.atom_channel }} + + - name: Install Visual Studio 2015 on Windows + if: ${{ contains(matrix.os, 'windows') }} + run: | + choco install visualcpp-build-tools --version=14.0.25420.1 --ignore-dependencies -y --params "'/IncludeRequired'" + echo ::set-env name=VCTargetsPath::'C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140' + + - name: Install dependencies + run: apm install + + - name: Run tests + run: apm test + + Skip: + if: contains(github.event.head_commit.message, '[skip ci]') + runs-on: ubuntu-latest + steps: + - name: Skip CI 🚫 + run: echo skip ci diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 47ee9a1a..00000000 --- a/.travis.yml +++ /dev/null @@ -1,41 +0,0 @@ -### Project specific config ### -language: generic - -env: - global: - - APM_TEST_PACKAGES="" - - ATOM_LINT_WITH_BUNDLED_NODE="true" - - matrix: - - ATOM_CHANNEL=stable - - ATOM_CHANNEL=beta - -### Generic setup follows ### -script: - - curl -s -O https://raw.githubusercontent.com/atom/ci/master/build-package.sh - - chmod u+x build-package.sh - - ./build-package.sh - -notifications: - email: - on_success: never - on_failure: change - -branches: - only: - - master - -git: - depth: 10 - -sudo: false - -dist: trusty - -addons: - apt: - packages: - - build-essential - - fakeroot - - git - - libsecret-1-dev diff --git a/README.md b/README.md index 42d9ef46..f91a7f57 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # JavaScript language support in Atom -[![macOS Build Status](https://travis-ci.org/atom/language-javascript.svg?branch=master)](https://travis-ci.org/atom/language-javascript) -[![Windows Build Status](https://ci.appveyor.com/api/projects/status/ktooccwna96ssiyr/branch/master?svg=true)](https://ci.appveyor.com/project/Atom/language-javascript-dijf8/branch/master) + +![ci](https://github.com/atom/language-javascript/workflows/ci/badge.svg) [![Dependency Status](https://david-dm.org/atom/language-javascript.svg)](https://david-dm.org/atom/language-javascript) Adds syntax highlighting and snippets for JavaScript in Atom. diff --git a/appveyor.yml b/appveyor.yml index 7d07d05d..795da41c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,29 +1,6 @@ -version: "{build}" - -image: Visual Studio 2015 - -platform: x64 +# empty appveyor +build: off branches: - only: - - master - -clone_depth: 10 - -skip_tags: true - -environment: - APM_TEST_PACKAGES: - - matrix: - - ATOM_CHANNEL: stable - - ATOM_CHANNEL: beta - -install: - - ps: Install-Product node 4 - -build_script: - - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/atom/ci/master/build-package.ps1')) - -test: off -deploy: off + only: + - non-existing From 2a6da6aa46e26e4a64283be3e42ee1fb022e9cb1 Mon Sep 17 00:00:00 2001 From: steven nguyen <58114641+icecream17@users.noreply.github.com> Date: Fri, 13 Nov 2020 08:02:28 -0600 Subject: [PATCH 409/420] Update tree-sitter-javascript.cson --- grammars/tree-sitter-javascript.cson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index a061c4d3..86919162 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -114,11 +114,11 @@ scopes: 'identifier': [ { - match: '^(global|module|exports|__filename|__dirname)$', + match: '^(global|globalThis|module|exports|__filename|__dirname)$', scopes: 'support.variable' }, { - match: '^(window|event|document|performance|screen|navigator|console)$' + match: '^(window|self|frames|event|document|performance|screen|navigator|console)$' scopes: 'support.variable.dom' }, { From 40a1be4a118e26ae164fb800f8f9e0a809bda585 Mon Sep 17 00:00:00 2001 From: steven nguyen <58114641+icecream17@users.noreply.github.com> Date: Fri, 13 Nov 2020 08:07:50 -0600 Subject: [PATCH 410/420] Update javascript.cson --- grammars/javascript.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 09b456cb..f5a76a94 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -997,7 +997,7 @@ } { 'match': '''(?x) (? Date: Fri, 13 Nov 2020 08:12:29 -0600 Subject: [PATCH 411/420] Update javascript.cson --- grammars/javascript.cson | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index f5a76a94..97ccdc68 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -997,7 +997,7 @@ } { 'match': '''(?x) (? Date: Fri, 20 Nov 2020 14:46:14 -0600 Subject: [PATCH 412/420] fix: add numeric separators --- grammars/javascript.cson | 67 +++++++++++++------- spec/javascript-spec.coffee | 119 ++++++++++++++++++++++++++++++++++++ 2 files changed, 165 insertions(+), 21 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 09b456cb..51a88018 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1245,45 +1245,70 @@ 'numbers': 'patterns': [ { - 'match': '\\b(? {tokens} = grammar.tokenizeLine('0X1D306n') expect(tokens[0]).toEqual value: '0X1D306n', scopes: ['source.js', 'constant.numeric.hex.js'] + {tokens} = grammar.tokenizeLine('0X1D30_69A3') + expect(tokens[0]).toEqual value: '0X1D30', scopes: ['source.js', 'constant.numeric.hex.js'] + expect(tokens[1]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.hex.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[2]).toEqual value: '69A3', scopes: ['source.js', 'constant.numeric.hex.js'] + it "tokenizes binary literals", -> {tokens} = grammar.tokenizeLine('0b011101110111010001100110') expect(tokens[0]).toEqual value: '0b011101110111010001100110', scopes: ['source.js', 'constant.numeric.binary.js'] @@ -336,6 +341,19 @@ describe "JavaScript grammar", -> {tokens} = grammar.tokenizeLine('0B011101110111010001100110n') expect(tokens[0]).toEqual value: '0B011101110111010001100110n', scopes: ['source.js', 'constant.numeric.binary.js'] + {tokens} = grammar.tokenizeLine('0B0111_0111_0111_0100_0110_0110') + expect(tokens[0]).toEqual value: '0B0111', scopes: ['source.js', 'constant.numeric.binary.js'] + expect(tokens[1]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.binary.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[2]).toEqual value: '0111', scopes: ['source.js', 'constant.numeric.binary.js'] + expect(tokens[3]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.binary.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[4]).toEqual value: '0111', scopes: ['source.js', 'constant.numeric.binary.js'] + expect(tokens[5]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.binary.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[6]).toEqual value: '0100', scopes: ['source.js', 'constant.numeric.binary.js'] + expect(tokens[7]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.binary.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[8]).toEqual value: '0110', scopes: ['source.js', 'constant.numeric.binary.js'] + expect(tokens[9]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.binary.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[10]).toEqual value: '0110', scopes: ['source.js', 'constant.numeric.binary.js'] + it "tokenizes octal literals", -> {tokens} = grammar.tokenizeLine('0o1411') expect(tokens[0]).toEqual value: '0o1411', scopes: ['source.js', 'constant.numeric.octal.js'] @@ -352,6 +370,18 @@ describe "JavaScript grammar", -> {tokens} = grammar.tokenizeLine('0010') expect(tokens[0]).toEqual value: '0010', scopes: ['source.js', 'constant.numeric.octal.js'] + {tokens} = grammar.tokenizeLine('0010_7201_5112') + expect(tokens[0]).toEqual value: '0010', scopes: ['source.js', 'constant.numeric.octal.js'] + expect(tokens[1]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.octal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[2]).toEqual value: '7201', scopes: ['source.js', 'constant.numeric.octal.js'] + expect(tokens[3]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.octal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[4]).toEqual value: '5112', scopes: ['source.js', 'constant.numeric.octal.js'] + + {tokens} = grammar.tokenizeLine('0O1411_1236') + expect(tokens[0]).toEqual value: '0O1411', scopes: ['source.js', 'constant.numeric.octal.js'] + expect(tokens[1]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.octal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[2]).toEqual value: '1236', scopes: ['source.js', 'constant.numeric.octal.js'] + it "tokenizes decimals", -> {tokens} = grammar.tokenizeLine('1234') expect(tokens[0]).toEqual value: '1234', scopes: ['source.js', 'constant.numeric.decimal.js'] @@ -359,6 +389,13 @@ describe "JavaScript grammar", -> {tokens} = grammar.tokenizeLine('123456789n') expect(tokens[0]).toEqual value: '123456789n', scopes: ['source.js', 'constant.numeric.decimal.js'] + {tokens} = grammar.tokenizeLine('123_456_789n') + expect(tokens[0]).toEqual value: '123', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[1]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[2]).toEqual value: '456', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[3]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[4]).toEqual value: '789n', scopes: ['source.js', 'constant.numeric.decimal.js'] + {tokens} = grammar.tokenizeLine('5e-10') expect(tokens[0]).toEqual value: '5e-10', scopes: ['source.js', 'constant.numeric.decimal.js'] @@ -369,24 +406,92 @@ describe "JavaScript grammar", -> expect(tokens[0]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.decimal.period.js'] + {tokens} = grammar.tokenizeLine('9_9.') + expect(tokens[0]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[1]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[2]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[3]).toEqual value: '.', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.decimal.period.js'] + {tokens} = grammar.tokenizeLine('.9') expect(tokens[0]).toEqual value: '.', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.decimal.period.js'] expect(tokens[1]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] + {tokens} = grammar.tokenizeLine('.9_9') + expect(tokens[0]).toEqual value: '.', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.decimal.period.js'] + expect(tokens[1]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[2]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[3]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] + {tokens} = grammar.tokenizeLine('9.9') expect(tokens[0]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.decimal.period.js'] expect(tokens[2]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] + {tokens} = grammar.tokenizeLine('9_9.9_9') + expect(tokens[0]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[1]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[2]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[3]).toEqual value: '.', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.decimal.period.js'] + expect(tokens[4]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[5]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[6]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] + {tokens} = grammar.tokenizeLine('.1e-23') expect(tokens[0]).toEqual value: '.', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.decimal.period.js'] expect(tokens[1]).toEqual value: '1e-23', scopes: ['source.js', 'constant.numeric.decimal.js'] + {tokens} = grammar.tokenizeLine('.1_1E+1_1') + expect(tokens[0]).toEqual value: '.', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.decimal.period.js'] + expect(tokens[1]).toEqual value: '1', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[2]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[3]).toEqual value: '1E+1', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[4]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[5]).toEqual value: '1', scopes: ['source.js', 'constant.numeric.decimal.js'] + {tokens} = grammar.tokenizeLine('1.E3') expect(tokens[0]).toEqual value: '1', scopes: ['source.js', 'constant.numeric.decimal.js'] expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.decimal.period.js'] expect(tokens[2]).toEqual value: 'E3', scopes: ['source.js', 'constant.numeric.decimal.js'] + {tokens} = grammar.tokenizeLine('1_1.E-1_1') + expect(tokens[0]).toEqual value: '1', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[1]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[2]).toEqual value: '1', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[3]).toEqual value: '.', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.decimal.period.js'] + expect(tokens[4]).toEqual value: 'E-1', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[5]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[6]).toEqual value: '1', scopes: ['source.js', 'constant.numeric.decimal.js'] + + {tokens} = grammar.tokenizeLine('1_1.1_1E1_1') + expect(tokens[0]).toEqual value: '1', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[1]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[2]).toEqual value: '1', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[3]).toEqual value: '.', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.decimal.period.js'] + expect(tokens[4]).toEqual value: '1', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[5]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[6]).toEqual value: '1E1', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[7]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[8]).toEqual value: '1', scopes: ['source.js', 'constant.numeric.decimal.js'] + + {tokens} = grammar.tokenizeLine('9_9') + expect(tokens[0]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[1]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[2]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] + + {tokens} = grammar.tokenizeLine('9_9_9') + expect(tokens[0]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[1]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[2]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[3]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[4]).toEqual value: '9', scopes: ['source.js', 'constant.numeric.decimal.js'] + + {tokens} = grammar.tokenizeLine('999_999_999') + expect(tokens[0]).toEqual value: '999', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[1]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[2]).toEqual value: '999', scopes: ['source.js', 'constant.numeric.decimal.js'] + expect(tokens[3]).toEqual value: '_', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.numeric.separator.js'] + expect(tokens[4]).toEqual value: '999', scopes: ['source.js', 'constant.numeric.decimal.js'] + it "does not tokenize numbers that are part of a variable", -> {tokens} = grammar.tokenizeLine('hi$1') expect(tokens[0]).toEqual value: 'hi$1', scopes: ['source.js'] @@ -394,6 +499,20 @@ describe "JavaScript grammar", -> {tokens} = grammar.tokenizeLine('hi_1') expect(tokens[0]).toEqual value: 'hi_1', scopes: ['source.js'] + {tokens} = grammar.tokenizeLine('_1') + expect(tokens[0]).toEqual value: '_1', scopes: ['source.js', 'constant.other.js'] + + {tokens} = grammar.tokenizeLine('1_') + expect(tokens[0]).toEqual value: '1_', scopes: ['source.js', 'invalid.illegal.identifier.js'] + + {tokens} = grammar.tokenizeLine('1_._1') + expect(tokens[0]).toEqual value: '1_', scopes: ['source.js', 'invalid.illegal.identifier.js'] + expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'meta.delimiter.property.period.js'] + expect(tokens[2]).toEqual value: '_1', scopes: ['source.js', 'variable.other.property.js'] + + {tokens} = grammar.tokenizeLine('1__1') + expect(tokens[0]).toEqual value: '1__1', scopes: ['source.js', 'invalid.illegal.identifier.js'] + describe "operators", -> it "tokenizes them", -> operators = ["delete", "in", "of", "instanceof", "new", "typeof", "void"] From 4f2d5c76ca4b8076cfb4ec250ce8f40f2ba19e53 Mon Sep 17 00:00:00 2001 From: aminya Date: Wed, 28 Oct 2020 21:17:53 -0500 Subject: [PATCH 413/420] :arrow_up: update tree-sitter packages to 0.16.0 --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 62ca8ee8..081b8b7b 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.15.2", - "tree-sitter-jsdoc": "^0.15.2", - "tree-sitter-regex": "^0.15.1" + "tree-sitter-javascript": "^0.16.0", + "tree-sitter-jsdoc": "^0.16.0", + "tree-sitter-regex": "^0.16.0" } } From 3b60b4d22b51c84d1b26e8af0b65bfcd0a6ea3d1 Mon Sep 17 00:00:00 2001 From: steven nguyen Date: Sun, 28 Mar 2021 11:54:49 -0500 Subject: [PATCH 414/420] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20update=20tree-sitt?= =?UTF-8?q?er=20packages=20to=200.19.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit My operators pr is almost not blocked now! --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 081b8b7b..36b7f799 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.16.0", - "tree-sitter-jsdoc": "^0.16.0", - "tree-sitter-regex": "^0.16.0" + "tree-sitter-javascript": "^0.19.0", + "tree-sitter-jsdoc": "^0.19.0", + "tree-sitter-regex": "^0.19.0" } } From 7a9e1ad6ff6682ea0e216ad3b513c7f3d474e3a3 Mon Sep 17 00:00:00 2001 From: steven nguyen Date: Thu, 2 Sep 2021 20:51:26 -0500 Subject: [PATCH 415/420] Remove windows-build installation step Based off https://github.com/atom/github/commit/9207c7b2a793327ae26b71f50fde4e63c50e9c5f --- .github/workflows/ci.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16f1825b..432a2dce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,12 +31,6 @@ jobs: with: channel: ${{ matrix.atom_channel }} - - name: Install Visual Studio 2015 on Windows - if: ${{ contains(matrix.os, 'windows') }} - run: | - choco install visualcpp-build-tools --version=14.0.25420.1 --ignore-dependencies -y --params "'/IncludeRequired'" - echo ::set-env name=VCTargetsPath::'C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140' - - name: Install dependencies run: apm install From d1cc4e85fb8a30b48f3b79eeb9635c2ca682a5f4 Mon Sep 17 00:00:00 2001 From: sadick254 Date: Mon, 4 Oct 2021 21:09:02 +0300 Subject: [PATCH 416/420] Install the exact version instead of range ^version means install any version that is compatible with the range. This means npm can even install tree-sitter-javascript version 0.15 since in semver 0.15 should be compatible with 0.19. tree-sitter seems to have broken semver. 0.15 is not compatible with 0.19 --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 36b7f799..d466261b 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "coffeelint": "^1.10.1" }, "dependencies": { - "tree-sitter-javascript": "^0.19.0", - "tree-sitter-jsdoc": "^0.19.0", - "tree-sitter-regex": "^0.19.0" + "tree-sitter-javascript": "0.19.0", + "tree-sitter-jsdoc": "0.19.0", + "tree-sitter-regex": "0.19.0" } } From 7473342eef0d44597faeab0f1c6c1dc02120ceff Mon Sep 17 00:00:00 2001 From: sadick254 Date: Mon, 4 Oct 2021 21:19:22 +0300 Subject: [PATCH 417/420] Remove windows build tools --- .github/workflows/ci.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16f1825b..432a2dce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,12 +31,6 @@ jobs: with: channel: ${{ matrix.atom_channel }} - - name: Install Visual Studio 2015 on Windows - if: ${{ contains(matrix.os, 'windows') }} - run: | - choco install visualcpp-build-tools --version=14.0.25420.1 --ignore-dependencies -y --params "'/IncludeRequired'" - echo ::set-env name=VCTargetsPath::'C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140' - - name: Install dependencies run: apm install From 72c8b9d06eb00e549d7f2b1677f0174603f5abce Mon Sep 17 00:00:00 2001 From: sadick254 Date: Mon, 4 Oct 2021 21:29:51 +0300 Subject: [PATCH 418/420] Prepare v0.134.2 release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d466261b..e20d5484 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "language-javascript", - "version": "0.134.1", + "version": "0.134.2", "description": "JavaScript language support in Atom", "engines": { "atom": "*", From 5c5b74962d938f380485745cd93f525a185dfb2c Mon Sep 17 00:00:00 2001 From: steven nguyen Date: Mon, 25 Oct 2021 13:27:00 -0500 Subject: [PATCH 419/420] Fix #697 This is a copy of #698, but remade so that there's only 1 commit and so that the tests are reflected as passing. --- grammars/javascript.cson | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 7f947188..62011cef 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -973,10 +973,10 @@ } { 'match': '''(?x) (? Date: Wed, 28 Sep 2022 11:52:01 +0100 Subject: [PATCH 420/420] add sunset message --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f91a7f57..d80d4475 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# JavaScript language support in Atom +##### Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our [official announcement](https://github.blog/2022-06-08-sunsetting-atom/) + # JavaScript language support in Atom ![ci](https://github.com/atom/language-javascript/workflows/ci/badge.svg) [![Dependency Status](https://david-dm.org/atom/language-javascript.svg)](https://david-dm.org/atom/language-javascript)