@@ -16,7 +16,7 @@ import type { BaseLogger, LogOptions } from "../common/logging";
1616import { queryServerLogger } from "../common/logging/vscode";
1717import { QueryResultType } from "../query-server/messages";
1818import type {
19- CoreQueryResults ,
19+ CoreQueryResult ,
2020 CoreQueryRun,
2121 QueryRunner,
2222} from "../query-server";
@@ -25,6 +25,7 @@ import type * as CodeQLProtocol from "./debug-protocol";
2525import type { QuickEvalContext } from "../run-queries-shared";
2626import { getErrorMessage } from "../common/helpers-pure";
2727import { DisposableObject } from "../common/disposable-object";
28+ import { basename } from "path";
2829
2930// More complete implementations of `Event` for certain events, because the classes from
3031// `@vscode/debugadapter` make it more difficult to provide some of the message values.
@@ -107,9 +108,9 @@ class EvaluationCompletedEvent
107108 public readonly event = "codeql-evaluation-completed";
108109 public readonly body: CodeQLProtocol.EvaluationCompletedEvent["body"];
109110
110- constructor(results: CoreQueryResults ) {
111+ constructor(result: CoreQueryResult ) {
111112 super("codeql-evaluation-completed");
112- this.body = results ;
113+ this.body = result ;
113114 }
114115}
115116
@@ -143,6 +144,7 @@ const QUERY_THREAD_NAME = "Evaluation thread";
143144class RunningQuery extends DisposableObject {
144145 private readonly tokenSource = this.push(new CancellationTokenSource());
145146 public readonly queryRun: CoreQueryRun;
147+ private readonly queryPath: string;
146148
147149 public constructor(
148150 queryRunner: QueryRunner,
@@ -154,12 +156,15 @@ class RunningQuery extends DisposableObject {
154156 ) {
155157 super();
156158
159+ this.queryPath = config.query;
157160 // Create the query run, which will give us some information about the query even before the
158161 // evaluation has completed.
159162 this.queryRun = queryRunner.createQueryRun(
160163 config.database,
161164 {
162- queryPath: config.query,
165+ queryInputsOutputs: [
166+ { queryPath: this.queryPath, outputBaseName: "results" },
167+ ],
163168 quickEvalPosition: quickEvalContext?.quickEvalPosition,
164169 quickEvalCountOnly: quickEvalContext?.quickEvalCount,
165170 },
@@ -168,7 +173,7 @@ class RunningQuery extends DisposableObject {
168173 config.extensionPacks,
169174 config.additionalRunQueryArgs,
170175 queryStorageDir,
171- undefined ,
176+ basename(config.query) ,
172177 undefined,
173178 );
174179 }
@@ -208,7 +213,7 @@ class RunningQuery extends DisposableObject {
208213 progressStart.body.cancellable = true;
209214 this.sendEvent(progressStart);
210215 try {
211- return await this.queryRun.evaluate(
216+ const completedQuery = await this.queryRun.evaluate(
212217 (p) => {
213218 const progressUpdate = new ProgressUpdateEvent(
214219 this.queryRun.id,
@@ -220,6 +225,14 @@ class RunningQuery extends DisposableObject {
220225 this.tokenSource.token,
221226 this.logger,
222227 );
228+ return (
229+ completedQuery.results.get(this.queryPath) ?? {
230+ resultType: QueryResultType.OTHER_ERROR,
231+ message: "Missing query results",
232+ evaluationTime: 0,
233+ outputBaseName: "unknown",
234+ }
235+ );
223236 } finally {
224237 this.sendEvent(new ProgressEndEvent(this.queryRun.id));
225238 }
@@ -229,6 +242,7 @@ class RunningQuery extends DisposableObject {
229242 resultType: QueryResultType.OTHER_ERROR,
230243 message,
231244 evaluationTime: 0,
245+ outputBaseName: "unknown",
232246 };
233247 }
234248 }
0 commit comments