mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Support multiple parents in parentModule in vscode-client
This commit is contained in:
parent
2e3c156b0e
commit
f05fef7063
1 changed files with 15 additions and 9 deletions
|
@ -170,22 +170,28 @@ export function parentModule(ctx: Ctx): Cmd {
|
||||||
const client = ctx.client;
|
const client = ctx.client;
|
||||||
if (!editor || !client) return;
|
if (!editor || !client) return;
|
||||||
|
|
||||||
const response = await client.sendRequest(ra.parentModule, {
|
const locations = await client.sendRequest(ra.parentModule, {
|
||||||
textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document),
|
textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document),
|
||||||
position: client.code2ProtocolConverter.asPosition(
|
position: client.code2ProtocolConverter.asPosition(
|
||||||
editor.selection.active,
|
editor.selection.active,
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
const loc = response[0];
|
|
||||||
if (!loc) return;
|
|
||||||
|
|
||||||
const uri = client.protocol2CodeConverter.asUri(loc.targetUri);
|
if (locations.length === 1) {
|
||||||
const range = client.protocol2CodeConverter.asRange(loc.targetRange);
|
const loc = locations[0];
|
||||||
|
|
||||||
const doc = await vscode.workspace.openTextDocument(uri);
|
const uri = client.protocol2CodeConverter.asUri(loc.targetUri);
|
||||||
const e = await vscode.window.showTextDocument(doc);
|
const range = client.protocol2CodeConverter.asRange(loc.targetRange);
|
||||||
e.selection = new vscode.Selection(range.start, range.start);
|
|
||||||
e.revealRange(range, vscode.TextEditorRevealType.InCenter);
|
const doc = await vscode.workspace.openTextDocument(uri);
|
||||||
|
const e = await vscode.window.showTextDocument(doc);
|
||||||
|
e.selection = new vscode.Selection(range.start, range.start);
|
||||||
|
e.revealRange(range, vscode.TextEditorRevealType.InCenter);
|
||||||
|
} else {
|
||||||
|
const uri = editor.document.uri.toString();
|
||||||
|
const position = client.code2ProtocolConverter.asPosition(editor.selection.active);
|
||||||
|
await showReferencesImpl(client, uri, position, locations.map(loc => lc.Location.create(loc.targetUri, loc.targetRange)));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue