Discourage use of "Quick query" in single-folder workspaces (#3082)
This commit is contained in:
Родитель
208efb57d3
Коммит
424e8d3145
|
@ -2,6 +2,8 @@
|
|||
|
||||
## [UNRELEASED]
|
||||
|
||||
- Add a prompt to the "Quick query" command to encourage users in single-folder workspaces to use "Create query" instead. [#3082](https://github.com/github/vscode-codeql/pull/3082)
|
||||
|
||||
## 1.10.0 - 16 November 2023
|
||||
|
||||
- Add new CodeQL views for managing databases and queries:
|
||||
|
|
|
@ -146,6 +146,7 @@ export type LocalQueryCommands = {
|
|||
"codeQL.quickQuery": () => Promise<void>;
|
||||
"codeQL.getCurrentQuery": () => Promise<string>;
|
||||
"codeQL.createQuery": () => Promise<void>;
|
||||
"codeQLQuickQuery.createQuery": () => Promise<void>;
|
||||
};
|
||||
|
||||
// Debugger commands
|
||||
|
|
|
@ -42,7 +42,6 @@ import { WebviewReveal } from "./webview";
|
|||
import { asError, getErrorMessage } from "../common/helpers-pure";
|
||||
import { CliVersionConstraint, CodeQLCliServer } from "../codeql-cli/cli";
|
||||
import { LocalQueryCommands } from "../common/commands";
|
||||
import { App } from "../common/app";
|
||||
import { DisposableObject } from "../common/disposable-object";
|
||||
import { SkeletonQueryWizard } from "./skeleton-query-wizard";
|
||||
import { LocalQueryRun } from "./local-query-run";
|
||||
|
@ -51,6 +50,7 @@ import { findLanguage } from "../codeql-cli/query-language";
|
|||
import type { QueryTreeViewItem } from "../queries-panel/query-tree-view-item";
|
||||
import { tryGetQueryLanguage } from "../common/query-language";
|
||||
import { LanguageContextStore } from "../language-context-store";
|
||||
import { ExtensionApp } from "../common/vscode/vscode-app";
|
||||
|
||||
interface DatabaseQuickPickItem extends QuickPickItem {
|
||||
databaseItem: DatabaseItem;
|
||||
|
@ -66,7 +66,7 @@ export class LocalQueries extends DisposableObject {
|
|||
private selectedQueryTreeViewItems: readonly QueryTreeViewItem[] = [];
|
||||
|
||||
public constructor(
|
||||
private readonly app: App,
|
||||
private readonly app: ExtensionApp,
|
||||
private readonly queryRunner: QueryRunner,
|
||||
private readonly queryHistoryManager: QueryHistoryManager,
|
||||
private readonly databaseManager: DatabaseManager,
|
||||
|
@ -119,6 +119,7 @@ export class LocalQueries extends DisposableObject {
|
|||
return this.getCurrentQuery(true);
|
||||
},
|
||||
"codeQL.createQuery": this.createSkeletonQuery.bind(this),
|
||||
"codeQLQuickQuery.createQuery": this.createSkeletonQuery.bind(this),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import { CancellationToken, window as Window, workspace, Uri } from "vscode";
|
|||
import { LSPErrorCodes, ResponseError } from "vscode-languageclient";
|
||||
import { CodeQLCliServer } from "../codeql-cli/cli";
|
||||
import { DatabaseUI } from "../databases/local-databases-ui";
|
||||
import { showBinaryChoiceDialog } from "../common/vscode/dialog";
|
||||
import { getInitialQueryContents } from "./query-contents";
|
||||
import { getPrimaryDbscheme, getQlPackForDbscheme } from "../databases/qlpack";
|
||||
import {
|
||||
|
@ -15,6 +14,7 @@ import {
|
|||
import { getErrorMessage } from "../common/helpers-pure";
|
||||
import { FALLBACK_QLPACK_FILENAME, getQlPackPath } from "../common/ql";
|
||||
import { App } from "../common/app";
|
||||
import { ExtensionApp } from "../common/vscode/vscode-app";
|
||||
|
||||
const QUICK_QUERIES_DIR_NAME = "quick-queries";
|
||||
const QUICK_QUERY_QUERY_NAME = "quick-query.ql";
|
||||
|
@ -52,7 +52,7 @@ function findExistingQuickQueryEditor() {
|
|||
* Show a buffer the user can enter a simple query into.
|
||||
*/
|
||||
export async function displayQuickQuery(
|
||||
app: App,
|
||||
app: ExtensionApp,
|
||||
cliServer: CodeQLCliServer,
|
||||
databaseUI: DatabaseUI,
|
||||
progress: ProgressCallback,
|
||||
|
@ -80,12 +80,24 @@ export async function displayQuickQuery(
|
|||
// being undefined) just let the user know that they're in for a
|
||||
// restart.
|
||||
if (workspace.workspaceFile === undefined) {
|
||||
const makeMultiRoot = await showBinaryChoiceDialog(
|
||||
"Quick query requires multiple folders in the workspace. Reload workspace as multi-folder workspace?",
|
||||
const createQueryOption = 'Run "Create query"';
|
||||
const quickQueryOption = 'Run "Quick query" anyway';
|
||||
const quickQueryPrompt = await Window.showWarningMessage(
|
||||
'"Quick query" requires reloading your workspace as a multi-root workspace, which may cause query history and databases to be lost.',
|
||||
{
|
||||
modal: true,
|
||||
detail:
|
||||
'The "Create query" command does not require reloading the workspace.',
|
||||
},
|
||||
createQueryOption,
|
||||
quickQueryOption,
|
||||
);
|
||||
if (makeMultiRoot) {
|
||||
if (quickQueryPrompt === quickQueryOption) {
|
||||
updateQuickQueryDir(queriesDir, workspaceFolders.length, 0);
|
||||
}
|
||||
if (quickQueryPrompt === createQueryOption) {
|
||||
await app.queryServerCommands.execute("codeQLQuickQuery.createQuery");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ describe("commands declared in package.json", () => {
|
|||
command.match(/^codeQLLanguageSelection\./) ||
|
||||
command.match(/^codeQLDatabases\./) ||
|
||||
command.match(/^codeQLQueries\./) ||
|
||||
command.match(/^codeQLQuickQuery\./) ||
|
||||
command.match(/^codeQLVariantAnalysisRepositories\./) ||
|
||||
command.match(/^codeQLQueryHistory\./) ||
|
||||
command.match(/^codeQLAstViewer\./) ||
|
||||
|
@ -114,7 +115,7 @@ describe("commands declared in package.json", () => {
|
|||
expect(disabledInPalette.has(command)).toBe(false);
|
||||
});
|
||||
|
||||
// Commands in contribContextMenuCmds may reasonbly be enabled or
|
||||
// Commands in contribContextMenuCmds may reasonably be enabled or
|
||||
// disabled in the command palette; for example, codeQL.runQuery
|
||||
// is available there, since we heuristically figure out which
|
||||
// query to run, but codeQL.setCurrentDatabase is not.
|
||||
|
|
Загрузка…
Ссылка в новой задаче