Pull out object literal method separately so that constructor and new syntax doesnt play into it.
Fixes #361
This commit is contained in:
Родитель
ea59fd12e8
Коммит
1e6da3079b
|
@ -603,7 +603,34 @@ repository:
|
|||
match: '[_$[:alpha:]][_$[:alnum:]]*'
|
||||
- name: keyword.operator.optional.ts
|
||||
match: \?
|
||||
|
||||
|
||||
object-literal-method-declaration:
|
||||
name: meta.method.declaration.ts
|
||||
begin: (?<!\.|\$)(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]+\])+\]))\s*(\??))?\s*[\(\<])
|
||||
beginCaptures:
|
||||
'1': { name: storage.modifier.async.ts } # captures keyword (async)
|
||||
'2': { name: storage.type.property.ts } # captures keyword (get|set)
|
||||
'3': { name: keyword.generator.asterisk.ts } # captures keyword (*)
|
||||
end: '(?=\}|;|,)|(?<=\})'
|
||||
patterns:
|
||||
- include: '#method-declaration-name'
|
||||
- include: '#comment'
|
||||
- include: '#type-parameters'
|
||||
- include: '#function-parameters'
|
||||
- include: '#return-type'
|
||||
- include: '#method-overload-declaration'
|
||||
- include: '#decl-block'
|
||||
|
||||
object-literal-method-overload-declaration:
|
||||
begin: (?<!\.|\$)(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]+\])+\]))\s*(\??))?\s*[\(\<])
|
||||
beginCaptures:
|
||||
'1': { name: storage.modifier.async.ts } # captures keyword (async)
|
||||
'2': { name: storage.type.property.ts } # captures keyword (get|set)
|
||||
'3': { name: keyword.generator.asterisk.ts } # captures keyword (*)
|
||||
end: (?=\(|\<)
|
||||
patterns:
|
||||
- include: '#method-declaration-name'
|
||||
|
||||
indexer-declaration:
|
||||
name: meta.indexer.declaration.ts
|
||||
begin: (?:(?<!\.|\$)\b(readonly)\s*)?(\[)\s*([_$[:alpha:]][_$[:alnum:]]*)\s*(?=:)
|
||||
|
@ -1432,7 +1459,7 @@ repository:
|
|||
object-member:
|
||||
patterns:
|
||||
- include: '#comment'
|
||||
- include: '#method-declaration'
|
||||
- include: '#object-literal-method-declaration'
|
||||
- name: meta.object.member.ts
|
||||
begin: (?=(?:(?:\'[^']*\')|(?:\"[^"]*\")|(?:\[([^\[\]]|\[[^\[\]]+\])+\]))\s*:)
|
||||
end: (?=,|\})
|
||||
|
|
|
@ -1861,6 +1861,96 @@
|
|||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>object-literal-method-declaration</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.method.declaration.ts</string>
|
||||
<key>begin</key>
|
||||
<string>(?<!\.|\$)(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]+\])+\]))\s*(\??))?\s*[\(\<])</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.modifier.async.ts</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.type.property.ts</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.generator.asterisk.ts</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>(?=\}|;|,)|(?<=\})</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#method-declaration-name</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#comment</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#type-parameters</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#function-parameters</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#return-type</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#method-overload-declaration</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#decl-block</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>object-literal-method-overload-declaration</key>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>(?<!\.|\$)(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]+\])+\]))\s*(\??))?\s*[\(\<])</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.modifier.async.ts</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.type.property.ts</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.generator.asterisk.ts</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>(?=\(|\<)</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#method-declaration-name</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>indexer-declaration</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
|
@ -3889,7 +3979,7 @@
|
|||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#method-declaration</string>
|
||||
<string>#object-literal-method-declaration</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
|
|
|
@ -1865,6 +1865,96 @@
|
|||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>object-literal-method-declaration</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>meta.method.declaration.tsx</string>
|
||||
<key>begin</key>
|
||||
<string>(?<!\.|\$)(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]+\])+\]))\s*(\??))?\s*[\(\<])</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.modifier.async.tsx</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.type.property.tsx</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.generator.asterisk.tsx</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>(?=\}|;|,)|(?<=\})</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#method-declaration-name</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#comment</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#type-parameters</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#function-parameters</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#return-type</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#method-overload-declaration</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#decl-block</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>object-literal-method-overload-declaration</key>
|
||||
<dict>
|
||||
<key>begin</key>
|
||||
<string>(?<!\.|\$)(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]+\])+\]))\s*(\??))?\s*[\(\<])</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.modifier.async.tsx</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.type.property.tsx</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.generator.asterisk.tsx</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>(?=\(|\<)</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#method-declaration-name</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>indexer-declaration</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
|
@ -3871,7 +3961,7 @@
|
|||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#method-declaration</string>
|
||||
<string>#object-literal-method-declaration</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
original file
|
||||
-----------------------------------
|
||||
const constructor = someObject.prototype.constructor;
|
||||
const objectLiteral = { constructor };
|
||||
-----------------------------------
|
||||
|
||||
Grammar: TypeScript.tmLanguage
|
||||
-----------------------------------
|
||||
>const constructor = someObject.prototype.constructor;
|
||||
^^^^^
|
||||
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 support.class.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts punctuation.accessor.ts
|
||||
^^^^^^^^^
|
||||
source.ts meta.var.expr.ts support.variable.property.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts punctuation.accessor.ts
|
||||
^^^^^^^^^^^
|
||||
source.ts meta.var.expr.ts support.variable.property.ts
|
||||
^
|
||||
source.ts punctuation.terminator.statement.ts
|
||||
^^
|
||||
source.ts
|
||||
> const objectLiteral = { constructor };
|
||||
^
|
||||
source.ts
|
||||
^^^^^
|
||||
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
|
||||
^^^^^^^^^^^
|
||||
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts variable.other.readwrite.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.objectliteral.ts punctuation.definition.block.ts
|
||||
^
|
||||
source.ts punctuation.terminator.statement.ts
|
|
@ -0,0 +1,2 @@
|
|||
const constructor = someObject.prototype.constructor;
|
||||
const objectLiteral = { constructor };
|
Загрузка…
Ссылка в новой задаче