Simplify query history type checks
This commit is contained in:
@@ -22,7 +22,7 @@ export function getRawQueryName(item: QueryHistoryInfo): string {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an identifier for the query history item which could be
|
* Gets an identifier for the query history item which could be
|
||||||
* a local/remote query or a variant analysis. This id isn't guaranteed
|
* a local query or a variant analysis. This id isn't guaranteed
|
||||||
* to be unique for each item in the query history.
|
* to be unique for each item in the query history.
|
||||||
* @param item the history item.
|
* @param item the history item.
|
||||||
* @returns the id of the query or variant analysis.
|
* @returns the id of the query or variant analysis.
|
||||||
|
|||||||
@@ -755,14 +755,12 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
) {
|
) {
|
||||||
// show original query file on double click
|
// show original query file on double click
|
||||||
await this.handleOpenQuery(finalSingleItem, [finalSingleItem]);
|
await this.handleOpenQuery(finalSingleItem, [finalSingleItem]);
|
||||||
} else {
|
} else if (
|
||||||
|
finalSingleItem.t === "variant-analysis" ||
|
||||||
|
finalSingleItem.status === QueryStatus.Completed
|
||||||
|
) {
|
||||||
// show results on single click (if results view is available)
|
// show results on single click (if results view is available)
|
||||||
if (
|
await this.openQueryResults(finalSingleItem);
|
||||||
finalSingleItem.t === "variant-analysis" ||
|
|
||||||
finalSingleItem.status === QueryStatus.Completed
|
|
||||||
) {
|
|
||||||
await this.openQueryResults(finalSingleItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -797,6 +795,8 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
return this.variantAnalysisManager.getVariantAnalysisStorageLocation(
|
return this.variantAnalysisManager.getVariantAnalysisStorageLocation(
|
||||||
queryHistoryItem.variantAnalysis.id,
|
queryHistoryItem.variantAnalysis.id,
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
assertNever(queryHistoryItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error("Unable to get query directory");
|
throw new Error("Unable to get query directory");
|
||||||
@@ -830,6 +830,8 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
),
|
),
|
||||||
"timestamp",
|
"timestamp",
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
assertNever(finalSingleItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (externalFilePath) {
|
if (externalFilePath) {
|
||||||
@@ -994,6 +996,8 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
"codeQL.cancelVariantAnalysis",
|
"codeQL.cancelVariantAnalysis",
|
||||||
item.variantAnalysis.id,
|
item.variantAnalysis.id,
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
assertNever(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1185,17 +1189,19 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
multiSelect,
|
multiSelect,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Remote queries only
|
// Variant analyses only
|
||||||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
|
if (
|
||||||
|
!this.assertSingleQuery(finalMultiSelect) ||
|
||||||
|
!finalSingleItem ||
|
||||||
|
finalSingleItem.t !== "variant-analysis"
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalSingleItem.t === "variant-analysis") {
|
await commands.executeCommand(
|
||||||
await commands.executeCommand(
|
"codeQL.copyVariantAnalysisRepoList",
|
||||||
"codeQL.copyVariantAnalysisRepoList",
|
finalSingleItem.variantAnalysis.id,
|
||||||
finalSingleItem.variantAnalysis.id,
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleExportResults(
|
async handleExportResults(
|
||||||
@@ -1207,17 +1213,19 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
multiSelect,
|
multiSelect,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
|
// Variant analysis only
|
||||||
|
if (
|
||||||
|
!this.assertSingleQuery(finalMultiSelect) ||
|
||||||
|
!finalSingleItem ||
|
||||||
|
finalSingleItem.t !== "variant-analysis"
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variant analysis only
|
await commands.executeCommand(
|
||||||
if (finalSingleItem.t === "variant-analysis") {
|
"codeQL.exportVariantAnalysisResults",
|
||||||
await commands.executeCommand(
|
finalSingleItem.variantAnalysis.id,
|
||||||
"codeQL.exportVariantAnalysisResults",
|
);
|
||||||
finalSingleItem.variantAnalysis.id,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addQuery(item: QueryHistoryInfo) {
|
addQuery(item: QueryHistoryInfo) {
|
||||||
@@ -1290,7 +1298,7 @@ the file in the file explorer and dragging it into the workspace.`,
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[],
|
multiSelect: QueryHistoryInfo[],
|
||||||
): Promise<CompletedLocalQueryInfo | undefined> {
|
): Promise<CompletedLocalQueryInfo | undefined> {
|
||||||
// Remote queries cannot be compared
|
// Variant analyses cannot be compared
|
||||||
if (
|
if (
|
||||||
singleItem.t !== "local" ||
|
singleItem.t !== "local" ||
|
||||||
multiSelect.some((s) => s.t !== "local") ||
|
multiSelect.some((s) => s.t !== "local") ||
|
||||||
|
|||||||
Reference in New Issue
Block a user