Skip to content

Commit 73c3961

Browse files
committed
Adding display parts to definition items to support FindAllReferences
1 parent ddb5a00 commit 73c3961

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/services/services.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ namespace ts {
300300
}
301301
}
302302
// For syntactic classifications, all trivia are classcified together, including jsdoc comments.
303-
// For that to work, the jsdoc comments should still be the leading trivia of the first child.
304-
// Restoring the scanner position ensures that.
303+
// For that to work, the jsdoc comments should still be the leading trivia of the first child.
304+
// Restoring the scanner position ensures that.
305305
pos = this.pos;
306306
forEachChild(this, processNode, processNodes);
307307
if (pos < this.end) {
@@ -1374,8 +1374,13 @@ namespace ts {
13741374
containerName: string;
13751375
}
13761376

1377+
export interface ReferencedSymbolDefinitionInfo extends DefinitionInfo {
1378+
// For more complex definitions where kind and name are insufficient to properly colorize the text
1379+
displayParts?: SymbolDisplayPart[];
1380+
}
1381+
13771382
export interface ReferencedSymbol {
1378-
definition: DefinitionInfo;
1383+
definition: ReferencedSymbolDefinitionInfo;
13791384
references: ReferenceEntry[];
13801385
}
13811386

@@ -6108,7 +6113,7 @@ namespace ts {
61086113

61096114
return result;
61106115

6111-
function getDefinition(symbol: Symbol): DefinitionInfo {
6116+
function getDefinition(symbol: Symbol): ReferencedSymbolDefinitionInfo {
61126117
const info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), node);
61136118
const name = map(info.displayParts, p => p.text).join("");
61146119
const declarations = symbol.declarations;
@@ -6122,7 +6127,8 @@ namespace ts {
61226127
name,
61236128
kind: info.symbolKind,
61246129
fileName: declarations[0].getSourceFile().fileName,
6125-
textSpan: createTextSpan(declarations[0].getStart(), 0)
6130+
textSpan: createTextSpan(declarations[0].getStart(), 0),
6131+
displayParts: info.displayParts
61266132
};
61276133
}
61286134

@@ -6317,7 +6323,7 @@ namespace ts {
63176323
}
63186324
});
63196325

6320-
const definition: DefinitionInfo = {
6326+
const definition: ReferencedSymbolDefinitionInfo = {
63216327
containerKind: "",
63226328
containerName: "",
63236329
fileName: targetLabel.getSourceFile().fileName,
@@ -6634,14 +6640,20 @@ namespace ts {
66346640
getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references);
66356641
}
66366642

6643+
const symbol = typeChecker.getSymbolAtLocation(node);
6644+
6645+
const displayParts = symbol ? getSymbolDisplayPartsDocumentationAndSymbolKind(
6646+
symbol, node.getSourceFile(), getContainerNode(node), node).displayParts : undefined;
6647+
66376648
return [{
66386649
definition: {
66396650
containerKind: "",
66406651
containerName: "",
66416652
fileName: node.getSourceFile().fileName,
66426653
kind: ScriptElementKind.variableElement,
66436654
name: type.text,
6644-
textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd())
6655+
textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()),
6656+
displayParts
66456657
},
66466658
references: references
66476659
}];

0 commit comments

Comments
 (0)