Skip to content

Commit d49c2d7

Browse files
committed
Add getRawName helper function to query-history-info
1 parent 01d7329 commit d49c2d7

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

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

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { env } from 'vscode';
22
import * as path from 'path';
33
import { QueryHistoryConfig } from './config';
44
import { LocalQueryInfo } from './query-results';
5-
import { QueryHistoryInfo } from './query-history-info';
5+
import { getRawName, QueryHistoryInfo } from './query-history-info';
66
import { RemoteQueryHistoryItem } from './remote-queries/remote-query-history-item';
77
import { pluralize } from './helpers';
88
import { VariantAnalysisHistoryItem } from './remote-queries/variant-analysis-history-item';
@@ -51,20 +51,9 @@ export class HistoryItemLabelProvider {
5151
* @returns the name of the query, unless there is a custom label for this query.
5252
*/
5353
getShortLabel(item: QueryHistoryInfo): string {
54-
if (item.userSpecifiedLabel) {
55-
return this.getLabel(item);
56-
} else {
57-
switch (item.t) {
58-
case 'local':
59-
return item.getQueryName();
60-
case 'remote':
61-
return item.remoteQuery.queryName;
62-
case 'variant-analysis':
63-
return item.variantAnalysis.query.name;
64-
default:
65-
assertNever(item);
66-
}
67-
}
54+
return item.userSpecifiedLabel
55+
? this.getLabel(item)
56+
: getRawName(item);
6857
}
6958

7059

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
import { RemoteQueryHistoryItem } from './remote-queries/remote-query-history-item';
22
import { VariantAnalysisHistoryItem } from './remote-queries/variant-analysis-history-item';
33
import { LocalQueryInfo } from './query-results';
4+
import { assertNever } from './pure/helpers-pure';
45

56
export type QueryHistoryInfo = LocalQueryInfo | RemoteQueryHistoryItem | VariantAnalysisHistoryItem;
67

8+
export function getRawName(item: QueryHistoryInfo): string {
9+
switch (item.t) {
10+
case 'local':
11+
return item.getQueryName();
12+
case 'remote':
13+
return item.remoteQuery.queryName;
14+
case 'variant-analysis':
15+
return item.variantAnalysis.query.name;
16+
default:
17+
assertNever(item);
18+
}
19+
}

0 commit comments

Comments
 (0)