Skip to content

Commit 46e0220

Browse files
committed
fmt
1 parent 8af3d63 commit 46e0220

File tree

8 files changed

+58
-37
lines changed

8 files changed

+58
-37
lines changed

editors/code/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1920,4 +1920,4 @@
19201920
}
19211921
]
19221922
}
1923-
}
1923+
}

editors/code/src/commands.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -756,14 +756,18 @@ export function addProject(ctx: CtxInit): Cmd {
756756
return;
757757
}
758758

759-
let workspaces: JsonProject[] = await Promise.all(vscode.workspace.workspaceFolders!.map(async (folder): Promise<JsonProject> => {
760-
return discoverWorkspace(vscode.workspace.textDocuments, discoverProjectCommand, { cwd: folder.uri.fsPath });
761-
}));
759+
const workspaces: JsonProject[] = await Promise.all(
760+
vscode.workspace.workspaceFolders!.map(async (folder): Promise<JsonProject> => {
761+
return discoverWorkspace(vscode.workspace.textDocuments, discoverProjectCommand, {
762+
cwd: folder.uri.fsPath,
763+
});
764+
})
765+
);
762766

763767
await ctx.client.sendRequest(ra.addProject, {
764-
project: workspaces
768+
project: workspaces,
765769
});
766-
}
770+
};
767771
}
768772

769773
async function showReferencesImpl(

editors/code/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export class Config {
215215
}
216216

217217
get discoverProjectCommand() {
218-
return this.get<string[] | undefined>("discoverProjectCommand")
218+
return this.get<string[] | undefined>("discoverProjectCommand");
219219
}
220220

221221
get cargoRunner() {

editors/code/src/ctx.ts

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ import * as ra from "./lsp_ext";
44

55
import { Config, substituteVSCodeVariables } from "./config";
66
import { createClient } from "./client";
7-
import { executeDiscoverProject, isRustDocument, isRustEditor, LazyOutputChannel, log, RustEditor } from "./util";
7+
import {
8+
executeDiscoverProject,
9+
isRustDocument,
10+
isRustEditor,
11+
LazyOutputChannel,
12+
log,
13+
RustEditor,
14+
} from "./util";
815
import { ServerStatusParams } from "./lsp_ext";
916
import { PersistentState } from "./persistent_state";
1017
import { bootstrap } from "./bootstrap";
@@ -17,12 +24,12 @@ import { ExecOptions } from "child_process";
1724
export type Workspace =
1825
| { kind: "Empty" }
1926
| {
20-
kind: "Workspace Folder";
21-
}
27+
kind: "Workspace Folder";
28+
}
2229
| {
23-
kind: "Detached Files";
24-
files: vscode.TextDocument[];
25-
};
30+
kind: "Detached Files";
31+
files: vscode.TextDocument[];
32+
};
2633

2734
export function fetchWorkspace(): Workspace {
2835
const folders = (vscode.workspace.workspaceFolders || []).filter(
@@ -36,13 +43,17 @@ export function fetchWorkspace(): Workspace {
3643
? rustDocuments.length === 0
3744
? { kind: "Empty" }
3845
: {
39-
kind: "Detached Files",
40-
files: rustDocuments,
41-
}
46+
kind: "Detached Files",
47+
files: rustDocuments,
48+
}
4249
: { kind: "Workspace Folder" };
4350
}
4451

45-
export async function discoverWorkspace(files: readonly vscode.TextDocument[], command: string[], options: ExecOptions): Promise<JsonProject> {
52+
export async function discoverWorkspace(
53+
files: readonly vscode.TextDocument[],
54+
command: string[],
55+
options: ExecOptions
56+
): Promise<JsonProject> {
4657
const paths = files.map((f) => f.uri.fsPath).join(" ");
4758
const joinedCommand = command.join(" ");
4859
const data = await executeDiscoverProject(`${joinedCommand} -- ${paths}`, options);
@@ -80,7 +91,7 @@ export class Ctx {
8091
constructor(
8192
readonly extCtx: vscode.ExtensionContext,
8293
commandFactories: Record<string, CommandFactory>,
83-
workspace: Workspace,
94+
workspace: Workspace
8495
) {
8596
extCtx.subscriptions.push(this);
8697
this.statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
@@ -180,16 +191,22 @@ export class Ctx {
180191

181192
const discoverProjectCommand = this.config.discoverProjectCommand;
182193
if (discoverProjectCommand) {
183-
let workspaces: JsonProject[] = await Promise.all(vscode.workspace.workspaceFolders!.map(async (folder): Promise<JsonProject> => {
184-
return discoverWorkspace(vscode.workspace.textDocuments, discoverProjectCommand, { cwd: folder.uri.fsPath });
185-
}));
194+
const workspaces: JsonProject[] = await Promise.all(
195+
vscode.workspace.workspaceFolders!.map(async (folder): Promise<JsonProject> => {
196+
return discoverWorkspace(
197+
vscode.workspace.textDocuments,
198+
discoverProjectCommand,
199+
{ cwd: folder.uri.fsPath }
200+
);
201+
})
202+
);
186203

187204
this.discoveredWorkspaces = workspaces;
188205
}
189206

190-
let initializationOptions = substituteVSCodeVariables(rawInitializationOptions);
207+
const initializationOptions = substituteVSCodeVariables(rawInitializationOptions);
191208
// this appears to be load-bearing, for better or worse.
192-
await initializationOptions.update('linkedProjects', this.discoveredWorkspaces)
209+
await initializationOptions.update("linkedProjects", this.discoveredWorkspaces);
193210

194211
this._client = await createClient(
195212
this.traceOutputChannel,

editors/code/src/lsp_ext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, Te
4545
export const reloadWorkspace = new lc.RequestType0<null, void>("rust-analyzer/reloadWorkspace");
4646
export const addProject = new lc.RequestType<AddProjectParams, string, void>(
4747
"rust-analyzer/addProject"
48-
)
48+
);
4949

5050
export const runFlycheck = new lc.NotificationType<{
5151
textDocument: lc.TextDocumentIdentifier | null;

editors/code/src/main.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ export async function activate(
2424
vscode.window
2525
.showWarningMessage(
2626
`You have both the rust-analyzer (rust-lang.rust-analyzer) and Rust (rust-lang.rust) ` +
27-
"plugins enabled. These are known to conflict and cause various functions of " +
28-
"both plugins to not work correctly. You should disable one of them.",
27+
"plugins enabled. These are known to conflict and cause various functions of " +
28+
"both plugins to not work correctly. You should disable one of them.",
2929
"Got it"
3030
)
31-
.then(() => { }, console.error);
31+
.then(() => {}, console.error);
3232
}
3333

3434
const ctx = new Ctx(context, createCommands(), fetchWorkspace());
@@ -146,7 +146,7 @@ function createCommands(): Record<string, CommandFactory> {
146146
health: "stopped",
147147
});
148148
},
149-
disabled: (_) => async () => { },
149+
disabled: (_) => async () => {},
150150
},
151151

152152
analyzerStatus: { enabled: commands.analyzerStatus },

editors/code/src/rust_project.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ interface Crate {
6060
/// rust-analyzer assumes that files from one
6161
/// source can't refer to files in another source.
6262
source?: {
63-
include_dirs: string[],
64-
exclude_dirs: string[],
65-
},
63+
include_dirs: string[];
64+
exclude_dirs: string[];
65+
};
6666
/// The set of cfgs activated for a given crate, like
6767
/// `["unix", "feature=\"foo\"", "feature=\"bar\""]`.
6868
cfg: string[];
@@ -73,7 +73,7 @@ interface Crate {
7373
target?: string;
7474
/// Environment variables, used for
7575
/// the `env!` macro
76-
env: { [key: string]: string; },
76+
env: { [key: string]: string };
7777

7878
/// Whether the crate is a proc-macro crate.
7979
is_proc_macro: boolean;
@@ -84,8 +84,8 @@ interface Crate {
8484

8585
interface Dep {
8686
/// Index of a crate in the `crates` array.
87-
crate: number,
87+
crate: number;
8888
/// Name as should appear in the (implicit)
8989
/// `extern crate name` declaration.
90-
name: string,
91-
}
90+
name: string;
91+
}

editors/code/src/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export function memoizeAsync<Ret, TThis, Param extends string>(
150150

151151
/** Awaitable wrapper around `child_process.exec` */
152152
export function execute(command: string, options: ExecOptions): Promise<string> {
153-
log.info(`running command: ${command}`)
153+
log.info(`running command: ${command}`);
154154
return new Promise((resolve, reject) => {
155155
exec(command, options, (err, stdout, stderr) => {
156156
if (err) {
@@ -170,7 +170,7 @@ export function execute(command: string, options: ExecOptions): Promise<string>
170170
}
171171

172172
export function executeDiscoverProject(command: string, options: ExecOptions): Promise<string> {
173-
log.info(`running command: ${command}`)
173+
log.info(`running command: ${command}`);
174174
return new Promise((resolve, reject) => {
175175
exec(command, options, (err, stdout, _) => {
176176
if (err) {

0 commit comments

Comments
 (0)