Correctly parse expression after typeof operator
Adds support for typeof class as part of microsoft/TypeScript#41587
This commit is contained in:
Родитель
968be2a8f1
Коммит
400612015b
|
@ -1726,8 +1726,12 @@ repository:
|
|||
'1': { name: keyword.operator.arithmetic.ts }
|
||||
|
||||
typeof-operator:
|
||||
name: keyword.operator.expression.typeof.ts
|
||||
match: '{{startOfIdentifier}}typeof{{endOfIdentifier}}'
|
||||
begin: '{{startOfIdentifier}}typeof{{endOfIdentifier}}'
|
||||
beginCaptures:
|
||||
'0': { name: keyword.operator.expression.typeof.ts }
|
||||
end: (?=[,);}\]=]|$|{{endOfStatement}})
|
||||
patterns:
|
||||
- include: '#expression'
|
||||
|
||||
#literals
|
||||
literal:
|
||||
|
|
|
@ -5592,10 +5592,25 @@
|
|||
</dict>
|
||||
<key>typeof-operator</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.expression.typeof.ts</string>
|
||||
<key>match</key>
|
||||
<key>begin</key>
|
||||
<string>(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))typeof(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.expression.typeof.ts</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>(?=[,);}\]=]|$|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#expression</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>literal</key>
|
||||
<dict>
|
||||
|
|
|
@ -5538,10 +5538,25 @@
|
|||
</dict>
|
||||
<key>typeof-operator</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.expression.typeof.tsx</string>
|
||||
<key>match</key>
|
||||
<key>begin</key>
|
||||
<string>(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))typeof(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))</string>
|
||||
<key>beginCaptures</key>
|
||||
<dict>
|
||||
<key>0</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.expression.typeof.tsx</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>end</key>
|
||||
<string>(?=[,);}\]=]|$|;|(?:^\s*(?:abstract|async|class|const|declare|enum|export|function|import|interface|let|module|namespace|return|type|var)\b))</string>
|
||||
<key>patterns</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#expression</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<key>literal</key>
|
||||
<dict>
|
||||
|
|
|
@ -470,7 +470,7 @@ Grammar: TypeScript.tmLanguage
|
|||
^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts entity.name.type.ts
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts variable.other.constant.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
|
||||
^
|
||||
|
|
|
@ -92,7 +92,7 @@ Grammar: TypeScript.tmLanguage
|
|||
^
|
||||
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.type.parameters.ts
|
||||
^^^^^^^
|
||||
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.type.parameters.ts entity.name.type.ts
|
||||
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.type.parameters.ts variable.other.readwrite.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.objectliteral.ts meta.object.member.ts meta.type.parameters.ts punctuation.separator.comma.ts
|
||||
^
|
||||
|
|
|
@ -305,4 +305,4 @@ Grammar: TypeScript.tmLanguage
|
|||
^
|
||||
source.ts meta.type.declaration.ts
|
||||
^^^^^^
|
||||
source.ts meta.type.declaration.ts entity.name.type.ts
|
||||
source.ts meta.type.declaration.ts variable.other.readwrite.ts
|
|
@ -259,17 +259,17 @@ Grammar: TypeScript.tmLanguage
|
|||
^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts keyword.operator.expression.import.ts
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts meta.function-call.ts keyword.operator.expression.import.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.brace.round.ts
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts meta.brace.round.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts meta.type.paren.cover.ts string.quoted.double.ts punctuation.definition.string.begin.ts
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts string.quoted.double.ts punctuation.definition.string.begin.ts
|
||||
^^^^^^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts meta.type.paren.cover.ts string.quoted.double.ts
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts string.quoted.double.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts meta.type.paren.cover.ts string.quoted.double.ts punctuation.definition.string.end.ts
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts string.quoted.double.ts punctuation.definition.string.end.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts meta.type.paren.cover.ts meta.brace.round.ts
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts meta.brace.round.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
|
||||
^
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
original file
|
||||
-----------------------------------
|
||||
type TC1 = typeof class {
|
||||
constructor(s: string);
|
||||
static n: number;
|
||||
s: string;
|
||||
};
|
||||
-----------------------------------
|
||||
|
||||
Grammar: TypeScript.tmLanguage
|
||||
-----------------------------------
|
||||
>type TC1 = typeof class {
|
||||
^^^^
|
||||
source.ts meta.type.declaration.ts storage.type.type.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts
|
||||
^^^
|
||||
source.ts meta.type.declaration.ts entity.name.type.alias.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts keyword.operator.assignment.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts
|
||||
^^^^^^
|
||||
source.ts meta.type.declaration.ts keyword.operator.expression.typeof.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts
|
||||
^^^^^
|
||||
source.ts meta.type.declaration.ts meta.class.ts storage.type.class.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts punctuation.definition.block.ts
|
||||
> constructor(s: string);
|
||||
^^^^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.method.declaration.ts
|
||||
^^^^^^^^^^^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.method.declaration.ts storage.type.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts variable.parameter.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts meta.type.annotation.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts punctuation.definition.parameters.end.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts punctuation.terminator.statement.ts
|
||||
> static n: number;
|
||||
^^^^
|
||||
source.ts meta.type.declaration.ts meta.class.ts
|
||||
^^^^^^
|
||||
source.ts meta.type.declaration.ts meta.class.ts storage.modifier.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.field.declaration.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.field.declaration.ts meta.definition.property.ts variable.object.property.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.field.declaration.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.field.declaration.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.field.declaration.ts meta.type.annotation.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts punctuation.terminator.statement.ts
|
||||
> s: string;
|
||||
^^^^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.field.declaration.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.field.declaration.ts meta.definition.property.ts variable.object.property.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.field.declaration.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.field.declaration.ts meta.type.annotation.ts
|
||||
^^^^^^
|
||||
source.ts meta.type.declaration.ts meta.class.ts meta.field.declaration.ts meta.type.annotation.ts support.type.primitive.ts
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts punctuation.terminator.statement.ts
|
||||
>};
|
||||
^
|
||||
source.ts meta.type.declaration.ts meta.class.ts punctuation.definition.block.ts
|
||||
^
|
||||
source.ts punctuation.terminator.statement.ts
|
|
@ -0,0 +1,5 @@
|
|||
type TC1 = typeof class {
|
||||
constructor(s: string);
|
||||
static n: number;
|
||||
s: string;
|
||||
};
|
Загрузка…
Ссылка в новой задаче