Skip to content

Commit 4f04f9d

Browse files
authored
Merge pull request #1179 from github/aeisenberg/open-query-folder
Add new command to open the query history directory
2 parents f28c1f9 + 025a1a1 commit 4f04f9d

5 files changed

Lines changed: 51 additions & 3 deletions

File tree

extensions/ql-vscode/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Open the query server logs for query errors (instead of the extension log). This will make it easier to track down query errors. [#1158](https://github.com/github/vscode-codeql/pull/1158)
77
- Fix a bug where queries took a long time to run if there are no folders in the workspace. [#1157](https://github.com/github/vscode-codeql/pull/1157)
88
- [BREAKING CHANGE] The `codeQL.runningQueries.customLogDirectory` setting is deprecated and no longer has any function. Instead, all query log files will be stored in the query history directory, next to the query results. [#1178](https://github.com/github/vscode-codeql/pull/1178)
9+
- Add a _Open query directory_ command for query items. This command opens the directory containing all artifacts for a query. [#1179](https://github.com/github/vscode-codeql/pull/1179)
910

1011
## 1.5.11 - 10 February 2022
1112

extensions/ql-vscode/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,10 @@
508508
"command": "codeQLQueryHistory.showQueryLog",
509509
"title": "Show Query Log"
510510
},
511+
{
512+
"command": "codeQLQueryHistory.openQueryDirectory",
513+
"title": "Open query directory"
514+
},
511515
{
512516
"command": "codeQLQueryHistory.cancel",
513517
"title": "Cancel"
@@ -697,6 +701,11 @@
697701
"group": "9_qlCommands",
698702
"when": "viewItem == rawResultsItem || viewItem == interpretedResultsItem"
699703
},
704+
{
705+
"command": "codeQLQueryHistory.openQueryDirectory",
706+
"group": "9_qlCommands",
707+
"when": "view == codeQLQueryHistory && !hasRemoteServer"
708+
},
700709
{
701710
"command": "codeQLQueryHistory.showQueryText",
702711
"group": "9_qlCommands",
@@ -887,6 +896,10 @@
887896
"command": "codeQLQueryHistory.showQueryLog",
888897
"when": "false"
889898
},
899+
{
900+
"command": "codeQLQueryHistory.openQueryDirectory",
901+
"when": "false"
902+
},
890903
{
891904
"command": "codeQLQueryHistory.cancel",
892905
"when": "false"

extensions/ql-vscode/src/query-history.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,12 @@ export class QueryHistoryManager extends DisposableObject {
400400
this.handleShowQueryLog.bind(this)
401401
)
402402
);
403+
this.push(
404+
commandRunner(
405+
'codeQLQueryHistory.openQueryDirectory',
406+
this.handleOpenQueryDirectory.bind(this)
407+
)
408+
);
403409
this.push(
404410
commandRunner(
405411
'codeQLQueryHistory.cancel',
@@ -703,6 +709,34 @@ export class QueryHistoryManager extends DisposableObject {
703709
}
704710
}
705711

712+
async handleOpenQueryDirectory(
713+
singleItem: QueryHistoryInfo,
714+
multiSelect: QueryHistoryInfo[]
715+
) {
716+
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);
717+
718+
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
719+
return;
720+
}
721+
722+
let p: string | undefined;
723+
if (finalSingleItem.t === 'local') {
724+
if (finalSingleItem.completedQuery) {
725+
p = finalSingleItem.completedQuery.query.querySaveDir;
726+
}
727+
} else if (finalSingleItem.t === 'remote') {
728+
p = path.join(this.queryStorageDir, finalSingleItem.queryId);
729+
}
730+
731+
if (p) {
732+
try {
733+
await commands.executeCommand('revealFileInOS', Uri.file(p));
734+
} catch (e) {
735+
throw new Error(`Failed to open ${p}: ${e.message}`);
736+
}
737+
}
738+
}
739+
706740
async handleCancel(
707741
singleItem: QueryHistoryInfo,
708742
multiSelect: QueryHistoryInfo[]

extensions/ql-vscode/src/remote-queries/remote-query-history-item.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ export interface RemoteQueryHistoryItem {
1010
status: QueryStatus;
1111
completed: boolean;
1212
readonly queryId: string,
13-
label: string, // TODO, the query label should have interpolation like local queries
14-
remoteQuery: RemoteQuery,
13+
label: string; // TODO, the query label should have interpolation like local queries
14+
remoteQuery: RemoteQuery;
1515
}

extensions/ql-vscode/src/run-queries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class QueryEvaluationInfo {
6767
* by explicitly setting the prototype in order to avoid calling this constructor.
6868
*/
6969
constructor(
70-
private readonly querySaveDir: string,
70+
public readonly querySaveDir: string,
7171
public readonly dbItemPath: string,
7272
private readonly databaseHasMetadataFile: boolean,
7373
public readonly queryDbscheme: string, // the dbscheme file the query expects, based on library path resolution

0 commit comments

Comments
 (0)