Corrected isExpression for templates.

Fixes #1046.
This commit is contained in:
Daniel Rosenwasser 2014-11-07 13:29:59 -08:00
parent 356622c8e9
commit dbcb6dc01e
3 changed files with 27 additions and 1 deletions

View File

@ -490,6 +490,7 @@ module ts {
case SyntaxKind.BinaryExpression:
case SyntaxKind.ConditionalExpression:
case SyntaxKind.TemplateExpression:
case SyntaxKind.NoSubstitutionTemplateLiteral:
case SyntaxKind.OmittedExpression:
return true;
case SyntaxKind.QualifiedName:
@ -502,7 +503,6 @@ module ts {
// fall through
case SyntaxKind.NumericLiteral:
case SyntaxKind.StringLiteral:
case SyntaxKind.NoSubstitutionTemplateLiteral:
var parent = node.parent;
switch (parent.kind) {
case SyntaxKind.VariableDeclaration:
@ -531,6 +531,8 @@ module ts {
(<ForInStatement>parent).expression === node;
case SyntaxKind.TypeAssertion:
return node === (<TypeAssertion>parent).operand;
case SyntaxKind.TemplateSpan:
return node === (<TemplateSpan>parent).expression;
default:
if (isExpression(parent)) {
return true;

View File

@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>
////var [|x|] = 10;
////var y = `${ [|x|] } ${ [|x|] }`
test.ranges().forEach(targetRange => {
goTo.position(targetRange.start);
test.ranges().forEach(range => {
verify.referencesAtPositionContains(range);
}
}

View File

@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>
////function [|f|](...rest: any[]) { }
////[|f|] `${ [|f|] } ${ [|f|] }`
test.ranges().forEach(targetRange => {
goTo.position(targetRange.start);
test.ranges().forEach(range => {
verify.referencesAtPositionContains(range);
}
}