Skip to content

Commit 9ac8a15

Browse files
Address review comments from @aeisenberg
1 parent 81b8104 commit 9ac8a15

3 files changed

Lines changed: 23 additions & 12 deletions

File tree

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -767,13 +767,15 @@ export class QueryHistoryManager extends DisposableObject {
767767
singleItem: QueryHistoryInfo,
768768
multiSelect: QueryHistoryInfo[]
769769
) {
770-
// Local queries only
771-
if (!this.assertSingleQuery(multiSelect) || singleItem?.t !== 'local') {
770+
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);
771+
772+
// Only applicable to an individual local query
773+
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem || finalSingleItem.t !== 'local') {
772774
return;
773775
}
774776

775-
if (singleItem.evalLogLocation) {
776-
await this.tryOpenExternalFile(singleItem.evalLogLocation);
777+
if (finalSingleItem.evalLogLocation) {
778+
await this.tryOpenExternalFile(finalSingleItem.evalLogLocation);
777779
} else {
778780
this.warnNoEvalLog();
779781
}
@@ -783,17 +785,18 @@ export class QueryHistoryManager extends DisposableObject {
783785
singleItem: QueryHistoryInfo,
784786
multiSelect: QueryHistoryInfo[]
785787
) {
786-
// Local queries only
787-
if (!this.assertSingleQuery(multiSelect) || singleItem?.t !== 'local') {
788+
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);
789+
790+
// Only applicable to an individual local query
791+
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem || finalSingleItem.t !== 'local') {
788792
return;
789793
}
790794

791-
if (singleItem.evalLogLocation) {
792-
const summaryLocation = singleItem.evalLogLocation + '.summary';
793-
if (!fs.existsSync(summaryLocation)) {
794-
await this.qs.cliServer.generateLogSummary(singleItem.evalLogLocation, summaryLocation);
795+
if (finalSingleItem.evalLogLocation) {
796+
if (!fs.existsSync(finalSingleItem.evalLogSummaryLocation)) {
797+
await this.qs.cliServer.generateLogSummary(finalSingleItem.evalLogLocation, finalSingleItem.evalLogSummaryLocation);
795798
}
796-
await this.tryOpenExternalFile(summaryLocation);
799+
await this.tryOpenExternalFile(finalSingleItem.evalLogSummaryLocation);
797800
} else {
798801
this.warnNoEvalLog();
799802
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,14 @@ export class LocalQueryInfo {
312312
}
313313
}
314314

315+
/**
316+
* Return the location of a query's evaluator log summary. This file may not exist yet,
317+
* in which case it can be created by invoking `codeql generate log-summary`.
318+
*/
319+
get evalLogSummaryLocation(): string {
320+
return this.evalLogLocation + '.summary';
321+
}
322+
315323
get completed(): boolean {
316324
return !!this.completedQuery;
317325
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ export async function compileAndRunQueryAgainstDatabase(
676676
progress: ProgressCallback,
677677
token: CancellationToken,
678678
templates?: messages.TemplateDefinitions,
679-
queryInfo?: LocalQueryInfo,
679+
queryInfo?: LocalQueryInfo, // May be omitted for queries not initiated by the user. If omitted we won't create a structured log for the query.
680680
): Promise<QueryWithResults> {
681681
if (!dbItem.contents || !dbItem.contents.dbSchemeUri) {
682682
throw new Error(`Database ${dbItem.databaseUri} does not have a CodeQL database scheme.`);

0 commit comments

Comments
 (0)