File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ import { spawnIdeServer } from './ide-server';
4343import { InterfaceManager } from './interface' ;
4444import { WebviewReveal } from './interface-utils' ;
4545import { ideServerLogger , logger , queryServerLogger } from './logging' ;
46- import { QueryHistoryManager } from './query-history' ;
46+ import { QueryHistoryManager , updateTreeItemContextValue } from './query-history' ;
4747import { CompletedQuery } from './query-results' ;
4848import * as qsClient from './queryserver-client' ;
4949import { displayQuickQuery } from './quick-query' ;
@@ -406,6 +406,10 @@ async function activateWithInstalledDistribution(
406406 ) ;
407407 const item = qhm . addQuery ( info ) ;
408408 await showResultsForCompletedQuery ( item , WebviewReveal . NotForced ) ;
409+ // The call to showResults potentially creates SARIF file;
410+ // Update the tree item context value to allow viewing that
411+ // SARIF file from context menu.
412+ await updateTreeItemContextValue ( item ) ;
409413 } catch ( e ) {
410414 if ( e instanceof UserCancellationException ) {
411415 if ( e . silent ) {
Original file line number Diff line number Diff line change @@ -50,6 +50,15 @@ const SHOW_QUERY_TEXT_QUICK_EVAL_MSG = `\
5050 */
5151const FAILED_QUERY_HISTORY_ITEM_ICON = 'media/red-x.svg' ;
5252
53+ export async function updateTreeItemContextValue ( element : CompletedQuery ) : Promise < void > {
54+ // Mark this query history item according to whether it has a
55+ // SARIF file so that we can make context menu items conditionally
56+ // available.
57+ element . treeItem ! . contextValue = ( await element . query . hasInterpretedResults ( ) )
58+ ? 'interpretedResultsItem'
59+ : 'rawResultsItem' ;
60+ }
61+
5362/**
5463 * Tree data provider for the query history view.
5564 */
@@ -77,6 +86,9 @@ class HistoryTreeDataProvider
7786 constructor ( private ctx : ExtensionContext ) { }
7887
7988 async getTreeItem ( element : CompletedQuery ) : Promise < vscode . TreeItem > {
89+ if ( element . treeItem !== undefined )
90+ return element . treeItem ;
91+
8092 const it = new vscode . TreeItem ( element . toString ( ) ) ;
8193
8294 it . command = {
@@ -85,12 +97,8 @@ class HistoryTreeDataProvider
8597 arguments : [ element ] ,
8698 } ;
8799
88- // Mark this query history item according to whether it has a
89- // SARIF file so that we can make context menu items conditionally
90- // available.
91- it . contextValue = ( await element . query . hasInterpretedResults ( ) )
92- ? 'interpretedResultsItem'
93- : 'rawResultsItem' ;
100+ element . treeItem = it ;
101+ updateTreeItemContextValue ( element ) ;
94102
95103 if ( ! element . didRunSuccessfully ) {
96104 it . iconPath = path . join (
Original file line number Diff line number Diff line change 1- import { env } from 'vscode' ;
1+ import { env , TreeItem } from 'vscode' ;
22
33import { QueryWithResults , tmpDir , QueryInfo } from './run-queries' ;
44import * as messages from './messages' ;
@@ -17,6 +17,7 @@ export class CompletedQuery implements QueryWithResults {
1717 readonly database : DatabaseInfo ;
1818 readonly logFileLocation ?: string ;
1919 options : QueryHistoryItemOptions ;
20+ treeItem ?: TreeItem ;
2021 dispose : ( ) => void ;
2122
2223 /**
You can’t perform that action at this time.
0 commit comments