Move show and log functions out of helpers
This commit is contained in:
@@ -6,7 +6,6 @@ import * as semver from "semver";
|
|||||||
import { URL } from "url";
|
import { URL } from "url";
|
||||||
import { ExtensionContext, Event } from "vscode";
|
import { ExtensionContext, Event } from "vscode";
|
||||||
import { DistributionConfig } from "../config";
|
import { DistributionConfig } from "../config";
|
||||||
import { showAndLogErrorMessage, showAndLogWarningMessage } from "../helpers";
|
|
||||||
import { extLogger } from "../common";
|
import { extLogger } from "../common";
|
||||||
import { getCodeQlCliVersion } from "./cli-version";
|
import { getCodeQlCliVersion } from "./cli-version";
|
||||||
import {
|
import {
|
||||||
@@ -23,6 +22,10 @@ import {
|
|||||||
InvocationRateLimiter,
|
InvocationRateLimiter,
|
||||||
InvocationRateLimiterResultKind,
|
InvocationRateLimiterResultKind,
|
||||||
} from "../common/invocation-rate-limiter";
|
} from "../common/invocation-rate-limiter";
|
||||||
|
import {
|
||||||
|
showAndLogErrorMessage,
|
||||||
|
showAndLogWarningMessage,
|
||||||
|
} from "../common/vscode/log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* distribution.ts
|
* distribution.ts
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import {
|
|||||||
} from "../../pure/helpers-pure";
|
} from "../../pure/helpers-pure";
|
||||||
import { redactableError } from "../../pure/errors";
|
import { redactableError } from "../../pure/errors";
|
||||||
import { UserCancellationException } from "./progress";
|
import { UserCancellationException } from "./progress";
|
||||||
|
import { telemetryListener } from "../../telemetry";
|
||||||
import {
|
import {
|
||||||
showAndLogExceptionWithTelemetry,
|
showAndLogExceptionWithTelemetry,
|
||||||
showAndLogWarningMessage,
|
showAndLogWarningMessage,
|
||||||
} from "../../helpers";
|
} from "./log";
|
||||||
import { telemetryListener } from "../../telemetry";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a command manager for VSCode, wrapping registerCommandWithErrorHandling
|
* Create a command manager for VSCode, wrapping registerCommandWithErrorHandling
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Uri, window } from "vscode";
|
import { Uri, window } from "vscode";
|
||||||
import { AppCommandManager } from "../commands";
|
import { AppCommandManager } from "../commands";
|
||||||
import { showAndLogExceptionWithTelemetry } from "../../helpers";
|
|
||||||
import { showBinaryChoiceDialog } from "./dialog";
|
import { showBinaryChoiceDialog } from "./dialog";
|
||||||
import { redactableError } from "../../pure/errors";
|
import { redactableError } from "../../pure/errors";
|
||||||
import {
|
import {
|
||||||
@@ -8,6 +7,7 @@ import {
|
|||||||
getErrorMessage,
|
getErrorMessage,
|
||||||
getErrorStack,
|
getErrorStack,
|
||||||
} from "../../pure/helpers-pure";
|
} from "../../pure/helpers-pure";
|
||||||
|
import { showAndLogExceptionWithTelemetry } from "./log";
|
||||||
|
|
||||||
export async function tryOpenExternalFile(
|
export async function tryOpenExternalFile(
|
||||||
commandManager: AppCommandManager,
|
commandManager: AppCommandManager,
|
||||||
|
|||||||
109
extensions/ql-vscode/src/common/vscode/log.ts
Normal file
109
extensions/ql-vscode/src/common/vscode/log.ts
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
import { window } from "vscode";
|
||||||
|
import { RedactableError } from "../../pure/errors";
|
||||||
|
import { telemetryListener } from "../../telemetry";
|
||||||
|
import { extLogger, OutputChannelLogger } from "../logging";
|
||||||
|
|
||||||
|
interface ShowAndLogExceptionOptions extends ShowAndLogOptions {
|
||||||
|
/** Custom properties to include in the telemetry report. */
|
||||||
|
extraTelemetryProperties?: { [key: string]: string };
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ShowAndLogOptions {
|
||||||
|
/** The output logger that will receive the message. */
|
||||||
|
outputLogger?: OutputChannelLogger;
|
||||||
|
/** A set of items that will be rendered as actions in the message. */
|
||||||
|
items?: string[];
|
||||||
|
/**
|
||||||
|
* An alternate message that is added to the log, but not displayed in the popup.
|
||||||
|
* This is useful for adding extra detail to the logs that would be too noisy for the popup.
|
||||||
|
*/
|
||||||
|
fullMessage?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show an error message, log it to the console, and emit redacted information as telemetry
|
||||||
|
*
|
||||||
|
* @param error The error to show. Only redacted information will be included in the telemetry.
|
||||||
|
* @param options See individual fields on `ShowAndLogExceptionOptions` type.
|
||||||
|
*
|
||||||
|
* @return A promise that resolves to the selected item or undefined when being dismissed.
|
||||||
|
*/
|
||||||
|
export async function showAndLogExceptionWithTelemetry(
|
||||||
|
error: RedactableError,
|
||||||
|
options: ShowAndLogExceptionOptions = {},
|
||||||
|
): Promise<string | undefined> {
|
||||||
|
telemetryListener?.sendError(error, options.extraTelemetryProperties);
|
||||||
|
return showAndLogErrorMessage(error.fullMessage, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show an error message and log it to the console
|
||||||
|
*
|
||||||
|
* @param message The message to show.
|
||||||
|
* @param options See individual fields on `ShowAndLogOptions` type.
|
||||||
|
*
|
||||||
|
* @return A promise that resolves to the selected item or undefined when being dismissed.
|
||||||
|
*/
|
||||||
|
export async function showAndLogErrorMessage(
|
||||||
|
message: string,
|
||||||
|
options?: ShowAndLogOptions,
|
||||||
|
): Promise<string | undefined> {
|
||||||
|
return internalShowAndLog(
|
||||||
|
dropLinesExceptInitial(message),
|
||||||
|
window.showErrorMessage,
|
||||||
|
{ fullMessage: message, ...options },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function dropLinesExceptInitial(message: string, n = 2) {
|
||||||
|
return message.toString().split(/\r?\n/).slice(0, n).join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a warning message and log it to the console
|
||||||
|
*
|
||||||
|
* @param message The message to show.
|
||||||
|
* @param options See individual fields on `ShowAndLogOptions` type.
|
||||||
|
*
|
||||||
|
* @return A promise that resolves to the selected item or undefined when being dismissed.
|
||||||
|
*/
|
||||||
|
export async function showAndLogWarningMessage(
|
||||||
|
message: string,
|
||||||
|
options?: ShowAndLogOptions,
|
||||||
|
): Promise<string | undefined> {
|
||||||
|
return internalShowAndLog(message, window.showWarningMessage, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show an information message and log it to the console
|
||||||
|
*
|
||||||
|
* @param message The message to show.
|
||||||
|
* @param options See individual fields on `ShowAndLogOptions` type.
|
||||||
|
*
|
||||||
|
* @return A promise that resolves to the selected item or undefined when being dismissed.
|
||||||
|
*/
|
||||||
|
export async function showAndLogInformationMessage(
|
||||||
|
message: string,
|
||||||
|
options?: ShowAndLogOptions,
|
||||||
|
): Promise<string | undefined> {
|
||||||
|
return internalShowAndLog(message, window.showInformationMessage, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
type ShowMessageFn = (
|
||||||
|
message: string,
|
||||||
|
...items: string[]
|
||||||
|
) => Thenable<string | undefined>;
|
||||||
|
|
||||||
|
async function internalShowAndLog(
|
||||||
|
message: string,
|
||||||
|
fn: ShowMessageFn,
|
||||||
|
{ items = [], outputLogger = extLogger, fullMessage }: ShowAndLogOptions = {},
|
||||||
|
): Promise<string | undefined> {
|
||||||
|
const label = "Show Log";
|
||||||
|
void outputLogger.log(fullMessage || message);
|
||||||
|
const result = await fn(message, label, ...items);
|
||||||
|
if (result === label) {
|
||||||
|
outputLogger.show();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { showAndLogErrorMessage } from "../../helpers";
|
|
||||||
import {
|
import {
|
||||||
ExplorerSelectionCommandFunction,
|
ExplorerSelectionCommandFunction,
|
||||||
TreeViewContextMultiSelectionCommandFunction,
|
TreeViewContextMultiSelectionCommandFunction,
|
||||||
TreeViewContextSingleSelectionCommandFunction,
|
TreeViewContextSingleSelectionCommandFunction,
|
||||||
} from "../commands";
|
} from "../commands";
|
||||||
|
import { showAndLogErrorMessage } from "./log";
|
||||||
|
|
||||||
// A hack to match types that are not an array, which is useful to help avoid
|
// A hack to match types that are not an array, which is useful to help avoid
|
||||||
// misusing createSingleSelectionCommand, e.g. where T accidentally gets instantiated
|
// misusing createSingleSelectionCommand, e.g. where T accidentally gets instantiated
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ import {
|
|||||||
} from "../common/vscode/abstract-webview";
|
} from "../common/vscode/abstract-webview";
|
||||||
import { telemetryListener } from "../telemetry";
|
import { telemetryListener } from "../telemetry";
|
||||||
import { redactableError } from "../pure/errors";
|
import { redactableError } from "../pure/errors";
|
||||||
import { showAndLogExceptionWithTelemetry } from "../helpers";
|
|
||||||
|
import { showAndLogExceptionWithTelemetry } from "../common/vscode/log";
|
||||||
|
|
||||||
interface ComparePair {
|
interface ComparePair {
|
||||||
from: CompletedLocalQueryInfo;
|
from: CompletedLocalQueryInfo;
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import { DatabaseManager } from "../databases/local-databases";
|
|||||||
import { ensureDir } from "fs-extra";
|
import { ensureDir } from "fs-extra";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { App } from "../common/app";
|
import { App } from "../common/app";
|
||||||
import { showAndLogErrorMessage } from "../helpers";
|
|
||||||
import { withProgress } from "../common/vscode/progress";
|
import { withProgress } from "../common/vscode/progress";
|
||||||
import { pickExtensionPackModelFile } from "./extension-pack-picker";
|
import { pickExtensionPackModelFile } from "./extension-pack-picker";
|
||||||
|
import { showAndLogErrorMessage } from "../common/vscode/log";
|
||||||
|
|
||||||
const SUPPORTED_LANGUAGES: string[] = ["java", "csharp"];
|
const SUPPORTED_LANGUAGES: string[] = ["java", "csharp"];
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,6 @@ import {
|
|||||||
} from "../pure/interface-types";
|
} from "../pure/interface-types";
|
||||||
import { ProgressUpdate } from "../common/vscode/progress";
|
import { ProgressUpdate } from "../common/vscode/progress";
|
||||||
import { QueryRunner } from "../query-server";
|
import { QueryRunner } from "../query-server";
|
||||||
import {
|
|
||||||
showAndLogErrorMessage,
|
|
||||||
showAndLogExceptionWithTelemetry,
|
|
||||||
} from "../helpers";
|
|
||||||
import { extLogger } from "../common";
|
import { extLogger } from "../common";
|
||||||
import { outputFile, pathExists, readFile } from "fs-extra";
|
import { outputFile, pathExists, readFile } from "fs-extra";
|
||||||
import { load as loadYaml } from "js-yaml";
|
import { load as loadYaml } from "js-yaml";
|
||||||
@@ -46,6 +42,10 @@ import {
|
|||||||
} from "./auto-model";
|
} from "./auto-model";
|
||||||
import { showLlmGeneration } from "../config";
|
import { showLlmGeneration } from "../config";
|
||||||
import { getAutoModelUsages } from "./auto-model-usages-query";
|
import { getAutoModelUsages } from "./auto-model-usages-query";
|
||||||
|
import {
|
||||||
|
showAndLogErrorMessage,
|
||||||
|
showAndLogExceptionWithTelemetry,
|
||||||
|
} from "../common/vscode/log";
|
||||||
|
|
||||||
export class DataExtensionsEditorView extends AbstractWebview<
|
export class DataExtensionsEditorView extends AbstractWebview<
|
||||||
ToDataExtensionsEditorMessage,
|
ToDataExtensionsEditorMessage,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { dump as dumpYaml, load as loadYaml } from "js-yaml";
|
|||||||
import { minimatch } from "minimatch";
|
import { minimatch } from "minimatch";
|
||||||
import { CancellationToken, window } from "vscode";
|
import { CancellationToken, window } from "vscode";
|
||||||
import { CodeQLCliServer } from "../codeql-cli/cli";
|
import { CodeQLCliServer } from "../codeql-cli/cli";
|
||||||
import { showAndLogErrorMessage } from "../helpers";
|
|
||||||
import {
|
import {
|
||||||
getOnDiskWorkspaceFolders,
|
getOnDiskWorkspaceFolders,
|
||||||
getOnDiskWorkspaceFoldersObjects,
|
getOnDiskWorkspaceFoldersObjects,
|
||||||
@@ -14,6 +13,7 @@ import { DatabaseItem } from "../databases/local-databases";
|
|||||||
import { getQlPackPath, QLPACK_FILENAMES } from "../pure/ql";
|
import { getQlPackPath, QLPACK_FILENAMES } from "../pure/ql";
|
||||||
import { getErrorMessage } from "../pure/helpers-pure";
|
import { getErrorMessage } from "../pure/helpers-pure";
|
||||||
import { ExtensionPack, ExtensionPackModelFile } from "./shared/extension-pack";
|
import { ExtensionPack, ExtensionPackModelFile } from "./shared/extension-pack";
|
||||||
|
import { showAndLogErrorMessage } from "../common/vscode/log";
|
||||||
|
|
||||||
const maxStep = 3;
|
const maxStep = 3;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { CoreCompletedQuery, QueryRunner } from "../query-server";
|
|||||||
import { dir } from "tmp-promise";
|
import { dir } from "tmp-promise";
|
||||||
import { writeFile } from "fs-extra";
|
import { writeFile } from "fs-extra";
|
||||||
import { dump as dumpYaml } from "js-yaml";
|
import { dump as dumpYaml } from "js-yaml";
|
||||||
import { showAndLogExceptionWithTelemetry } from "../helpers";
|
|
||||||
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
||||||
import { TeeLogger } from "../common";
|
import { TeeLogger } from "../common";
|
||||||
import { isQueryLanguage } from "../common/query-language";
|
import { isQueryLanguage } from "../common/query-language";
|
||||||
@@ -14,6 +13,7 @@ import { fetchExternalApiQueries } from "./queries";
|
|||||||
import { QueryResultType } from "../pure/new-messages";
|
import { QueryResultType } from "../pure/new-messages";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { redactableError } from "../pure/errors";
|
import { redactableError } from "../pure/errors";
|
||||||
|
import { showAndLogExceptionWithTelemetry } from "../common/vscode/log";
|
||||||
|
|
||||||
export type RunQueryOptions = {
|
export type RunQueryOptions = {
|
||||||
cliServer: Pick<CodeQLCliServer, "resolveQlpacks">;
|
cliServer: Pick<CodeQLCliServer, "resolveQlpacks">;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { CodeQLCliServer } from "../codeql-cli/cli";
|
|||||||
import { TeeLogger } from "../common";
|
import { TeeLogger } from "../common";
|
||||||
import { extensiblePredicateDefinitions } from "./predicates";
|
import { extensiblePredicateDefinitions } from "./predicates";
|
||||||
import { ProgressCallback } from "../common/vscode/progress";
|
import { ProgressCallback } from "../common/vscode/progress";
|
||||||
import { showAndLogExceptionWithTelemetry } from "../helpers";
|
|
||||||
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
||||||
import {
|
import {
|
||||||
ModeledMethodType,
|
ModeledMethodType,
|
||||||
@@ -18,6 +17,7 @@ import { file } from "tmp-promise";
|
|||||||
import { writeFile } from "fs-extra";
|
import { writeFile } from "fs-extra";
|
||||||
import { dump } from "js-yaml";
|
import { dump } from "js-yaml";
|
||||||
import { qlpackOfDatabase } from "../language-support";
|
import { qlpackOfDatabase } from "../language-support";
|
||||||
|
import { showAndLogExceptionWithTelemetry } from "../common/vscode/log";
|
||||||
|
|
||||||
type FlowModelOptions = {
|
type FlowModelOptions = {
|
||||||
cliServer: CodeQLCliServer;
|
cliServer: CodeQLCliServer;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { retry } from "@octokit/plugin-retry";
|
|||||||
import { throttling } from "@octokit/plugin-throttling";
|
import { throttling } from "@octokit/plugin-throttling";
|
||||||
import { Octokit } from "@octokit/rest";
|
import { Octokit } from "@octokit/rest";
|
||||||
import { Progress, CancellationToken } from "vscode";
|
import { Progress, CancellationToken } from "vscode";
|
||||||
import { showAndLogWarningMessage } from "../helpers";
|
|
||||||
import { Credentials } from "../common/authentication";
|
import { Credentials } from "../common/authentication";
|
||||||
|
import { showAndLogWarningMessage } from "../common/vscode/log";
|
||||||
|
|
||||||
export async function getCodeSearchRepositories(
|
export async function getCodeSearchRepositories(
|
||||||
query: string,
|
query: string,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import * as Octokit from "@octokit/rest";
|
|||||||
import { retry } from "@octokit/plugin-retry";
|
import { retry } from "@octokit/plugin-retry";
|
||||||
|
|
||||||
import { DatabaseManager, DatabaseItem } from "./local-databases";
|
import { DatabaseManager, DatabaseItem } from "./local-databases";
|
||||||
import { showAndLogInformationMessage, tmpDir } from "../helpers";
|
import { tmpDir } from "../helpers";
|
||||||
import {
|
import {
|
||||||
reportStreamProgress,
|
reportStreamProgress,
|
||||||
ProgressCallback,
|
ProgressCallback,
|
||||||
@@ -31,6 +31,7 @@ import {
|
|||||||
import { Credentials } from "../common/authentication";
|
import { Credentials } from "../common/authentication";
|
||||||
import { AppCommandManager } from "../common/commands";
|
import { AppCommandManager } from "../common/commands";
|
||||||
import { ALLOW_HTTP_SETTING } from "../config";
|
import { ALLOW_HTTP_SETTING } from "../config";
|
||||||
|
import { showAndLogInformationMessage } from "../common/vscode/log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prompts a user to fetch a database from a remote location. Database is assumed to be an archive file.
|
* Prompts a user to fetch a database from a remote location. Database is assumed to be an archive file.
|
||||||
|
|||||||
@@ -28,10 +28,6 @@ import {
|
|||||||
withInheritedProgress,
|
withInheritedProgress,
|
||||||
withProgress,
|
withProgress,
|
||||||
} from "../common/vscode/progress";
|
} from "../common/vscode/progress";
|
||||||
import {
|
|
||||||
showAndLogErrorMessage,
|
|
||||||
showAndLogExceptionWithTelemetry,
|
|
||||||
} from "../helpers";
|
|
||||||
import {
|
import {
|
||||||
isLikelyDatabaseRoot,
|
isLikelyDatabaseRoot,
|
||||||
isLikelyDbLanguageFolder,
|
isLikelyDbLanguageFolder,
|
||||||
@@ -52,6 +48,10 @@ import {
|
|||||||
createMultiSelectionCommand,
|
createMultiSelectionCommand,
|
||||||
createSingleSelectionCommand,
|
createSingleSelectionCommand,
|
||||||
} from "../common/vscode/selection-commands";
|
} from "../common/vscode/selection-commands";
|
||||||
|
import {
|
||||||
|
showAndLogErrorMessage,
|
||||||
|
showAndLogExceptionWithTelemetry,
|
||||||
|
} from "../common/vscode/log";
|
||||||
|
|
||||||
enum SortOrder {
|
enum SortOrder {
|
||||||
NameAsc = "NameAsc",
|
NameAsc = "NameAsc",
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import {
|
|||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { FullDatabaseOptions } from "./database-options";
|
import { FullDatabaseOptions } from "./database-options";
|
||||||
import { DatabaseItemImpl } from "./database-item-impl";
|
import { DatabaseItemImpl } from "./database-item-impl";
|
||||||
import { showAndLogExceptionWithTelemetry } from "../../helpers";
|
|
||||||
import { showNeverAskAgainDialog } from "../../common/vscode/dialog";
|
import { showNeverAskAgainDialog } from "../../common/vscode/dialog";
|
||||||
import {
|
import {
|
||||||
getFirstWorkspaceFolder,
|
getFirstWorkspaceFolder,
|
||||||
@@ -29,6 +28,7 @@ import { remove } from "fs-extra";
|
|||||||
import { containsPath } from "../../pure/files";
|
import { containsPath } from "../../pure/files";
|
||||||
import { DatabaseChangedEvent, DatabaseEventKind } from "./database-events";
|
import { DatabaseChangedEvent, DatabaseEventKind } from "./database-events";
|
||||||
import { DatabaseResolver } from "./database-resolver";
|
import { DatabaseResolver } from "./database-resolver";
|
||||||
|
import { showAndLogExceptionWithTelemetry } from "../../common/vscode/log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the key in the workspaceState dictionary in which we
|
* The name of the key in the workspaceState dictionary in which we
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ import {
|
|||||||
DatabaseKind,
|
DatabaseKind,
|
||||||
} from "./database-contents";
|
} from "./database-contents";
|
||||||
import { glob } from "glob";
|
import { glob } from "glob";
|
||||||
|
import { encodeArchiveBasePath } from "../../common/vscode/archive-filesystem-provider";
|
||||||
import {
|
import {
|
||||||
showAndLogInformationMessage,
|
showAndLogInformationMessage,
|
||||||
showAndLogWarningMessage,
|
showAndLogWarningMessage,
|
||||||
} from "../../helpers";
|
} from "../../common/vscode/log";
|
||||||
import { encodeArchiveBasePath } from "../../common/vscode/archive-filesystem-provider";
|
|
||||||
|
|
||||||
export class DatabaseResolver {
|
export class DatabaseResolver {
|
||||||
public static async resolveDatabaseContents(
|
public static async resolveDatabaseContents(
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ import {
|
|||||||
getOwnerFromGitHubUrl,
|
getOwnerFromGitHubUrl,
|
||||||
isValidGitHubOwner,
|
isValidGitHubOwner,
|
||||||
} from "../../common/github-url-identifier-helper";
|
} from "../../common/github-url-identifier-helper";
|
||||||
import {
|
|
||||||
showAndLogErrorMessage,
|
|
||||||
showAndLogInformationMessage,
|
|
||||||
} from "../../helpers";
|
|
||||||
import { DisposableObject } from "../../pure/disposable-object";
|
import { DisposableObject } from "../../pure/disposable-object";
|
||||||
import {
|
import {
|
||||||
DbItem,
|
DbItem,
|
||||||
@@ -38,6 +34,10 @@ import { DatabasePanelCommands } from "../../common/commands";
|
|||||||
import { App } from "../../common/app";
|
import { App } from "../../common/app";
|
||||||
import { QueryLanguage } from "../../common/query-language";
|
import { QueryLanguage } from "../../common/query-language";
|
||||||
import { getCodeSearchRepositories } from "../code-search-api";
|
import { getCodeSearchRepositories } from "../code-search-api";
|
||||||
|
import {
|
||||||
|
showAndLogErrorMessage,
|
||||||
|
showAndLogInformationMessage,
|
||||||
|
} from "../../common/vscode/log";
|
||||||
|
|
||||||
export interface RemoteDatabaseQuickPickItem extends QuickPickItem {
|
export interface RemoteDatabaseQuickPickItem extends QuickPickItem {
|
||||||
remoteDatabaseKind: string;
|
remoteDatabaseKind: string;
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import {
|
|||||||
DebugConfigurationProvider,
|
DebugConfigurationProvider,
|
||||||
WorkspaceFolder,
|
WorkspaceFolder,
|
||||||
} from "vscode";
|
} from "vscode";
|
||||||
import { showAndLogErrorMessage } from "../helpers";
|
|
||||||
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
||||||
import { LocalQueries } from "../local-queries";
|
import { LocalQueries } from "../local-queries";
|
||||||
import { getQuickEvalContext, validateQueryPath } from "../run-queries-shared";
|
import { getQuickEvalContext, validateQueryPath } from "../run-queries-shared";
|
||||||
import * as CodeQLProtocol from "./debug-protocol";
|
import * as CodeQLProtocol from "./debug-protocol";
|
||||||
import { getErrorMessage } from "../pure/helpers-pure";
|
import { getErrorMessage } from "../pure/helpers-pure";
|
||||||
|
import { showAndLogErrorMessage } from "../common/vscode/log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The CodeQL launch arguments, as specified in "launch.json".
|
* The CodeQL launch arguments, as specified in "launch.json".
|
||||||
|
|||||||
@@ -55,14 +55,7 @@ import {
|
|||||||
GithubApiError,
|
GithubApiError,
|
||||||
GithubRateLimitedError,
|
GithubRateLimitedError,
|
||||||
} from "./codeql-cli/distribution";
|
} from "./codeql-cli/distribution";
|
||||||
import {
|
import { tmpDir, tmpDirDisposal } from "./helpers";
|
||||||
showAndLogErrorMessage,
|
|
||||||
showAndLogExceptionWithTelemetry,
|
|
||||||
showAndLogInformationMessage,
|
|
||||||
showAndLogWarningMessage,
|
|
||||||
tmpDir,
|
|
||||||
tmpDirDisposal,
|
|
||||||
} from "./helpers";
|
|
||||||
import { prepareCodeTour } from "./code-tour";
|
import { prepareCodeTour } from "./code-tour";
|
||||||
import {
|
import {
|
||||||
showBinaryChoiceDialog,
|
showBinaryChoiceDialog,
|
||||||
@@ -131,6 +124,12 @@ import { TestRunner } from "./query-testing/test-runner";
|
|||||||
import { TestManagerBase } from "./query-testing/test-manager-base";
|
import { TestManagerBase } from "./query-testing/test-manager-base";
|
||||||
import { NewQueryRunner, QueryRunner, QueryServerClient } from "./query-server";
|
import { NewQueryRunner, QueryRunner, QueryServerClient } from "./query-server";
|
||||||
import { QueriesModule } from "./queries-panel/queries-module";
|
import { QueriesModule } from "./queries-panel/queries-module";
|
||||||
|
import {
|
||||||
|
showAndLogErrorMessage,
|
||||||
|
showAndLogExceptionWithTelemetry,
|
||||||
|
showAndLogInformationMessage,
|
||||||
|
showAndLogWarningMessage,
|
||||||
|
} from "./common/vscode/log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* extension.ts
|
* extension.ts
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
import { ensureDirSync, ensureDir, writeFile } from "fs-extra";
|
import { ensureDir, ensureDirSync, writeFile } from "fs-extra";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { dirSync } from "tmp-promise";
|
import { dirSync } from "tmp-promise";
|
||||||
import { Uri, window as Window } from "vscode";
|
import { Uri, window as Window } from "vscode";
|
||||||
import { CodeQLCliServer } from "./codeql-cli/cli";
|
import { CodeQLCliServer } from "./codeql-cli/cli";
|
||||||
import { UserCancellationException } from "./common/vscode/progress";
|
import { UserCancellationException } from "./common/vscode/progress";
|
||||||
import { extLogger, OutputChannelLogger } from "./common";
|
import { extLogger } from "./common";
|
||||||
import { QueryMetadata } from "./pure/interface-types";
|
import { QueryMetadata } from "./pure/interface-types";
|
||||||
import { telemetryListener } from "./telemetry";
|
|
||||||
import { RedactableError } from "./pure/errors";
|
|
||||||
import { isQueryLanguage, QueryLanguage } from "./common/query-language";
|
import { isQueryLanguage, QueryLanguage } from "./common/query-language";
|
||||||
import { getOnDiskWorkspaceFolders } from "./common/vscode/workspace-folders";
|
import { getOnDiskWorkspaceFolders } from "./common/vscode/workspace-folders";
|
||||||
|
import { showAndLogErrorMessage } from "./common/vscode/log";
|
||||||
|
|
||||||
// Shared temporary folder for the extension.
|
// Shared temporary folder for the extension.
|
||||||
export const tmpDir = dirSync({
|
export const tmpDir = dirSync({
|
||||||
@@ -32,111 +31,6 @@ export const tmpDirDisposal = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
interface ShowAndLogExceptionOptions extends ShowAndLogOptions {
|
|
||||||
/** Custom properties to include in the telemetry report. */
|
|
||||||
extraTelemetryProperties?: { [key: string]: string };
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ShowAndLogOptions {
|
|
||||||
/** The output logger that will receive the message. */
|
|
||||||
outputLogger?: OutputChannelLogger;
|
|
||||||
/** A set of items that will be rendered as actions in the message. */
|
|
||||||
items?: string[];
|
|
||||||
/**
|
|
||||||
* An alternate message that is added to the log, but not displayed in the popup.
|
|
||||||
* This is useful for adding extra detail to the logs that would be too noisy for the popup.
|
|
||||||
*/
|
|
||||||
fullMessage?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show an error message, log it to the console, and emit redacted information as telemetry
|
|
||||||
*
|
|
||||||
* @param error The error to show. Only redacted information will be included in the telemetry.
|
|
||||||
* @param options See individual fields on `ShowAndLogExceptionOptions` type.
|
|
||||||
*
|
|
||||||
* @return A promise that resolves to the selected item or undefined when being dismissed.
|
|
||||||
*/
|
|
||||||
export async function showAndLogExceptionWithTelemetry(
|
|
||||||
error: RedactableError,
|
|
||||||
options: ShowAndLogExceptionOptions = {},
|
|
||||||
): Promise<string | undefined> {
|
|
||||||
telemetryListener?.sendError(error, options.extraTelemetryProperties);
|
|
||||||
return showAndLogErrorMessage(error.fullMessage, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show an error message and log it to the console
|
|
||||||
*
|
|
||||||
* @param message The message to show.
|
|
||||||
* @param options See individual fields on `ShowAndLogOptions` type.
|
|
||||||
*
|
|
||||||
* @return A promise that resolves to the selected item or undefined when being dismissed.
|
|
||||||
*/
|
|
||||||
export async function showAndLogErrorMessage(
|
|
||||||
message: string,
|
|
||||||
options?: ShowAndLogOptions,
|
|
||||||
): Promise<string | undefined> {
|
|
||||||
return internalShowAndLog(
|
|
||||||
dropLinesExceptInitial(message),
|
|
||||||
Window.showErrorMessage,
|
|
||||||
{ fullMessage: message, ...options },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function dropLinesExceptInitial(message: string, n = 2) {
|
|
||||||
return message.toString().split(/\r?\n/).slice(0, n).join("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show a warning message and log it to the console
|
|
||||||
*
|
|
||||||
* @param message The message to show.
|
|
||||||
* @param options See individual fields on `ShowAndLogOptions` type.
|
|
||||||
*
|
|
||||||
* @return A promise that resolves to the selected item or undefined when being dismissed.
|
|
||||||
*/
|
|
||||||
export async function showAndLogWarningMessage(
|
|
||||||
message: string,
|
|
||||||
options?: ShowAndLogOptions,
|
|
||||||
): Promise<string | undefined> {
|
|
||||||
return internalShowAndLog(message, Window.showWarningMessage, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show an information message and log it to the console
|
|
||||||
*
|
|
||||||
* @param message The message to show.
|
|
||||||
* @param options See individual fields on `ShowAndLogOptions` type.
|
|
||||||
*
|
|
||||||
* @return A promise that resolves to the selected item or undefined when being dismissed.
|
|
||||||
*/
|
|
||||||
export async function showAndLogInformationMessage(
|
|
||||||
message: string,
|
|
||||||
options?: ShowAndLogOptions,
|
|
||||||
): Promise<string | undefined> {
|
|
||||||
return internalShowAndLog(message, Window.showInformationMessage, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
type ShowMessageFn = (
|
|
||||||
message: string,
|
|
||||||
...items: string[]
|
|
||||||
) => Thenable<string | undefined>;
|
|
||||||
|
|
||||||
async function internalShowAndLog(
|
|
||||||
message: string,
|
|
||||||
fn: ShowMessageFn,
|
|
||||||
{ items = [], outputLogger = extLogger, fullMessage }: ShowAndLogOptions = {},
|
|
||||||
): Promise<string | undefined> {
|
|
||||||
const label = "Show Log";
|
|
||||||
void outputLogger.log(fullMessage || message);
|
|
||||||
const result = await fn(message, label, ...items);
|
|
||||||
if (result === label) {
|
|
||||||
outputLogger.show();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the language that a query targets.
|
* Finds the language that a query targets.
|
||||||
* If it can't be autodetected, prompt the user to specify the language manually.
|
* If it can't be autodetected, prompt the user to specify the language manually.
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ import {
|
|||||||
isLineColumnLoc,
|
isLineColumnLoc,
|
||||||
} from "../../pure/bqrs-utils";
|
} from "../../pure/bqrs-utils";
|
||||||
import { DisposableObject } from "../../pure/disposable-object";
|
import { DisposableObject } from "../../pure/disposable-object";
|
||||||
import { showAndLogExceptionWithTelemetry } from "../../helpers";
|
|
||||||
import { asError, getErrorMessage } from "../../pure/helpers-pure";
|
import { asError, getErrorMessage } from "../../pure/helpers-pure";
|
||||||
import { redactableError } from "../../pure/errors";
|
import { redactableError } from "../../pure/errors";
|
||||||
import { AstViewerCommands } from "../../common/commands";
|
import { AstViewerCommands } from "../../common/commands";
|
||||||
|
import { showAndLogExceptionWithTelemetry } from "../../common/vscode/log";
|
||||||
|
|
||||||
export interface AstItem {
|
export interface AstItem {
|
||||||
id: BqrsId;
|
id: BqrsId;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { dump } from "js-yaml";
|
|||||||
import { file } from "tmp-promise";
|
import { file } from "tmp-promise";
|
||||||
import { basename, dirname, resolve } from "path";
|
import { basename, dirname, resolve } from "path";
|
||||||
|
|
||||||
import { showAndLogExceptionWithTelemetry } from "../../helpers";
|
|
||||||
import { getOnDiskWorkspaceFolders } from "../../common/vscode/workspace-folders";
|
import { getOnDiskWorkspaceFolders } from "../../common/vscode/workspace-folders";
|
||||||
import {
|
import {
|
||||||
getPrimaryDbscheme,
|
getPrimaryDbscheme,
|
||||||
@@ -24,6 +23,7 @@ import { ProgressCallback } from "../../common/vscode/progress";
|
|||||||
import { CoreCompletedQuery, QueryRunner } from "../../query-server";
|
import { CoreCompletedQuery, QueryRunner } from "../../query-server";
|
||||||
import { redactableError } from "../../pure/errors";
|
import { redactableError } from "../../pure/errors";
|
||||||
import { QLPACK_FILENAMES } from "../../pure/ql";
|
import { QLPACK_FILENAMES } from "../../pure/ql";
|
||||||
|
import { showAndLogExceptionWithTelemetry } from "../../common/vscode/log";
|
||||||
|
|
||||||
export async function qlpackOfDatabase(
|
export async function qlpackOfDatabase(
|
||||||
cli: Pick<CodeQLCliServer, "resolveQlpacks">,
|
cli: Pick<CodeQLCliServer, "resolveQlpacks">,
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import { QueryRunner } from "../query-server";
|
|||||||
import { basename, join } from "path";
|
import { basename, join } from "path";
|
||||||
import { getErrorMessage } from "../pure/helpers-pure";
|
import { getErrorMessage } from "../pure/helpers-pure";
|
||||||
import { redactableError } from "../pure/errors";
|
import { redactableError } from "../pure/errors";
|
||||||
import { showAndLogExceptionWithTelemetry } from "../helpers";
|
|
||||||
import { AppCommandManager, QueryEditorCommands } from "../common/commands";
|
import { AppCommandManager, QueryEditorCommands } from "../common/commands";
|
||||||
|
import { showAndLogExceptionWithTelemetry } from "../common/vscode/log";
|
||||||
|
|
||||||
type QueryEditorOptions = {
|
type QueryEditorOptions = {
|
||||||
commandManager: AppCommandManager;
|
commandManager: AppCommandManager;
|
||||||
|
|||||||
@@ -16,12 +16,7 @@ import { extLogger, TeeLogger } from "../common";
|
|||||||
import { isCanary, MAX_QUERIES } from "../config";
|
import { isCanary, MAX_QUERIES } from "../config";
|
||||||
import { gatherQlFiles } from "../pure/files";
|
import { gatherQlFiles } from "../pure/files";
|
||||||
import { basename } from "path";
|
import { basename } from "path";
|
||||||
import {
|
import { createTimestampFile, findLanguage } from "../helpers";
|
||||||
createTimestampFile,
|
|
||||||
findLanguage,
|
|
||||||
showAndLogErrorMessage,
|
|
||||||
showAndLogWarningMessage,
|
|
||||||
} from "../helpers";
|
|
||||||
import { showBinaryChoiceDialog } from "../common/vscode/dialog";
|
import { showBinaryChoiceDialog } from "../common/vscode/dialog";
|
||||||
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
||||||
import { displayQuickQuery } from "./quick-query";
|
import { displayQuickQuery } from "./quick-query";
|
||||||
@@ -48,6 +43,10 @@ import { DisposableObject } from "../pure/disposable-object";
|
|||||||
import { SkeletonQueryWizard } from "../skeleton-query-wizard";
|
import { SkeletonQueryWizard } from "../skeleton-query-wizard";
|
||||||
import { LocalQueryRun } from "./local-query-run";
|
import { LocalQueryRun } from "./local-query-run";
|
||||||
import { createMultiSelectionCommand } from "../common/vscode/selection-commands";
|
import { createMultiSelectionCommand } from "../common/vscode/selection-commands";
|
||||||
|
import {
|
||||||
|
showAndLogErrorMessage,
|
||||||
|
showAndLogWarningMessage,
|
||||||
|
} from "../common/vscode/log";
|
||||||
|
|
||||||
interface DatabaseQuickPickItem extends QuickPickItem {
|
interface DatabaseQuickPickItem extends QuickPickItem {
|
||||||
databaseItem: DatabaseItem;
|
databaseItem: DatabaseItem;
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
import { BaseLogger, Logger } from "../common";
|
import { BaseLogger, Logger } from "../common";
|
||||||
import {
|
import { tryGetQueryMetadata } from "../helpers";
|
||||||
showAndLogExceptionWithTelemetry,
|
|
||||||
showAndLogWarningMessage,
|
|
||||||
tryGetQueryMetadata,
|
|
||||||
} from "../helpers";
|
|
||||||
import { CoreQueryResults } from "../query-server";
|
import { CoreQueryResults } from "../query-server";
|
||||||
import { QueryHistoryManager } from "../query-history/query-history-manager";
|
import { QueryHistoryManager } from "../query-history/query-history-manager";
|
||||||
import { DatabaseItem } from "../databases/local-databases";
|
import { DatabaseItem } from "../databases/local-databases";
|
||||||
@@ -21,6 +17,10 @@ import { CodeQLCliServer } from "../codeql-cli/cli";
|
|||||||
import { QueryResultType } from "../pure/new-messages";
|
import { QueryResultType } from "../pure/new-messages";
|
||||||
import { redactableError } from "../pure/errors";
|
import { redactableError } from "../pure/errors";
|
||||||
import { LocalQueries } from "./local-queries";
|
import { LocalQueries } from "./local-queries";
|
||||||
|
import {
|
||||||
|
showAndLogExceptionWithTelemetry,
|
||||||
|
showAndLogWarningMessage,
|
||||||
|
} from "../common/vscode/log";
|
||||||
|
|
||||||
function formatResultMessage(result: CoreQueryResults): string {
|
function formatResultMessage(result: CoreQueryResults): string {
|
||||||
switch (result.resultType) {
|
switch (result.resultType) {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import {
|
|||||||
DatabaseItem,
|
DatabaseItem,
|
||||||
DatabaseManager,
|
DatabaseManager,
|
||||||
} from "../databases/local-databases";
|
} from "../databases/local-databases";
|
||||||
import { showAndLogExceptionWithTelemetry } from "../helpers";
|
|
||||||
import {
|
import {
|
||||||
asError,
|
asError,
|
||||||
assertNever,
|
assertNever,
|
||||||
@@ -74,6 +73,7 @@ import { HistoryItemLabelProvider } from "../query-history/history-item-label-pr
|
|||||||
import { telemetryListener } from "../telemetry";
|
import { telemetryListener } from "../telemetry";
|
||||||
import { redactableError } from "../pure/errors";
|
import { redactableError } from "../pure/errors";
|
||||||
import { ResultsViewCommands } from "../common/commands";
|
import { ResultsViewCommands } from "../common/commands";
|
||||||
|
import { showAndLogExceptionWithTelemetry } from "../common/vscode/log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* results-view.ts
|
* results-view.ts
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
import { CodeQLCliServer } from "../codeql-cli/cli";
|
import { CodeQLCliServer } from "../codeql-cli/cli";
|
||||||
import {
|
|
||||||
showAndLogExceptionWithTelemetry,
|
|
||||||
showAndLogInformationMessage,
|
|
||||||
} from "../helpers";
|
|
||||||
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
||||||
import { QuickPickItem, window } from "vscode";
|
import { QuickPickItem, window } from "vscode";
|
||||||
import {
|
import {
|
||||||
@@ -15,6 +11,10 @@ import { asError, getErrorStack } from "../pure/helpers-pure";
|
|||||||
import { redactableError } from "../pure/errors";
|
import { redactableError } from "../pure/errors";
|
||||||
import { PACKS_BY_QUERY_LANGUAGE } from "../common/query-language";
|
import { PACKS_BY_QUERY_LANGUAGE } from "../common/query-language";
|
||||||
import { PackagingCommands } from "../common/commands";
|
import { PackagingCommands } from "../common/commands";
|
||||||
|
import {
|
||||||
|
showAndLogExceptionWithTelemetry,
|
||||||
|
showAndLogInformationMessage,
|
||||||
|
} from "../common/vscode/log";
|
||||||
|
|
||||||
type PackagingOptions = {
|
type PackagingOptions = {
|
||||||
cliServer: CodeQLCliServer;
|
cliServer: CodeQLCliServer;
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ import {
|
|||||||
TreeItemCollapsibleState,
|
TreeItemCollapsibleState,
|
||||||
} from "vscode";
|
} from "vscode";
|
||||||
import { DisposableObject } from "../pure/disposable-object";
|
import { DisposableObject } from "../pure/disposable-object";
|
||||||
import { showAndLogExceptionWithTelemetry } from "../helpers";
|
|
||||||
import { asError, getErrorMessage } from "../pure/helpers-pure";
|
import { asError, getErrorMessage } from "../pure/helpers-pure";
|
||||||
import { redactableError } from "../pure/errors";
|
import { redactableError } from "../pure/errors";
|
||||||
import { EvalLogViewerCommands } from "../common/commands";
|
import { EvalLogViewerCommands } from "../common/commands";
|
||||||
|
import { showAndLogExceptionWithTelemetry } from "../common/vscode/log";
|
||||||
|
|
||||||
export interface EvalLogTreeItem {
|
export interface EvalLogTreeItem {
|
||||||
label?: string;
|
label?: string;
|
||||||
|
|||||||
@@ -13,11 +13,6 @@ import {
|
|||||||
workspace,
|
workspace,
|
||||||
} from "vscode";
|
} from "vscode";
|
||||||
import { QueryHistoryConfig } from "../config";
|
import { QueryHistoryConfig } from "../config";
|
||||||
import {
|
|
||||||
showAndLogErrorMessage,
|
|
||||||
showAndLogInformationMessage,
|
|
||||||
showAndLogWarningMessage,
|
|
||||||
} from "../helpers";
|
|
||||||
import {
|
import {
|
||||||
showBinaryChoiceDialog,
|
showBinaryChoiceDialog,
|
||||||
showInformationMessageWithAction,
|
showInformationMessageWithAction,
|
||||||
@@ -61,6 +56,11 @@ import {
|
|||||||
createMultiSelectionCommand,
|
createMultiSelectionCommand,
|
||||||
createSingleSelectionCommand,
|
createSingleSelectionCommand,
|
||||||
} from "../common/vscode/selection-commands";
|
} from "../common/vscode/selection-commands";
|
||||||
|
import {
|
||||||
|
showAndLogErrorMessage,
|
||||||
|
showAndLogInformationMessage,
|
||||||
|
showAndLogWarningMessage,
|
||||||
|
} from "../common/vscode/log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* query-history-manager.ts
|
* query-history-manager.ts
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { pathExists, remove, mkdir, writeFile, readJson } from "fs-extra";
|
import { pathExists, remove, mkdir, writeFile, readJson } from "fs-extra";
|
||||||
import { dirname } from "path";
|
import { dirname } from "path";
|
||||||
|
|
||||||
import { showAndLogExceptionWithTelemetry } from "../../helpers";
|
|
||||||
import {
|
import {
|
||||||
asError,
|
asError,
|
||||||
asyncFilter,
|
asyncFilter,
|
||||||
@@ -13,6 +12,7 @@ import { redactableError } from "../../pure/errors";
|
|||||||
import { QueryHistoryDto, QueryHistoryItemDto } from "./query-history-dto";
|
import { QueryHistoryDto, QueryHistoryItemDto } from "./query-history-dto";
|
||||||
import { mapQueryHistoryToDomainModel } from "./query-history-dto-mapper";
|
import { mapQueryHistoryToDomainModel } from "./query-history-dto-mapper";
|
||||||
import { mapQueryHistoryToDto } from "./query-history-domain-mapper";
|
import { mapQueryHistoryToDto } from "./query-history-domain-mapper";
|
||||||
|
import { showAndLogExceptionWithTelemetry } from "../../common/vscode/log";
|
||||||
|
|
||||||
const ALLOWED_QUERY_HISTORY_VERSIONS = [1, 2];
|
const ALLOWED_QUERY_HISTORY_VERSIONS = [1, 2];
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,7 @@ import {
|
|||||||
DatabaseItem,
|
DatabaseItem,
|
||||||
DatabaseResolver,
|
DatabaseResolver,
|
||||||
} from "../../databases/local-databases";
|
} from "../../databases/local-databases";
|
||||||
import {
|
import { upgradesTmpDir } from "../../helpers";
|
||||||
showAndLogExceptionWithTelemetry,
|
|
||||||
showAndLogWarningMessage,
|
|
||||||
upgradesTmpDir,
|
|
||||||
} from "../../helpers";
|
|
||||||
import { ProgressCallback } from "../../common/vscode/progress";
|
import { ProgressCallback } from "../../common/vscode/progress";
|
||||||
import { QueryMetadata } from "../../pure/interface-types";
|
import { QueryMetadata } from "../../pure/interface-types";
|
||||||
import { extLogger, Logger } from "../../common";
|
import { extLogger, Logger } from "../../common";
|
||||||
@@ -26,6 +22,10 @@ import { QueryEvaluationInfo, QueryOutputDir } from "../../run-queries-shared";
|
|||||||
import { redactableError } from "../../pure/errors";
|
import { redactableError } from "../../pure/errors";
|
||||||
import { CoreQueryResults, CoreQueryTarget } from "../query-runner";
|
import { CoreQueryResults, CoreQueryTarget } from "../query-runner";
|
||||||
import { Position } from "../../pure/messages-shared";
|
import { Position } from "../../pure/messages-shared";
|
||||||
|
import {
|
||||||
|
showAndLogExceptionWithTelemetry,
|
||||||
|
showAndLogWarningMessage,
|
||||||
|
} from "../../common/vscode/log";
|
||||||
|
|
||||||
export async function compileQuery(
|
export async function compileQuery(
|
||||||
qs: qsClient.QueryServerClient,
|
qs: qsClient.QueryServerClient,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as vscode from "vscode";
|
import * as vscode from "vscode";
|
||||||
import { showAndLogExceptionWithTelemetry, tmpDir } from "../../helpers";
|
import { tmpDir } from "../../helpers";
|
||||||
import { getOnDiskWorkspaceFolders } from "../../common/vscode/workspace-folders";
|
import { getOnDiskWorkspaceFolders } from "../../common/vscode/workspace-folders";
|
||||||
import {
|
import {
|
||||||
ProgressCallback,
|
ProgressCallback,
|
||||||
@@ -13,6 +13,7 @@ import { dirname } from "path";
|
|||||||
import { DatabaseItem } from "../../databases/local-databases";
|
import { DatabaseItem } from "../../databases/local-databases";
|
||||||
import { asError, getErrorMessage } from "../../pure/helpers-pure";
|
import { asError, getErrorMessage } from "../../pure/helpers-pure";
|
||||||
import { redactableError } from "../../pure/errors";
|
import { redactableError } from "../../pure/errors";
|
||||||
|
import { showAndLogExceptionWithTelemetry } from "../../common/vscode/log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum number of lines to include from database upgrade message,
|
* Maximum number of lines to include from database upgrade message,
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ import {
|
|||||||
} from "../common/vscode/progress";
|
} from "../common/vscode/progress";
|
||||||
import { ServerProcess } from "./server-process";
|
import { ServerProcess } from "./server-process";
|
||||||
import { App } from "../common/app";
|
import { App } from "../common/app";
|
||||||
import { showAndLogErrorMessage } from "../helpers";
|
|
||||||
|
import { showAndLogErrorMessage } from "../common/vscode/log";
|
||||||
|
|
||||||
type ServerOpts = {
|
type ServerOpts = {
|
||||||
logger: Logger;
|
logger: Logger;
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import { CancellationToken, Uri } from "vscode";
|
import { CancellationToken, Uri } from "vscode";
|
||||||
import { CodeQLCliServer, TestCompleted } from "../codeql-cli/cli";
|
import { CodeQLCliServer, TestCompleted } from "../codeql-cli/cli";
|
||||||
import { DatabaseItem, DatabaseManager } from "../databases/local-databases";
|
import { DatabaseItem, DatabaseManager } from "../databases/local-databases";
|
||||||
import {
|
|
||||||
showAndLogExceptionWithTelemetry,
|
|
||||||
showAndLogWarningMessage,
|
|
||||||
} from "../helpers";
|
|
||||||
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
||||||
import { asError, getErrorMessage } from "../pure/helpers-pure";
|
import { asError, getErrorMessage } from "../pure/helpers-pure";
|
||||||
import { redactableError } from "../pure/errors";
|
import { redactableError } from "../pure/errors";
|
||||||
import { access } from "fs-extra";
|
import { access } from "fs-extra";
|
||||||
import { BaseLogger } from "../common";
|
import { BaseLogger } from "../common";
|
||||||
import { DisposableObject } from "../pure/disposable-object";
|
import { DisposableObject } from "../pure/disposable-object";
|
||||||
|
import {
|
||||||
|
showAndLogExceptionWithTelemetry,
|
||||||
|
showAndLogWarningMessage,
|
||||||
|
} from "../common/vscode/log";
|
||||||
|
|
||||||
async function isFileAccessible(uri: Uri): Promise<boolean> {
|
async function isFileAccessible(uri: Uri): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as messages from "./pure/messages-shared";
|
|||||||
import * as legacyMessages from "./pure/legacy-messages";
|
import * as legacyMessages from "./pure/legacy-messages";
|
||||||
import { DatabaseInfo, QueryMetadata } from "./pure/interface-types";
|
import { DatabaseInfo, QueryMetadata } from "./pure/interface-types";
|
||||||
import { join, parse, dirname, basename } from "path";
|
import { join, parse, dirname, basename } from "path";
|
||||||
import { createTimestampFile, showAndLogWarningMessage } from "./helpers";
|
import { createTimestampFile } from "./helpers";
|
||||||
import {
|
import {
|
||||||
ConfigurationTarget,
|
ConfigurationTarget,
|
||||||
Range,
|
Range,
|
||||||
@@ -30,6 +30,7 @@ import { DecodedBqrsChunk, EntityValue } from "./pure/bqrs-cli-types";
|
|||||||
import { BaseLogger, extLogger } from "./common";
|
import { BaseLogger, extLogger } from "./common";
|
||||||
import { generateSummarySymbolsFile } from "./log-insights/summary-parser";
|
import { generateSummarySymbolsFile } from "./log-insights/summary-parser";
|
||||||
import { getErrorMessage } from "./pure/helpers-pure";
|
import { getErrorMessage } from "./pure/helpers-pure";
|
||||||
|
import { showAndLogWarningMessage } from "./common/vscode/log";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* run-queries.ts
|
* run-queries.ts
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import {
|
|||||||
ToDataFlowPathsMessage,
|
ToDataFlowPathsMessage,
|
||||||
} from "../pure/interface-types";
|
} from "../pure/interface-types";
|
||||||
import { DataFlowPaths } from "./shared/data-flow-paths";
|
import { DataFlowPaths } from "./shared/data-flow-paths";
|
||||||
import { showAndLogExceptionWithTelemetry } from "../helpers";
|
|
||||||
import { redactableError } from "../pure/errors";
|
import { redactableError } from "../pure/errors";
|
||||||
|
import { showAndLogExceptionWithTelemetry } from "../common/vscode/log";
|
||||||
|
|
||||||
export class DataFlowPathsView extends AbstractWebview<
|
export class DataFlowPathsView extends AbstractWebview<
|
||||||
ToDataFlowPathsMessage,
|
ToDataFlowPathsMessage,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { TextDocumentContentProvider, Uri } from "vscode";
|
import { TextDocumentContentProvider, Uri } from "vscode";
|
||||||
import { URLSearchParams } from "url";
|
import { URLSearchParams } from "url";
|
||||||
import { showAndLogWarningMessage } from "../helpers";
|
|
||||||
import { SHOW_QUERY_TEXT_MSG } from "../query-history/query-history-manager";
|
import { SHOW_QUERY_TEXT_MSG } from "../query-history/query-history-manager";
|
||||||
import { VariantAnalysisManager } from "./variant-analysis-manager";
|
import { VariantAnalysisManager } from "./variant-analysis-manager";
|
||||||
|
import { showAndLogWarningMessage } from "../common/vscode/log";
|
||||||
|
|
||||||
export const createVariantAnalysisContentProvider = (
|
export const createVariantAnalysisContentProvider = (
|
||||||
variantAnalysisManager: VariantAnalysisManager,
|
variantAnalysisManager: VariantAnalysisManager,
|
||||||
|
|||||||
@@ -43,12 +43,7 @@ import {
|
|||||||
processVariantAnalysisRepositoryTask,
|
processVariantAnalysisRepositoryTask,
|
||||||
} from "./variant-analysis-processor";
|
} from "./variant-analysis-processor";
|
||||||
import PQueue from "p-queue";
|
import PQueue from "p-queue";
|
||||||
import {
|
import { createTimestampFile } from "../helpers";
|
||||||
createTimestampFile,
|
|
||||||
showAndLogExceptionWithTelemetry,
|
|
||||||
showAndLogInformationMessage,
|
|
||||||
showAndLogWarningMessage,
|
|
||||||
} from "../helpers";
|
|
||||||
import { readFile, remove, pathExists } from "fs-extra";
|
import { readFile, remove, pathExists } from "fs-extra";
|
||||||
import { EOL } from "os";
|
import { EOL } from "os";
|
||||||
import { cancelVariantAnalysis } from "./gh-api/gh-actions-api-client";
|
import { cancelVariantAnalysis } from "./gh-api/gh-actions-api-client";
|
||||||
@@ -77,6 +72,11 @@ import {
|
|||||||
import { GITHUB_AUTH_PROVIDER_ID } from "../common/vscode/authentication";
|
import { GITHUB_AUTH_PROVIDER_ID } from "../common/vscode/authentication";
|
||||||
import { FetchError } from "node-fetch";
|
import { FetchError } from "node-fetch";
|
||||||
import { extLogger } from "../common";
|
import { extLogger } from "../common";
|
||||||
|
import {
|
||||||
|
showAndLogExceptionWithTelemetry,
|
||||||
|
showAndLogInformationMessage,
|
||||||
|
showAndLogWarningMessage,
|
||||||
|
} from "../common/vscode/log";
|
||||||
|
|
||||||
const maxRetryCount = 3;
|
const maxRetryCount = 3;
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ import { processUpdatedVariantAnalysis } from "./variant-analysis-processor";
|
|||||||
import { DisposableObject } from "../pure/disposable-object";
|
import { DisposableObject } from "../pure/disposable-object";
|
||||||
import { sleep } from "../pure/time";
|
import { sleep } from "../pure/time";
|
||||||
import { getErrorMessage } from "../pure/helpers-pure";
|
import { getErrorMessage } from "../pure/helpers-pure";
|
||||||
import { showAndLogWarningMessage } from "../helpers";
|
|
||||||
import { App } from "../common/app";
|
import { App } from "../common/app";
|
||||||
import { extLogger } from "../common";
|
import { extLogger } from "../common";
|
||||||
|
import { showAndLogWarningMessage } from "../common/vscode/log";
|
||||||
|
|
||||||
export class VariantAnalysisMonitor extends DisposableObject {
|
export class VariantAnalysisMonitor extends DisposableObject {
|
||||||
// With a sleep of 5 seconds, the maximum number of attempts takes
|
// With a sleep of 5 seconds, the maximum number of attempts takes
|
||||||
|
|||||||
@@ -18,10 +18,6 @@ import {
|
|||||||
VariantAnalysisViewInterface,
|
VariantAnalysisViewInterface,
|
||||||
VariantAnalysisViewManager,
|
VariantAnalysisViewManager,
|
||||||
} from "./variant-analysis-view-manager";
|
} from "./variant-analysis-view-manager";
|
||||||
import {
|
|
||||||
showAndLogExceptionWithTelemetry,
|
|
||||||
showAndLogWarningMessage,
|
|
||||||
} from "../helpers";
|
|
||||||
import { telemetryListener } from "../telemetry";
|
import { telemetryListener } from "../telemetry";
|
||||||
import { redactableError } from "../pure/errors";
|
import { redactableError } from "../pure/errors";
|
||||||
import { DataFlowPathsView } from "./data-flow-paths-view";
|
import { DataFlowPathsView } from "./data-flow-paths-view";
|
||||||
@@ -31,6 +27,10 @@ import {
|
|||||||
getVariantAnalysisDefaultResultsFilter,
|
getVariantAnalysisDefaultResultsFilter,
|
||||||
getVariantAnalysisDefaultResultsSort,
|
getVariantAnalysisDefaultResultsSort,
|
||||||
} from "../config";
|
} from "../config";
|
||||||
|
import {
|
||||||
|
showAndLogExceptionWithTelemetry,
|
||||||
|
showAndLogWarningMessage,
|
||||||
|
} from "../common/vscode/log";
|
||||||
|
|
||||||
export class VariantAnalysisView
|
export class VariantAnalysisView
|
||||||
extends AbstractWebview<ToVariantAnalysisMessage, FromVariantAnalysisMessage>
|
extends AbstractWebview<ToVariantAnalysisMessage, FromVariantAnalysisMessage>
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ import {
|
|||||||
import { createMockVariantAnalysis } from "../../../factories/variant-analysis/shared/variant-analysis";
|
import { createMockVariantAnalysis } from "../../../factories/variant-analysis/shared/variant-analysis";
|
||||||
import { createMockApp } from "../../../__mocks__/appMock";
|
import { createMockApp } from "../../../__mocks__/appMock";
|
||||||
import { createMockCommandManager } from "../../../__mocks__/commandsMock";
|
import { createMockCommandManager } from "../../../__mocks__/commandsMock";
|
||||||
import * as helpers from "../../../../src/helpers";
|
import * as log from "../../../../src/common/vscode/log";
|
||||||
|
import { showAndLogWarningMessage } from "../../../../src/common/vscode/log";
|
||||||
|
|
||||||
jest.setTimeout(60_000);
|
jest.setTimeout(60_000);
|
||||||
|
|
||||||
@@ -200,14 +201,14 @@ describe("Variant Analysis Monitor", () => {
|
|||||||
|
|
||||||
describe("when some responses fail", () => {
|
describe("when some responses fail", () => {
|
||||||
let showAndLogWarningMessageSpy: jest.SpiedFunction<
|
let showAndLogWarningMessageSpy: jest.SpiedFunction<
|
||||||
typeof helpers.showAndLogWarningMessage
|
typeof showAndLogWarningMessage
|
||||||
>;
|
>;
|
||||||
|
|
||||||
let scannedRepos: ApiVariantAnalysisScannedRepository[];
|
let scannedRepos: ApiVariantAnalysisScannedRepository[];
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
showAndLogWarningMessageSpy = jest
|
showAndLogWarningMessageSpy = jest
|
||||||
.spyOn(helpers, "showAndLogWarningMessage")
|
.spyOn(log, "showAndLogWarningMessage")
|
||||||
.mockResolvedValue(undefined);
|
.mockResolvedValue(undefined);
|
||||||
|
|
||||||
scannedRepos = createMockScannedRepos([
|
scannedRepos = createMockScannedRepos([
|
||||||
@@ -301,12 +302,12 @@ describe("Variant Analysis Monitor", () => {
|
|||||||
|
|
||||||
describe("when a 404 is returned", () => {
|
describe("when a 404 is returned", () => {
|
||||||
let showAndLogWarningMessageSpy: jest.SpiedFunction<
|
let showAndLogWarningMessageSpy: jest.SpiedFunction<
|
||||||
typeof helpers.showAndLogWarningMessage
|
typeof showAndLogWarningMessage
|
||||||
>;
|
>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
showAndLogWarningMessageSpy = jest
|
showAndLogWarningMessageSpy = jest
|
||||||
.spyOn(helpers, "showAndLogWarningMessage")
|
.spyOn(log, "showAndLogWarningMessage")
|
||||||
.mockResolvedValue(undefined);
|
.mockResolvedValue(undefined);
|
||||||
|
|
||||||
const scannedRepos = createMockScannedRepos([
|
const scannedRepos = createMockScannedRepos([
|
||||||
|
|||||||
@@ -4,13 +4,17 @@ import { join } from "path";
|
|||||||
import { CodeQLCliServer } from "../../../../src/codeql-cli/cli";
|
import { CodeQLCliServer } from "../../../../src/codeql-cli/cli";
|
||||||
import { getErrorMessage } from "../../../../src/pure/helpers-pure";
|
import { getErrorMessage } from "../../../../src/pure/helpers-pure";
|
||||||
|
|
||||||
import * as helpers from "../../../../src/helpers";
|
import * as log from "../../../../src/common/vscode/log";
|
||||||
import {
|
import {
|
||||||
handleDownloadPacks,
|
handleDownloadPacks,
|
||||||
handleInstallPackDependencies,
|
handleInstallPackDependencies,
|
||||||
} from "../../../../src/packaging";
|
} from "../../../../src/packaging";
|
||||||
import { mockedQuickPickItem } from "../../utils/mocking.helpers";
|
import { mockedQuickPickItem } from "../../utils/mocking.helpers";
|
||||||
import { getActivatedExtension } from "../../global.helper";
|
import { getActivatedExtension } from "../../global.helper";
|
||||||
|
import {
|
||||||
|
showAndLogExceptionWithTelemetry,
|
||||||
|
showAndLogInformationMessage,
|
||||||
|
} from "../../../../src/common/vscode/log";
|
||||||
|
|
||||||
describe("Packaging commands", () => {
|
describe("Packaging commands", () => {
|
||||||
let cli: CodeQLCliServer;
|
let cli: CodeQLCliServer;
|
||||||
@@ -18,10 +22,10 @@ describe("Packaging commands", () => {
|
|||||||
let quickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
|
let quickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
|
||||||
let inputBoxSpy: jest.SpiedFunction<typeof window.showInputBox>;
|
let inputBoxSpy: jest.SpiedFunction<typeof window.showInputBox>;
|
||||||
let showAndLogExceptionWithTelemetrySpy: jest.SpiedFunction<
|
let showAndLogExceptionWithTelemetrySpy: jest.SpiedFunction<
|
||||||
typeof helpers.showAndLogExceptionWithTelemetry
|
typeof showAndLogExceptionWithTelemetry
|
||||||
>;
|
>;
|
||||||
let showAndLogInformationMessageSpy: jest.SpiedFunction<
|
let showAndLogInformationMessageSpy: jest.SpiedFunction<
|
||||||
typeof helpers.showAndLogInformationMessage
|
typeof showAndLogInformationMessage
|
||||||
>;
|
>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@@ -32,10 +36,10 @@ describe("Packaging commands", () => {
|
|||||||
.spyOn(window, "showInputBox")
|
.spyOn(window, "showInputBox")
|
||||||
.mockResolvedValue(undefined);
|
.mockResolvedValue(undefined);
|
||||||
showAndLogExceptionWithTelemetrySpy = jest
|
showAndLogExceptionWithTelemetrySpy = jest
|
||||||
.spyOn(helpers, "showAndLogExceptionWithTelemetry")
|
.spyOn(log, "showAndLogExceptionWithTelemetry")
|
||||||
.mockResolvedValue(undefined);
|
.mockResolvedValue(undefined);
|
||||||
showAndLogInformationMessageSpy = jest
|
showAndLogInformationMessageSpy = jest
|
||||||
.spyOn(helpers, "showAndLogInformationMessage")
|
.spyOn(log, "showAndLogInformationMessage")
|
||||||
.mockResolvedValue(undefined);
|
.mockResolvedValue(undefined);
|
||||||
|
|
||||||
const extension = await getActivatedExtension();
|
const extension = await getActivatedExtension();
|
||||||
|
|||||||
@@ -1,20 +1,24 @@
|
|||||||
import * as fetch from "node-fetch";
|
import * as fetch from "node-fetch";
|
||||||
import { Range } from "semver";
|
import { Range } from "semver";
|
||||||
|
|
||||||
import * as helpers from "../../../../src/helpers";
|
import * as log from "../../../../src/common/vscode/log";
|
||||||
import { extLogger } from "../../../../src/common";
|
import { extLogger } from "../../../../src/common";
|
||||||
import * as fs from "fs-extra";
|
import * as fs from "fs-extra";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as os from "os";
|
import * as os from "os";
|
||||||
import * as tmp from "tmp-promise";
|
import * as tmp from "tmp-promise";
|
||||||
|
import { DirectoryResult } from "tmp-promise";
|
||||||
import {
|
import {
|
||||||
|
DistributionManager,
|
||||||
|
getExecutableFromDirectory,
|
||||||
GithubRelease,
|
GithubRelease,
|
||||||
GithubReleaseAsset,
|
GithubReleaseAsset,
|
||||||
ReleasesApiConsumer,
|
ReleasesApiConsumer,
|
||||||
getExecutableFromDirectory,
|
|
||||||
DistributionManager,
|
|
||||||
} from "../../../../src/codeql-cli/distribution";
|
} from "../../../../src/codeql-cli/distribution";
|
||||||
import { DirectoryResult } from "tmp-promise";
|
import {
|
||||||
|
showAndLogErrorMessage,
|
||||||
|
showAndLogWarningMessage,
|
||||||
|
} from "../../../../src/common/vscode/log";
|
||||||
|
|
||||||
jest.mock("os", () => {
|
jest.mock("os", () => {
|
||||||
const original = jest.requireActual("os");
|
const original = jest.requireActual("os");
|
||||||
@@ -204,8 +208,8 @@ describe("Releases API consumer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("Launcher path", () => {
|
describe("Launcher path", () => {
|
||||||
let warnSpy: jest.SpiedFunction<typeof helpers.showAndLogWarningMessage>;
|
let warnSpy: jest.SpiedFunction<typeof showAndLogWarningMessage>;
|
||||||
let errorSpy: jest.SpiedFunction<typeof helpers.showAndLogErrorMessage>;
|
let errorSpy: jest.SpiedFunction<typeof showAndLogErrorMessage>;
|
||||||
let logSpy: jest.SpiedFunction<typeof extLogger.log>;
|
let logSpy: jest.SpiedFunction<typeof extLogger.log>;
|
||||||
|
|
||||||
let directory: DirectoryResult;
|
let directory: DirectoryResult;
|
||||||
@@ -215,10 +219,10 @@ describe("Launcher path", () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
warnSpy = jest
|
warnSpy = jest
|
||||||
.spyOn(helpers, "showAndLogWarningMessage")
|
.spyOn(log, "showAndLogWarningMessage")
|
||||||
.mockResolvedValue(undefined);
|
.mockResolvedValue(undefined);
|
||||||
errorSpy = jest
|
errorSpy = jest
|
||||||
.spyOn(helpers, "showAndLogErrorMessage")
|
.spyOn(log, "showAndLogErrorMessage")
|
||||||
.mockResolvedValue(undefined);
|
.mockResolvedValue(undefined);
|
||||||
logSpy = jest.spyOn(extLogger, "log").mockResolvedValue(undefined);
|
logSpy = jest.spyOn(extLogger, "log").mockResolvedValue(undefined);
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ import {
|
|||||||
QlpacksInfo,
|
QlpacksInfo,
|
||||||
ResolveExtensionsResult,
|
ResolveExtensionsResult,
|
||||||
} from "../../../../src/codeql-cli/cli";
|
} from "../../../../src/codeql-cli/cli";
|
||||||
import * as helpers from "../../../../src/helpers";
|
import * as log from "../../../../src/common/vscode/log";
|
||||||
|
|
||||||
import { pickExtensionPackModelFile } from "../../../../src/data-extensions-editor/extension-pack-picker";
|
import { pickExtensionPackModelFile } from "../../../../src/data-extensions-editor/extension-pack-picker";
|
||||||
import { ExtensionPack } from "../../../../src/data-extensions-editor/shared/extension-pack";
|
import { ExtensionPack } from "../../../../src/data-extensions-editor/shared/extension-pack";
|
||||||
|
import { showAndLogErrorMessage } from "../../../../src/common/vscode/log";
|
||||||
|
|
||||||
describe("pickExtensionPackModelFile", () => {
|
describe("pickExtensionPackModelFile", () => {
|
||||||
let tmpDir: string;
|
let tmpDir: string;
|
||||||
@@ -33,7 +34,7 @@ describe("pickExtensionPackModelFile", () => {
|
|||||||
let showQuickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
|
let showQuickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
|
||||||
let showInputBoxSpy: jest.SpiedFunction<typeof window.showInputBox>;
|
let showInputBoxSpy: jest.SpiedFunction<typeof window.showInputBox>;
|
||||||
let showAndLogErrorMessageSpy: jest.SpiedFunction<
|
let showAndLogErrorMessageSpy: jest.SpiedFunction<
|
||||||
typeof helpers.showAndLogErrorMessage
|
typeof showAndLogErrorMessage
|
||||||
>;
|
>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@@ -79,7 +80,7 @@ describe("pickExtensionPackModelFile", () => {
|
|||||||
.spyOn(window, "showInputBox")
|
.spyOn(window, "showInputBox")
|
||||||
.mockRejectedValue(new Error("Unexpected call to showInputBox"));
|
.mockRejectedValue(new Error("Unexpected call to showInputBox"));
|
||||||
showAndLogErrorMessageSpy = jest
|
showAndLogErrorMessageSpy = jest
|
||||||
.spyOn(helpers, "showAndLogErrorMessage")
|
.spyOn(log, "showAndLogErrorMessage")
|
||||||
.mockImplementation((msg) => {
|
.mockImplementation((msg) => {
|
||||||
throw new Error(`Unexpected call to showAndLogErrorMessage: ${msg}`);
|
throw new Error(`Unexpected call to showAndLogErrorMessage: ${msg}`);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ import { readdir, readFile } from "fs-extra";
|
|||||||
import { load } from "js-yaml";
|
import { load } from "js-yaml";
|
||||||
import { dirname, join } from "path";
|
import { dirname, join } from "path";
|
||||||
import { fetchExternalApiQueries } from "../../../../src/data-extensions-editor/queries";
|
import { fetchExternalApiQueries } from "../../../../src/data-extensions-editor/queries";
|
||||||
import * as helpers from "../../../../src/helpers";
|
import * as log from "../../../../src/common/vscode/log";
|
||||||
import { RedactableError } from "../../../../src/pure/errors";
|
import { RedactableError } from "../../../../src/pure/errors";
|
||||||
|
import { showAndLogExceptionWithTelemetry } from "../../../../src/common/vscode/log";
|
||||||
|
|
||||||
function createMockUri(path = "/a/b/c/foo"): Uri {
|
function createMockUri(path = "/a/b/c/foo"): Uri {
|
||||||
return {
|
return {
|
||||||
@@ -134,12 +135,12 @@ describe("readQueryResults", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let showAndLogExceptionWithTelemetrySpy: jest.SpiedFunction<
|
let showAndLogExceptionWithTelemetrySpy: jest.SpiedFunction<
|
||||||
typeof helpers.showAndLogExceptionWithTelemetry
|
typeof showAndLogExceptionWithTelemetry
|
||||||
>;
|
>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
showAndLogExceptionWithTelemetrySpy = jest.spyOn(
|
showAndLogExceptionWithTelemetrySpy = jest.spyOn(
|
||||||
helpers,
|
log,
|
||||||
"showAndLogExceptionWithTelemetry",
|
"showAndLogExceptionWithTelemetry",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import * as fs from "fs-extra";
|
|||||||
|
|
||||||
import { getErrorMessage } from "../../../../../src/pure/helpers-pure";
|
import { getErrorMessage } from "../../../../../src/pure/helpers-pure";
|
||||||
|
|
||||||
import * as helpers from "../../../../../src/helpers";
|
import * as log from "../../../../../src/common/vscode/log";
|
||||||
import * as workspaceFolders from "../../../../../src/common/vscode/workspace-folders";
|
import * as workspaceFolders from "../../../../../src/common/vscode/workspace-folders";
|
||||||
import * as qlpack from "../../../../../src/databases/qlpack";
|
import * as qlpack from "../../../../../src/databases/qlpack";
|
||||||
import {
|
import {
|
||||||
@@ -42,7 +42,7 @@ describe("queryResolver", () => {
|
|||||||
jest
|
jest
|
||||||
.spyOn(workspaceFolders, "getOnDiskWorkspaceFolders")
|
.spyOn(workspaceFolders, "getOnDiskWorkspaceFolders")
|
||||||
.mockReturnValue([]);
|
.mockReturnValue([]);
|
||||||
jest.spyOn(helpers, "showAndLogErrorMessage").mockResolvedValue(undefined);
|
jest.spyOn(log, "showAndLogErrorMessage").mockResolvedValue(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("resolveQueries", () => {
|
describe("resolveQueries", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user