@@ -32,8 +32,7 @@ import {
3232 runContextualQuery ,
3333} from "./queryResolver" ;
3434import { isCanary , NO_CACHE_AST_VIEWER } from "../config" ;
35- import { QueryWithResults } from "../run-queries-shared" ;
36- import { QueryRunner } from "../queryRunner" ;
35+ import { CoreCompletedQuery , QueryRunner } from "../queryRunner" ;
3736
3837/**
3938 * Runs templated CodeQL queries to find definitions in
@@ -155,25 +154,22 @@ export class TemplateQueryReferenceProvider implements ReferenceProvider {
155154 }
156155}
157156
158- type QueryWithDb = {
159- query : QueryWithResults ;
160- dbUri : Uri ;
161- } ;
162-
163157/**
164158 * Run templated CodeQL queries to produce AST information for
165159 * source-language files.
166160 */
167161export class TemplatePrintAstProvider {
168- private cache : CachedOperation < QueryWithDb > ;
162+ private cache : CachedOperation < CoreCompletedQuery > ;
169163
170164 constructor (
171165 private cli : CodeQLCliServer ,
172166 private qs : QueryRunner ,
173167 private dbm : DatabaseManager ,
174168 private queryStorageDir : string ,
175169 ) {
176- this . cache = new CachedOperation < QueryWithDb > ( this . getAst . bind ( this ) ) ;
170+ this . cache = new CachedOperation < CoreCompletedQuery > (
171+ this . getAst . bind ( this ) ,
172+ ) ;
177173 }
178174
179175 async provideAst (
@@ -186,14 +182,14 @@ export class TemplatePrintAstProvider {
186182 "Cannot view the AST. Please select a valid source file inside a CodeQL database." ,
187183 ) ;
188184 }
189- const { query , dbUri } = this . shouldCache ( )
185+ const completedQuery = this . shouldCache ( )
190186 ? await this . cache . get ( fileUri . toString ( ) , progress , token )
191187 : await this . getAst ( fileUri . toString ( ) , progress , token ) ;
192188
193189 return new AstBuilder (
194- query ,
190+ completedQuery . outputDir ,
195191 this . cli ,
196- this . dbm . findDatabaseItem ( dbUri ) ! ,
192+ this . dbm . findDatabaseItem ( Uri . file ( completedQuery . dbPath ) ) ! ,
197193 fileUri ,
198194 ) ;
199195 }
@@ -206,7 +202,7 @@ export class TemplatePrintAstProvider {
206202 uriString : string ,
207203 progress : ProgressCallback ,
208204 token : CancellationToken ,
209- ) : Promise < QueryWithDb > {
205+ ) : Promise < CoreCompletedQuery > {
210206 const uri = Uri . parse ( uriString , true ) ;
211207 if ( uri . scheme !== zipArchiveScheme ) {
212208 throw new Error (
@@ -242,7 +238,7 @@ export class TemplatePrintAstProvider {
242238 [ TEMPLATE_NAME ] : zippedArchive . pathWithinSourceArchive ,
243239 } ;
244240
245- const queryResult = await runContextualQuery (
241+ const results = await runContextualQuery (
246242 query ,
247243 db ,
248244 this . queryStorageDir ,
@@ -252,10 +248,7 @@ export class TemplatePrintAstProvider {
252248 token ,
253249 templates ,
254250 ) ;
255- return {
256- query : queryResult ,
257- dbUri : db . databaseUri ,
258- } ;
251+ return results ;
259252 }
260253}
261254
0 commit comments