File tree Expand file tree Collapse file tree 4 files changed +17
-5
lines changed
Expand file tree Collapse file tree 4 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 395395 {
396396 "command" : " codeQLQueryHistory.viewSarif" ,
397397 "group" : " 9_qlCommands" ,
398- "when" : " view == codeQLQueryHistory"
398+ "when" : " view == codeQLQueryHistory && viewItem == interpretedResultsItem "
399399 },
400400 {
401401 "command" : " codeQLTests.showOutputDifferences" ,
Original file line number Diff line number Diff line change @@ -440,7 +440,7 @@ export class InterfaceManager extends DisposableObject {
440440 ) : Promise < Interpretation | undefined > {
441441 let interpretation : Interpretation | undefined = undefined ;
442442 if (
443- ( await query . hasInterpretedResults ( ) ) &&
443+ ( await query . canHaveInterpretedResults ( ) ) &&
444444 query . quickEvalPosition === undefined // never do results interpretation if quickEval
445445 ) {
446446 try {
Original file line number Diff line number Diff line change @@ -83,6 +83,11 @@ class HistoryTreeDataProvider implements vscode.TreeDataProvider<CompletedQuery>
8383 arguments : [ element ] ,
8484 } ;
8585
86+ // Mark this query history item according to whether it has a
87+ // SARIF file so that we can make context menu items conditionally
88+ // available.
89+ it . contextValue = element . query . hasInterpretedResults ( ) ? 'interpretedResultsItem' : 'rawResultsItem' ;
90+
8691 if ( ! element . didRunSuccessfully ) {
8792 it . iconPath = path . join ( this . ctx . extensionPath , FAILED_QUERY_HISTORY_ITEM_ICON ) ;
8893 }
@@ -259,7 +264,7 @@ export class QueryHistoryManager {
259264
260265 async handleViewSarif ( queryHistoryItem : CompletedQuery ) {
261266 try {
262- const hasInterpretedResults = await queryHistoryItem . query . hasInterpretedResults ( ) ;
267+ const hasInterpretedResults = await queryHistoryItem . query . canHaveInterpretedResults ( ) ;
263268 if ( hasInterpretedResults ) {
264269 const textDocument = await vscode . workspace . openTextDocument ( vscode . Uri . file ( queryHistoryItem . query . resultsPaths . interpretedResultsPath ) ) ;
265270 await vscode . window . showTextDocument ( textDocument , vscode . ViewColumn . One ) ;
Original file line number Diff line number Diff line change @@ -157,15 +157,22 @@ export class QueryInfo {
157157 }
158158
159159 /**
160- * Holds if this query should produce interpreted results.
160+ * Holds if this query can in principle produce interpreted results.
161161 */
162- async hasInterpretedResults ( ) : Promise < boolean > {
162+ async canHaveInterpretedResults ( ) : Promise < boolean > {
163163 const hasMetadataFile = await this . dbItem . hasMetadataFile ( ) ;
164164 if ( ! hasMetadataFile ) {
165165 logger . log ( "Cannot produce interpreted results since the database does not have a .dbinfo or codeql-database.yml file." ) ;
166166 }
167167 return hasMetadataFile ;
168168 }
169+
170+ /**
171+ * Holds if this query actually has produced interpreted results.
172+ */
173+ hasInterpretedResults ( ) : boolean {
174+ return fs . existsSync ( this . resultsPaths . interpretedResultsPath ) ;
175+ }
169176}
170177
171178export interface QueryWithResults {
You can’t perform that action at this time.
0 commit comments