Skip to content

Commit a6ea497

Browse files
Classify the '=' sign in variable/parameter/property as if it was an operator.
1 parent 48bef46 commit a6ea497

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/services/services.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4985,10 +4985,17 @@ module ts {
49854985
}
49864986

49874987
if (isPunctuation(tokenKind)) {
4988-
// the '=' in a variable declaration is special cased here.
49894988
if (token) {
4989+
if (tokenKind === SyntaxKind.EqualsToken) {
4990+
// the '=' in a variable declaration is special cased here.
4991+
if (token.parent.kind === SyntaxKind.VariableDeclaration ||
4992+
token.parent.kind === SyntaxKind.PropertyDeclaration ||
4993+
token.parent.kind === SyntaxKind.Parameter) {
4994+
return ClassificationTypeNames.operator;
4995+
}
4996+
}
4997+
49904998
if (token.parent.kind === SyntaxKind.BinaryExpression ||
4991-
token.parent.kind === SyntaxKind.VariableDeclaration ||
49924999
token.parent.kind === SyntaxKind.PrefixUnaryExpression ||
49935000
token.parent.kind === SyntaxKind.PostfixUnaryExpression ||
49945001
token.parent.kind === SyntaxKind.ConditionalExpression) {

tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var c = classification;
1212
verify.syntacticClassificationsAre(
1313
c.keyword("class"), c.className("C"), c.punctuation("{"),
1414
c.comment("<<<<<<< HEAD"),
15-
c.text("v"), c.punctuation("="), c.numericLiteral("1"), c.punctuation(";"),
15+
c.text("v"), c.operator("="), c.numericLiteral("1"), c.punctuation(";"),
1616
c.comment("======="),
1717
c.text("v"), c.punctuation("="), c.numericLiteral("2"), c.punctuation(";"),
1818
c.comment(">>>>>>> Branch - a"),

0 commit comments

Comments
 (0)