Merge commit '258b15c506' into sync-from-ra

This commit is contained in:
Laurențiu Nicola 2023-09-18 12:32:37 +03:00
parent 7e786ea4cf
commit bcfc997eac
195 changed files with 5773 additions and 2750 deletions

View file

@ -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) => {