mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Support getting references even if quickInfo failed (#24476)
* Support getting references even if quickInfo failed * Add test
This commit is contained in:
parent
239dde8ff1
commit
77371679be
@ -1025,13 +1025,10 @@ namespace ts.server {
|
||||
const position = this.getPosition(args, scriptInfo);
|
||||
if (simplifiedResult) {
|
||||
const nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position);
|
||||
if (!nameInfo) {
|
||||
return undefined;
|
||||
}
|
||||
const displayString = displayPartsToString(nameInfo.displayParts);
|
||||
const nameSpan = nameInfo.textSpan;
|
||||
const nameColStart = scriptInfo.positionToLineOffset(nameSpan.start).offset;
|
||||
const nameText = scriptInfo.getSnapshot().getText(nameSpan.start, textSpanEnd(nameSpan));
|
||||
const displayString = nameInfo ? displayPartsToString(nameInfo.displayParts) : "";
|
||||
const nameSpan = nameInfo && nameInfo.textSpan;
|
||||
const nameColStart = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0;
|
||||
const nameText = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, textSpanEnd(nameSpan)) : "";
|
||||
const refs = combineProjectOutput<NormalizedPath, protocol.ReferencesResponseItem>(
|
||||
file,
|
||||
path => this.projectService.getScriptInfoForPath(path)!.fileName,
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
/// <reference path='../fourslash.ts'/>
|
||||
|
||||
// @Filename: /a.ts
|
||||
////type Options = "[|{| "isInString": true |}option 1|]" | "option 2";
|
||||
////let myOption: Options = "[|{| "isInString": true |}option 1|]";
|
||||
|
||||
const [r0, r1] = test.ranges();
|
||||
goTo.eachRange(() => {
|
||||
verify.getReferencesForServerTest([
|
||||
{ fileName: "/a.ts", isDefinition: false, isWriteAccess: false, textSpan: toSpan(r0) },
|
||||
{ fileName: "/a.ts", isDefinition: false, isWriteAccess: false, textSpan: toSpan(r1) },
|
||||
]);
|
||||
});
|
||||
|
||||
function toSpan(r: FourSlashInterface.Range) {
|
||||
return { start: r.pos, length: r.end - r.pos };
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user