From a6ea497ff1f15645ff0ebe199fcd93065aa7a739 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 18 Dec 2014 19:38:19 -0800 Subject: [PATCH] Classify the '=' sign in variable/parameter/property as if it was an operator. --- src/services/services.ts | 11 +++++++++-- .../syntacticClassificationsConflictMarkers1.ts | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 83a00d2dea0..e6d4d3c9b37 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4985,10 +4985,17 @@ module ts { } if (isPunctuation(tokenKind)) { - // the '=' in a variable declaration is special cased here. if (token) { + if (tokenKind === SyntaxKind.EqualsToken) { + // the '=' in a variable declaration is special cased here. + if (token.parent.kind === SyntaxKind.VariableDeclaration || + token.parent.kind === SyntaxKind.PropertyDeclaration || + token.parent.kind === SyntaxKind.Parameter) { + return ClassificationTypeNames.operator; + } + } + if (token.parent.kind === SyntaxKind.BinaryExpression || - token.parent.kind === SyntaxKind.VariableDeclaration || token.parent.kind === SyntaxKind.PrefixUnaryExpression || token.parent.kind === SyntaxKind.PostfixUnaryExpression || token.parent.kind === SyntaxKind.ConditionalExpression) { diff --git a/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts b/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts index 15309d1431e..e381856c41e 100644 --- a/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts +++ b/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts @@ -12,7 +12,7 @@ var c = classification; verify.syntacticClassificationsAre( c.keyword("class"), c.className("C"), c.punctuation("{"), c.comment("<<<<<<< HEAD"), - c.text("v"), c.punctuation("="), c.numericLiteral("1"), c.punctuation(";"), + c.text("v"), c.operator("="), c.numericLiteral("1"), c.punctuation(";"), c.comment("======="), c.text("v"), c.punctuation("="), c.numericLiteral("2"), c.punctuation(";"), c.comment(">>>>>>> Branch - a"),