Skip to content

Commit 061940d

Browse files
committed
running prettier
1 parent 440889e commit 061940d

File tree

4 files changed

+86
-91
lines changed

4 files changed

+86
-91
lines changed

editors/code/src/ctx.ts

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import * as lc from "vscode-languageclient/node";
33
import * as ra from "./lsp_ext";
44
import * as path from "path";
55

6-
import {Config, prepareVSCodeConfig} from "./config";
7-
import {createClient} from "./client";
6+
import { Config, prepareVSCodeConfig } from "./config";
7+
import { createClient } from "./client";
88
import {
99
executeDiscoverProject,
1010
isRustDocument,
@@ -13,7 +13,7 @@ import {
1313
log,
1414
RustEditor,
1515
} from "./util";
16-
import {ServerStatusParams} from "./lsp_ext";
16+
import { ServerStatusParams } from "./lsp_ext";
1717
import {
1818
Dependency,
1919
DependencyFile,
@@ -27,10 +27,10 @@ import {
2727
RustDependenciesProvider,
2828
DependencyId,
2929
} from "./dependencies_provider";
30-
import {execRevealDependency} from "./commands";
31-
import {PersistentState} from "./persistent_state";
32-
import {bootstrap} from "./bootstrap";
33-
import {ExecOptions} from "child_process";
30+
import { execRevealDependency } from "./commands";
31+
import { PersistentState } from "./persistent_state";
32+
import { bootstrap } from "./bootstrap";
33+
import { ExecOptions } from "child_process";
3434

3535
// We only support local folders, not eg. Live Share (`vlsl:` scheme), so don't activate if
3636
// only those are in use. We use "Empty" to represent these scenarios
@@ -39,12 +39,12 @@ import {ExecOptions} from "child_process";
3939
export type Workspace =
4040
| { kind: "Empty" }
4141
| {
42-
kind: "Workspace Folder";
43-
}
42+
kind: "Workspace Folder";
43+
}
4444
| {
45-
kind: "Detached Files";
46-
files: vscode.TextDocument[];
47-
};
45+
kind: "Detached Files";
46+
files: vscode.TextDocument[];
47+
};
4848

4949
export function fetchWorkspace(): Workspace {
5050
const folders = (vscode.workspace.workspaceFolders || []).filter(
@@ -56,12 +56,12 @@ export function fetchWorkspace(): Workspace {
5656

5757
return folders.length === 0
5858
? rustDocuments.length === 0
59-
? {kind: "Empty"}
59+
? { kind: "Empty" }
6060
: {
61-
kind: "Detached Files",
62-
files: rustDocuments,
63-
}
64-
: {kind: "Workspace Folder"};
61+
kind: "Detached Files",
62+
files: rustDocuments,
63+
}
64+
: { kind: "Workspace Folder" };
6565
}
6666

6767
export async function discoverWorkspace(
@@ -116,7 +116,7 @@ export class Ctx {
116116
constructor(
117117
readonly extCtx: vscode.ExtensionContext,
118118
commandFactories: Record<string, CommandFactory>,
119-
workspace: Workspace,
119+
workspace: Workspace
120120
) {
121121
extCtx.subscriptions.push(this);
122122
this.statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
@@ -128,8 +128,7 @@ export class Ctx {
128128
this.state = new PersistentState(extCtx.globalState);
129129
this.config = new Config(extCtx);
130130

131-
this.updateCommands("disable"
132-
);
131+
this.updateCommands("disable");
133132
this.setServerStatus({
134133
health: "stopped",
135134
});
@@ -198,7 +197,7 @@ export class Ctx {
198197
const newEnv = Object.assign({}, process.env, this.config.serverExtraEnv);
199198
const run: lc.Executable = {
200199
command: this._serverPath,
201-
options: {env: newEnv},
200+
options: { env: newEnv },
202201
};
203202
const serverOptions = {
204203
run,
@@ -276,7 +275,7 @@ export class Ctx {
276275
private prepareTreeDependenciesView(client: lc.LanguageClient) {
277276
const ctxInit: CtxInit = {
278277
...this,
279-
client: client
278+
client: client,
280279
};
281280
const rootPath = vscode.workspace.workspaceFolders![0].uri.fsPath;
282281
this._dependencies = new RustDependenciesProvider(rootPath, ctxInit);

editors/code/src/dependencies_provider.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import * as ra from "./lsp_ext";
1313
export class RustDependenciesProvider
1414
implements vscode.TreeDataProvider<Dependency | DependencyFile>
1515
{
16-
17-
dependenciesMap: { [id: string]: Dependency | DependencyFile };ctx: CtxInit;
16+
dependenciesMap: { [id: string]: Dependency | DependencyFile };
17+
ctx: CtxInit;
1818

1919
constructor(private readonly workspaceRoot: string,ctx: CtxInit) {
2020
this.dependenciesMap = {};
@@ -82,7 +82,10 @@ export class RustDependenciesProvider
8282
private async getRootDependencies(): Promise<Dependency[]> {
8383
const crates = await this.ctx.client.sendRequest(ra.fetchDependencyGraph, {});
8484

85-
const dependenciesResult: FetchDependencyGraphResult = await this.ctx.client.sendRequest(ra.fetchDependencyGraph, {});
85+
const dependenciesResult: FetchDependencyGraphResult = await this.ctx.client.sendRequest(
86+
ra.fetchDependencyGraph,
87+
{}
88+
);
8689
const crates = dependenciesResult.crates;
8790
const deps = crates.map((crate) => {
8891
const dep = this.toDep(crate.name, crate.version, crate.path);
@@ -93,15 +96,10 @@ export class RustDependenciesProvider
9396
return deps;
9497
}
9598

96-
private toDep(moduleName: string, version: string, path: string): Dependency {
97-
//const cratePath = fspath.join(basePath, `${moduleName}-${version}`);
98-
return new Dependency(
99-
moduleName,
100-
version,
101-
path,
102-
vscode.TreeItemCollapsibleState.Collapsed
103-
);
104-
}
99+
private toDep(moduleName: string, version: string, path: string): Dependency {
100+
// const cratePath = fspath.join(basePath, `${moduleName}-${version}`);
101+
return new Dependency(moduleName, version, path, vscode.TreeItemCollapsibleState.Collapsed);
102+
}
105103
}
106104

107105
export class Dependency extends vscode.TreeItem {

editors/code/src/main.ts

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import * as vscode from "vscode";
22
import * as lc from "vscode-languageclient/node";
33

44
import * as commands from "./commands";
5-
import {CommandFactory, Ctx, fetchWorkspace} from "./ctx";
5+
import { CommandFactory, Ctx, fetchWorkspace } from "./ctx";
66
import * as diagnostics from "./diagnostics";
7-
import {activateTaskProvider} from "./tasks";
8-
import {setContextValue} from "./util";
7+
import { activateTaskProvider } from "./tasks";
8+
import { setContextValue } from "./util";
99

1010
const RUST_PROJECT_CONTEXT_NAME = "inRustProject";
1111

@@ -24,12 +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(() => {
32-
}, console.error);
31+
.then(() => {}, console.error);
3332
}
3433

3534
const ctx = new Ctx(context, createCommands(), fetchWorkspace());
@@ -119,7 +118,7 @@ function createCommands(): Record<string, CommandFactory> {
119118
return {
120119
onEnter: {
121120
enabled: commands.onEnter,
122-
disabled: (_) => () => vscode.commands.executeCommand("default:type", {text: "\n"}),
121+
disabled: (_) => () => vscode.commands.executeCommand("default:type", { text: "\n" }),
123122
},
124123
restartServer: {
125124
enabled: (ctx) => async () => {
@@ -145,53 +144,52 @@ function createCommands(): Record<string, CommandFactory> {
145144
health: "stopped",
146145
});
147146
},
148-
disabled: (_) => async () => {
149-
},
147+
disabled: (_) => async () => {},
150148
},
151149

152-
analyzerStatus: {enabled: commands.analyzerStatus},
153-
memoryUsage: {enabled: commands.memoryUsage},
154-
shuffleCrateGraph: {enabled: commands.shuffleCrateGraph},
155-
reloadWorkspace: {enabled: commands.reloadWorkspace},
156-
rebuildProcMacros: {enabled: commands.rebuildProcMacros},
157-
addProject: {enabled: commands.addProject},
158-
matchingBrace: {enabled: commands.matchingBrace},
159-
joinLines: {enabled: commands.joinLines},
160-
parentModule: {enabled: commands.parentModule},
161-
syntaxTree: {enabled: commands.syntaxTree},
162-
viewHir: {enabled: commands.viewHir},
163-
viewMir: {enabled: commands.viewMir},
150+
analyzerStatus: { enabled: commands.analyzerStatus },
151+
memoryUsage: { enabled: commands.memoryUsage },
152+
shuffleCrateGraph: { enabled: commands.shuffleCrateGraph },
153+
reloadWorkspace: { enabled: commands.reloadWorkspace },
154+
rebuildProcMacros: { enabled: commands.rebuildProcMacros },
155+
addProject: { enabled: commands.addProject },
156+
matchingBrace: { enabled: commands.matchingBrace },
157+
joinLines: { enabled: commands.joinLines },
158+
parentModule: { enabled: commands.parentModule },
159+
syntaxTree: { enabled: commands.syntaxTree },
160+
viewHir: { enabled: commands.viewHir },
161+
viewMir: { enabled: commands.viewMir },
164162
interpretFunction: { enabled: commands.interpretFunction },
165-
viewFileText: {enabled: commands.viewFileText},
166-
viewItemTree: {enabled: commands.viewItemTree},
167-
viewCrateGraph: {enabled: commands.viewCrateGraph},
168-
viewFullCrateGraph: {enabled: commands.viewFullCrateGraph},
169-
expandMacro: {enabled: commands.expandMacro},
170-
run: {enabled: commands.run},
171-
copyRunCommandLine: {enabled: commands.copyRunCommandLine},
172-
debug: {enabled: commands.debug},
173-
newDebugConfig: {enabled: commands.newDebugConfig},
174-
openDocs: {enabled: commands.openDocs},
175-
openCargoToml: {enabled: commands.openCargoToml},
176-
peekTests: {enabled: commands.peekTests},
177-
moveItemUp: {enabled: commands.moveItemUp},
178-
moveItemDown: {enabled: commands.moveItemDown},
179-
cancelFlycheck: {enabled: commands.cancelFlycheck},
180-
clearFlycheck: {enabled: commands.clearFlycheck},
181-
runFlycheck: {enabled: commands.runFlycheck},
182-
ssr: {enabled: commands.ssr},
183-
serverVersion: {enabled: commands.serverVersion},
163+
viewFileText: { enabled: commands.viewFileText },
164+
viewItemTree: { enabled: commands.viewItemTree },
165+
viewCrateGraph: { enabled: commands.viewCrateGraph },
166+
viewFullCrateGraph: { enabled: commands.viewFullCrateGraph },
167+
expandMacro: { enabled: commands.expandMacro },
168+
run: { enabled: commands.run },
169+
copyRunCommandLine: { enabled: commands.copyRunCommandLine },
170+
debug: { enabled: commands.debug },
171+
newDebugConfig: { enabled: commands.newDebugConfig },
172+
openDocs: { enabled: commands.openDocs },
173+
openCargoToml: { enabled: commands.openCargoToml },
174+
peekTests: { enabled: commands.peekTests },
175+
moveItemUp: { enabled: commands.moveItemUp },
176+
moveItemDown: { enabled: commands.moveItemDown },
177+
cancelFlycheck: { enabled: commands.cancelFlycheck },
178+
clearFlycheck: { enabled: commands.clearFlycheck },
179+
runFlycheck: { enabled: commands.runFlycheck },
180+
ssr: { enabled: commands.ssr },
181+
serverVersion: { enabled: commands.serverVersion },
184182
// Internal commands which are invoked by the server.
185-
applyActionGroup: {enabled: commands.applyActionGroup},
186-
applySnippetWorkspaceEdit: {enabled: commands.applySnippetWorkspaceEditCommand},
187-
debugSingle: {enabled: commands.debugSingle},
188-
gotoLocation: {enabled: commands.gotoLocation},
189-
linkToCommand: {enabled: commands.linkToCommand},
190-
resolveCodeAction: {enabled: commands.resolveCodeAction},
191-
runSingle: {enabled: commands.runSingle},
192-
showReferences: {enabled: commands.showReferences},
193-
triggerParameterHints: {enabled: commands.triggerParameterHints},
194-
openLogs: {enabled: commands.openLogs},
195-
revealDependency: {enabled: commands.revealDependency}
183+
applyActionGroup: { enabled: commands.applyActionGroup },
184+
applySnippetWorkspaceEdit: { enabled: commands.applySnippetWorkspaceEditCommand },
185+
debugSingle: { enabled: commands.debugSingle },
186+
gotoLocation: { enabled: commands.gotoLocation },
187+
linkToCommand: { enabled: commands.linkToCommand },
188+
resolveCodeAction: { enabled: commands.resolveCodeAction },
189+
runSingle: { enabled: commands.runSingle },
190+
showReferences: { enabled: commands.showReferences },
191+
triggerParameterHints: { enabled: commands.triggerParameterHints },
192+
openLogs: { enabled: commands.openLogs },
193+
revealDependency: { enabled: commands.revealDependency },
196194
};
197195
}

editors/code/src/toolchain.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as os from "os";
33
import * as path from "path";
44
import * as readline from "readline";
55
import * as vscode from "vscode";
6-
import {execute, log, memoizeAsync} from "./util";
6+
import { execute, log, memoizeAsync } from "./util";
77

88
interface CompilationArtifact {
99
fileName: string;
@@ -42,7 +42,7 @@ export class Cargo {
4242
}
4343
}
4444

45-
const result: ArtifactSpec = {cargoArgs: cargoArgs};
45+
const result: ArtifactSpec = { cargoArgs: cargoArgs };
4646
if (cargoArgs[0] === "test" || cargoArgs[0] === "bench") {
4747
// for instance, `crates\rust-analyzer\tests\heavy_tests\main.rs` tests
4848
// produce 2 artifacts: {"kind": "bin"} and {"kind": "test"}
@@ -147,7 +147,7 @@ export class Cargo {
147147

148148
cargo.stderr.on("data", (chunk) => onStderrString(chunk.toString()));
149149

150-
const rl = readline.createInterface({input: cargo.stdout});
150+
const rl = readline.createInterface({ input: cargo.stdout });
151151
rl.on("line", (line) => {
152152
const message = JSON.parse(line);
153153
onStdoutJson(message);
@@ -189,14 +189,14 @@ export async function getSysroot(dir: string): Promise<string> {
189189
const rustcPath = await getPathForExecutable("rustc");
190190

191191
// do not memoize the result because the toolchain may change between runs
192-
return await execute(`${rustcPath} --print sysroot`, {cwd: dir});
192+
return await execute(`${rustcPath} --print sysroot`, { cwd: dir });
193193
}
194194

195195
export async function getRustcId(dir: string): Promise<string> {
196196
const rustcPath = await getPathForExecutable("rustc");
197197

198198
// do not memoize the result because the toolchain may change between runs
199-
const data = await execute(`${rustcPath} -V -v`, {cwd: dir});
199+
const data = await execute(`${rustcPath} -V -v`, { cwd: dir });
200200
const rx = /commit-hash:\s(.*)$/m;
201201

202202
return rx.exec(data)![1];

0 commit comments

Comments
 (0)