Merge pull request #1094 from Microsoft/findAllRefsInTemplates

Corrected isExpression for templates.
This commit is contained in:
Daniel Rosenwasser
2014-11-07 16:24:22 -08:00
5 changed files with 29 additions and 3 deletions

View File

@@ -491,6 +491,7 @@ module ts {
case SyntaxKind.BinaryExpression:
case SyntaxKind.ConditionalExpression:
case SyntaxKind.TemplateExpression:
case SyntaxKind.NoSubstitutionTemplateLiteral:
case SyntaxKind.OmittedExpression:
return true;
case SyntaxKind.QualifiedName:
@@ -503,7 +504,6 @@ module ts {
// fall through
case SyntaxKind.NumericLiteral:
case SyntaxKind.StringLiteral:
case SyntaxKind.NoSubstitutionTemplateLiteral:
var parent = node.parent;
switch (parent.kind) {
case SyntaxKind.VariableDeclaration:
@@ -532,6 +532,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

@@ -3,5 +3,5 @@ var x = x => `abc${ x }def`;
>x : (x: any) => string
>x => `abc${ x }def` : (x: any) => string
>x : any
>x : unknown
>x : any

View File

@@ -3,5 +3,5 @@ var x = x => `abc${ x }def`;
>x : (x: any) => string
>x => `abc${ x }def` : (x: any) => string
>x : any
>x : unknown
>x : any

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);
}
}