diff --git a/crates/ide-core/src/settings.rs b/crates/ide-core/src/settings.rs index 90577c70d2..90dd847226 100644 --- a/crates/ide-core/src/settings.rs +++ b/crates/ide-core/src/settings.rs @@ -71,7 +71,7 @@ pub struct Settings { pub scopes: Vec, /// Appearance & Behavior › File Colors. pub file_colors: FileColorSettings, - /// Database › Query Execution. + /// Database › Query Execution, Languages & Frameworks › SQL Resolution Scopes. pub database: DatabaseSettings, /// Plugin settings (`[contributes.settings]`): plugin id → its values by key. #[specta(type = BTreeMap>)] diff --git a/crates/ide-core/src/workflow_settings.rs b/crates/ide-core/src/workflow_settings.rs index 568d6ccd06..764b3f4a4e 100644 --- a/crates/ide-core/src/workflow_settings.rs +++ b/crates/ide-core/src/workflow_settings.rs @@ -241,13 +241,28 @@ impl Default for LogLevelColors { } } -/// Database › Query Execution. +/// Database settings: Query Execution and SQL Resolution Scopes. #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Type)] #[serde(default, rename_all = "camelCase")] pub struct DatabaseSettings { /// A console's result sets show under the statements that produced them, in the editor, /// instead of in the Services view's result tabs. pub in_editor_results: bool, + /// Languages & Frameworks › SQL Resolution Scopes: the data source SQL in a file or folder + /// resolves against (completion, inspections, navigation), most specific path first. + pub resolution_scopes: Vec, +} + +/// One row of SQL Resolution Scopes. +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Type)] +#[serde(default, rename_all = "camelCase")] +pub struct SqlResolutionScope { + /// Project-relative file or folder, `/`-separated; empty for the whole project. + pub path: String, + /// Data source id. + pub data_source: String, + /// Schema unqualified names resolve in; empty for the data source's default. + pub schema: String, } /// Build, Execution, Deployment › Console. diff --git a/src/bindings.ts b/src/bindings.ts index 6a3ef73d23..476588e845 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -3862,13 +3862,18 @@ export type DataSource_Serialize = { pluginSourceId?: string | null, }; -/** Database › Query Execution. */ +/** Database settings: Query Execution and SQL Resolution Scopes. */ export type DatabaseSettings = { /** * A console's result sets show under the statements that produced them, in the editor, * instead of in the Services view's result tabs. */ inEditorResults?: boolean, + /** + * Languages & Frameworks › SQL Resolution Scopes: the data source SQL in a file or folder + * resolves against (completion, inspections, navigation), most specific path first. + */ + resolutionScopes?: SqlResolutionScope[], }; /** System Settings › Date Formats (Git log, Local History, blame). */ @@ -9947,7 +9952,7 @@ export type Settings_Deserialize = { scopes?: NamedScope[], /** Appearance & Behavior › File Colors. */ fileColors?: FileColorSettings, - /** Database › Query Execution. */ + /** Database › Query Execution, Languages & Frameworks › SQL Resolution Scopes. */ database?: DatabaseSettings, /** Plugin settings (`[contributes.settings]`): plugin id → its values by key. */ plugins?: { [key in string]: { [key in string]: unknown } }, @@ -10019,7 +10024,7 @@ export type Settings_Serialize = { scopes: NamedScope[], /** Appearance & Behavior › File Colors. */ fileColors: FileColorSettings, - /** Database › Query Execution. */ + /** Database › Query Execution, Languages & Frameworks › SQL Resolution Scopes. */ database: DatabaseSettings, /** Plugin settings (`[contributes.settings]`): plugin id → its values by key. */ plugins: { [key in string]: { [key in string]: unknown } }, @@ -10169,6 +10174,16 @@ export type SpellingSettings = { customDictionaries?: string[], }; +/** One row of SQL Resolution Scopes. */ +export type SqlResolutionScope = { + /** Project-relative file or folder, `/`-separated; empty for the whole project. */ + path?: string, + /** Data source id. */ + dataSource?: string, + /** Schema unqualified names resolve in; empty for the data source's default. */ + schema?: string, +}; + export type SqlStatement = { /** * UTF-16 offsets of the statement text (whitespace trimmed, `;` excluded except diff --git a/src/features/database/SqlScopesPage.module.css b/src/features/database/SqlScopesPage.module.css new file mode 100644 index 0000000000..4b7ff83cb6 --- /dev/null +++ b/src/features/database/SqlScopesPage.module.css @@ -0,0 +1,37 @@ +.page { + display: flex; + flex-direction: column; + gap: var(--space-2); + color: var(--fg); + font-size: var(--fs-ui); +} +.intro, +.hint { + margin: 0; + color: var(--fg-muted); +} +.list { + display: flex; + flex-direction: column; + border: 1px solid var(--border-strong); + border-radius: var(--radius-small); + padding: var(--space-0-5) 0; +} +.head, +.row { + display: grid; + grid-template-columns: minmax(160px, 2fr) minmax(140px, 1.5fr) minmax(100px, 1fr) 24px; + align-items: center; + gap: var(--space-2); + min-height: 30px; + padding: 0 var(--space-2); +} +.head { + min-height: 24px; + color: var(--fg-muted); + border-bottom: 1px solid var(--border); +} +.project { + padding-left: var(--space-1); + font-weight: 600; +} diff --git a/src/features/database/SqlScopesPage.tsx b/src/features/database/SqlScopesPage.tsx new file mode 100644 index 0000000000..15c7210a19 --- /dev/null +++ b/src/features/database/SqlScopesPage.tsx @@ -0,0 +1,144 @@ +/** + * Languages & Frameworks › SQL Resolution Scopes: which data source (and schema) SQL in a + * folder or file resolves against — completion, inspections, navigation and running + * consoles there. The project row applies wherever no folder or file row does. + */ +import { useEffect, useState } from "react"; +import { call, commands, type DataSource } from "@/platform/ipc"; +import { tx } from "@/platform/i18n"; +import { IconButton, Input, Select, T, type SelectOption } from "@/ui"; +import { useSettingsForm } from "@/workbench/contributions"; +import { scopePath, validateResolutionScopes, type SqlResolutionScope } from "./resolutionScopes"; +import styles from "./SqlScopesPage.module.css"; + +const KEY = "database.resolutionScopes"; +const NONE = ""; +/** An example path, the same in every language. */ +const PATH_EXAMPLE = "src/main/resources/mapper"; + +function useDataSources(): DataSource[] | null { + const [sources, setSources] = useState(null); + useEffect(() => { + let stale = false; + call(commands.dbSources()) + .then((list) => !stale && setSources(list)) + .catch(() => !stale && setSources([])); + return () => { + stale = true; + }; + }, []); + return sources; +} + +export function SqlScopesPage() { + const form = useSettingsForm(); + const scopes = validateResolutionScopes(form.useValue(KEY)); + const sources = useDataSources(); + const set = (next: SqlResolutionScope[]) => form.set(KEY, next); + + const options: SelectOption[] = [ + { value: NONE, label: tx("") }, + ...(sources ?? []).map((s) => ({ value: s.id ?? "", label: s.name ?? s.id ?? "", icon: "database" })), + ]; + const sourceOptions = (current: string) => + current && !options.some((o) => o.value === current) + ? [...options, { value: current, label: tx`${current} (missing)` }] + : options; + + const projectIndex = scopes.findIndex((s) => !s.path); + const project = scopes[projectIndex]; + const rows = scopes.map((scope, index) => ({ scope, index })).filter(({ index }) => index !== projectIndex); + const empty = (): SqlResolutionScope => ({ path: "", dataSource: NONE, schema: "" }); + + const patch = (index: number, p: Partial) => + set(scopes.map((s, i) => (i === index ? { ...s, ...p } : s))); + const setProject = (p: Partial) => + project ? patch(projectIndex, p) : set([{ ...empty(), ...p }, ...scopes]); + + return ( +
+

+ + SQL in these folders and files resolves against the data source: completion, inspections and navigation use + its tables, and query consoles run on it unless another data source is picked in their toolbar. + +

+
+
+ + Path + + + Data Source + + + Schema + + +
+
+ + Project + + setProject({ schema: e.target.value })} + aria-label={tx("Project schema")} + /> + +
+ {rows.map(({ scope, index }) => ( +
+ patch(index, { path: e.target.value })} + aria-label={tx("Path")} + /> + patch(index, { schema: e.target.value })} + aria-label={tx("Schema")} + /> + set(scopes.filter((_, i) => i !== index))} + /> +
+ ))} +
+
+ set([...(project ? [] : [empty()]), ...scopes, empty()])} + /> +
+

+ Paths are relative to the project root. The deepest folder or file that contains a file applies to it. +

+
+ ); +} diff --git a/src/features/database/console.tsx b/src/features/database/console.tsx index 1304a1d195..92ad838e0b 100644 --- a/src/features/database/console.tsx +++ b/src/features/database/console.tsx @@ -474,6 +474,8 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) { const pending = useDatabase((s) => !!bound && s.pendingTx.has(bound)); const databases = useDatabase((s) => s.databases); const inEditor = useProject((s) => inEditorResults(s.settings)); + // SQL resolution scopes in the settings can move the console to another data source. + useProject((s) => s.settings); const boundId = bound ? splitTarget(bound).id : null; const supportsTransactions = sourceById(boundId)?.driver !== "clickhouse"; const sqlServer = sourceById(boundId)?.driver === "sqlServer"; diff --git a/src/features/database/index.ts b/src/features/database/index.ts index feee44a2f3..9f6a742b5e 100644 --- a/src/features/database/index.ts +++ b/src/features/database/index.ts @@ -81,6 +81,8 @@ function tableTarget(arg: unknown): TableCommandTarget { return { rows: activeCellGrid()?.selectedRows() ?? [], editor: null }; } +export { activateSettingsPages } from "./settingsPages"; + export function activate(): () => void { const disposers = [ onIdeEvent("dbSourcesChanged", () => { diff --git a/src/features/database/resolutionScopes.test.ts b/src/features/database/resolutionScopes.test.ts new file mode 100644 index 0000000000..6c10d53508 --- /dev/null +++ b/src/features/database/resolutionScopes.test.ts @@ -0,0 +1,54 @@ +import { beforeEach, describe, expect, it } from "vitest"; +import { useProject } from "@/platform/project"; +import { resolutionScopeOf, validateResolutionScopes } from "./resolutionScopes"; +import { bindConsole, consoleSchema, consoleSource, useDatabase } from "./store"; + +const scopes = validateResolutionScopes([ + { path: "", dataSource: "main", schema: "" }, + { path: "./src/main/resources/mapper/", dataSource: "orders", schema: "sales" }, + { path: "src/main/resources/mapper/legacy/Old.xml", dataSource: "legacy", schema: "" }, + { path: "src/gone", dataSource: "removed", schema: "" }, +]); + +describe("SQL resolution scopes", () => { + it("normalises paths and picks the deepest folder or file covering a file, else the project row", () => { + expect(scopes[1]!.path).toBe("src/main/resources/mapper"); + const at = (rel: string) => resolutionScopeOf(`/p/${rel}`, "/p", scopes)?.dataSource; + expect(at("src/main/resources/mapper/UserMapper.xml")).toBe("orders"); + expect(at("src/main/resources/mapper/legacy/Old.xml")).toBe("legacy"); + expect(at("src/main/resources/mapper/legacy/New.xml")).toBe("orders"); + // A sibling folder whose name starts the same is not inside. + expect(at("src/main/resources/mapperx/A.xml")).toBe("main"); + expect(resolutionScopeOf("/elsewhere/a.sql", "/p", scopes)).toBeNull(); + }); + + it("skips rows whose data source no longer exists", () => { + const known = (id: string) => id !== "removed"; + expect(resolutionScopeOf("/p/src/gone/a.sql", "/p", scopes, known)?.dataSource).toBe("main"); + }); +}); + +describe("the data source a SQL file resolves against", () => { + beforeEach(() => { + useProject.setState({ + project: { name: "p", root: "/p", trusted: true } as never, + settings: { database: { resolutionScopes: scopes } } as never, + }); + useDatabase.setState({ + sources: ["main", "orders", "legacy"].map((id) => ({ id, name: id, driver: "postgres" as const })), + consoles: {}, + consoleSchemas: {}, + completion: { orders: { defaultSchema: "public", tables: [], foreignKeys: [] } }, + }); + }); + + it("is the one picked in its toolbar, else its scope's (with the scope's schema)", () => { + const file = "/p/src/main/resources/mapper/UserMapper.xml"; + expect(consoleSource(file)).toBe("orders"); + expect(consoleSchema(file)).toBe("sales"); + bindConsole(file, "legacy"); + expect(consoleSource(file)).toBe("legacy"); + bindConsole(file, null); + expect(consoleSource("/p/scratch.sql")).toBe("main"); + }); +}); diff --git a/src/features/database/resolutionScopes.ts b/src/features/database/resolutionScopes.ts new file mode 100644 index 0000000000..a80645db63 --- /dev/null +++ b/src/features/database/resolutionScopes.ts @@ -0,0 +1,61 @@ +/** + * Languages & Frameworks › SQL Resolution Scopes: the data source (and schema) SQL in a + * file or folder resolves against. The most specific path wins; an empty path is the + * whole project. + */ +export interface SqlResolutionScope { + /** Project-relative file or folder, `/`-separated; empty for the whole project. */ + path: string; + dataSource: string; + schema: string; +} + +const str = (v: unknown) => (typeof v === "string" ? v : ""); + +/** Normalises a project-relative path: `/`-separated, without `./` or surrounding slashes. */ +export function scopePath(path: string): string { + return path + .trim() + .replace(/\\/g, "/") + .replace(/^(\.\/)+/, "") + .replace(/^\/+|\/+$/g, ""); +} + +export function validateResolutionScopes(raw: unknown): SqlResolutionScope[] { + if (!Array.isArray(raw)) return []; + return raw.flatMap((r) => { + if (!r || typeof r !== "object") return []; + const o = r as Record; + return [{ path: scopePath(str(o.path)), dataSource: str(o.dataSource), schema: str(o.schema).trim() }]; + }); +} + +/** The scopes in raw settings (`database.resolutionScopes`). */ +export function resolutionScopesOf(settings: unknown): SqlResolutionScope[] { + const database = (settings as { database?: { resolutionScopes?: unknown } } | null)?.database; + return validateResolutionScopes(database?.resolutionScopes); +} + +/** + * The scope of `file` (absolute, under project `root`) among `scopes` whose data source + * `known` accepts: the deepest folder or the file itself, else the project's row. + */ +export function resolutionScopeOf( + file: string, + root: string, + scopes: readonly SqlResolutionScope[], + known: (dataSource: string) => boolean = () => true, +): SqlResolutionScope | null { + const base = root.replace(/\\/g, "/").replace(/\/+$/, ""); + const normalized = file.replace(/\\/g, "/"); + if (!base || !normalized.startsWith(`${base}/`)) return null; + const rel = normalized.slice(base.length + 1); + let best: SqlResolutionScope | null = null; + for (const scope of scopes) { + if (!scope.dataSource || !known(scope.dataSource)) continue; + const p = scope.path; + const covers = !p || rel === p || rel.startsWith(`${p}/`); + if (covers && (!best || p.length > best.path.length)) best = scope; + } + return best; +} diff --git a/src/features/database/settingsPages.ts b/src/features/database/settingsPages.ts new file mode 100644 index 0000000000..27bbefc898 --- /dev/null +++ b/src/features/database/settingsPages.ts @@ -0,0 +1,16 @@ +import { lazyComponent } from "@/ui"; +import { registerSettingsPage } from "@/workbench/contributions"; + +/** Settings › Languages & Frameworks › SQL Resolution Scopes (also used by the Settings window). */ +export function activateSettingsPages(): () => void { + return registerSettingsPage({ + id: "languages.sqlResolutionScopes", + title: "SQL Resolution Scopes", + group: "Languages & Frameworks", + order: 404.5, + projectScope: true, + defaultScope: "project", + keywords: ["sql", "data source", "database", "schema", "mybatis", "mapper", "resolve", "dialect"], + component: lazyComponent(() => import("./SqlScopesPage").then((m) => m.SqlScopesPage)), + }); +} diff --git a/src/features/database/store.ts b/src/features/database/store.ts index cb4daf17c0..8240e5825a 100644 --- a/src/features/database/store.ts +++ b/src/features/database/store.ts @@ -56,6 +56,7 @@ import { formatted } from "./sql/format"; import { bindParams, findParams } from "./sql/params"; import { isReadOnlyQuery } from "./sql/readOnly"; import { pageFetch } from "./resultView"; +import { resolutionScopeOf, resolutionScopesOf, type SqlResolutionScope } from "./resolutionScopes"; import { databaseRequest, invalidateDatabaseRequests, projectRequest } from "./requests"; import { tx } from "@/platform/i18n"; @@ -884,7 +885,10 @@ export function bindConsole(path: string, id: string | null) { export function consoleSchema(path: string): string { const s = useDatabase.getState(); const id = consoleSource(path); - return activeSchema(s.consoleSchemas[path], id ? s.completion[id]?.defaultSchema : undefined); + // A scope's schema applies while the console is on that scope's data source. + const scope = s.consoles[path] ? null : scopeOf(path); + const picked = s.consoleSchemas[path] ?? (scope && scope.dataSource === id ? scope.schema : undefined); + return activeSchema(picked || undefined, id ? s.completion[id]?.defaultSchema : undefined); } /** Sets (or clears, for `null`) the console's active schema and remembers it per console file. */ @@ -902,11 +906,26 @@ export function setConsoleSchema(path: string, schema: string | null) { }); } -/** The data source a console / SQL file runs on: its binding, else the only data source. */ +/** The SQL resolution scope of file `path` (Languages & Frameworks › SQL Resolution Scopes), if any. */ +function scopeOf(path: string): SqlResolutionScope | null { + const { project, settings } = useProject.getState(); + if (!project) return null; + const sources = useDatabase.getState().sources; + return resolutionScopeOf(path, project.root, resolutionScopesOf(settings), (id) => + sources.some((x) => x.id === splitTarget(id).id), + ); +} + +/** + * The data source a console / SQL file runs on and resolves against: the one picked in its + * toolbar, else its SQL resolution scope's, else the only data source. + */ export function consoleSource(path: string): string | null { const s = useDatabase.getState(); const bound = s.consoles[path]; if (bound && s.sources.some((x) => x.id === splitTarget(bound).id)) return bound; + const scope = scopeOf(path); + if (scope) return scope.dataSource; return s.sources.length === 1 ? (s.sources[0]!.id ?? null) : null; } diff --git a/src/features/index.ts b/src/features/index.ts index cb65adc414..058cc72f04 100644 --- a/src/features/index.ts +++ b/src/features/index.ts @@ -48,7 +48,7 @@ import { activate as analysis } from "./analysis"; import { activate as services } from "./services"; import { activate as github, activateSettingsPages as githubPages } from "./github"; import { activate as httpClient } from "./http-client"; -import { activate as database } from "./database"; +import { activate as database, activateSettingsPages as databasePages } from "./database"; import { activate as graphql } from "./graphql"; import { activate as deployment, activateDeploymentWindow } from "./deployment"; import { activate as agents, activateSettingsPages as agentsPages } from "./agents"; @@ -188,6 +188,7 @@ export function activateSettingsWindowFeatures(parent: string): () => void { ["vim", vimPages], ["vcs", vcsPages], ["github", githubPages], + ["database", databasePages], ]; return activateAll("settings pages", pages); } diff --git a/src/features/settings/dialog/SettingsDialog.tsx b/src/features/settings/dialog/SettingsDialog.tsx index 8d5dadcc1f..233bf0212e 100644 --- a/src/features/settings/dialog/SettingsDialog.tsx +++ b/src/features/settings/dialog/SettingsDialog.tsx @@ -152,10 +152,11 @@ function PageHost({ const spec = page ? builtinSpec(page.id) : undefined; const projectScope = !!(spec?.projectScope ?? page?.projectScope) && hasProject && !newProjects; const scopeKey = spec?.scopeGroup ?? pageId; - const chosen = useSettingsDialog((s) => s.scopes[scopeKey]) ?? spec?.defaultScope; + const defaultScope = spec?.defaultScope ?? page?.defaultScope; + const chosen = useSettingsDialog((s) => s.scopes[scopeKey]) ?? defaultScope; const scope: Scope = projectScope && chosen === "project" ? "project" : "global"; // Where a project value is the norm, say what the global one is for. - const globalNote = newProjects || (projectScope && scope === "global" && spec?.defaultScope === "project"); + const globalNote = newProjects || (projectScope && scope === "global" && defaultScope === "project"); const ctx = useMemo(() => ({ pageId, scope }), [pageId, scope]); const form = useSettingsFormFor(pageId, scope); const focus = useSettingsDialog((s) => s.focus); diff --git a/src/features/settings/model/schema.ts b/src/features/settings/model/schema.ts index 8fce3e61c0..7b2c5af2c5 100644 --- a/src/features/settings/model/schema.ts +++ b/src/features/settings/model/schema.ts @@ -64,7 +64,7 @@ export interface ValidSettings extends WorkflowSettings { scopes: NamedScope[]; fileColors: FileColorSettings; /** Database › Query Execution. */ - database: { inEditorResults: boolean }; + database: { inEditorResults: boolean; resolutionScopes: Array<{ path: string; dataSource: string; schema: string }> }; general: { reopenLastProject: boolean; confirmExit: boolean; @@ -167,7 +167,7 @@ export const DEFAULT_SETTINGS: ValidSettings = { plugins: {}, scopes: [], fileColors: DEFAULT_FILE_COLORS, - database: { inEditorResults: false }, + database: { inEditorResults: false, resolutionScopes: [] }, general: { reopenLastProject: true, confirmExit: true, @@ -343,7 +343,17 @@ export function validateSettings(raw: Settings | unknown): ValidSettings { plugins: Object.fromEntries(Object.entries(obj(root.plugins)).map(([id, values]) => [id, obj(values)])), scopes: validateScopes(root.scopes), fileColors: validateFileColors(root.fileColors), - database: { inEditorResults: bool(obj(root.database).inEditorResults, d.database.inEditorResults) }, + database: { + inEditorResults: bool(obj(root.database).inEditorResults, d.database.inEditorResults), + resolutionScopes: (Array.isArray(obj(root.database).resolutionScopes) + ? (obj(root.database).resolutionScopes as unknown[]) + : [] + ).map((r) => ({ + path: str(obj(r).path, ""), + dataSource: str(obj(r).dataSource, ""), + schema: str(obj(r).schema, ""), + })), + }, general: { ...validateGeneralExtras(g), reopenLastProject: bool(g.reopenLastProject, d.general.reopenLastProject), diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json index e06e1ad929..15ea95752c 100644 --- a/src/platform/locales/text/en.json +++ b/src/platform/locales/text/en.json @@ -1971,5 +1971,11 @@ "Edit File Colors…": "Edit File Colors…", "Enable system notifications": "Enable system notifications", "In-Editor Results": "In-Editor Results", - "Show query results in the editor, under the statements that produced them": "Show query results in the editor, under the statements that produced them" + "Show query results in the editor, under the statements that produced them": "Show query results in the editor, under the statements that produced them", + "SQL Resolution Scopes": "SQL Resolution Scopes", + "SQL in these folders and files resolves against the data source: completion, inspections and navigation use its tables, and query consoles run on it unless another data source is picked in their toolbar.": "SQL in these folders and files resolves against the data source: completion, inspections and navigation use its tables, and query consoles run on it unless another data source is picked in their toolbar.", + "Project data source": "Project data source", + "Project schema": "Project schema", + "Add Folder or File": "Add Folder or File", + "Paths are relative to the project root. The deepest folder or file that contains a file applies to it.": "Paths are relative to the project root. The deepest folder or file that contains a file applies to it." } diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index 400612ce65..8d875b1400 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -8363,5 +8363,11 @@ "Edit File Colors…": "编辑文件颜色…", "Enable system notifications": "启用系统通知", "In-Editor Results": "编辑器内结果", - "Show query results in the editor, under the statements that produced them": "在编辑器中、产生结果的语句下方显示查询结果" + "Show query results in the editor, under the statements that produced them": "在编辑器中、产生结果的语句下方显示查询结果", + "SQL Resolution Scopes": "SQL 解析作用域", + "SQL in these folders and files resolves against the data source: completion, inspections and navigation use its tables, and query consoles run on it unless another data source is picked in their toolbar.": "这些文件夹和文件中的 SQL 按所选数据源解析:补全、检查和导航使用它的表;查询控制台也在它上面执行,除非在控制台工具栏中另选了数据源。", + "Project data source": "项目数据源", + "Project schema": "项目架构", + "Add Folder or File": "添加文件夹或文件", + "Paths are relative to the project root. The deepest folder or file that contains a file applies to it.": "路径相对于项目根目录。对某个文件生效的是包含它的最深一级文件夹或该文件本身。" } diff --git a/src/workbench/contributions.ts b/src/workbench/contributions.ts index 20ed3aa3ac..a4a77ef499 100644 --- a/src/workbench/contributions.ts +++ b/src/workbench/contributions.ts @@ -1091,6 +1091,8 @@ export interface SettingsPageContribution { component?: ComponentType; /** The page edits settings that a project can override (Global / This project switch). */ projectScope?: boolean; + /** The scope the switch starts on (default: global). */ + defaultScope?: "global" | "project"; } /**