Remove the determineSelection method
This commit is contained in:
@@ -396,38 +396,34 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async handleOpenQuery(
|
async handleOpenQuery(
|
||||||
singleItem: QueryHistoryInfo | undefined,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
if (!this.assertSingleQuery(multiSelect)) {
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalSingleItem.t === "variant-analysis") {
|
if (singleItem.t === "variant-analysis") {
|
||||||
await this.variantAnalysisManager.openQueryFile(
|
await this.variantAnalysisManager.openQueryFile(
|
||||||
finalSingleItem.variantAnalysis.id,
|
singleItem.variantAnalysis.id,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let queryPath: string;
|
let queryPath: string;
|
||||||
switch (finalSingleItem.t) {
|
switch (singleItem.t) {
|
||||||
case "local":
|
case "local":
|
||||||
queryPath = finalSingleItem.initialInfo.queryPath;
|
queryPath = singleItem.initialInfo.queryPath;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assertNever(finalSingleItem);
|
assertNever(singleItem);
|
||||||
}
|
}
|
||||||
const textDocument = await workspace.openTextDocument(Uri.file(queryPath));
|
const textDocument = await workspace.openTextDocument(Uri.file(queryPath));
|
||||||
const editor = await window.showTextDocument(textDocument, ViewColumn.One);
|
const editor = await window.showTextDocument(textDocument, ViewColumn.One);
|
||||||
|
|
||||||
if (finalSingleItem.t === "local") {
|
if (singleItem.t === "local") {
|
||||||
const queryText = finalSingleItem.initialInfo.queryText;
|
const queryText = singleItem.initialInfo.queryText;
|
||||||
if (queryText !== undefined && finalSingleItem.initialInfo.isQuickQuery) {
|
if (queryText !== undefined && singleItem.initialInfo.isQuickQuery) {
|
||||||
await editor.edit((edit) =>
|
await editor.edit((edit) =>
|
||||||
edit.replace(
|
edit.replace(
|
||||||
textDocument.validateRange(
|
textDocument.validateRange(
|
||||||
@@ -459,16 +455,12 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async handleRemoveHistoryItem(
|
async handleRemoveHistoryItem(
|
||||||
singleItem: QueryHistoryInfo | undefined,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
) {
|
) {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
multiSelect ||= [singleItem];
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
const toDelete = finalMultiSelect || [finalSingleItem];
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
toDelete.map(async (item) => {
|
multiSelect.map(async (item) => {
|
||||||
if (item.t === "local") {
|
if (item.t === "local") {
|
||||||
// Removing in progress local queries is not supported. They must be cancelled first.
|
// Removing in progress local queries is not supported. They must be cancelled first.
|
||||||
if (item.status !== QueryStatus.InProgress) {
|
if (item.status !== QueryStatus.InProgress) {
|
||||||
@@ -562,18 +554,13 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
if (!this.assertSingleQuery(multiSelect)) {
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await window.showInputBox({
|
const response = await window.showInputBox({
|
||||||
placeHolder: `(use default: ${this.queryHistoryConfigListener.format})`,
|
placeHolder: `(use default: ${this.queryHistoryConfigListener.format})`,
|
||||||
value: finalSingleItem.userSpecifiedLabel ?? "",
|
value: singleItem.userSpecifiedLabel ?? "",
|
||||||
title: "Set query label",
|
title: "Set query label",
|
||||||
prompt:
|
prompt:
|
||||||
"Set the query history item label. See the description of the codeQL.queryHistory.format setting for more information.",
|
"Set the query history item label. See the description of the codeQL.queryHistory.format setting for more information.",
|
||||||
@@ -581,8 +568,7 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
// undefined response means the user cancelled the dialog; don't change anything
|
// undefined response means the user cancelled the dialog; don't change anything
|
||||||
if (response !== undefined) {
|
if (response !== undefined) {
|
||||||
// Interpret empty string response as 'go back to using default'
|
// Interpret empty string response as 'go back to using default'
|
||||||
finalSingleItem.userSpecifiedLabel =
|
singleItem.userSpecifiedLabel = response === "" ? undefined : response;
|
||||||
response === "" ? undefined : response;
|
|
||||||
await this.refreshTreeView();
|
await this.refreshTreeView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -591,25 +577,22 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
) {
|
) {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
multiSelect ||= [singleItem];
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// local queries only
|
// local queries only
|
||||||
if (finalSingleItem?.t !== "local") {
|
if (singleItem?.t !== "local") {
|
||||||
throw new Error("Please select a local query.");
|
throw new Error("Please select a local query.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!finalSingleItem.completedQuery?.successful) {
|
if (!singleItem.completedQuery?.successful) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Please select a query that has completed successfully.",
|
"Please select a query that has completed successfully.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const from = this.compareWithItem || singleItem;
|
const from = this.compareWithItem || singleItem;
|
||||||
const to = await this.findOtherQueryToCompare(from, finalMultiSelect);
|
const to = await this.findOtherQueryToCompare(from, multiSelect);
|
||||||
|
|
||||||
if (from.completed && to?.completed) {
|
if (from.completed && to?.completed) {
|
||||||
await this.doCompareCallback(
|
await this.doCompareCallback(
|
||||||
@@ -627,36 +610,32 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async handleItemClicked(
|
async handleItemClicked(
|
||||||
singleItem: QueryHistoryInfo | undefined,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
) {
|
) {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
if (!this.assertSingleQuery(multiSelect)) {
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.treeDataProvider.setCurrentItem(finalSingleItem);
|
this.treeDataProvider.setCurrentItem(singleItem);
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const prevItemClick = this.lastItemClick;
|
const prevItemClick = this.lastItemClick;
|
||||||
this.lastItemClick = { time: now, item: finalSingleItem };
|
this.lastItemClick = { time: now, item: singleItem };
|
||||||
|
|
||||||
if (
|
if (
|
||||||
prevItemClick !== undefined &&
|
prevItemClick !== undefined &&
|
||||||
now.valueOf() - prevItemClick.time.valueOf() < DOUBLE_CLICK_TIME &&
|
now.valueOf() - prevItemClick.time.valueOf() < DOUBLE_CLICK_TIME &&
|
||||||
finalSingleItem === prevItemClick.item
|
singleItem === prevItemClick.item
|
||||||
) {
|
) {
|
||||||
// show original query file on double click
|
// show original query file on double click
|
||||||
await this.handleOpenQuery(finalSingleItem, [finalSingleItem]);
|
await this.handleOpenQuery(singleItem, [singleItem]);
|
||||||
} else if (
|
} else if (
|
||||||
finalSingleItem.t === "variant-analysis" ||
|
singleItem.t === "variant-analysis" ||
|
||||||
finalSingleItem.status === QueryStatus.Completed
|
singleItem.status === QueryStatus.Completed
|
||||||
) {
|
) {
|
||||||
// show results on single click (if results view is available)
|
// show results on single click (if results view is available)
|
||||||
await this.openQueryResults(finalSingleItem);
|
await this.openQueryResults(singleItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -705,32 +684,27 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
) {
|
) {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
if (!this.assertSingleQuery(multiSelect)) {
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let externalFilePath: string | undefined;
|
let externalFilePath: string | undefined;
|
||||||
if (finalSingleItem.t === "local") {
|
if (singleItem.t === "local") {
|
||||||
if (finalSingleItem.completedQuery) {
|
if (singleItem.completedQuery) {
|
||||||
externalFilePath = join(
|
externalFilePath = join(
|
||||||
finalSingleItem.completedQuery.query.querySaveDir,
|
singleItem.completedQuery.query.querySaveDir,
|
||||||
"timestamp",
|
"timestamp",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (finalSingleItem.t === "variant-analysis") {
|
} else if (singleItem.t === "variant-analysis") {
|
||||||
externalFilePath = join(
|
externalFilePath = join(
|
||||||
this.variantAnalysisManager.getVariantAnalysisStorageLocation(
|
this.variantAnalysisManager.getVariantAnalysisStorageLocation(
|
||||||
finalSingleItem.variantAnalysis.id,
|
singleItem.variantAnalysis.id,
|
||||||
),
|
),
|
||||||
"timestamp",
|
"timestamp",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
assertNever(finalSingleItem);
|
assertNever(singleItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (externalFilePath) {
|
if (externalFilePath) {
|
||||||
@@ -779,25 +753,13 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
) {
|
) {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Only applicable to an individual local query
|
// Only applicable to an individual local query
|
||||||
if (
|
if (!this.assertSingleQuery(multiSelect) || singleItem.t !== "local") {
|
||||||
!this.assertSingleQuery(finalMultiSelect) ||
|
|
||||||
!finalSingleItem ||
|
|
||||||
finalSingleItem.t !== "local"
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalSingleItem.evalLogLocation) {
|
if (singleItem.evalLogLocation) {
|
||||||
await tryOpenExternalFile(
|
await tryOpenExternalFile(this.app.commands, singleItem.evalLogLocation);
|
||||||
this.app.commands,
|
|
||||||
finalSingleItem.evalLogLocation,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
this.warnNoEvalLogs();
|
this.warnNoEvalLogs();
|
||||||
}
|
}
|
||||||
@@ -807,32 +769,23 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
) {
|
) {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Only applicable to an individual local query
|
// Only applicable to an individual local query
|
||||||
if (
|
if (!this.assertSingleQuery(multiSelect) || singleItem.t !== "local") {
|
||||||
!this.assertSingleQuery(finalMultiSelect) ||
|
|
||||||
!finalSingleItem ||
|
|
||||||
finalSingleItem.t !== "local"
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalSingleItem.evalLogSummaryLocation) {
|
if (singleItem.evalLogSummaryLocation) {
|
||||||
await tryOpenExternalFile(
|
await tryOpenExternalFile(
|
||||||
this.app.commands,
|
this.app.commands,
|
||||||
finalSingleItem.evalLogSummaryLocation,
|
singleItem.evalLogSummaryLocation,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Summary log file doesn't exist.
|
// Summary log file doesn't exist.
|
||||||
if (
|
if (
|
||||||
finalSingleItem.evalLogLocation &&
|
singleItem.evalLogLocation &&
|
||||||
(await pathExists(finalSingleItem.evalLogLocation))
|
(await pathExists(singleItem.evalLogLocation))
|
||||||
) {
|
) {
|
||||||
// If raw log does exist, then the summary log is still being generated.
|
// If raw log does exist, then the summary log is still being generated.
|
||||||
this.warnInProgressEvalLogSummary();
|
this.warnInProgressEvalLogSummary();
|
||||||
@@ -845,21 +798,13 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
) {
|
) {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
// Only applicable to an individual local query
|
// Only applicable to an individual local query
|
||||||
if (
|
if (!this.assertSingleQuery(multiSelect) || singleItem.t !== "local") {
|
||||||
!this.assertSingleQuery(finalMultiSelect) ||
|
|
||||||
!finalSingleItem ||
|
|
||||||
finalSingleItem.t !== "local"
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the JSON summary file location wasn't saved, display error
|
// If the JSON summary file location wasn't saved, display error
|
||||||
if (finalSingleItem.jsonEvalLogSummaryLocation === undefined) {
|
if (singleItem.jsonEvalLogSummaryLocation === undefined) {
|
||||||
this.warnInProgressEvalLogViewer();
|
this.warnInProgressEvalLogViewer();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -867,16 +812,16 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
// TODO(angelapwen): Stream the file in.
|
// TODO(angelapwen): Stream the file in.
|
||||||
try {
|
try {
|
||||||
const evalLogData: EvalLogData[] = await parseViewerData(
|
const evalLogData: EvalLogData[] = await parseViewerData(
|
||||||
finalSingleItem.jsonEvalLogSummaryLocation,
|
singleItem.jsonEvalLogSummaryLocation,
|
||||||
);
|
);
|
||||||
const evalLogTreeBuilder = new EvalLogTreeBuilder(
|
const evalLogTreeBuilder = new EvalLogTreeBuilder(
|
||||||
finalSingleItem.getQueryName(),
|
singleItem.getQueryName(),
|
||||||
evalLogData,
|
evalLogData,
|
||||||
);
|
);
|
||||||
this.evalLogViewer.updateRoots(await evalLogTreeBuilder.getRoots());
|
this.evalLogViewer.updateRoots(await evalLogTreeBuilder.getRoots());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Could not read evaluator log summary JSON file to generate viewer data at ${finalSingleItem.jsonEvalLogSummaryLocation}.`,
|
`Could not read evaluator log summary JSON file to generate viewer data at ${singleItem.jsonEvalLogSummaryLocation}.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -885,14 +830,9 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
) {
|
) {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
multiSelect ||= [singleItem];
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
|
|
||||||
const selected = finalMultiSelect || [finalSingleItem];
|
const results = multiSelect.map(async (item) => {
|
||||||
|
|
||||||
const results = selected.map(async (item) => {
|
|
||||||
if (item.status === QueryStatus.InProgress) {
|
if (item.status === QueryStatus.InProgress) {
|
||||||
if (item.t === "local") {
|
if (item.t === "local") {
|
||||||
item.cancel();
|
item.cancel();
|
||||||
@@ -913,18 +853,13 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] = [],
|
multiSelect: QueryHistoryInfo[] = [],
|
||||||
) {
|
) {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
if (!this.assertSingleQuery(multiSelect)) {
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalSingleItem.t === "variant-analysis") {
|
if (singleItem.t === "variant-analysis") {
|
||||||
await this.variantAnalysisManager.openQueryText(
|
await this.variantAnalysisManager.openQueryText(
|
||||||
finalSingleItem.variantAnalysis.id,
|
singleItem.variantAnalysis.id,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -932,14 +867,13 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
isQuickEval: String(
|
isQuickEval: String(
|
||||||
!!(
|
!!(
|
||||||
finalSingleItem.t === "local" &&
|
singleItem.t === "local" && singleItem.initialInfo.quickEvalPosition
|
||||||
finalSingleItem.initialInfo.quickEvalPosition
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
queryText: encodeURIComponent(getQueryText(finalSingleItem)),
|
queryText: encodeURIComponent(getQueryText(singleItem)),
|
||||||
});
|
});
|
||||||
|
|
||||||
const queryId = getQueryId(finalSingleItem);
|
const queryId = getQueryId(singleItem);
|
||||||
|
|
||||||
const uri = Uri.parse(`codeql:${queryId}.ql?${params.toString()}`, true);
|
const uri = Uri.parse(`codeql:${queryId}.ql?${params.toString()}`, true);
|
||||||
const doc = await workspace.openTextDocument(uri);
|
const doc = await workspace.openTextDocument(uri);
|
||||||
@@ -950,22 +884,16 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
) {
|
) {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Local queries only
|
// Local queries only
|
||||||
if (
|
if (
|
||||||
!this.assertSingleQuery(finalMultiSelect) ||
|
!this.assertSingleQuery(multiSelect) ||
|
||||||
!finalSingleItem ||
|
singleItem.t !== "local" ||
|
||||||
finalSingleItem.t !== "local" ||
|
!singleItem.completedQuery
|
||||||
!finalSingleItem.completedQuery
|
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = finalSingleItem.completedQuery.query;
|
const query = singleItem.completedQuery.query;
|
||||||
const hasInterpretedResults = query.canHaveInterpretedResults();
|
const hasInterpretedResults = query.canHaveInterpretedResults();
|
||||||
if (hasInterpretedResults) {
|
if (hasInterpretedResults) {
|
||||||
await tryOpenExternalFile(
|
await tryOpenExternalFile(
|
||||||
@@ -973,7 +901,7 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
query.resultsPaths.interpretedResultsPath,
|
query.resultsPaths.interpretedResultsPath,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const label = this.labelProvider.getLabel(finalSingleItem);
|
const label = this.labelProvider.getLabel(singleItem);
|
||||||
void showAndLogInformationMessage(
|
void showAndLogInformationMessage(
|
||||||
`Query ${label} has no interpreted results.`,
|
`Query ${label} has no interpreted results.`,
|
||||||
);
|
);
|
||||||
@@ -984,21 +912,15 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
) {
|
) {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Local queries only
|
// Local queries only
|
||||||
if (
|
if (
|
||||||
!this.assertSingleQuery(finalMultiSelect) ||
|
!this.assertSingleQuery(multiSelect) ||
|
||||||
!finalSingleItem ||
|
singleItem.t !== "local" ||
|
||||||
finalSingleItem.t !== "local" ||
|
!singleItem.completedQuery
|
||||||
!finalSingleItem.completedQuery
|
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const query = finalSingleItem.completedQuery.query;
|
const query = singleItem.completedQuery.query;
|
||||||
if (await query.hasCsv()) {
|
if (await query.hasCsv()) {
|
||||||
void tryOpenExternalFile(this.app.commands, query.csvPath);
|
void tryOpenExternalFile(this.app.commands, query.csvPath);
|
||||||
return;
|
return;
|
||||||
@@ -1012,24 +934,18 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
) {
|
) {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Local queries only
|
// Local queries only
|
||||||
if (
|
if (
|
||||||
!this.assertSingleQuery(finalMultiSelect) ||
|
!this.assertSingleQuery(multiSelect) ||
|
||||||
!finalSingleItem ||
|
singleItem.t !== "local" ||
|
||||||
finalSingleItem.t !== "local" ||
|
!singleItem.completedQuery
|
||||||
!finalSingleItem.completedQuery
|
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await tryOpenExternalFile(
|
await tryOpenExternalFile(
|
||||||
this.app.commands,
|
this.app.commands,
|
||||||
await finalSingleItem.completedQuery.query.ensureCsvAlerts(
|
await singleItem.completedQuery.query.ensureCsvAlerts(
|
||||||
this.qs.cliServer,
|
this.qs.cliServer,
|
||||||
this.dbm,
|
this.dbm,
|
||||||
),
|
),
|
||||||
@@ -1040,26 +956,18 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
) {
|
) {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Local queries only
|
// Local queries only
|
||||||
if (
|
if (
|
||||||
!this.assertSingleQuery(finalMultiSelect) ||
|
!this.assertSingleQuery(multiSelect) ||
|
||||||
!finalSingleItem ||
|
singleItem.t !== "local" ||
|
||||||
finalSingleItem.t !== "local" ||
|
!singleItem.completedQuery
|
||||||
!finalSingleItem.completedQuery
|
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await tryOpenExternalFile(
|
await tryOpenExternalFile(
|
||||||
this.app.commands,
|
this.app.commands,
|
||||||
await finalSingleItem.completedQuery.query.ensureDilPath(
|
await singleItem.completedQuery.query.ensureDilPath(this.qs.cliServer),
|
||||||
this.qs.cliServer,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1067,20 +975,14 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
) {
|
) {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
if (
|
||||||
singleItem,
|
!this.assertSingleQuery(multiSelect) ||
|
||||||
multiSelect,
|
singleItem.t !== "variant-analysis"
|
||||||
);
|
) {
|
||||||
|
|
||||||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalSingleItem.t === "local") {
|
const actionsWorkflowRunUrl = getActionsWorkflowRunUrl(singleItem);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const actionsWorkflowRunUrl = getActionsWorkflowRunUrl(finalSingleItem);
|
|
||||||
|
|
||||||
await this.app.commands.execute(
|
await this.app.commands.execute(
|
||||||
"vscode.open",
|
"vscode.open",
|
||||||
@@ -1092,23 +994,17 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
) {
|
) {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Variant analyses only
|
// Variant analyses only
|
||||||
if (
|
if (
|
||||||
!this.assertSingleQuery(finalMultiSelect) ||
|
!this.assertSingleQuery(multiSelect) ||
|
||||||
!finalSingleItem ||
|
singleItem.t !== "variant-analysis"
|
||||||
finalSingleItem.t !== "variant-analysis"
|
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.app.commands.execute(
|
await this.app.commands.execute(
|
||||||
"codeQL.copyVariantAnalysisRepoList",
|
"codeQL.copyVariantAnalysisRepoList",
|
||||||
finalSingleItem.variantAnalysis.id,
|
singleItem.variantAnalysis.id,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1116,22 +1012,16 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
singleItem: QueryHistoryInfo,
|
singleItem: QueryHistoryInfo,
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
multiSelect: QueryHistoryInfo[] | undefined,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
|
||||||
singleItem,
|
|
||||||
multiSelect,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Variant analysis only
|
// Variant analysis only
|
||||||
if (
|
if (
|
||||||
!this.assertSingleQuery(finalMultiSelect) ||
|
!this.assertSingleQuery(multiSelect) ||
|
||||||
!finalSingleItem ||
|
singleItem.t !== "variant-analysis"
|
||||||
finalSingleItem.t !== "variant-analysis"
|
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.variantAnalysisManager.exportResults(
|
await this.variantAnalysisManager.exportResults(
|
||||||
finalSingleItem.variantAnalysis.id,
|
singleItem.variantAnalysis.id,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1277,52 +1167,6 @@ export class QueryHistoryManager extends DisposableObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* If no items are selected, attempt to grab the selection from the treeview.
|
|
||||||
* However, often the treeview itself does not have any selection. In this case,
|
|
||||||
* grab the selection from the `treeDataProvider` current item.
|
|
||||||
*
|
|
||||||
* We need to use this method because when clicking on commands from the view title
|
|
||||||
* bar, the selections are not passed in.
|
|
||||||
*
|
|
||||||
* @param singleItem the single item selected, or undefined if no item is selected
|
|
||||||
* @param multiSelect a multi-select or undefined if no items are selected
|
|
||||||
*/
|
|
||||||
private determineSelection(
|
|
||||||
singleItem: QueryHistoryInfo | undefined,
|
|
||||||
multiSelect: QueryHistoryInfo[] | undefined,
|
|
||||||
): {
|
|
||||||
finalSingleItem: QueryHistoryInfo | undefined;
|
|
||||||
finalMultiSelect: QueryHistoryInfo[];
|
|
||||||
} {
|
|
||||||
if (!singleItem && !multiSelect?.[0]) {
|
|
||||||
const selection = this.treeView.selection;
|
|
||||||
const current = this.treeDataProvider.getCurrent();
|
|
||||||
if (selection?.length) {
|
|
||||||
return {
|
|
||||||
finalSingleItem: selection[0],
|
|
||||||
finalMultiSelect: [...selection],
|
|
||||||
};
|
|
||||||
} else if (current) {
|
|
||||||
return {
|
|
||||||
finalSingleItem: current,
|
|
||||||
finalMultiSelect: [current],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ensure we only return undefined if we have neither a single or multi-selecion
|
|
||||||
if (singleItem && !multiSelect?.[0]) {
|
|
||||||
multiSelect = [singleItem];
|
|
||||||
} else if (!singleItem && multiSelect?.[0]) {
|
|
||||||
singleItem = multiSelect[0];
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
finalSingleItem: singleItem,
|
|
||||||
finalMultiSelect: multiSelect || [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async refreshTreeView(): Promise<void> {
|
async refreshTreeView(): Promise<void> {
|
||||||
this.treeDataProvider.refresh();
|
this.treeDataProvider.refresh();
|
||||||
await this.writeQueryHistory();
|
await this.writeQueryHistory();
|
||||||
|
|||||||
Reference in New Issue
Block a user