@@ -12,6 +12,8 @@ import { logger } from './logging';
1212import * as messages from './messages' ;
1313import * as qsClient from './queryserver-client' ;
1414import { promisify } from 'util' ;
15+ import { QueryHistoryItemOptions } from './query-history' ;
16+ import { isQuickQueryPath } from './quick-query' ;
1517
1618/**
1719 * queries.ts
@@ -205,6 +207,7 @@ export interface EvaluationInfo {
205207 query : QueryInfo ;
206208 result : messages . EvaluationResult ;
207209 database : DatabaseInfo ;
210+ historyItemOptions : QueryHistoryItemOptions ;
208211}
209212
210213/**
@@ -393,7 +396,7 @@ export async function clearCacheInDatabase(qs: qsClient.QueryServerClient, dbIte
393396 title : "Clearing Cache" ,
394397 cancellable : false ,
395398 } , ( progress , token ) =>
396- qs . sendRequest ( messages . clearCache , params , token , progress )
399+ qs . sendRequest ( messages . clearCache , params , token , progress )
397400 ) ;
398401}
399402
@@ -574,6 +577,12 @@ export async function compileAndRunQueryAgainstDatabase(
574577 // Determine which query to run, based on the selection and the active editor.
575578 const { queryPath, quickEvalPosition } = await determineSelectedQuery ( selectedQueryUri , quickEval ) ;
576579
580+ // If this is quick query, store the query text
581+ const historyItemOptions : QueryHistoryItemOptions = { } ;
582+ if ( isQuickQueryPath ( queryPath ) ) {
583+ historyItemOptions . queryText = await fs . readFile ( queryPath , 'utf8' ) ;
584+ }
585+
577586 // Get the workspace folder paths.
578587 const diskWorkspaceFolders = helpers . getOnDiskWorkspaceFolders ( ) ;
579588 // Figure out the library path for the query.
@@ -616,7 +625,6 @@ export async function compileAndRunQueryAgainstDatabase(
616625
617626 const errors = await query . compile ( qs ) ;
618627
619-
620628 if ( errors . length == 0 ) {
621629 const result = await query . run ( qs ) ;
622630 return {
@@ -625,7 +633,8 @@ export async function compileAndRunQueryAgainstDatabase(
625633 database : {
626634 name : db . name ,
627635 databaseUri : db . databaseUri . toString ( true )
628- }
636+ } ,
637+ historyItemOptions
629638 } ;
630639 } else {
631640 // Error dialogs are limited in size and scrollability,
@@ -650,6 +659,7 @@ export async function compileAndRunQueryAgainstDatabase(
650659 " and the query and database use the same target language. For more details on the error, go to View > Output," +
651660 " and choose CodeQL Query Server from the dropdown." ) ;
652661 }
662+
653663 return {
654664 query,
655665 result : {
@@ -662,7 +672,8 @@ export async function compileAndRunQueryAgainstDatabase(
662672 database : {
663673 name : db . name ,
664674 databaseUri : db . databaseUri . toString ( true )
665- }
675+ } ,
676+ historyItemOptions,
666677 } ;
667678 }
668679}
0 commit comments