Move openReferencedFile to top level
This commit is contained in:
@@ -745,17 +745,6 @@ async function activateWithInstalledDistribution(
|
|||||||
});
|
});
|
||||||
ctx.subscriptions.push({ dispose: qhelpTmpDir.removeCallback });
|
ctx.subscriptions.push({ dispose: qhelpTmpDir.removeCallback });
|
||||||
|
|
||||||
async function openReferencedFile(selectedQuery: Uri): Promise<void> {
|
|
||||||
// If no file is selected, the path of the file in the editor is selected
|
|
||||||
const path =
|
|
||||||
selectedQuery?.fsPath || window.activeTextEditor?.document.uri.fsPath;
|
|
||||||
if (qs !== undefined && path) {
|
|
||||||
const resolved = await cliServer.resolveQlref(path);
|
|
||||||
const uri = Uri.file(resolved.resolvedPath);
|
|
||||||
await window.showTextDocument(uri, { preview: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.subscriptions.push(tmpDirDisposal);
|
ctx.subscriptions.push(tmpDirDisposal);
|
||||||
|
|
||||||
void extLogger.log("Initializing CodeQL language server.");
|
void extLogger.log("Initializing CodeQL language server.");
|
||||||
@@ -1274,19 +1263,28 @@ async function activateWithInstalledDistribution(
|
|||||||
);
|
);
|
||||||
|
|
||||||
ctx.subscriptions.push(
|
ctx.subscriptions.push(
|
||||||
commandRunner("codeQL.openReferencedFile", openReferencedFile),
|
commandRunner("codeQL.openReferencedFile", async (selectedQuery: Uri) => {
|
||||||
|
await openReferencedFile(qs, cliServer, selectedQuery);
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.openReferencedFile" command
|
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.openReferencedFile" command
|
||||||
ctx.subscriptions.push(
|
ctx.subscriptions.push(
|
||||||
commandRunner("codeQL.openReferencedFileContextEditor", openReferencedFile),
|
commandRunner(
|
||||||
|
"codeQL.openReferencedFileContextEditor",
|
||||||
|
async (selectedQuery: Uri) => {
|
||||||
|
await openReferencedFile(qs, cliServer, selectedQuery);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.openReferencedFile" command
|
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.openReferencedFile" command
|
||||||
ctx.subscriptions.push(
|
ctx.subscriptions.push(
|
||||||
commandRunner(
|
commandRunner(
|
||||||
"codeQL.openReferencedFileContextExplorer",
|
"codeQL.openReferencedFileContextExplorer",
|
||||||
openReferencedFile,
|
async (selectedQuery: Uri) => {
|
||||||
|
await openReferencedFile(qs, cliServer, selectedQuery);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1882,6 +1880,21 @@ async function previewQueryHelp(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function openReferencedFile(
|
||||||
|
qs: QueryRunner,
|
||||||
|
cliServer: CodeQLCliServer,
|
||||||
|
selectedQuery: Uri,
|
||||||
|
): Promise<void> {
|
||||||
|
// If no file is selected, the path of the file in the editor is selected
|
||||||
|
const path =
|
||||||
|
selectedQuery?.fsPath || window.activeTextEditor?.document.uri.fsPath;
|
||||||
|
if (qs !== undefined && path) {
|
||||||
|
const resolved = await cliServer.resolveQlref(path);
|
||||||
|
const uri = Uri.file(resolved.resolvedPath);
|
||||||
|
await window.showTextDocument(uri, { preview: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function addUnhandledRejectionListener() {
|
function addUnhandledRejectionListener() {
|
||||||
const handler = (error: unknown) => {
|
const handler = (error: unknown) => {
|
||||||
// This listener will be triggered for errors from other extensions as
|
// This listener will be triggered for errors from other extensions as
|
||||||
|
|||||||
Reference in New Issue
Block a user