Skip to content

Commit c4fe868

Browse files
committed
Add a way to show language for qury history.
1 parent c43d0fa commit c4fe868

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

extensions/ql-vscode/src/query-history/history-item-label-provider.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { QueryHistoryConfig } from "../config";
44
import { LocalQueryInfo } from "../query-results";
55
import {
66
buildRepoLabel,
7+
getLanguage,
78
getRawQueryName,
89
QueryHistoryInfo,
910
} from "./query-history-info";
@@ -19,6 +20,7 @@ interface InterpolateReplacements {
1920
r: string; // Result count/Empty
2021
s: string; // Status
2122
f: string; // Query file name
23+
l: string; // Query language
2224
"%": "%"; // Percent sign
2325
}
2426

@@ -84,6 +86,7 @@ export class HistoryItemLabelProvider {
8486
r: `(${resultCount} results)`,
8587
s: statusString,
8688
f: item.getQueryFileName(),
89+
l: this.getLanguageLabel(item),
8790
"%": "%",
8891
};
8992
}
@@ -103,7 +106,13 @@ export class HistoryItemLabelProvider {
103106
r: resultCount,
104107
s: humanizeQueryStatus(item.status),
105108
f: basename(item.variantAnalysis.query.filePath),
109+
l: this.getLanguageLabel(item),
106110
"%": "%",
107111
};
108112
}
113+
114+
private getLanguageLabel(item: QueryHistoryInfo): string {
115+
const language = getLanguage(item);
116+
return language === undefined ? "unknown" : `${language}`;
117+
}
109118
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
hasRepoScanCompleted,
77
getActionsWorkflowRunUrl as getVariantAnalysisActionsWorkflowRunUrl,
88
} from "../variant-analysis/shared/variant-analysis";
9+
import { QueryLanguage } from "../common/query-language";
910

1011
export type QueryHistoryInfo = LocalQueryInfo | VariantAnalysisHistoryItem;
1112

@@ -49,6 +50,17 @@ export function getQueryText(item: QueryHistoryInfo): string {
4950
}
5051
}
5152

53+
export function getLanguage(item: QueryHistoryInfo): QueryLanguage | undefined {
54+
switch (item.t) {
55+
case "local":
56+
return item.initialInfo.databaseInfo.language;
57+
case "variant-analysis":
58+
return item.variantAnalysis.query.language;
59+
default:
60+
assertNever(item);
61+
}
62+
}
63+
5264
export function buildRepoLabel(item: VariantAnalysisHistoryItem): string {
5365
const totalScannedRepositoryCount =
5466
item.variantAnalysis.scannedRepos?.length ?? 0;

0 commit comments

Comments
 (0)