Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/ctx.ts')
| -rw-r--r-- | editors/code/src/ctx.ts | 57 |
1 files changed, 4 insertions, 53 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 675bfda65a..49e002627d 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -1,5 +1,5 @@ import * as vscode from "vscode"; -import * as lc from "vscode-languageclient/node"; +import type * as lc from "vscode-languageclient/node"; import * as ra from "./lsp_ext"; import { Config, prepareVSCodeConfig } from "./config"; @@ -22,11 +22,10 @@ import { import { execRevealDependency } from "./commands"; import { PersistentState } from "./persistent_state"; import { bootstrap } from "./bootstrap"; -import type { RustAnalyzerExtensionApi } from "./main"; -import type { JsonProject } from "./rust_project"; import { prepareTestExplorer } from "./test_explorer"; import { spawn } from "node:child_process"; import { text } from "node:stream/consumers"; +import type { RustAnalyzerExtensionApi } from "./main"; // We only support local folders, not eg. Live Share (`vlsl:` scheme), so don't activate if // only those are in use. We use "Empty" to represent these scenarios @@ -71,7 +70,7 @@ export type CtxInit = Ctx & { export class Ctx implements RustAnalyzerExtensionApi { readonly statusBar: vscode.StatusBarItem; - config: Config; + readonly config: Config; readonly workspace: Workspace; readonly version: string; @@ -212,15 +211,6 @@ export class Ctx implements RustAnalyzerExtensionApi { }; let rawInitializationOptions = vscode.workspace.getConfiguration("rust-analyzer"); - if (this.config.discoverProjectRunner) { - const command = `${this.config.discoverProjectRunner}.discoverWorkspaceCommand`; - log.info(`running command: ${command}`); - const uris = vscode.workspace.textDocuments - .filter(isRustDocument) - .map((document) => document.uri); - const projects: JsonProject[] = await vscode.commands.executeCommand(command, uris); - this.setWorkspaces(projects); - } if (this.workspace.kind === "Detached Files") { rawInitializationOptions = { @@ -229,16 +219,7 @@ export class Ctx implements RustAnalyzerExtensionApi { }; } - const initializationOptions = prepareVSCodeConfig( - rawInitializationOptions, - (key, obj) => { - // we only want to set discovered workspaces on the right key - // and if a workspace has been discovered. - if (key === "linkedProjects" && this.config.discoveredWorkspaces.length > 0) { - obj["linkedProjects"] = this.config.discoveredWorkspaces; - } - }, - ); + const initializationOptions = prepareVSCodeConfig(rawInitializationOptions); this._client = await createClient( this.traceOutputChannel, @@ -258,23 +239,6 @@ export class Ctx implements RustAnalyzerExtensionApi { this.outputChannel!.show(); }), ); - this.pushClientCleanup( - this._client.onNotification(ra.unindexedProject, async (params) => { - if (this.config.discoverProjectRunner) { - const command = `${this.config.discoverProjectRunner}.discoverWorkspaceCommand`; - log.info(`running command: ${command}`); - const uris = params.textDocuments.map((doc) => - vscode.Uri.parse(doc.uri, true), - ); - const projects: JsonProject[] = await vscode.commands.executeCommand( - command, - uris, - ); - this.setWorkspaces(projects); - await this.notifyRustAnalyzer(); - } - }), - ); } return this._client; } @@ -400,19 +364,6 @@ export class Ctx implements RustAnalyzerExtensionApi { return this.extCtx.subscriptions; } - setWorkspaces(workspaces: JsonProject[]) { - this.config.discoveredWorkspaces = workspaces; - } - - async notifyRustAnalyzer(): Promise<void> { - // this is a workaround to avoid needing writing the `rust-project.json` into - // a workspace-level VS Code-specific settings folder. We'd like to keep the - // `rust-project.json` entirely in-memory. - await this.client?.sendNotification(lc.DidChangeConfigurationNotification.type, { - settings: "", - }); - } - private updateCommands(forceDisable?: "disable") { this.commandDisposables.forEach((disposable) => disposable.dispose()); this.commandDisposables = []; |