Skip to content

Commit 03e0238

Browse files
author
Andy Hanson
committed
Don't need isInString to be a property
1 parent 94f6839 commit 03e0238

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

src/services/findAllReferences.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,21 @@ namespace ts.FindAllReferences {
88
}
99

1010
type Definition =
11-
| { type: "symbol"; symbol: Symbol; node: Node; }
12-
| { type: "label"; node: Identifier; }
13-
| { type: "keyword"; node: ts.Node; }
14-
| { type: "this"; node: ts.Node; }
11+
| { type: "symbol"; symbol: Symbol; node: Node }
12+
| { type: "label"; node: Identifier }
13+
| { type: "keyword"; node: ts.Node }
14+
| { type: "this"; node: ts.Node }
1515
| { type: "string"; node: ts.StringLiteral };
1616

1717
export type Entry = NodeEntry | SpanEntry;
18-
export interface NodeEntry {
19-
type: "node";
20-
node: Node;
21-
isInString: boolean;
22-
}
18+
export interface NodeEntry { type: "node"; node: Node; }
2319
interface SpanEntry {
2420
type: "span";
2521
fileName: string;
2622
textSpan: TextSpan;
2723
}
28-
export function nodeEntry(node: ts.Node, isInString = false): NodeEntry {
29-
return { type: "node", node, isInString };
24+
export function nodeEntry(node: ts.Node): NodeEntry {
25+
return { type: "node", node };
3026
}
3127

3228
export interface Options {
@@ -167,13 +163,13 @@ namespace ts.FindAllReferences {
167163
return { textSpan: entry.textSpan, fileName: entry.fileName, isWriteAccess: false, isDefinition: false };
168164
}
169165

170-
const { node, isInString } = entry;
166+
const { node } = entry;
171167
return {
172168
fileName: node.getSourceFile().fileName,
173169
textSpan: getTextSpan(node),
174170
isWriteAccess: isWriteAccess(node),
175171
isDefinition: isDeclarationName(node) || isLiteralComputedPropertyDeclarationName(node),
176-
isInString: isInString ? true : undefined
172+
isInString: node.kind === ts.SyntaxKind.StringLiteral ? true : undefined
177173
};
178174
}
179175

@@ -215,13 +211,13 @@ namespace ts.FindAllReferences {
215211
return { fileName, span: { textSpan, kind: HighlightSpanKind.reference } };
216212
}
217213

218-
const { node, isInString } = entry;
214+
const { node } = entry;
219215
const fileName = entry.node.getSourceFile().fileName;
220216
const writeAccess = isWriteAccess(node);
221217
const span: HighlightSpan = {
222218
textSpan: getTextSpan(node),
223219
kind: writeAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference,
224-
isInString: isInString ? true : undefined
220+
isInString: node.kind === ts.SyntaxKind.StringLiteral ? true : undefined
225221
};
226222
return { fileName, span };
227223
}
@@ -483,7 +479,7 @@ namespace ts.FindAllReferences.Core {
483479
references = symbolIdToReferences[symbolId] = [];
484480
result.push({ definition: { type: "symbol", symbol: referenceSymbol, node: searchLocation }, references });
485481
}
486-
return node => references.push({ type: "node", node, isInString: false });
482+
return node => references.push(nodeEntry(node));
487483
}
488484

489485
function addStringOrCommentReference(fileName: string, textSpan: TextSpan): void {
@@ -1359,7 +1355,7 @@ namespace ts.FindAllReferences.Core {
13591355

13601356
const type = getStringLiteralTypeForNode(<StringLiteral>node, checker);
13611357
if (type === searchType) {
1362-
references.push(nodeEntry(node, /*isInString*/true));
1358+
references.push(nodeEntry(node));
13631359
}
13641360
}
13651361
}

0 commit comments

Comments
 (0)