mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
fmt
This commit is contained in:
parent
8af3d6367e
commit
46e022098f
@ -756,14 +756,18 @@ export function addProject(ctx: CtxInit): Cmd {
|
||||
return;
|
||||
}
|
||||
|
||||
let workspaces: JsonProject[] = await Promise.all(vscode.workspace.workspaceFolders!.map(async (folder): Promise<JsonProject> => {
|
||||
return discoverWorkspace(vscode.workspace.textDocuments, discoverProjectCommand, { cwd: folder.uri.fsPath });
|
||||
}));
|
||||
const workspaces: JsonProject[] = await Promise.all(
|
||||
vscode.workspace.workspaceFolders!.map(async (folder): Promise<JsonProject> => {
|
||||
return discoverWorkspace(vscode.workspace.textDocuments, discoverProjectCommand, {
|
||||
cwd: folder.uri.fsPath,
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
await ctx.client.sendRequest(ra.addProject, {
|
||||
project: workspaces
|
||||
project: workspaces,
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async function showReferencesImpl(
|
||||
|
@ -215,7 +215,7 @@ export class Config {
|
||||
}
|
||||
|
||||
get discoverProjectCommand() {
|
||||
return this.get<string[] | undefined>("discoverProjectCommand")
|
||||
return this.get<string[] | undefined>("discoverProjectCommand");
|
||||
}
|
||||
|
||||
get cargoRunner() {
|
||||
|
@ -4,7 +4,14 @@ import * as ra from "./lsp_ext";
|
||||
|
||||
import { Config, substituteVSCodeVariables } from "./config";
|
||||
import { createClient } from "./client";
|
||||
import { executeDiscoverProject, isRustDocument, isRustEditor, LazyOutputChannel, log, RustEditor } from "./util";
|
||||
import {
|
||||
executeDiscoverProject,
|
||||
isRustDocument,
|
||||
isRustEditor,
|
||||
LazyOutputChannel,
|
||||
log,
|
||||
RustEditor,
|
||||
} from "./util";
|
||||
import { ServerStatusParams } from "./lsp_ext";
|
||||
import { PersistentState } from "./persistent_state";
|
||||
import { bootstrap } from "./bootstrap";
|
||||
@ -42,7 +49,11 @@ export function fetchWorkspace(): Workspace {
|
||||
: { kind: "Workspace Folder" };
|
||||
}
|
||||
|
||||
export async function discoverWorkspace(files: readonly vscode.TextDocument[], command: string[], options: ExecOptions): Promise<JsonProject> {
|
||||
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);
|
||||
@ -80,7 +91,7 @@ export class Ctx {
|
||||
constructor(
|
||||
readonly extCtx: vscode.ExtensionContext,
|
||||
commandFactories: Record<string, CommandFactory>,
|
||||
workspace: Workspace,
|
||||
workspace: Workspace
|
||||
) {
|
||||
extCtx.subscriptions.push(this);
|
||||
this.statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
|
||||
@ -180,16 +191,22 @@ export class Ctx {
|
||||
|
||||
const discoverProjectCommand = this.config.discoverProjectCommand;
|
||||
if (discoverProjectCommand) {
|
||||
let workspaces: JsonProject[] = await Promise.all(vscode.workspace.workspaceFolders!.map(async (folder): Promise<JsonProject> => {
|
||||
return discoverWorkspace(vscode.workspace.textDocuments, discoverProjectCommand, { cwd: folder.uri.fsPath });
|
||||
}));
|
||||
const workspaces: JsonProject[] = await Promise.all(
|
||||
vscode.workspace.workspaceFolders!.map(async (folder): Promise<JsonProject> => {
|
||||
return discoverWorkspace(
|
||||
vscode.workspace.textDocuments,
|
||||
discoverProjectCommand,
|
||||
{ cwd: folder.uri.fsPath }
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
this.discoveredWorkspaces = workspaces;
|
||||
}
|
||||
|
||||
let initializationOptions = substituteVSCodeVariables(rawInitializationOptions);
|
||||
const initializationOptions = substituteVSCodeVariables(rawInitializationOptions);
|
||||
// this appears to be load-bearing, for better or worse.
|
||||
await initializationOptions.update('linkedProjects', this.discoveredWorkspaces)
|
||||
await initializationOptions.update("linkedProjects", this.discoveredWorkspaces);
|
||||
|
||||
this._client = await createClient(
|
||||
this.traceOutputChannel,
|
||||
|
@ -45,7 +45,7 @@ export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, Te
|
||||
export const reloadWorkspace = new lc.RequestType0<null, void>("rust-analyzer/reloadWorkspace");
|
||||
export const addProject = new lc.RequestType<AddProjectParams, string, void>(
|
||||
"rust-analyzer/addProject"
|
||||
)
|
||||
);
|
||||
|
||||
export const runFlycheck = new lc.NotificationType<{
|
||||
textDocument: lc.TextDocumentIdentifier | null;
|
||||
|
@ -28,7 +28,7 @@ export async function activate(
|
||||
"both plugins to not work correctly. You should disable one of them.",
|
||||
"Got it"
|
||||
)
|
||||
.then(() => { }, console.error);
|
||||
.then(() => {}, console.error);
|
||||
}
|
||||
|
||||
const ctx = new Ctx(context, createCommands(), fetchWorkspace());
|
||||
@ -146,7 +146,7 @@ function createCommands(): Record<string, CommandFactory> {
|
||||
health: "stopped",
|
||||
});
|
||||
},
|
||||
disabled: (_) => async () => { },
|
||||
disabled: (_) => async () => {},
|
||||
},
|
||||
|
||||
analyzerStatus: { enabled: commands.analyzerStatus },
|
||||
|
@ -60,9 +60,9 @@ interface Crate {
|
||||
/// rust-analyzer assumes that files from one
|
||||
/// source can't refer to files in another source.
|
||||
source?: {
|
||||
include_dirs: string[],
|
||||
exclude_dirs: string[],
|
||||
},
|
||||
include_dirs: string[];
|
||||
exclude_dirs: string[];
|
||||
};
|
||||
/// The set of cfgs activated for a given crate, like
|
||||
/// `["unix", "feature=\"foo\"", "feature=\"bar\""]`.
|
||||
cfg: string[];
|
||||
@ -73,7 +73,7 @@ interface Crate {
|
||||
target?: string;
|
||||
/// Environment variables, used for
|
||||
/// the `env!` macro
|
||||
env: { [key: string]: string; },
|
||||
env: { [key: string]: string };
|
||||
|
||||
/// Whether the crate is a proc-macro crate.
|
||||
is_proc_macro: boolean;
|
||||
@ -84,8 +84,8 @@ interface Crate {
|
||||
|
||||
interface Dep {
|
||||
/// Index of a crate in the `crates` array.
|
||||
crate: number,
|
||||
crate: number;
|
||||
/// Name as should appear in the (implicit)
|
||||
/// `extern crate name` declaration.
|
||||
name: string,
|
||||
name: string;
|
||||
}
|
@ -150,7 +150,7 @@ export function memoizeAsync<Ret, TThis, Param extends string>(
|
||||
|
||||
/** Awaitable wrapper around `child_process.exec` */
|
||||
export function execute(command: string, options: ExecOptions): Promise<string> {
|
||||
log.info(`running command: ${command}`)
|
||||
log.info(`running command: ${command}`);
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(command, options, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
@ -170,7 +170,7 @@ export function execute(command: string, options: ExecOptions): Promise<string>
|
||||
}
|
||||
|
||||
export function executeDiscoverProject(command: string, options: ExecOptions): Promise<string> {
|
||||
log.info(`running command: ${command}`)
|
||||
log.info(`running command: ${command}`);
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(command, options, (err, stdout, _) => {
|
||||
if (err) {
|
||||
|
Loading…
Reference in New Issue
Block a user