Skip to content

Commit 45b32e9

Browse files
Address review comments from @aeisenberg
1 parent b31b26f commit 45b32e9

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
@@ -759,13 +759,15 @@ export class QueryHistoryManager extends DisposableObject {
759759
singleItem: QueryHistoryInfo,
760760
multiSelect: QueryHistoryInfo[]
761761
) {
762-
// Local queries only
763-
if (!this.assertSingleQuery(multiSelect) || singleItem?.t !== 'local') {
762+
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);
763+
764+
// Only applicable to an individual local query
765+
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem || finalSingleItem.t !== 'local') {
764766
return;
765767
}
766768

767-
if (singleItem.evalLogLocation) {
768-
await this.tryOpenExternalFile(singleItem.evalLogLocation);
769+
if (finalSingleItem.evalLogLocation) {
770+
await this.tryOpenExternalFile(finalSingleItem.evalLogLocation);
769771
} else {
770772
this.warnNoEvalLog();
771773
}
@@ -775,17 +777,18 @@ export class QueryHistoryManager extends DisposableObject {
775777
singleItem: QueryHistoryInfo,
776778
multiSelect: QueryHistoryInfo[]
777779
) {
778-
// Local queries only
779-
if (!this.assertSingleQuery(multiSelect) || singleItem?.t !== 'local') {
780+
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);
781+
782+
// Only applicable to an individual local query
783+
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem || finalSingleItem.t !== 'local') {
780784
return;
781785
}
782786

783-
if (singleItem.evalLogLocation) {
784-
const summaryLocation = singleItem.evalLogLocation + '.summary';
785-
if (!fs.existsSync(summaryLocation)) {
786-
await this.qs.cliServer.generateLogSummary(singleItem.evalLogLocation, summaryLocation);
787+
if (finalSingleItem.evalLogLocation) {
788+
if (!fs.existsSync(finalSingleItem.evalLogSummaryLocation)) {
789+
await this.qs.cliServer.generateLogSummary(finalSingleItem.evalLogLocation, finalSingleItem.evalLogSummaryLocation);
787790
}
788-
await this.tryOpenExternalFile(summaryLocation);
791+
await this.tryOpenExternalFile(finalSingleItem.evalLogSummaryLocation);
789792
} else {
790793
this.warnNoEvalLog();
791794
}

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
@@ -675,7 +675,7 @@ export async function compileAndRunQueryAgainstDatabase(
675675
progress: ProgressCallback,
676676
token: CancellationToken,
677677
templates?: messages.TemplateDefinitions,
678-
queryInfo?: LocalQueryInfo,
678+
queryInfo?: LocalQueryInfo, // May be omitted for queries not initiated by the user. If omitted we won't create a structured log for the query.
679679
): Promise<QueryWithResults> {
680680
if (!dbItem.contents || !dbItem.contents.dbSchemeUri) {
681681
throw new Error(`Database ${dbItem.databaseUri} does not have a CodeQL database scheme.`);

0 commit comments

Comments
 (0)