Support extensionPacks debug configuration
This commit is contained in:
@@ -101,12 +101,20 @@
|
||||
"string"
|
||||
],
|
||||
"description": "Additional folders to search for library packs. Defaults to searching all workspace folders."
|
||||
},
|
||||
"extensionPacks": {
|
||||
"type": [
|
||||
"array",
|
||||
"string"
|
||||
],
|
||||
"description": "Names of extension packs to include in the evaluation. These are resolved from the locations specified in `additionalPacks`."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"currentDatabase": "codeQL.getCurrentDatabase"
|
||||
"currentDatabase": "codeQL.getCurrentDatabase",
|
||||
"currentQuery": "codeQL.getCurrentQuery"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -482,6 +490,10 @@
|
||||
"command": "codeQL.getCurrentDatabase",
|
||||
"title": "CodeQL: Get Current Database"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.getCurrentQuery",
|
||||
"title": "CodeQL: Get Current Query"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.viewAst",
|
||||
"title": "CodeQL: View AST"
|
||||
@@ -1104,6 +1116,10 @@
|
||||
"command": "codeQL.getCurrentDatabase",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.getCurrentQuery",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.viewAst",
|
||||
"when": "resourceScheme == codeql-zip-archive"
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
WorkspaceFolder,
|
||||
} from "vscode";
|
||||
import { getOnDiskWorkspaceFolders, showAndLogErrorMessage } from "../helpers";
|
||||
import { LocalQueries } from "../local-queries";
|
||||
|
||||
interface QLDebugArgs {
|
||||
query: string;
|
||||
@@ -26,6 +27,8 @@ export type QLResolvedDebugConfiguration = DebugConfiguration &
|
||||
export class QLDebugConfigurationProvider
|
||||
implements DebugConfigurationProvider
|
||||
{
|
||||
public constructor(private readonly localQueries: LocalQueries) {}
|
||||
|
||||
public resolveDebugConfiguration(
|
||||
_folder: WorkspaceFolder | undefined,
|
||||
debugConfiguration: DebugConfiguration,
|
||||
@@ -62,25 +65,30 @@ export class QLDebugConfigurationProvider
|
||||
return null;
|
||||
}
|
||||
|
||||
// Fill in defaults here, instead of in `resolveDebugConfiguration`, to avoid the highly
|
||||
// unusual case where one of the computed default values looks like a variable substitution.
|
||||
const additionalPacks =
|
||||
qlConfiguration.additionalPacks === undefined
|
||||
? getOnDiskWorkspaceFolders()
|
||||
: typeof qlConfiguration.additionalPacks === "string"
|
||||
? [qlConfiguration.additionalPacks]
|
||||
: qlConfiguration.additionalPacks;
|
||||
|
||||
// Default to computing the extension packs based on the extension configuration and the search
|
||||
// path.
|
||||
const extensionPacks =
|
||||
qlConfiguration.extensionPacks === undefined
|
||||
? await this.localQueries.getDefaultExtensionPacks(additionalPacks)
|
||||
: typeof qlConfiguration.extensionPacks === "string"
|
||||
? [qlConfiguration.extensionPacks]
|
||||
: qlConfiguration.extensionPacks;
|
||||
|
||||
const resultConfiguration: QLResolvedDebugConfiguration = {
|
||||
...qlConfiguration,
|
||||
query: qlConfiguration.query,
|
||||
database: qlConfiguration.database,
|
||||
additionalPacks:
|
||||
// Fill in defaults here, instead of in `resolveDebugConfiguration`, to avoid the highly
|
||||
// unusual case where one of the workspace folder paths contains something that looks like a
|
||||
// variable substitution.
|
||||
qlConfiguration.additionalPacks === undefined
|
||||
? getOnDiskWorkspaceFolders()
|
||||
: typeof qlConfiguration.additionalPacks === "string"
|
||||
? [qlConfiguration.additionalPacks]
|
||||
: qlConfiguration.additionalPacks,
|
||||
extensionPacks:
|
||||
qlConfiguration.extensionPacks === undefined
|
||||
? []
|
||||
: typeof qlConfiguration.extensionPacks === "string"
|
||||
? [qlConfiguration.extensionPacks]
|
||||
: qlConfiguration.extensionPacks,
|
||||
additionalPacks,
|
||||
extensionPacks,
|
||||
};
|
||||
|
||||
return resultConfiguration;
|
||||
|
||||
@@ -66,4 +66,5 @@ export interface LaunchRequestArguments
|
||||
query: string;
|
||||
database: string;
|
||||
additionalPacks: string[];
|
||||
extensionPacks: string[];
|
||||
}
|
||||
|
||||
@@ -235,6 +235,7 @@ export class QLDebugSession extends LoggingDebugSession implements Disposable {
|
||||
},
|
||||
true,
|
||||
args.additionalPacks,
|
||||
args.extensionPacks,
|
||||
this.queryStorageDir,
|
||||
undefined,
|
||||
undefined,
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
DebugSession,
|
||||
ProviderResult,
|
||||
} from "vscode";
|
||||
import { LocalQueries } from "../local-queries";
|
||||
import { DisposableObject } from "../pure/disposable-object";
|
||||
import { QueryRunner } from "../queryRunner";
|
||||
import { QLDebugConfigurationProvider } from "./debug-configuration";
|
||||
@@ -23,13 +24,14 @@ export class QLDebugAdapterDescriptorFactory
|
||||
constructor(
|
||||
private readonly queryStorageDir: string,
|
||||
private readonly queryRunner: QueryRunner,
|
||||
localQueries: LocalQueries,
|
||||
) {
|
||||
super();
|
||||
this.push(debug.registerDebugAdapterDescriptorFactory("codeql", this));
|
||||
this.push(
|
||||
debug.registerDebugConfigurationProvider(
|
||||
"codeql",
|
||||
new QLDebugConfigurationProvider(),
|
||||
new QLDebugConfigurationProvider(localQueries),
|
||||
DebugConfigurationProviderTriggerKind.Dynamic,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -864,7 +864,7 @@ async function activateWithInstalledDistribution(
|
||||
|
||||
void extLogger.log("Initializing debugger factory.");
|
||||
const debuggerFactory = ctx.subscriptions.push(
|
||||
new QLDebugAdapterDescriptorFactory(queryStorageDir, qs),
|
||||
new QLDebugAdapterDescriptorFactory(queryStorageDir, qs, localQueries),
|
||||
);
|
||||
void debuggerFactory;
|
||||
|
||||
|
||||
@@ -456,9 +456,7 @@ export class LocalQueries extends DisposableObject {
|
||||
}
|
||||
|
||||
const additionalPacks = getOnDiskWorkspaceFolders();
|
||||
const extensionPacks = (await this.cliServer.useExtensionPacks())
|
||||
? Object.keys(await this.cliServer.resolveQlpacks(additionalPacks, true))
|
||||
: undefined;
|
||||
const extensionPacks = await this.getDefaultExtensionPacks(additionalPacks);
|
||||
|
||||
const coreQueryRun = this.queryRunner.createQueryRun(
|
||||
databaseItem.databaseUri.fsPath,
|
||||
@@ -584,4 +582,12 @@ export class LocalQueries extends DisposableObject {
|
||||
): Promise<void> {
|
||||
await this.localQueryResultsView.showResults(query, forceReveal, false);
|
||||
}
|
||||
|
||||
public async getDefaultExtensionPacks(
|
||||
additionalPacks: string[],
|
||||
): Promise<string[]> {
|
||||
return (await this.cliServer.useExtensionPacks())
|
||||
? Object.keys(await this.cliServer.resolveQlpacks(additionalPacks, true))
|
||||
: [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user