Handle multiline computed or string literal name methods

Fixes #571
This commit is contained in:
Sheetal Nandi 2018-03-02 12:31:00 -08:00
Родитель e8d2994e04
Коммит 7ad6fafff9
5 изменённых файлов: 201 добавлений и 6 удалений

Просмотреть файл

@ -1005,14 +1005,19 @@ repository:
- include: '#object-literal-method-declaration'
- name: meta.object.member.ts meta.object-literal.key.ts
begin: (?=\[)
end: (?=:)
end: (?=:)|((?<=[\]])(?=\s*[\(\<]))
patterns:
- include: '#array-literal'
- name: meta.object.member.ts meta.object-literal.key.ts
begin: (?=[\'\"])
end: (?=:)
end: (?=:)|((?<=[\'\"])(?=\s*[\(\<]))
patterns:
- include: '#string'
- name: meta.method.declaration.ts
begin: (?<=[\]\'\"])(?=\s*[\(\<])
end: (?=\}|;|,)|(?<=\})
patterns:
- include: '#function-body'
- name: meta.object.member.ts
match: (?![_$[:alpha:]])([[:digit:]]+)\s*(?=:)
captures:

Просмотреть файл

@ -3142,7 +3142,7 @@
<key>begin</key>
<string>(?=\[)</string>
<key>end</key>
<string>(?=:)</string>
<string>(?=:)|((?&lt;=[\]])(?=\s*[\(\&lt;]))</string>
<key>patterns</key>
<array>
<dict>
@ -3157,7 +3157,7 @@
<key>begin</key>
<string>(?=[\'\"])</string>
<key>end</key>
<string>(?=:)</string>
<string>(?=:)|((?&lt;=[\'\"])(?=\s*[\(\&lt;]))</string>
<key>patterns</key>
<array>
<dict>
@ -3166,6 +3166,21 @@
</dict>
</array>
</dict>
<dict>
<key>name</key>
<string>meta.method.declaration.ts</string>
<key>begin</key>
<string>(?&lt;=[\]\'\"])(?=\s*[\(\&lt;])</string>
<key>end</key>
<string>(?=\}|;|,)|(?&lt;=\})</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#function-body</string>
</dict>
</array>
</dict>
<dict>
<key>name</key>
<string>meta.object.member.ts</string>

Просмотреть файл

@ -3146,7 +3146,7 @@
<key>begin</key>
<string>(?=\[)</string>
<key>end</key>
<string>(?=:)</string>
<string>(?=:)|((?&lt;=[\]])(?=\s*[\(\&lt;]))</string>
<key>patterns</key>
<array>
<dict>
@ -3161,7 +3161,7 @@
<key>begin</key>
<string>(?=[\'\"])</string>
<key>end</key>
<string>(?=:)</string>
<string>(?=:)|((?&lt;=[\'\"])(?=\s*[\(\&lt;]))</string>
<key>patterns</key>
<array>
<dict>
@ -3170,6 +3170,21 @@
</dict>
</array>
</dict>
<dict>
<key>name</key>
<string>meta.method.declaration.tsx</string>
<key>begin</key>
<string>(?&lt;=[\]\'\"])(?=\s*[\(\&lt;])</string>
<key>end</key>
<string>(?=\}|;|,)|(?&lt;=\})</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#function-body</string>
</dict>
</array>
</dict>
<dict>
<key>name</key>
<string>meta.object.member.tsx</string>

Просмотреть файл

@ -0,0 +1,150 @@
original file
-----------------------------------
const o = {
["a" +
"b"]() {
return 0; // no highlighting!
},
'a\
'() {
return 0; // no highlighting!
}
};
-----------------------------------
Grammar: TypeScript.tmLanguage
-----------------------------------
>const o = {
^^^^^
source.ts meta.var.expr.ts storage.type.ts
^
source.ts meta.var.expr.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.readwrite.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
^
source.ts meta.var.expr.ts keyword.operator.assignment.ts
^
source.ts meta.var.expr.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts punctuation.definition.block.ts
^^
source.ts meta.var.expr.ts meta.objectliteral.ts
> ["a" +
^
source.ts meta.var.expr.ts meta.objectliteral.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts meta.array.literal.ts meta.brace.square.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts meta.array.literal.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts meta.array.literal.ts string.quoted.double.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts meta.array.literal.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts meta.array.literal.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts meta.array.literal.ts keyword.operator.arithmetic.ts
^^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts meta.array.literal.ts
> "b"]() {
^^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts meta.array.literal.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts meta.array.literal.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts meta.array.literal.ts string.quoted.double.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts meta.array.literal.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts meta.array.literal.ts meta.brace.square.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts
> return 0; // no highlighting!
^^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts
^^^^^^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts keyword.control.flow.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts constant.numeric.decimal.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts punctuation.terminator.statement.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts
^^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts comment.line.double-slash.ts
> },
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts punctuation.definition.block.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts punctuation.separator.comma.ts
^^
source.ts meta.var.expr.ts meta.objectliteral.ts
> 'a\
^
source.ts meta.var.expr.ts meta.objectliteral.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts string.quoted.single.ts punctuation.definition.string.begin.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts string.quoted.single.ts
^^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts string.quoted.single.ts constant.character.escape.ts
> '() {
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts string.quoted.single.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.object-literal.key.ts string.quoted.single.ts punctuation.definition.string.end.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts
> return 0; // no highlighting!
^^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts
^^^^^^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts keyword.control.flow.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts constant.numeric.decimal.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts punctuation.terminator.statement.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts
^^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts comment.line.double-slash.ts punctuation.definition.comment.ts
^^^^^^^^^^^^^^^^^^^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts comment.line.double-slash.ts
> }
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts
^
source.ts meta.var.expr.ts meta.objectliteral.ts meta.method.declaration.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts meta.var.expr.ts meta.objectliteral.ts
>};
^
source.ts meta.var.expr.ts meta.objectliteral.ts punctuation.definition.block.ts
^
source.ts punctuation.terminator.statement.ts

10
tests/cases/Issue571.ts Normal file
Просмотреть файл

@ -0,0 +1,10 @@
const o = {
["a" +
"b"]() {
return 0; // no highlighting!
},
'a\
'() {
return 0; // no highlighting!
}
};