@@ -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,21 +156,25 @@ 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 ,
161- {
162- queryPath : config . query ,
163- quickEvalPosition : quickEvalContext ?. quickEvalPosition ,
164- quickEvalCountOnly : quickEvalContext ?. quickEvalCount ,
165- } ,
164+ [
165+ {
166+ queryPath : this . queryPath ,
167+ outputBaseName : "results" ,
168+ quickEvalPosition : quickEvalContext ?. quickEvalPosition ,
169+ quickEvalCountOnly : quickEvalContext ?. quickEvalCount ,
170+ } ,
171+ ] ,
166172 true ,
167173 config . additionalPacks ,
168174 config . extensionPacks ,
169175 config . additionalRunQueryArgs ,
170176 queryStorageDir ,
171- undefined ,
177+ basename ( config . query ) ,
172178 undefined ,
173179 ) ;
174180 }
@@ -208,7 +214,7 @@ class RunningQuery extends DisposableObject {
208214 progressStart . body . cancellable = true ;
209215 this . sendEvent ( progressStart ) ;
210216 try {
211- return await this . queryRun . evaluate (
217+ const completedQuery = await this . queryRun . evaluate (
212218 ( p ) => {
213219 const progressUpdate = new ProgressUpdateEvent (
214220 this . queryRun . id ,
@@ -220,6 +226,14 @@ class RunningQuery extends DisposableObject {
220226 this . tokenSource . token ,
221227 this . logger ,
222228 ) ;
229+ return (
230+ completedQuery . results . get ( this . queryPath ) ?? {
231+ resultType : QueryResultType . OTHER_ERROR ,
232+ message : "Missing query results" ,
233+ evaluationTime : 0 ,
234+ outputBaseName : "unknown" ,
235+ }
236+ ) ;
223237 } finally {
224238 this . sendEvent ( new ProgressEndEvent ( this . queryRun . id ) ) ;
225239 }
@@ -229,6 +243,7 @@ class RunningQuery extends DisposableObject {
229243 resultType : QueryResultType . OTHER_ERROR ,
230244 message,
231245 evaluationTime : 0 ,
246+ outputBaseName : "unknown" ,
232247 } ;
233248 }
234249 }
0 commit comments