Skip to content

Commit 4c71862

Browse files
author
Andy Hanson
committed
Nope, need 'isInString'
1 parent 03e0238 commit 4c71862

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/services/findAllReferences.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ namespace ts.FindAllReferences {
1515
| { type: "string"; node: ts.StringLiteral };
1616

1717
export type Entry = NodeEntry | SpanEntry;
18-
export interface NodeEntry { type: "node"; node: Node; }
18+
export interface NodeEntry {
19+
type: "node";
20+
node: Node;
21+
isInString?: true;
22+
}
1923
interface SpanEntry {
2024
type: "span";
2125
fileName: string;
2226
textSpan: TextSpan;
2327
}
24-
export function nodeEntry(node: ts.Node): NodeEntry {
25-
return { type: "node", node };
28+
export function nodeEntry(node: ts.Node, isInString?: true): NodeEntry {
29+
return { type: "node", node, isInString };
2630
}
2731

2832
export interface Options {
@@ -163,13 +167,13 @@ namespace ts.FindAllReferences {
163167
return { textSpan: entry.textSpan, fileName: entry.fileName, isWriteAccess: false, isDefinition: false };
164168
}
165169

166-
const { node } = entry;
170+
const { node, isInString } = entry;
167171
return {
168172
fileName: node.getSourceFile().fileName,
169173
textSpan: getTextSpan(node),
170174
isWriteAccess: isWriteAccess(node),
171175
isDefinition: isDeclarationName(node) || isLiteralComputedPropertyDeclarationName(node),
172-
isInString: node.kind === ts.SyntaxKind.StringLiteral ? true : undefined
176+
isInString
173177
};
174178
}
175179

@@ -211,13 +215,13 @@ namespace ts.FindAllReferences {
211215
return { fileName, span: { textSpan, kind: HighlightSpanKind.reference } };
212216
}
213217

214-
const { node } = entry;
218+
const { node, isInString } = entry;
215219
const fileName = entry.node.getSourceFile().fileName;
216220
const writeAccess = isWriteAccess(node);
217221
const span: HighlightSpan = {
218222
textSpan: getTextSpan(node),
219223
kind: writeAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference,
220-
isInString: node.kind === ts.SyntaxKind.StringLiteral ? true : undefined
224+
isInString
221225
};
222226
return { fileName, span };
223227
}
@@ -1355,7 +1359,7 @@ namespace ts.FindAllReferences.Core {
13551359

13561360
const type = getStringLiteralTypeForNode(<StringLiteral>node, checker);
13571361
if (type === searchType) {
1358-
references.push(nodeEntry(node));
1362+
references.push(nodeEntry(node, /*isInString*/true));
13591363
}
13601364
}
13611365
}

0 commit comments

Comments
 (0)