File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -4743,6 +4743,19 @@ namespace ts {
4743
4743
|| kind === SyntaxKind . TemplateTail ;
4744
4744
}
4745
4745
4746
+ export function isStringTextContainingNode ( node : Node ) {
4747
+ switch ( node . kind ) {
4748
+ case SyntaxKind . StringLiteral :
4749
+ case SyntaxKind . TemplateHead :
4750
+ case SyntaxKind . TemplateMiddle :
4751
+ case SyntaxKind . TemplateTail :
4752
+ case SyntaxKind . NoSubstitutionTemplateLiteral :
4753
+ return true ;
4754
+ default :
4755
+ return false ;
4756
+ }
4757
+ }
4758
+
4746
4759
// Identifiers
4747
4760
4748
4761
/* @internal */
Original file line number Diff line number Diff line change @@ -787,7 +787,7 @@ namespace ts {
787
787
788
788
export function isInString ( sourceFile : SourceFile , position : number ) : boolean {
789
789
const previousToken = findPrecedingToken ( position , sourceFile ) ;
790
- if ( previousToken && previousToken . kind === SyntaxKind . StringLiteral ) {
790
+ if ( previousToken && isStringTextContainingNode ( previousToken ) ) {
791
791
const start = previousToken . getStart ( ) ;
792
792
const end = previousToken . getEnd ( ) ;
793
793
Original file line number Diff line number Diff line change 2
2
3
3
///////<reference path="./Bar.ts" />
4
4
5
- ////function /**/ [|Bar|]() {
5
+ ////function [|Bar|]() {
6
6
//// // This is a reference to [|Bar|] in a comment.
7
- //// "this is a reference to [|Bar|] in a string"
7
+ //// "this is a reference to [|Bar|] in a string";
8
+ //// `Foo [|Bar|] Baz.`;
9
+ //// {
10
+ //// const Bar = 0;
11
+ //// `[|Bar|] ba ${Bar} bara [|Bar|] berbobo ${Bar} araura [|Bar|] ara!`;
12
+ //// }
8
13
//// }
9
14
10
15
const ranges = test . ranges ( ) ;
You can’t perform that action at this time.
0 commit comments