@@ -16,16 +16,15 @@ import { CodeQLCliServer } from '../cli';
1616import { DatabaseManager } from '../databases' ;
1717import { CachedOperation } from '../helpers' ;
1818import { ProgressCallback , withProgress } from '../commandRunner' ;
19- import * as messages from '../pure/messages' ;
20- import { QueryServerClient } from '../queryserver-client' ;
21- import { compileAndRunQueryAgainstDatabase , createInitialQueryInfo , QueryWithResults } from '../run-queries' ;
2219import AstBuilder from './astBuilder' ;
2320import {
2421 KeyType ,
2522} from './keyType' ;
2623import { FullLocationLink , getLocationsForUriString , TEMPLATE_NAME } from './locationFinder' ;
2724import { qlpackOfDatabase , resolveQueries } from './queryResolver' ;
2825import { isCanary , NO_CACHE_AST_VIEWER } from '../config' ;
26+ import { createInitialQueryInfo , QueryWithResults } from '../run-queries-shared' ;
27+ import { QueryRunner } from '../queryRunner' ;
2928
3029/**
3130 * Run templated CodeQL queries to find definitions and references in
@@ -39,7 +38,7 @@ export class TemplateQueryDefinitionProvider implements DefinitionProvider {
3938
4039 constructor (
4140 private cli : CodeQLCliServer ,
42- private qs : QueryServerClient ,
41+ private qs : QueryRunner ,
4342 private dbm : DatabaseManager ,
4443 private queryStorageDir : string ,
4544 ) {
@@ -83,7 +82,7 @@ export class TemplateQueryReferenceProvider implements ReferenceProvider {
8382
8483 constructor (
8584 private cli : CodeQLCliServer ,
86- private qs : QueryServerClient ,
85+ private qs : QueryRunner ,
8786 private dbm : DatabaseManager ,
8887 private queryStorageDir : string ,
8988 ) {
@@ -137,7 +136,7 @@ export class TemplatePrintAstProvider {
137136
138137 constructor (
139138 private cli : CodeQLCliServer ,
140- private qs : QueryServerClient ,
139+ private qs : QueryRunner ,
141140 private dbm : DatabaseManager ,
142141 private queryStorageDir : string ,
143142 ) {
@@ -195,14 +194,9 @@ export class TemplatePrintAstProvider {
195194 }
196195
197196 const query = queries [ 0 ] ;
198- const templates : messages . TemplateDefinitions = {
199- [ TEMPLATE_NAME ] : {
200- values : {
201- tuples : [ [ {
202- stringValue : zippedArchive . pathWithinSourceArchive
203- } ] ]
204- }
205- }
197+ const templates : Record < string , string > = {
198+ [ TEMPLATE_NAME ] :
199+ zippedArchive . pathWithinSourceArchive
206200 } ;
207201
208202 const initialInfo = await createInitialQueryInfo (
@@ -215,9 +209,7 @@ export class TemplatePrintAstProvider {
215209 ) ;
216210
217211 return {
218- query : await compileAndRunQueryAgainstDatabase (
219- this . cli ,
220- this . qs ,
212+ query : await this . qs . compileAndRunQueryAgainstDatabase (
221213 db ,
222214 initialInfo ,
223215 this . queryStorageDir ,
@@ -231,23 +223,23 @@ export class TemplatePrintAstProvider {
231223}
232224
233225export class TemplatePrintCfgProvider {
234- private cache : CachedOperation < [ Uri , messages . TemplateDefinitions ] | undefined > ;
226+ private cache : CachedOperation < [ Uri , Record < string , string > ] | undefined > ;
235227
236228 constructor (
237229 private cli : CodeQLCliServer ,
238230 private dbm : DatabaseManager ,
239231 ) {
240- this . cache = new CachedOperation < [ Uri , messages . TemplateDefinitions ] | undefined > ( this . getCfgUri . bind ( this ) ) ;
232+ this . cache = new CachedOperation < [ Uri , Record < string , string > ] | undefined > ( this . getCfgUri . bind ( this ) ) ;
241233 }
242234
243- async provideCfgUri ( document ?: TextDocument ) : Promise < [ Uri , messages . TemplateDefinitions ] | undefined > {
235+ async provideCfgUri ( document ?: TextDocument ) : Promise < [ Uri , Record < string , string > ] | undefined > {
244236 if ( ! document ) {
245237 return ;
246238 }
247239 return await this . cache . get ( document . uri . toString ( ) ) ;
248240 }
249241
250- private async getCfgUri ( uriString : string ) : Promise < [ Uri , messages . TemplateDefinitions ] > {
242+ private async getCfgUri ( uriString : string ) : Promise < [ Uri , Record < string , string > ] > {
251243 const uri = Uri . parse ( uriString , true ) ;
252244 if ( uri . scheme !== zipArchiveScheme ) {
253245 throw new Error ( 'CFG Viewing is only available for databases with zipped source archives.' ) ;
@@ -275,14 +267,8 @@ export class TemplatePrintCfgProvider {
275267
276268 const queryUri = Uri . file ( queries [ 0 ] ) ;
277269
278- const templates : messages . TemplateDefinitions = {
279- [ TEMPLATE_NAME ] : {
280- values : {
281- tuples : [ [ {
282- stringValue : zippedArchive . pathWithinSourceArchive
283- } ] ]
284- }
285- }
270+ const templates : Record < string , string > = {
271+ [ TEMPLATE_NAME ] : zippedArchive . pathWithinSourceArchive
286272 } ;
287273
288274 return [ queryUri , templates ] ;
0 commit comments