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.ts35
1 files changed, 6 insertions, 29 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index 363a7a82e6..904efa4d5e 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -1,12 +1,10 @@
import * as vscode from "vscode";
import type * as lc from "vscode-languageclient/node";
import * as ra from "./lsp_ext";
-import * as path from "path";
import { Config, prepareVSCodeConfig } from "./config";
import { createClient } from "./client";
import {
- executeDiscoverProject,
isDocumentInWorkspace,
isRustDocument,
isRustEditor,
@@ -24,7 +22,6 @@ import {
import { execRevealDependency } from "./commands";
import { PersistentState } from "./persistent_state";
import { bootstrap } from "./bootstrap";
-import type { ExecOptions } from "child_process";
// 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
@@ -58,17 +55,6 @@ export function fetchWorkspace(): Workspace {
: { kind: "Workspace Folder" };
}
-export async function discoverWorkspace(
- files: readonly vscode.TextDocument[],
- command: string[],
- options: ExecOptions,
-): Promise<JsonProject> {
- const paths = files.map((f) => `"${f.uri.fsPath}"`).join(" ");
- const joinedCommand = command.join(" ");
- const data = await executeDiscoverProject(`${joinedCommand} ${paths}`, options);
- return JSON.parse(data) as JsonProject;
-}
-
export type CommandFactory = {
enabled: (ctx: CtxInit) => Cmd;
disabled?: (ctx: Ctx) => Cmd;
@@ -200,6 +186,12 @@ export class Ctx {
};
let rawInitializationOptions = vscode.workspace.getConfiguration("rust-analyzer");
+ if (this.config.discoverProjectRunner) {
+ const command = `${this.config.discoverProjectRunner}.discoverWorkspaceCommand`;
+ log.info(`running command: ${command}`);
+ const project: JsonProject = await vscode.commands.executeCommand(command);
+ this.addToDiscoveredWorkspaces([project]);
+ }
if (this.workspace.kind === "Detached Files") {
rawInitializationOptions = {
@@ -208,21 +200,6 @@ export class Ctx {
};
}
- const discoverProjectCommand = this.config.discoverProjectCommand;
- if (discoverProjectCommand) {
- const workspaces: JsonProject[] = await Promise.all(
- vscode.workspace.textDocuments
- .filter(isRustDocument)
- .map(async (file): Promise<JsonProject> => {
- return discoverWorkspace([file], discoverProjectCommand, {
- cwd: path.dirname(file.uri.fsPath),
- });
- }),
- );
-
- this.addToDiscoveredWorkspaces(workspaces);
- }
-
const initializationOptions = prepareVSCodeConfig(
rawInitializationOptions,
(key, obj) => {