Classify the '=' sign in variable/parameter/property as if it was an operator.

This commit is contained in:
Cyrus Najmabadi 2014-12-18 19:38:19 -08:00
parent 48bef4698b
commit a6ea497ff1
2 changed files with 10 additions and 3 deletions

View File

@ -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) {

View File

@ -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"),