Merge branch 'main' into robertbrignull/handleCompareWith
uick 6363a6a4 Remove the determineSelection method
This commit is contained in:
@@ -1419,7 +1419,7 @@
|
||||
},
|
||||
{
|
||||
"command": "codeQL.createQuery",
|
||||
"when": "config.codeQL.canary"
|
||||
"when": "config.codeQL.codespacesTemplate"
|
||||
},
|
||||
{
|
||||
"command": "codeQLTests.acceptOutputContextTestItem",
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
TemplatePrintCfgProvider,
|
||||
} from "./contextual/templateProvider";
|
||||
import { AstCfgCommands } from "./common/commands";
|
||||
import { LocalQueries } from "./local-queries/local-queries";
|
||||
import { LocalQueries } from "./local-queries";
|
||||
|
||||
type AstCfgOptions = {
|
||||
localQueries: LocalQueries;
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
} from "./queryResolver";
|
||||
import { CancellationToken, LocationLink, Uri } from "vscode";
|
||||
import { QueryOutputDir } from "../run-queries-shared";
|
||||
import { QueryRunner } from "../queryRunner";
|
||||
import { QueryRunner } from "../query-server";
|
||||
import { QueryResultType } from "../pure/new-messages";
|
||||
|
||||
export const SELECT_QUERY_NAME = "#select";
|
||||
|
||||
@@ -16,7 +16,7 @@ import { DatabaseItem } from "../local-databases";
|
||||
import { extLogger, TeeLogger } from "../common";
|
||||
import { CancellationToken } from "vscode";
|
||||
import { ProgressCallback } from "../progress";
|
||||
import { CoreCompletedQuery, QueryRunner } from "../queryRunner";
|
||||
import { CoreCompletedQuery, QueryRunner } from "../query-server";
|
||||
import { redactableError } from "../pure/errors";
|
||||
import { QLPACK_FILENAMES } from "../pure/ql";
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import {
|
||||
runContextualQuery,
|
||||
} from "./queryResolver";
|
||||
import { isCanary, NO_CACHE_AST_VIEWER } from "../config";
|
||||
import { CoreCompletedQuery, QueryRunner } from "../queryRunner";
|
||||
import { CoreCompletedQuery, QueryRunner } from "../query-server";
|
||||
|
||||
/**
|
||||
* Runs templated CodeQL queries to find definitions in
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ExtensionContext } from "vscode";
|
||||
import { DataExtensionsEditorView } from "./data-extensions-editor-view";
|
||||
import { DataExtensionsEditorCommands } from "../common/commands";
|
||||
import { CliVersionConstraint, CodeQLCliServer } from "../cli";
|
||||
import { QueryRunner } from "../queryRunner";
|
||||
import { QueryRunner } from "../query-server";
|
||||
import { DatabaseManager } from "../local-databases";
|
||||
import { ensureDir } from "fs-extra";
|
||||
import { join } from "path";
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
ToDataExtensionsEditorMessage,
|
||||
} from "../pure/interface-types";
|
||||
import { ProgressUpdate } from "../progress";
|
||||
import { QueryRunner } from "../queryRunner";
|
||||
import { QueryRunner } from "../query-server";
|
||||
import {
|
||||
showAndLogErrorMessage,
|
||||
showAndLogExceptionWithTelemetry,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CoreCompletedQuery, QueryRunner } from "../queryRunner";
|
||||
import { CoreCompletedQuery, QueryRunner } from "../query-server";
|
||||
import { dir } from "tmp-promise";
|
||||
import { writeFile } from "fs-extra";
|
||||
import { dump as dumpYaml } from "js-yaml";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CancellationToken } from "vscode";
|
||||
import { DatabaseItem } from "../local-databases";
|
||||
import { join } from "path";
|
||||
import { QueryRunner } from "../queryRunner";
|
||||
import { QueryRunner } from "../query-server";
|
||||
import { CodeQLCliServer } from "../cli";
|
||||
import { TeeLogger } from "../common";
|
||||
import { extensiblePredicateDefinitions } from "./predicates";
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
WorkspaceFolder,
|
||||
} from "vscode";
|
||||
import { getOnDiskWorkspaceFolders, showAndLogErrorMessage } from "../helpers";
|
||||
import { LocalQueries } from "../local-queries/local-queries";
|
||||
import { LocalQueries } from "../local-queries";
|
||||
import { getQuickEvalContext, validateQueryPath } from "../run-queries-shared";
|
||||
import * as CodeQLProtocol from "./debug-protocol";
|
||||
import { getErrorMessage } from "../pure/helpers-pure";
|
||||
|
||||
@@ -14,7 +14,7 @@ import { Disposable } from "vscode";
|
||||
import { CancellationTokenSource } from "vscode-jsonrpc";
|
||||
import { BaseLogger, LogOptions, queryServerLogger } from "../common";
|
||||
import { QueryResultType } from "../pure/new-messages";
|
||||
import { CoreQueryResults, CoreQueryRun, QueryRunner } from "../queryRunner";
|
||||
import { CoreQueryResults, CoreQueryRun, QueryRunner } from "../query-server";
|
||||
import * as CodeQLProtocol from "./debug-protocol";
|
||||
import { QuickEvalContext } from "../run-queries-shared";
|
||||
import { getErrorMessage } from "../pure/helpers-pure";
|
||||
|
||||
@@ -9,9 +9,9 @@ import {
|
||||
ProviderResult,
|
||||
} from "vscode";
|
||||
import { isCanary } from "../config";
|
||||
import { LocalQueries } from "../local-queries/local-queries";
|
||||
import { LocalQueries } from "../local-queries";
|
||||
import { DisposableObject } from "../pure/disposable-object";
|
||||
import { QueryRunner } from "../queryRunner";
|
||||
import { QueryRunner } from "../query-server";
|
||||
import { QLDebugConfigurationProvider } from "./debug-configuration";
|
||||
import { QLDebugSession } from "./debug-session";
|
||||
|
||||
|
||||
@@ -9,9 +9,8 @@ import {
|
||||
} from "vscode";
|
||||
import { DebuggerCommands } from "../common/commands";
|
||||
import { DatabaseManager } from "../local-databases";
|
||||
import { LocalQueries } from "../local-queries/local-queries";
|
||||
import { DisposableObject } from "../pure/disposable-object";
|
||||
import { CoreQueryResults } from "../queryRunner";
|
||||
import { CoreQueryResults } from "../query-server";
|
||||
import {
|
||||
getQuickEvalContext,
|
||||
QueryOutputDir,
|
||||
@@ -20,7 +19,7 @@ import {
|
||||
import { QLResolvedDebugConfiguration } from "./debug-configuration";
|
||||
import * as CodeQLProtocol from "./debug-protocol";
|
||||
import { App } from "../common/app";
|
||||
import { LocalQueryRun } from "../local-queries/local-query-run";
|
||||
import { LocalQueryRun, LocalQueries } from "../local-queries";
|
||||
|
||||
/**
|
||||
* Listens to messages passing between VS Code and the debug adapter, so that we can supplement the
|
||||
|
||||
@@ -83,8 +83,10 @@ import {
|
||||
} from "./common";
|
||||
import { QueryHistoryManager } from "./query-history/query-history-manager";
|
||||
import { CompletedLocalQueryInfo } from "./query-results";
|
||||
import { QueryServerClient as LegacyQueryServerClient } from "./legacy-query-server/queryserver-client";
|
||||
import { QueryServerClient } from "./query-server/queryserver-client";
|
||||
import {
|
||||
LegacyQueryRunner,
|
||||
QueryServerClient as LegacyQueryServerClient,
|
||||
} from "./query-server/legacy";
|
||||
import { QLTestAdapterFactory } from "./test-adapter";
|
||||
import { TestUIService } from "./test-ui";
|
||||
import { CompareView } from "./compare/compare-view";
|
||||
@@ -97,9 +99,6 @@ import { EvalLogViewer } from "./eval-log-viewer";
|
||||
import { SummaryLanguageSupport } from "./log-insights/summary-language-support";
|
||||
import { JoinOrderScannerProvider } from "./log-insights/join-order";
|
||||
import { LogScannerService } from "./log-insights/log-scanner-service";
|
||||
import { LegacyQueryRunner } from "./legacy-query-server/legacyRunner";
|
||||
import { NewQueryRunner } from "./query-server/query-runner";
|
||||
import { QueryRunner } from "./queryRunner";
|
||||
import { VariantAnalysisView } from "./variant-analysis/variant-analysis-view";
|
||||
import { VariantAnalysisViewSerializer } from "./variant-analysis/variant-analysis-view-serializer";
|
||||
import { VariantAnalysisManager } from "./variant-analysis/variant-analysis-manager";
|
||||
@@ -117,7 +116,7 @@ import {
|
||||
PreActivationCommands,
|
||||
QueryServerCommands,
|
||||
} from "./common/commands";
|
||||
import { LocalQueries } from "./local-queries/local-queries";
|
||||
import { LocalQueries } from "./local-queries";
|
||||
import { getAstCfgCommands } from "./ast-cfg-commands";
|
||||
import { getQueryEditorCommands } from "./query-editor";
|
||||
import { App } from "./common/app";
|
||||
@@ -127,6 +126,7 @@ import { DataExtensionsEditorModule } from "./data-extensions-editor/data-extens
|
||||
import { TestManager } from "./test-manager";
|
||||
import { TestRunner } from "./test-runner";
|
||||
import { TestManagerBase } from "./test-manager-base";
|
||||
import { NewQueryRunner, QueryRunner, QueryServerClient } from "./query-server";
|
||||
|
||||
/**
|
||||
* extension.ts
|
||||
@@ -707,9 +707,14 @@ async function activateWithInstalledDistribution(
|
||||
for (const glob of PACK_GLOBS) {
|
||||
const fsWatcher = workspace.createFileSystemWatcher(glob);
|
||||
ctx.subscriptions.push(fsWatcher);
|
||||
fsWatcher.onDidChange(async (_uri) => {
|
||||
|
||||
const clearPackCache = async (_uri: Uri) => {
|
||||
await qs.clearPackCache();
|
||||
});
|
||||
};
|
||||
|
||||
fsWatcher.onDidCreate(clearPackCache);
|
||||
fsWatcher.onDidChange(clearPackCache);
|
||||
fsWatcher.onDidDelete(clearPackCache);
|
||||
}
|
||||
|
||||
void extLogger.log("Initializing database manager.");
|
||||
|
||||
@@ -41,7 +41,7 @@ import {
|
||||
promptImportInternetDatabase,
|
||||
} from "./databaseFetcher";
|
||||
import { asError, asyncFilter, getErrorMessage } from "./pure/helpers-pure";
|
||||
import { QueryRunner } from "./queryRunner";
|
||||
import { QueryRunner } from "./query-server";
|
||||
import { isCanary } from "./config";
|
||||
import { App } from "./common/app";
|
||||
import { redactableError } from "./pure/errors";
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
import { DisposableObject } from "./pure/disposable-object";
|
||||
import { Logger, extLogger } from "./common";
|
||||
import { asError, getErrorMessage } from "./pure/helpers-pure";
|
||||
import { QueryRunner } from "./queryRunner";
|
||||
import { QueryRunner } from "./query-server";
|
||||
import { pathsEqual } from "./pure/files";
|
||||
import { redactableError } from "./pure/errors";
|
||||
import { isCodespacesTemplate } from "./config";
|
||||
|
||||
2
extensions/ql-vscode/src/local-queries/index.ts
Normal file
2
extensions/ql-vscode/src/local-queries/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./local-queries";
|
||||
export * from "./local-query-run";
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
showBinaryChoiceDialog,
|
||||
} from "../helpers";
|
||||
import { displayQuickQuery } from "../quick-query";
|
||||
import { CoreCompletedQuery, QueryRunner } from "../queryRunner";
|
||||
import { CoreCompletedQuery, QueryRunner } from "../query-server";
|
||||
import { QueryHistoryManager } from "../query-history/query-history-manager";
|
||||
import { DatabaseUI } from "../local-databases-ui";
|
||||
import { ResultsView } from "../interface";
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
showAndLogWarningMessage,
|
||||
tryGetQueryMetadata,
|
||||
} from "../helpers";
|
||||
import { CoreQueryResults } from "../queryRunner";
|
||||
import { CoreQueryResults } from "../query-server";
|
||||
import { QueryHistoryManager } from "../query-history/query-history-manager";
|
||||
import { DatabaseItem } from "../local-databases";
|
||||
import {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Uri, window } from "vscode";
|
||||
import { CodeQLCliServer } from "./cli";
|
||||
import { QueryRunner } from "./queryRunner";
|
||||
import { QueryRunner } from "./query-server";
|
||||
import { basename, join } from "path";
|
||||
import { getErrorMessage } from "./pure/helpers-pure";
|
||||
import { redactableError } from "./pure/errors";
|
||||
|
||||
@@ -48,7 +48,7 @@ import { EvalLogViewer } from "../eval-log-viewer";
|
||||
import EvalLogTreeBuilder from "../eval-log-tree-builder";
|
||||
import { EvalLogData, parseViewerData } from "../pure/log-summary-parser";
|
||||
import { QueryWithResults } from "../run-queries-shared";
|
||||
import { QueryRunner } from "../queryRunner";
|
||||
import { QueryRunner } from "../query-server";
|
||||
import { VariantAnalysisManager } from "../variant-analysis/variant-analysis-manager";
|
||||
import { VariantAnalysisHistoryItem } from "./variant-analysis-history-item";
|
||||
import { getTotalResultCount } from "../variant-analysis/shared/variant-analysis";
|
||||
@@ -394,38 +394,34 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
}
|
||||
|
||||
async handleOpenQuery(
|
||||
singleItem: QueryHistoryInfo | undefined,
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
): Promise<void> {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
|
||||
if (!this.assertSingleQuery(multiSelect)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (finalSingleItem.t === "variant-analysis") {
|
||||
if (singleItem.t === "variant-analysis") {
|
||||
await this.variantAnalysisManager.openQueryFile(
|
||||
finalSingleItem.variantAnalysis.id,
|
||||
singleItem.variantAnalysis.id,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
let queryPath: string;
|
||||
switch (finalSingleItem.t) {
|
||||
switch (singleItem.t) {
|
||||
case "local":
|
||||
queryPath = finalSingleItem.initialInfo.queryPath;
|
||||
queryPath = singleItem.initialInfo.queryPath;
|
||||
break;
|
||||
default:
|
||||
assertNever(finalSingleItem);
|
||||
assertNever(singleItem);
|
||||
}
|
||||
const textDocument = await workspace.openTextDocument(Uri.file(queryPath));
|
||||
const editor = await window.showTextDocument(textDocument, ViewColumn.One);
|
||||
|
||||
if (finalSingleItem.t === "local") {
|
||||
const queryText = finalSingleItem.initialInfo.queryText;
|
||||
if (queryText !== undefined && finalSingleItem.initialInfo.isQuickQuery) {
|
||||
if (singleItem.t === "local") {
|
||||
const queryText = singleItem.initialInfo.queryText;
|
||||
if (queryText !== undefined && singleItem.initialInfo.isQuickQuery) {
|
||||
await editor.edit((edit) =>
|
||||
edit.replace(
|
||||
textDocument.validateRange(
|
||||
@@ -457,16 +453,12 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
}
|
||||
|
||||
async handleRemoveHistoryItem(
|
||||
singleItem: QueryHistoryInfo | undefined,
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
) {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
const toDelete = finalMultiSelect || [finalSingleItem];
|
||||
multiSelect ||= [singleItem];
|
||||
await Promise.all(
|
||||
toDelete.map(async (item) => {
|
||||
multiSelect.map(async (item) => {
|
||||
if (item.t === "local") {
|
||||
// Removing in progress local queries is not supported. They must be cancelled first.
|
||||
if (item.status !== QueryStatus.InProgress) {
|
||||
@@ -560,18 +552,13 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
): Promise<void> {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
|
||||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
|
||||
if (!this.assertSingleQuery(multiSelect)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await window.showInputBox({
|
||||
placeHolder: `(use default: ${this.queryHistoryConfigListener.format})`,
|
||||
value: finalSingleItem.userSpecifiedLabel ?? "",
|
||||
value: singleItem.userSpecifiedLabel ?? "",
|
||||
title: "Set query label",
|
||||
prompt:
|
||||
"Set the query history item label. See the description of the codeQL.queryHistory.format setting for more information.",
|
||||
@@ -579,8 +566,7 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
// undefined response means the user cancelled the dialog; don't change anything
|
||||
if (response !== undefined) {
|
||||
// Interpret empty string response as 'go back to using default'
|
||||
finalSingleItem.userSpecifiedLabel =
|
||||
response === "" ? undefined : response;
|
||||
singleItem.userSpecifiedLabel = response === "" ? undefined : response;
|
||||
await this.refreshTreeView();
|
||||
}
|
||||
}
|
||||
@@ -628,36 +614,32 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
}
|
||||
|
||||
async handleItemClicked(
|
||||
singleItem: QueryHistoryInfo | undefined,
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
) {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
|
||||
if (!this.assertSingleQuery(multiSelect)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.treeDataProvider.setCurrentItem(finalSingleItem);
|
||||
this.treeDataProvider.setCurrentItem(singleItem);
|
||||
|
||||
const now = new Date();
|
||||
const prevItemClick = this.lastItemClick;
|
||||
this.lastItemClick = { time: now, item: finalSingleItem };
|
||||
this.lastItemClick = { time: now, item: singleItem };
|
||||
|
||||
if (
|
||||
prevItemClick !== undefined &&
|
||||
now.valueOf() - prevItemClick.time.valueOf() < DOUBLE_CLICK_TIME &&
|
||||
finalSingleItem === prevItemClick.item
|
||||
singleItem === prevItemClick.item
|
||||
) {
|
||||
// show original query file on double click
|
||||
await this.handleOpenQuery(finalSingleItem, [finalSingleItem]);
|
||||
await this.handleOpenQuery(singleItem, [singleItem]);
|
||||
} else if (
|
||||
finalSingleItem.t === "variant-analysis" ||
|
||||
finalSingleItem.status === QueryStatus.Completed
|
||||
singleItem.t === "variant-analysis" ||
|
||||
singleItem.status === QueryStatus.Completed
|
||||
) {
|
||||
// show results on single click (if results view is available)
|
||||
await this.openQueryResults(finalSingleItem);
|
||||
await this.openQueryResults(singleItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -706,32 +688,27 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
) {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
|
||||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
|
||||
if (!this.assertSingleQuery(multiSelect)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let externalFilePath: string | undefined;
|
||||
if (finalSingleItem.t === "local") {
|
||||
if (finalSingleItem.completedQuery) {
|
||||
if (singleItem.t === "local") {
|
||||
if (singleItem.completedQuery) {
|
||||
externalFilePath = join(
|
||||
finalSingleItem.completedQuery.query.querySaveDir,
|
||||
singleItem.completedQuery.query.querySaveDir,
|
||||
"timestamp",
|
||||
);
|
||||
}
|
||||
} else if (finalSingleItem.t === "variant-analysis") {
|
||||
} else if (singleItem.t === "variant-analysis") {
|
||||
externalFilePath = join(
|
||||
this.variantAnalysisManager.getVariantAnalysisStorageLocation(
|
||||
finalSingleItem.variantAnalysis.id,
|
||||
singleItem.variantAnalysis.id,
|
||||
),
|
||||
"timestamp",
|
||||
);
|
||||
} else {
|
||||
assertNever(finalSingleItem);
|
||||
assertNever(singleItem);
|
||||
}
|
||||
|
||||
if (externalFilePath) {
|
||||
@@ -780,25 +757,13 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
) {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
|
||||
// Only applicable to an individual local query
|
||||
if (
|
||||
!this.assertSingleQuery(finalMultiSelect) ||
|
||||
!finalSingleItem ||
|
||||
finalSingleItem.t !== "local"
|
||||
) {
|
||||
if (!this.assertSingleQuery(multiSelect) || singleItem.t !== "local") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (finalSingleItem.evalLogLocation) {
|
||||
await tryOpenExternalFile(
|
||||
this.app.commands,
|
||||
finalSingleItem.evalLogLocation,
|
||||
);
|
||||
if (singleItem.evalLogLocation) {
|
||||
await tryOpenExternalFile(this.app.commands, singleItem.evalLogLocation);
|
||||
} else {
|
||||
this.warnNoEvalLogs();
|
||||
}
|
||||
@@ -808,32 +773,23 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
) {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
|
||||
// Only applicable to an individual local query
|
||||
if (
|
||||
!this.assertSingleQuery(finalMultiSelect) ||
|
||||
!finalSingleItem ||
|
||||
finalSingleItem.t !== "local"
|
||||
) {
|
||||
if (!this.assertSingleQuery(multiSelect) || singleItem.t !== "local") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (finalSingleItem.evalLogSummaryLocation) {
|
||||
if (singleItem.evalLogSummaryLocation) {
|
||||
await tryOpenExternalFile(
|
||||
this.app.commands,
|
||||
finalSingleItem.evalLogSummaryLocation,
|
||||
singleItem.evalLogSummaryLocation,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Summary log file doesn't exist.
|
||||
if (
|
||||
finalSingleItem.evalLogLocation &&
|
||||
(await pathExists(finalSingleItem.evalLogLocation))
|
||||
singleItem.evalLogLocation &&
|
||||
(await pathExists(singleItem.evalLogLocation))
|
||||
) {
|
||||
// If raw log does exist, then the summary log is still being generated.
|
||||
this.warnInProgressEvalLogSummary();
|
||||
@@ -846,21 +802,13 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
) {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
// Only applicable to an individual local query
|
||||
if (
|
||||
!this.assertSingleQuery(finalMultiSelect) ||
|
||||
!finalSingleItem ||
|
||||
finalSingleItem.t !== "local"
|
||||
) {
|
||||
if (!this.assertSingleQuery(multiSelect) || singleItem.t !== "local") {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the JSON summary file location wasn't saved, display error
|
||||
if (finalSingleItem.jsonEvalLogSummaryLocation === undefined) {
|
||||
if (singleItem.jsonEvalLogSummaryLocation === undefined) {
|
||||
this.warnInProgressEvalLogViewer();
|
||||
return;
|
||||
}
|
||||
@@ -868,16 +816,16 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
// TODO(angelapwen): Stream the file in.
|
||||
try {
|
||||
const evalLogData: EvalLogData[] = await parseViewerData(
|
||||
finalSingleItem.jsonEvalLogSummaryLocation,
|
||||
singleItem.jsonEvalLogSummaryLocation,
|
||||
);
|
||||
const evalLogTreeBuilder = new EvalLogTreeBuilder(
|
||||
finalSingleItem.getQueryName(),
|
||||
singleItem.getQueryName(),
|
||||
evalLogData,
|
||||
);
|
||||
this.evalLogViewer.updateRoots(await evalLogTreeBuilder.getRoots());
|
||||
} catch (e) {
|
||||
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}.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -886,14 +834,9 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
) {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
multiSelect ||= [singleItem];
|
||||
|
||||
const selected = finalMultiSelect || [finalSingleItem];
|
||||
|
||||
const results = selected.map(async (item) => {
|
||||
const results = multiSelect.map(async (item) => {
|
||||
if (item.status === QueryStatus.InProgress) {
|
||||
if (item.t === "local") {
|
||||
item.cancel();
|
||||
@@ -914,18 +857,13 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] = [],
|
||||
) {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
|
||||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
|
||||
if (!this.assertSingleQuery(multiSelect)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (finalSingleItem.t === "variant-analysis") {
|
||||
if (singleItem.t === "variant-analysis") {
|
||||
await this.variantAnalysisManager.openQueryText(
|
||||
finalSingleItem.variantAnalysis.id,
|
||||
singleItem.variantAnalysis.id,
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -933,14 +871,13 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
const params = new URLSearchParams({
|
||||
isQuickEval: String(
|
||||
!!(
|
||||
finalSingleItem.t === "local" &&
|
||||
finalSingleItem.initialInfo.quickEvalPosition
|
||||
singleItem.t === "local" && singleItem.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 doc = await workspace.openTextDocument(uri);
|
||||
@@ -951,22 +888,16 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
) {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
|
||||
// Local queries only
|
||||
if (
|
||||
!this.assertSingleQuery(finalMultiSelect) ||
|
||||
!finalSingleItem ||
|
||||
finalSingleItem.t !== "local" ||
|
||||
!finalSingleItem.completedQuery
|
||||
!this.assertSingleQuery(multiSelect) ||
|
||||
singleItem.t !== "local" ||
|
||||
!singleItem.completedQuery
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const query = finalSingleItem.completedQuery.query;
|
||||
const query = singleItem.completedQuery.query;
|
||||
const hasInterpretedResults = query.canHaveInterpretedResults();
|
||||
if (hasInterpretedResults) {
|
||||
await tryOpenExternalFile(
|
||||
@@ -974,7 +905,7 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
query.resultsPaths.interpretedResultsPath,
|
||||
);
|
||||
} else {
|
||||
const label = this.labelProvider.getLabel(finalSingleItem);
|
||||
const label = this.labelProvider.getLabel(singleItem);
|
||||
void showAndLogInformationMessage(
|
||||
`Query ${label} has no interpreted results.`,
|
||||
);
|
||||
@@ -985,21 +916,15 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
) {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
|
||||
// Local queries only
|
||||
if (
|
||||
!this.assertSingleQuery(finalMultiSelect) ||
|
||||
!finalSingleItem ||
|
||||
finalSingleItem.t !== "local" ||
|
||||
!finalSingleItem.completedQuery
|
||||
!this.assertSingleQuery(multiSelect) ||
|
||||
singleItem.t !== "local" ||
|
||||
!singleItem.completedQuery
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const query = finalSingleItem.completedQuery.query;
|
||||
const query = singleItem.completedQuery.query;
|
||||
if (await query.hasCsv()) {
|
||||
void tryOpenExternalFile(this.app.commands, query.csvPath);
|
||||
return;
|
||||
@@ -1013,24 +938,18 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
) {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
|
||||
// Local queries only
|
||||
if (
|
||||
!this.assertSingleQuery(finalMultiSelect) ||
|
||||
!finalSingleItem ||
|
||||
finalSingleItem.t !== "local" ||
|
||||
!finalSingleItem.completedQuery
|
||||
!this.assertSingleQuery(multiSelect) ||
|
||||
singleItem.t !== "local" ||
|
||||
!singleItem.completedQuery
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
await tryOpenExternalFile(
|
||||
this.app.commands,
|
||||
await finalSingleItem.completedQuery.query.ensureCsvAlerts(
|
||||
await singleItem.completedQuery.query.ensureCsvAlerts(
|
||||
this.qs.cliServer,
|
||||
this.dbm,
|
||||
),
|
||||
@@ -1041,26 +960,18 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
) {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
|
||||
// Local queries only
|
||||
if (
|
||||
!this.assertSingleQuery(finalMultiSelect) ||
|
||||
!finalSingleItem ||
|
||||
finalSingleItem.t !== "local" ||
|
||||
!finalSingleItem.completedQuery
|
||||
!this.assertSingleQuery(multiSelect) ||
|
||||
singleItem.t !== "local" ||
|
||||
!singleItem.completedQuery
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
await tryOpenExternalFile(
|
||||
this.app.commands,
|
||||
await finalSingleItem.completedQuery.query.ensureDilPath(
|
||||
this.qs.cliServer,
|
||||
),
|
||||
await singleItem.completedQuery.query.ensureDilPath(this.qs.cliServer),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1068,20 +979,14 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
) {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
|
||||
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) {
|
||||
if (
|
||||
!this.assertSingleQuery(multiSelect) ||
|
||||
singleItem.t !== "variant-analysis"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (finalSingleItem.t === "local") {
|
||||
return;
|
||||
}
|
||||
|
||||
const actionsWorkflowRunUrl = getActionsWorkflowRunUrl(finalSingleItem);
|
||||
const actionsWorkflowRunUrl = getActionsWorkflowRunUrl(singleItem);
|
||||
|
||||
await this.app.commands.execute(
|
||||
"vscode.open",
|
||||
@@ -1093,23 +998,17 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
) {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
|
||||
// Variant analyses only
|
||||
if (
|
||||
!this.assertSingleQuery(finalMultiSelect) ||
|
||||
!finalSingleItem ||
|
||||
finalSingleItem.t !== "variant-analysis"
|
||||
!this.assertSingleQuery(multiSelect) ||
|
||||
singleItem.t !== "variant-analysis"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.app.commands.execute(
|
||||
"codeQL.copyVariantAnalysisRepoList",
|
||||
finalSingleItem.variantAnalysis.id,
|
||||
singleItem.variantAnalysis.id,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1117,22 +1016,16 @@ export class QueryHistoryManager extends DisposableObject {
|
||||
singleItem: QueryHistoryInfo,
|
||||
multiSelect: QueryHistoryInfo[] | undefined,
|
||||
): Promise<void> {
|
||||
const { finalSingleItem, finalMultiSelect } = this.determineSelection(
|
||||
singleItem,
|
||||
multiSelect,
|
||||
);
|
||||
|
||||
// Variant analysis only
|
||||
if (
|
||||
!this.assertSingleQuery(finalMultiSelect) ||
|
||||
!finalSingleItem ||
|
||||
finalSingleItem.t !== "variant-analysis"
|
||||
!this.assertSingleQuery(multiSelect) ||
|
||||
singleItem.t !== "variant-analysis"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.variantAnalysisManager.exportResults(
|
||||
finalSingleItem.variantAnalysis.id,
|
||||
singleItem.variantAnalysis.id,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1261,52 +1154,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> {
|
||||
this.treeDataProvider.refresh();
|
||||
await this.writeQueryHistory();
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
QueryEvaluationInfo,
|
||||
QueryWithResults,
|
||||
} from "./run-queries-shared";
|
||||
import { formatLegacyMessage } from "./legacy-query-server/run-queries";
|
||||
import { formatLegacyMessage } from "./query-server/legacy";
|
||||
import { sarifParser } from "./sarif-parser";
|
||||
|
||||
/**
|
||||
|
||||
5
extensions/ql-vscode/src/query-server/index.ts
Normal file
5
extensions/ql-vscode/src/query-server/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export * from "./new-query-runner";
|
||||
export * from "./query-runner";
|
||||
export * from "./query-server-client";
|
||||
export * from "./run-queries";
|
||||
export * from "./server-process";
|
||||
4
extensions/ql-vscode/src/query-server/legacy/index.ts
Normal file
4
extensions/ql-vscode/src/query-server/legacy/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from "./legacy-query-runner";
|
||||
export * from "./query-server-client";
|
||||
export * from "./run-queries";
|
||||
export * from "./upgrades";
|
||||
@@ -1,16 +1,20 @@
|
||||
import { CancellationToken } from "vscode";
|
||||
import { CodeQLCliServer } from "../cli";
|
||||
import { ProgressCallback } from "../progress";
|
||||
import { Logger } from "../common";
|
||||
import { DatabaseItem } from "../local-databases";
|
||||
import { CodeQLCliServer } from "../../cli";
|
||||
import { ProgressCallback } from "../../progress";
|
||||
import { Logger } from "../../common";
|
||||
import { DatabaseItem } from "../../local-databases";
|
||||
import {
|
||||
Dataset,
|
||||
deregisterDatabases,
|
||||
registerDatabases,
|
||||
} from "../pure/legacy-messages";
|
||||
import { CoreQueryResults, CoreQueryTarget, QueryRunner } from "../queryRunner";
|
||||
import { QueryOutputDir } from "../run-queries-shared";
|
||||
import { QueryServerClient } from "./queryserver-client";
|
||||
} from "../../pure/legacy-messages";
|
||||
import {
|
||||
CoreQueryResults,
|
||||
CoreQueryTarget,
|
||||
QueryRunner,
|
||||
} from "../query-runner";
|
||||
import { QueryOutputDir } from "../../run-queries-shared";
|
||||
import { QueryServerClient } from "./query-server-client";
|
||||
import {
|
||||
clearCacheInDatabase,
|
||||
compileAndRunQueryAgainstDatabaseCore,
|
||||
@@ -1,21 +1,21 @@
|
||||
import { ensureFile } from "fs-extra";
|
||||
|
||||
import { DisposableObject } from "../pure/disposable-object";
|
||||
import { DisposableObject } from "../../pure/disposable-object";
|
||||
import { CancellationToken } from "vscode";
|
||||
import { createMessageConnection, RequestType } from "vscode-jsonrpc/node";
|
||||
import * as cli from "../cli";
|
||||
import { QueryServerConfig } from "../config";
|
||||
import { Logger, ProgressReporter } from "../common";
|
||||
import * as cli from "../../cli";
|
||||
import { QueryServerConfig } from "../../config";
|
||||
import { Logger, ProgressReporter } from "../../common";
|
||||
import {
|
||||
completeQuery,
|
||||
EvaluationResult,
|
||||
progress,
|
||||
ProgressMessage,
|
||||
WithProgressId,
|
||||
} from "../pure/legacy-messages";
|
||||
import { ProgressCallback, ProgressTask } from "../progress";
|
||||
import { ServerProcess } from "../json-rpc-server";
|
||||
import { App } from "../common/app";
|
||||
} from "../../pure/legacy-messages";
|
||||
import { ProgressCallback, ProgressTask } from "../../progress";
|
||||
import { ServerProcess } from "../server-process";
|
||||
import { App } from "../../common/app";
|
||||
|
||||
type WithProgressReporting = (
|
||||
task: (
|
||||
@@ -3,29 +3,29 @@ import { basename } from "path";
|
||||
import { CancellationToken, Uri } from "vscode";
|
||||
import { LSPErrorCodes, ResponseError } from "vscode-languageclient";
|
||||
|
||||
import * as cli from "../cli";
|
||||
import * as cli from "../../cli";
|
||||
import {
|
||||
DatabaseContentsWithDbScheme,
|
||||
DatabaseItem,
|
||||
DatabaseResolver,
|
||||
} from "../local-databases";
|
||||
} from "../../local-databases";
|
||||
import {
|
||||
showAndLogExceptionWithTelemetry,
|
||||
showAndLogWarningMessage,
|
||||
upgradesTmpDir,
|
||||
} from "../helpers";
|
||||
import { ProgressCallback } from "../progress";
|
||||
import { QueryMetadata } from "../pure/interface-types";
|
||||
import { extLogger, Logger } from "../common";
|
||||
import * as messages from "../pure/legacy-messages";
|
||||
import * as newMessages from "../pure/new-messages";
|
||||
import * as qsClient from "./queryserver-client";
|
||||
import { asError, getErrorMessage } from "../pure/helpers-pure";
|
||||
} from "../../helpers";
|
||||
import { ProgressCallback } from "../../progress";
|
||||
import { QueryMetadata } from "../../pure/interface-types";
|
||||
import { extLogger, Logger } from "../../common";
|
||||
import * as messages from "../../pure/legacy-messages";
|
||||
import * as newMessages from "../../pure/new-messages";
|
||||
import * as qsClient from "./query-server-client";
|
||||
import { asError, getErrorMessage } from "../../pure/helpers-pure";
|
||||
import { compileDatabaseUpgradeSequence } from "./upgrades";
|
||||
import { QueryEvaluationInfo, QueryOutputDir } from "../run-queries-shared";
|
||||
import { redactableError } from "../pure/errors";
|
||||
import { CoreQueryResults, CoreQueryTarget } from "../queryRunner";
|
||||
import { Position } from "../pure/messages-shared";
|
||||
import { QueryEvaluationInfo, QueryOutputDir } from "../../run-queries-shared";
|
||||
import { redactableError } from "../../pure/errors";
|
||||
import { CoreQueryResults, CoreQueryTarget } from "../query-runner";
|
||||
import { Position } from "../../pure/messages-shared";
|
||||
|
||||
export async function compileQuery(
|
||||
qs: qsClient.QueryServerClient,
|
||||
@@ -3,16 +3,16 @@ import {
|
||||
getOnDiskWorkspaceFolders,
|
||||
showAndLogExceptionWithTelemetry,
|
||||
tmpDir,
|
||||
} from "../helpers";
|
||||
import { ProgressCallback, UserCancellationException } from "../progress";
|
||||
import { extLogger } from "../common";
|
||||
import * as messages from "../pure/legacy-messages";
|
||||
import * as qsClient from "./queryserver-client";
|
||||
} from "../../helpers";
|
||||
import { ProgressCallback, UserCancellationException } from "../../progress";
|
||||
import { extLogger } from "../../common";
|
||||
import * as messages from "../../pure/legacy-messages";
|
||||
import * as qsClient from "./query-server-client";
|
||||
import * as tmp from "tmp-promise";
|
||||
import { dirname } from "path";
|
||||
import { DatabaseItem } from "../local-databases";
|
||||
import { asError, getErrorMessage } from "../pure/helpers-pure";
|
||||
import { redactableError } from "../pure/errors";
|
||||
import { DatabaseItem } from "../../local-databases";
|
||||
import { asError, getErrorMessage } from "../../pure/helpers-pure";
|
||||
import { redactableError } from "../../pure/errors";
|
||||
|
||||
/**
|
||||
* Maximum number of lines to include from database upgrade message,
|
||||
165
extensions/ql-vscode/src/query-server/new-query-runner.ts
Normal file
165
extensions/ql-vscode/src/query-server/new-query-runner.ts
Normal file
@@ -0,0 +1,165 @@
|
||||
import { CancellationToken } from "vscode";
|
||||
import { ProgressCallback, UserCancellationException } from "../progress";
|
||||
import { DatabaseItem } from "../local-databases";
|
||||
import {
|
||||
clearCache,
|
||||
ClearCacheParams,
|
||||
clearPackCache,
|
||||
deregisterDatabases,
|
||||
registerDatabases,
|
||||
upgradeDatabase,
|
||||
} from "../pure/new-messages";
|
||||
import { CoreQueryResults, CoreQueryTarget, QueryRunner } from "./query-runner";
|
||||
import { QueryServerClient } from "./query-server-client";
|
||||
import { compileAndRunQueryAgainstDatabaseCore } from "./run-queries";
|
||||
import * as vscode from "vscode";
|
||||
import { getOnDiskWorkspaceFolders } from "../helpers";
|
||||
import { CodeQLCliServer } from "../cli";
|
||||
import { Logger } from "../common";
|
||||
import { QueryOutputDir } from "../run-queries-shared";
|
||||
|
||||
export class NewQueryRunner extends QueryRunner {
|
||||
constructor(public readonly qs: QueryServerClient) {
|
||||
super();
|
||||
}
|
||||
|
||||
get cliServer(): CodeQLCliServer {
|
||||
return this.qs.cliServer;
|
||||
}
|
||||
|
||||
get customLogDirectory(): string | undefined {
|
||||
return this.qs.config.customLogDirectory;
|
||||
}
|
||||
|
||||
get logger(): Logger {
|
||||
return this.qs.logger;
|
||||
}
|
||||
|
||||
async restartQueryServer(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
): Promise<void> {
|
||||
await this.qs.restartQueryServer(progress, token);
|
||||
}
|
||||
|
||||
onStart(
|
||||
callBack: (
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
) => Promise<void>,
|
||||
) {
|
||||
this.qs.onDidStartQueryServer(callBack);
|
||||
}
|
||||
|
||||
async clearCacheInDatabase(
|
||||
dbItem: DatabaseItem,
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
): Promise<void> {
|
||||
if (dbItem.contents === undefined) {
|
||||
throw new Error("Can't clear the cache in an invalid database.");
|
||||
}
|
||||
|
||||
const db = dbItem.databaseUri.fsPath;
|
||||
const params: ClearCacheParams = {
|
||||
dryRun: false,
|
||||
db,
|
||||
};
|
||||
await this.qs.sendRequest(clearCache, params, token, progress);
|
||||
}
|
||||
|
||||
public async compileAndRunQueryAgainstDatabaseCore(
|
||||
dbPath: string,
|
||||
query: CoreQueryTarget,
|
||||
additionalPacks: string[],
|
||||
extensionPacks: string[] | undefined,
|
||||
generateEvalLog: boolean,
|
||||
outputDir: QueryOutputDir,
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
templates: Record<string, string> | undefined,
|
||||
logger: Logger,
|
||||
): Promise<CoreQueryResults> {
|
||||
return await compileAndRunQueryAgainstDatabaseCore(
|
||||
this.qs,
|
||||
dbPath,
|
||||
query,
|
||||
generateEvalLog,
|
||||
additionalPacks,
|
||||
extensionPacks,
|
||||
outputDir,
|
||||
progress,
|
||||
token,
|
||||
templates,
|
||||
logger,
|
||||
);
|
||||
}
|
||||
|
||||
async deregisterDatabase(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
dbItem: DatabaseItem,
|
||||
): Promise<void> {
|
||||
if (dbItem.contents) {
|
||||
const databases: string[] = [dbItem.databaseUri.fsPath];
|
||||
await this.qs.sendRequest(
|
||||
deregisterDatabases,
|
||||
{ databases },
|
||||
token,
|
||||
progress,
|
||||
);
|
||||
}
|
||||
}
|
||||
async registerDatabase(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
dbItem: DatabaseItem,
|
||||
): Promise<void> {
|
||||
if (dbItem.contents) {
|
||||
const databases: string[] = [dbItem.databaseUri.fsPath];
|
||||
await this.qs.sendRequest(
|
||||
registerDatabases,
|
||||
{ databases },
|
||||
token,
|
||||
progress,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async clearPackCache(): Promise<void> {
|
||||
await this.qs.sendRequest(clearPackCache, {});
|
||||
}
|
||||
|
||||
async upgradeDatabaseExplicit(
|
||||
dbItem: DatabaseItem,
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
): Promise<void> {
|
||||
const yesItem = { title: "Yes", isCloseAffordance: false };
|
||||
const noItem = { title: "No", isCloseAffordance: true };
|
||||
const dialogOptions: vscode.MessageItem[] = [yesItem, noItem];
|
||||
|
||||
const message = `Should the database ${dbItem.databaseUri.fsPath} be destructively upgraded?\n\nThis should not be necessary to run queries
|
||||
as we will non-destructively update it anyway.`;
|
||||
const chosenItem = await vscode.window.showInformationMessage(
|
||||
message,
|
||||
{ modal: true },
|
||||
...dialogOptions,
|
||||
);
|
||||
|
||||
if (chosenItem !== yesItem) {
|
||||
throw new UserCancellationException(
|
||||
"User cancelled the database upgrade.",
|
||||
);
|
||||
}
|
||||
await this.qs.sendRequest(
|
||||
upgradeDatabase,
|
||||
{
|
||||
db: dbItem.databaseUri.fsPath,
|
||||
additionalPacks: getOnDiskWorkspaceFolders(),
|
||||
},
|
||||
token,
|
||||
progress,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,74 +1,72 @@
|
||||
import { CancellationToken } from "vscode";
|
||||
import { ProgressCallback, UserCancellationException } from "../progress";
|
||||
import { DatabaseItem } from "../local-databases";
|
||||
import {
|
||||
clearCache,
|
||||
ClearCacheParams,
|
||||
clearPackCache,
|
||||
deregisterDatabases,
|
||||
registerDatabases,
|
||||
upgradeDatabase,
|
||||
} from "../pure/new-messages";
|
||||
import { CoreQueryResults, CoreQueryTarget, QueryRunner } from "../queryRunner";
|
||||
import { QueryServerClient } from "./queryserver-client";
|
||||
import { compileAndRunQueryAgainstDatabaseCore } from "./run-queries";
|
||||
import * as vscode from "vscode";
|
||||
import { getOnDiskWorkspaceFolders } from "../helpers";
|
||||
import { CodeQLCliServer } from "../cli";
|
||||
import { Logger } from "../common";
|
||||
import { ProgressCallback } from "../progress";
|
||||
import { DatabaseItem } from "../local-databases";
|
||||
import { QueryOutputDir } from "../run-queries-shared";
|
||||
import { Position, QueryResultType } from "../pure/new-messages";
|
||||
import { BaseLogger, Logger } from "../common";
|
||||
import { basename, join } from "path";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
export class NewQueryRunner extends QueryRunner {
|
||||
constructor(public readonly qs: QueryServerClient) {
|
||||
super();
|
||||
}
|
||||
export interface CoreQueryTarget {
|
||||
/** The full path to the query. */
|
||||
queryPath: string;
|
||||
/**
|
||||
* Optional position of text to be used as QuickEval target. This need not be in the same file as
|
||||
* `query`.
|
||||
*/
|
||||
quickEvalPosition?: Position;
|
||||
}
|
||||
|
||||
get cliServer(): CodeQLCliServer {
|
||||
return this.qs.cliServer;
|
||||
}
|
||||
export interface CoreQueryResults {
|
||||
readonly resultType: QueryResultType;
|
||||
readonly message: string | undefined;
|
||||
readonly evaluationTime: number;
|
||||
}
|
||||
|
||||
get customLogDirectory(): string | undefined {
|
||||
return this.qs.config.customLogDirectory;
|
||||
}
|
||||
export interface CoreQueryRun {
|
||||
readonly queryTarget: CoreQueryTarget;
|
||||
readonly dbPath: string;
|
||||
readonly id: string;
|
||||
readonly outputDir: QueryOutputDir;
|
||||
|
||||
get logger(): Logger {
|
||||
return this.qs.logger;
|
||||
}
|
||||
|
||||
async restartQueryServer(
|
||||
evaluate(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
): Promise<void> {
|
||||
await this.qs.restartQueryServer(progress, token);
|
||||
}
|
||||
logger: BaseLogger,
|
||||
): Promise<CoreCompletedQuery>;
|
||||
}
|
||||
|
||||
onStart(
|
||||
callBack: (
|
||||
/** Includes both the results of the query and the initial information from `CoreQueryRun`. */
|
||||
export type CoreCompletedQuery = CoreQueryResults &
|
||||
Omit<CoreQueryRun, "evaluate">;
|
||||
|
||||
export abstract class QueryRunner {
|
||||
abstract restartQueryServer(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
): Promise<void>;
|
||||
|
||||
abstract cliServer: CodeQLCliServer;
|
||||
abstract customLogDirectory: string | undefined;
|
||||
abstract logger: Logger;
|
||||
|
||||
abstract onStart(
|
||||
arg0: (
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
) => Promise<void>,
|
||||
) {
|
||||
this.qs.onDidStartQueryServer(callBack);
|
||||
}
|
||||
|
||||
async clearCacheInDatabase(
|
||||
): void;
|
||||
abstract clearCacheInDatabase(
|
||||
dbItem: DatabaseItem,
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
): Promise<void> {
|
||||
if (dbItem.contents === undefined) {
|
||||
throw new Error("Can't clear the cache in an invalid database.");
|
||||
}
|
||||
): Promise<void>;
|
||||
|
||||
const db = dbItem.databaseUri.fsPath;
|
||||
const params: ClearCacheParams = {
|
||||
dryRun: false,
|
||||
db,
|
||||
};
|
||||
await this.qs.sendRequest(clearCache, params, token, progress);
|
||||
}
|
||||
|
||||
public async compileAndRunQueryAgainstDatabaseCore(
|
||||
/**
|
||||
* Overridden in subclasses to evaluate the query via the query server and return the results.
|
||||
*/
|
||||
public abstract compileAndRunQueryAgainstDatabaseCore(
|
||||
dbPath: string,
|
||||
query: CoreQueryTarget,
|
||||
additionalPacks: string[],
|
||||
@@ -78,88 +76,76 @@ export class NewQueryRunner extends QueryRunner {
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
templates: Record<string, string> | undefined,
|
||||
logger: Logger,
|
||||
): Promise<CoreQueryResults> {
|
||||
return await compileAndRunQueryAgainstDatabaseCore(
|
||||
this.qs,
|
||||
logger: BaseLogger,
|
||||
): Promise<CoreQueryResults>;
|
||||
|
||||
abstract deregisterDatabase(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
dbItem: DatabaseItem,
|
||||
): Promise<void>;
|
||||
|
||||
abstract registerDatabase(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
dbItem: DatabaseItem,
|
||||
): Promise<void>;
|
||||
|
||||
abstract upgradeDatabaseExplicit(
|
||||
dbItem: DatabaseItem,
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
): Promise<void>;
|
||||
|
||||
abstract clearPackCache(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Create a `CoreQueryRun` object. This creates an object whose `evaluate()` function can be
|
||||
* called to actually evaluate the query. The returned object also contains information about the
|
||||
* query evaluation that is known even before evaluation starts, including the unique ID of the
|
||||
* evaluation and the path to its output directory.
|
||||
*/
|
||||
public createQueryRun(
|
||||
dbPath: string,
|
||||
query: CoreQueryTarget,
|
||||
generateEvalLog: boolean,
|
||||
additionalPacks: string[],
|
||||
extensionPacks: string[] | undefined,
|
||||
queryStorageDir: string,
|
||||
id = `${basename(query.queryPath)}-${nanoid()}`,
|
||||
templates: Record<string, string> | undefined,
|
||||
): CoreQueryRun {
|
||||
const outputDir = new QueryOutputDir(join(queryStorageDir, id));
|
||||
|
||||
return {
|
||||
queryTarget: query,
|
||||
dbPath,
|
||||
query,
|
||||
generateEvalLog,
|
||||
additionalPacks,
|
||||
extensionPacks,
|
||||
id,
|
||||
outputDir,
|
||||
progress,
|
||||
token,
|
||||
templates,
|
||||
logger,
|
||||
);
|
||||
}
|
||||
|
||||
async deregisterDatabase(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
dbItem: DatabaseItem,
|
||||
): Promise<void> {
|
||||
if (dbItem.contents) {
|
||||
const databases: string[] = [dbItem.databaseUri.fsPath];
|
||||
await this.qs.sendRequest(
|
||||
deregisterDatabases,
|
||||
{ databases },
|
||||
token,
|
||||
progress,
|
||||
);
|
||||
}
|
||||
}
|
||||
async registerDatabase(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
dbItem: DatabaseItem,
|
||||
): Promise<void> {
|
||||
if (dbItem.contents) {
|
||||
const databases: string[] = [dbItem.databaseUri.fsPath];
|
||||
await this.qs.sendRequest(
|
||||
registerDatabases,
|
||||
{ databases },
|
||||
token,
|
||||
progress,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async clearPackCache(): Promise<void> {
|
||||
await this.qs.sendRequest(clearPackCache, {});
|
||||
}
|
||||
|
||||
async upgradeDatabaseExplicit(
|
||||
dbItem: DatabaseItem,
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
): Promise<void> {
|
||||
const yesItem = { title: "Yes", isCloseAffordance: false };
|
||||
const noItem = { title: "No", isCloseAffordance: true };
|
||||
const dialogOptions: vscode.MessageItem[] = [yesItem, noItem];
|
||||
|
||||
const message = `Should the database ${dbItem.databaseUri.fsPath} be destructively upgraded?\n\nThis should not be necessary to run queries
|
||||
as we will non-destructively update it anyway.`;
|
||||
const chosenItem = await vscode.window.showInformationMessage(
|
||||
message,
|
||||
{ modal: true },
|
||||
...dialogOptions,
|
||||
);
|
||||
|
||||
if (chosenItem !== yesItem) {
|
||||
throw new UserCancellationException(
|
||||
"User cancelled the database upgrade.",
|
||||
);
|
||||
}
|
||||
await this.qs.sendRequest(
|
||||
upgradeDatabase,
|
||||
{
|
||||
db: dbItem.databaseUri.fsPath,
|
||||
additionalPacks: getOnDiskWorkspaceFolders(),
|
||||
evaluate: async (
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
logger: BaseLogger,
|
||||
): Promise<CoreCompletedQuery> => {
|
||||
return {
|
||||
id,
|
||||
outputDir,
|
||||
dbPath,
|
||||
queryTarget: query,
|
||||
...(await this.compileAndRunQueryAgainstDatabaseCore(
|
||||
dbPath,
|
||||
query,
|
||||
additionalPacks,
|
||||
extensionPacks,
|
||||
generateEvalLog,
|
||||
outputDir,
|
||||
progress,
|
||||
token,
|
||||
templates,
|
||||
logger,
|
||||
)),
|
||||
};
|
||||
},
|
||||
token,
|
||||
progress,
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
WithProgressId,
|
||||
} from "../pure/new-messages";
|
||||
import { ProgressCallback, ProgressTask } from "../progress";
|
||||
import { ServerProcess } from "../json-rpc-server";
|
||||
import { ServerProcess } from "./server-process";
|
||||
import { App } from "../common/app";
|
||||
|
||||
type ServerOpts = {
|
||||
@@ -2,8 +2,8 @@ import { CancellationToken } from "vscode";
|
||||
import { ProgressCallback } from "../progress";
|
||||
import * as messages from "../pure/new-messages";
|
||||
import { QueryOutputDir } from "../run-queries-shared";
|
||||
import * as qsClient from "./queryserver-client";
|
||||
import { CoreQueryResults, CoreQueryTarget } from "../queryRunner";
|
||||
import * as qsClient from "./query-server-client";
|
||||
import { CoreQueryResults, CoreQueryTarget } from "./query-runner";
|
||||
import { Logger } from "../common";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Logger } from "./common";
|
||||
import { Logger } from "../common";
|
||||
import * as cp from "child_process";
|
||||
import { Disposable } from "vscode";
|
||||
import { MessageConnection } from "vscode-jsonrpc";
|
||||
@@ -1,151 +0,0 @@
|
||||
import { CancellationToken } from "vscode";
|
||||
import { CodeQLCliServer } from "./cli";
|
||||
import { ProgressCallback } from "./progress";
|
||||
import { DatabaseItem } from "./local-databases";
|
||||
import { QueryOutputDir } from "./run-queries-shared";
|
||||
import { Position, QueryResultType } from "./pure/new-messages";
|
||||
import { BaseLogger, Logger } from "./common";
|
||||
import { basename, join } from "path";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
export interface CoreQueryTarget {
|
||||
/** The full path to the query. */
|
||||
queryPath: string;
|
||||
/**
|
||||
* Optional position of text to be used as QuickEval target. This need not be in the same file as
|
||||
* `query`.
|
||||
*/
|
||||
quickEvalPosition?: Position;
|
||||
}
|
||||
|
||||
export interface CoreQueryResults {
|
||||
readonly resultType: QueryResultType;
|
||||
readonly message: string | undefined;
|
||||
readonly evaluationTime: number;
|
||||
}
|
||||
|
||||
export interface CoreQueryRun {
|
||||
readonly queryTarget: CoreQueryTarget;
|
||||
readonly dbPath: string;
|
||||
readonly id: string;
|
||||
readonly outputDir: QueryOutputDir;
|
||||
|
||||
evaluate(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
logger: BaseLogger,
|
||||
): Promise<CoreCompletedQuery>;
|
||||
}
|
||||
|
||||
/** Includes both the results of the query and the initial information from `CoreQueryRun`. */
|
||||
export type CoreCompletedQuery = CoreQueryResults &
|
||||
Omit<CoreQueryRun, "evaluate">;
|
||||
|
||||
export abstract class QueryRunner {
|
||||
abstract restartQueryServer(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
): Promise<void>;
|
||||
|
||||
abstract cliServer: CodeQLCliServer;
|
||||
abstract customLogDirectory: string | undefined;
|
||||
abstract logger: Logger;
|
||||
|
||||
abstract onStart(
|
||||
arg0: (
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
) => Promise<void>,
|
||||
): void;
|
||||
abstract clearCacheInDatabase(
|
||||
dbItem: DatabaseItem,
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
* Overridden in subclasses to evaluate the query via the query server and return the results.
|
||||
*/
|
||||
public abstract compileAndRunQueryAgainstDatabaseCore(
|
||||
dbPath: string,
|
||||
query: CoreQueryTarget,
|
||||
additionalPacks: string[],
|
||||
extensionPacks: string[] | undefined,
|
||||
generateEvalLog: boolean,
|
||||
outputDir: QueryOutputDir,
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
templates: Record<string, string> | undefined,
|
||||
logger: BaseLogger,
|
||||
): Promise<CoreQueryResults>;
|
||||
|
||||
abstract deregisterDatabase(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
dbItem: DatabaseItem,
|
||||
): Promise<void>;
|
||||
|
||||
abstract registerDatabase(
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
dbItem: DatabaseItem,
|
||||
): Promise<void>;
|
||||
|
||||
abstract upgradeDatabaseExplicit(
|
||||
dbItem: DatabaseItem,
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
): Promise<void>;
|
||||
|
||||
abstract clearPackCache(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Create a `CoreQueryRun` object. This creates an object whose `evaluate()` function can be
|
||||
* called to actually evaluate the query. The returned object also contains information about the
|
||||
* query evaluation that is known even before evaluation starts, including the unique ID of the
|
||||
* evaluation and the path to its output directory.
|
||||
*/
|
||||
public createQueryRun(
|
||||
dbPath: string,
|
||||
query: CoreQueryTarget,
|
||||
generateEvalLog: boolean,
|
||||
additionalPacks: string[],
|
||||
extensionPacks: string[] | undefined,
|
||||
queryStorageDir: string,
|
||||
id = `${basename(query.queryPath)}-${nanoid()}`,
|
||||
templates: Record<string, string> | undefined,
|
||||
): CoreQueryRun {
|
||||
const outputDir = new QueryOutputDir(join(queryStorageDir, id));
|
||||
|
||||
return {
|
||||
queryTarget: query,
|
||||
dbPath,
|
||||
id,
|
||||
outputDir,
|
||||
evaluate: async (
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
logger: BaseLogger,
|
||||
): Promise<CoreCompletedQuery> => {
|
||||
return {
|
||||
id,
|
||||
outputDir,
|
||||
dbPath,
|
||||
queryTarget: query,
|
||||
...(await this.compileAndRunQueryAgainstDatabaseCore(
|
||||
dbPath,
|
||||
query,
|
||||
additionalPacks,
|
||||
extensionPacks,
|
||||
generateEvalLog,
|
||||
outputDir,
|
||||
progress,
|
||||
token,
|
||||
templates,
|
||||
logger,
|
||||
)),
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
[
|
||||
"v2.12.6",
|
||||
"v2.12.7",
|
||||
"v2.11.6",
|
||||
"v2.7.6",
|
||||
"v2.8.5",
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
import * as CodeQLProtocol from "../../../../src/debugger/debug-protocol";
|
||||
import { DisposableObject } from "../../../../src/pure/disposable-object";
|
||||
import { QueryResultType } from "../../../../src/pure/legacy-messages";
|
||||
import { CoreCompletedQuery } from "../../../../src/queryRunner";
|
||||
import { CoreCompletedQuery } from "../../../../src/query-server/query-runner";
|
||||
import { QueryOutputDir } from "../../../../src/run-queries-shared";
|
||||
import {
|
||||
QLDebugArgs,
|
||||
|
||||
@@ -4,11 +4,11 @@ import { dirSync } from "tmp";
|
||||
import { pathToFileURL } from "url";
|
||||
import { CancellationTokenSource } from "vscode-jsonrpc";
|
||||
import * as messages from "../../../src/pure/legacy-messages";
|
||||
import * as qsClient from "../../../src/legacy-query-server/queryserver-client";
|
||||
import * as qsClient from "../../../src/query-server/legacy/query-server-client";
|
||||
import * as cli from "../../../src/cli";
|
||||
import { CellValue } from "../../../src/pure/bqrs-cli-types";
|
||||
import { describeWithCodeQL } from "../cli";
|
||||
import { QueryServerClient } from "../../../src/legacy-query-server/queryserver-client";
|
||||
import { QueryServerClient } from "../../../src/query-server/legacy/query-server-client";
|
||||
import { extLogger, ProgressReporter } from "../../../src/common";
|
||||
import { createMockApp } from "../../__mocks__/appMock";
|
||||
import { getActivatedExtension } from "../global.helper";
|
||||
|
||||
@@ -2,11 +2,11 @@ import { join, basename } from "path";
|
||||
import { dirSync } from "tmp";
|
||||
import { CancellationTokenSource } from "vscode-jsonrpc";
|
||||
import * as messages from "../../../src/pure/new-messages";
|
||||
import * as qsClient from "../../../src/query-server/queryserver-client";
|
||||
import * as qsClient from "../../../src/query-server/query-server-client";
|
||||
import * as cli from "../../../src/cli";
|
||||
import { CellValue } from "../../../src/pure/bqrs-cli-types";
|
||||
import { describeWithCodeQL } from "../cli";
|
||||
import { QueryServerClient } from "../../../src/query-server/queryserver-client";
|
||||
import { QueryServerClient } from "../../../src/query-server/query-server-client";
|
||||
import { extLogger, ProgressReporter } from "../../../src/common";
|
||||
import { QueryResultType } from "../../../src/pure/new-messages";
|
||||
import { ensureTestDatabase, getActivatedExtension } from "../global.helper";
|
||||
|
||||
@@ -17,9 +17,12 @@ import {
|
||||
} from "../global.helper";
|
||||
import { CliVersionConstraint, CodeQLCliServer } from "../../../src/cli";
|
||||
import { describeWithCodeQL } from "../cli";
|
||||
import { CoreCompletedQuery, QueryRunner } from "../../../src/queryRunner";
|
||||
import {
|
||||
CoreCompletedQuery,
|
||||
QueryRunner,
|
||||
} from "../../../src/query-server/query-runner";
|
||||
import { SELECT_QUERY_NAME } from "../../../src/contextual/locationFinder";
|
||||
import { LocalQueries } from "../../../src/local-queries/local-queries";
|
||||
import { LocalQueries } from "../../../src/local-queries";
|
||||
import { QueryResultType } from "../../../src/pure/new-messages";
|
||||
import { createVSCodeCommandManager } from "../../../src/common/vscode/commands";
|
||||
import {
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
encodeSourceArchiveUri,
|
||||
} from "../../../src/archive-filesystem-provider";
|
||||
import { testDisposeHandler } from "../test-dispose-handler";
|
||||
import { QueryRunner } from "../../../src/queryRunner";
|
||||
import { QueryRunner } from "../../../src/query-server/query-runner";
|
||||
import * as helpers from "../../../src/helpers";
|
||||
import { Setting } from "../../../src/config";
|
||||
import { QlPackGenerator } from "../../../src/qlpack-generator";
|
||||
|
||||
@@ -635,7 +635,7 @@ describe("prepareCodeTour", () => {
|
||||
|
||||
describe("if the workspace is already open", () => {
|
||||
it("should not open the tutorial workspace", async () => {
|
||||
// Set isCodespaceTemplate to true to indicate the workspace has already been opened
|
||||
// Set isCodespacesTemplate to true to indicate the workspace has already been opened
|
||||
jest.spyOn(Setting.prototype, "getValue").mockReturnValue(true);
|
||||
|
||||
// set up directory to have a 'tutorial.code-workspace' file
|
||||
|
||||
@@ -9,7 +9,7 @@ import { tmpDir } from "../../../../src/helpers";
|
||||
import { HistoryItemLabelProvider } from "../../../../src/query-history/history-item-label-provider";
|
||||
import { ResultsView } from "../../../../src/interface";
|
||||
import { EvalLogViewer } from "../../../../src/eval-log-viewer";
|
||||
import { QueryRunner } from "../../../../src/queryRunner";
|
||||
import { QueryRunner } from "../../../../src/query-server/query-runner";
|
||||
import { VariantAnalysisManager } from "../../../../src/variant-analysis/variant-analysis-manager";
|
||||
import { QueryHistoryInfo } from "../../../../src/query-history/query-history-info";
|
||||
import {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { tmpDir } from "../../../../src/helpers";
|
||||
import { HistoryItemLabelProvider } from "../../../../src/query-history/history-item-label-provider";
|
||||
import { ResultsView } from "../../../../src/interface";
|
||||
import { EvalLogViewer } from "../../../../src/eval-log-viewer";
|
||||
import { QueryRunner } from "../../../../src/queryRunner";
|
||||
import { QueryRunner } from "../../../../src/query-server/query-runner";
|
||||
import { VariantAnalysisManager } from "../../../../src/variant-analysis/variant-analysis-manager";
|
||||
import { QueryHistoryInfo } from "../../../../src/query-history/query-history-info";
|
||||
import {
|
||||
@@ -247,20 +247,6 @@ describe("QueryHistoryManager", () => {
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("no selection", () => {
|
||||
it("should do nothing", async () => {
|
||||
queryHistoryManager = await createMockQueryHistory(allHistory);
|
||||
|
||||
await queryHistoryManager.handleItemClicked(undefined!, []);
|
||||
|
||||
expect(localQueriesResultsViewStub.showResults).not.toHaveBeenCalled();
|
||||
expect(variantAnalysisManagerStub.showView).not.toHaveBeenCalled();
|
||||
expect(
|
||||
queryHistoryManager.treeDataProvider.getCurrent(),
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("handleRemoveHistoryItem", () => {
|
||||
@@ -831,93 +817,6 @@ describe("QueryHistoryManager", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("determineSelection", () => {
|
||||
const singleItem = "a";
|
||||
const multipleItems = ["b", "c", "d"];
|
||||
|
||||
it("should get the selection from parameters", async () => {
|
||||
queryHistoryManager = await createMockQueryHistory(allHistory);
|
||||
const selection = (queryHistoryManager as any).determineSelection(
|
||||
singleItem,
|
||||
multipleItems,
|
||||
);
|
||||
expect(selection).toEqual({
|
||||
finalSingleItem: singleItem,
|
||||
finalMultiSelect: multipleItems,
|
||||
});
|
||||
});
|
||||
|
||||
it("should get the selection when single selection is empty", async () => {
|
||||
queryHistoryManager = await createMockQueryHistory(allHistory);
|
||||
const selection = (queryHistoryManager as any).determineSelection(
|
||||
undefined,
|
||||
multipleItems,
|
||||
);
|
||||
expect(selection).toEqual({
|
||||
finalSingleItem: multipleItems[0],
|
||||
finalMultiSelect: multipleItems,
|
||||
});
|
||||
});
|
||||
|
||||
it("should get the selection when multi-selection is empty", async () => {
|
||||
queryHistoryManager = await createMockQueryHistory(allHistory);
|
||||
const selection = (queryHistoryManager as any).determineSelection(
|
||||
singleItem,
|
||||
undefined,
|
||||
);
|
||||
expect(selection).toEqual({
|
||||
finalSingleItem: singleItem,
|
||||
finalMultiSelect: [singleItem],
|
||||
});
|
||||
});
|
||||
|
||||
it("should get the selection from the treeView when both selections are empty", async () => {
|
||||
queryHistoryManager = await createMockQueryHistory(allHistory);
|
||||
const p = new Promise<void>((done) => {
|
||||
queryHistoryManager!.treeView.onDidChangeSelection((s) => {
|
||||
if (s.selection[0] !== allHistory[1]) {
|
||||
return;
|
||||
}
|
||||
const selection = (queryHistoryManager as any).determineSelection(
|
||||
undefined,
|
||||
undefined,
|
||||
);
|
||||
expect(selection).toEqual({
|
||||
finalSingleItem: allHistory[1],
|
||||
finalMultiSelect: [allHistory[1]],
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// I can't explain why, but the first time the onDidChangeSelection event fires, the selection is
|
||||
// not correct (it is inexplicably allHistory[2]). So we fire the event a second time to get the
|
||||
// correct selection.
|
||||
await queryHistoryManager.treeView.reveal(allHistory[0], {
|
||||
select: true,
|
||||
});
|
||||
await queryHistoryManager.treeView.reveal(allHistory[1], {
|
||||
select: true,
|
||||
});
|
||||
await p;
|
||||
});
|
||||
|
||||
it.skip("should get the selection from the treeDataProvider when both selections and the treeView are empty", async () => {
|
||||
queryHistoryManager = await createMockQueryHistory(allHistory);
|
||||
await queryHistoryManager.treeView.reveal(allHistory[1], {
|
||||
select: true,
|
||||
});
|
||||
const selection = (queryHistoryManager as any).determineSelection(
|
||||
undefined,
|
||||
undefined,
|
||||
);
|
||||
expect(selection).toEqual({
|
||||
finalSingleItem: allHistory[1],
|
||||
finalMultiSelect: [allHistory[1]],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Local Queries", () => {
|
||||
describe("findOtherQueryToCompare", () => {
|
||||
it("should find the second query to compare when one is selected", async () => {
|
||||
|
||||
@@ -13,7 +13,7 @@ import { DatabaseInfo } from "../../../../../src/pure/interface-types";
|
||||
import { CancellationTokenSource, Uri } from "vscode";
|
||||
import { tmpDir } from "../../../../../src/helpers";
|
||||
import { QueryResultType } from "../../../../../src/pure/legacy-messages";
|
||||
import { QueryInProgress } from "../../../../../src/legacy-query-server/run-queries";
|
||||
import { QueryInProgress } from "../../../../../src/query-server/legacy";
|
||||
import { VariantAnalysisHistoryItem } from "../../../../../src/query-history/variant-analysis-history-item";
|
||||
import { QueryHistoryInfo } from "../../../../../src/query-history/query-history-info";
|
||||
import { createMockVariantAnalysisHistoryItem } from "../../../../factories/query-history/variant-analysis-history-item";
|
||||
|
||||
@@ -16,7 +16,7 @@ import { testDisposeHandler } from "../../test-dispose-handler";
|
||||
import { HistoryItemLabelProvider } from "../../../../src/query-history/history-item-label-provider";
|
||||
import { ResultsView } from "../../../../src/interface";
|
||||
import { EvalLogViewer } from "../../../../src/eval-log-viewer";
|
||||
import { QueryRunner } from "../../../../src/queryRunner";
|
||||
import { QueryRunner } from "../../../../src/query-server/query-runner";
|
||||
import { VariantAnalysisManager } from "../../../../src/variant-analysis/variant-analysis-manager";
|
||||
import { QueryHistoryManager } from "../../../../src/query-history/query-history-manager";
|
||||
import { mockedObject } from "../../utils/mocking.helpers";
|
||||
|
||||
@@ -24,7 +24,7 @@ import { tmpDir } from "../../../src/helpers";
|
||||
import {
|
||||
formatLegacyMessage,
|
||||
QueryInProgress,
|
||||
} from "../../../src/legacy-query-server/run-queries";
|
||||
} from "../../../src/query-server/legacy/run-queries";
|
||||
import {
|
||||
EvaluationResult,
|
||||
QueryResultType,
|
||||
|
||||
@@ -10,14 +10,16 @@ import {
|
||||
} from "../../../src/pure/legacy-messages";
|
||||
import * as config from "../../../src/config";
|
||||
import { tmpDir } from "../../../src/helpers";
|
||||
import { QueryServerClient } from "../../../src/legacy-query-server/queryserver-client";
|
||||
import { CodeQLCliServer } from "../../../src/cli";
|
||||
import { SELECT_QUERY_NAME } from "../../../src/contextual/locationFinder";
|
||||
import {
|
||||
QueryInProgress,
|
||||
compileQuery as compileQueryLegacy,
|
||||
} from "../../../src/legacy-query-server/run-queries";
|
||||
import { LegacyQueryRunner } from "../../../src/legacy-query-server/legacyRunner";
|
||||
} from "../../../src/query-server/legacy/run-queries";
|
||||
import {
|
||||
LegacyQueryRunner,
|
||||
QueryServerClient,
|
||||
} from "../../../src/query-server/legacy";
|
||||
import { DatabaseItem } from "../../../src/local-databases";
|
||||
import { DeepPartial, mockedObject } from "../utils/mocking.helpers";
|
||||
import { BqrsKind } from "../../../src/pure/bqrs-cli-types";
|
||||
|
||||
Reference in New Issue
Block a user