about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--editors/code/src/ctx.ts43
-rw-r--r--editors/code/src/dependencies_provider.ts22
-rw-r--r--editors/code/src/main.ts102
-rw-r--r--editors/code/src/toolchain.ts10
4 files changed, 86 insertions, 91 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index ea42b249ff9..69347522b86 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -3,8 +3,8 @@ import * 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 { Config, prepareVSCodeConfig } from "./config";
+import { createClient } from "./client";
 import {
     executeDiscoverProject,
     isRustDocument,
@@ -13,7 +13,7 @@ import {
     log,
     RustEditor,
 } from "./util";
-import {ServerStatusParams} from "./lsp_ext";
+import { ServerStatusParams } from "./lsp_ext";
 import {
     Dependency,
     DependencyFile,
@@ -27,10 +27,10 @@ import {
     RustDependenciesProvider,
     DependencyId,
 } from "./dependencies_provider";
-import {execRevealDependency} from "./commands";
-import {PersistentState} from "./persistent_state";
-import {bootstrap} from "./bootstrap";
-import {ExecOptions} from "child_process";
+import { execRevealDependency } from "./commands";
+import { PersistentState } from "./persistent_state";
+import { bootstrap } from "./bootstrap";
+import { 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
@@ -39,12 +39,12 @@ import {ExecOptions} from "child_process";
 export type Workspace =
     | { kind: "Empty" }
     | {
-    kind: "Workspace Folder";
-}
+          kind: "Workspace Folder";
+      }
     | {
-    kind: "Detached Files";
-    files: vscode.TextDocument[];
-};
+          kind: "Detached Files";
+          files: vscode.TextDocument[];
+      };
 
 export function fetchWorkspace(): Workspace {
     const folders = (vscode.workspace.workspaceFolders || []).filter(
@@ -56,12 +56,12 @@ export function fetchWorkspace(): Workspace {
 
     return folders.length === 0
         ? rustDocuments.length === 0
-            ? {kind: "Empty"}
+            ? { kind: "Empty" }
             : {
-                kind: "Detached Files",
-                files: rustDocuments,
-            }
-        : {kind: "Workspace Folder"};
+                  kind: "Detached Files",
+                  files: rustDocuments,
+              }
+        : { kind: "Workspace Folder" };
 }
 
 export async function discoverWorkspace(
@@ -116,7 +116,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);
@@ -128,8 +128,7 @@ export class Ctx {
         this.state = new PersistentState(extCtx.globalState);
         this.config = new Config(extCtx);
 
-        this.updateCommands("disable"
-        );
+        this.updateCommands("disable");
         this.setServerStatus({
             health: "stopped",
         });
@@ -198,7 +197,7 @@ export class Ctx {
             const newEnv = Object.assign({}, process.env, this.config.serverExtraEnv);
             const run: lc.Executable = {
                 command: this._serverPath,
-                options: {env: newEnv},
+                options: { env: newEnv },
             };
             const serverOptions = {
                 run,
@@ -276,7 +275,7 @@ export class Ctx {
     private prepareTreeDependenciesView(client: lc.LanguageClient) {
         const ctxInit: CtxInit = {
             ...this,
-            client: client
+            client: client,
         };
         const rootPath = vscode.workspace.workspaceFolders![0].uri.fsPath;
         this._dependencies = new RustDependenciesProvider(rootPath, ctxInit);
diff --git a/editors/code/src/dependencies_provider.ts b/editors/code/src/dependencies_provider.ts
index f2838af6e06..3713250b8fc 100644
--- a/editors/code/src/dependencies_provider.ts
+++ b/editors/code/src/dependencies_provider.ts
@@ -13,8 +13,8 @@ import * as ra from "./lsp_ext";
 export class RustDependenciesProvider
     implements vscode.TreeDataProvider<Dependency | DependencyFile>
 {
-
-    dependenciesMap: { [id: string]: Dependency | DependencyFile };ctx: CtxInit;
+    dependenciesMap: { [id: string]: Dependency | DependencyFile };
+    ctx: CtxInit;
 
     constructor(private readonly workspaceRoot: string,ctx: CtxInit) {
         this.dependenciesMap = {};
@@ -82,7 +82,10 @@ export class RustDependenciesProvider
     private async getRootDependencies(): Promise<Dependency[]> {
         const crates = await this.ctx.client.sendRequest(ra.fetchDependencyGraph, {});
 
-        const dependenciesResult: FetchDependencyGraphResult = await this.ctx.client.sendRequest(ra.fetchDependencyGraph, {});
+        const dependenciesResult: FetchDependencyGraphResult = await this.ctx.client.sendRequest(
+            ra.fetchDependencyGraph,
+            {}
+        );
         const crates = dependenciesResult.crates;
         const deps = crates.map((crate) => {
         const dep = this.toDep(crate.name, crate.version, crate.path);
@@ -93,15 +96,10 @@ export class RustDependenciesProvider
         return deps;
     }
 
-    private toDep(moduleName: string, version: string, path: string): Dependency  {
-            //const cratePath = fspath.join(basePath, `${moduleName}-${version}`);
-            return new Dependency(
-                moduleName,
-                version,
-                path,
-                vscode.TreeItemCollapsibleState.Collapsed
-            );
-        }
+    private toDep(moduleName: string, version: string, path: string): Dependency {
+        // const cratePath = fspath.join(basePath, `${moduleName}-${version}`);
+        return new Dependency(moduleName, version, path, vscode.TreeItemCollapsibleState.Collapsed);
+    }
 }
 
 export class Dependency extends vscode.TreeItem {
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 774600f6c39..be9bc9d363c 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -2,10 +2,10 @@ import * as vscode from "vscode";
 import * as lc from "vscode-languageclient/node";
 
 import * as commands from "./commands";
-import {CommandFactory, Ctx, fetchWorkspace} from "./ctx";
+import { CommandFactory, Ctx, fetchWorkspace } from "./ctx";
 import * as diagnostics from "./diagnostics";
-import {activateTaskProvider} from "./tasks";
-import {setContextValue} from "./util";
+import { activateTaskProvider } from "./tasks";
+import { setContextValue } from "./util";
 
 const RUST_PROJECT_CONTEXT_NAME = "inRustProject";
 
@@ -24,12 +24,11 @@ export async function activate(
         vscode.window
             .showWarningMessage(
                 `You have both the rust-analyzer (rust-lang.rust-analyzer) and Rust (rust-lang.rust) ` +
-                "plugins enabled. These are known to conflict and cause various functions of " +
-                "both plugins to not work correctly. You should disable one of them.",
+                    "plugins enabled. These are known to conflict and cause various functions of " +
+                    "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());
@@ -119,7 +118,7 @@ function createCommands(): Record<string, CommandFactory> {
     return {
         onEnter: {
             enabled: commands.onEnter,
-            disabled: (_) => () => vscode.commands.executeCommand("default:type", {text: "\n"}),
+            disabled: (_) => () => vscode.commands.executeCommand("default:type", { text: "\n" }),
         },
         restartServer: {
             enabled: (ctx) => async () => {
@@ -145,53 +144,52 @@ function createCommands(): Record<string, CommandFactory> {
                     health: "stopped",
                 });
             },
-            disabled: (_) => async () => {
-            },
+            disabled: (_) => async () => {},
         },
 
-        analyzerStatus: {enabled: commands.analyzerStatus},
-        memoryUsage: {enabled: commands.memoryUsage},
-        shuffleCrateGraph: {enabled: commands.shuffleCrateGraph},
-        reloadWorkspace: {enabled: commands.reloadWorkspace},
-        rebuildProcMacros: {enabled: commands.rebuildProcMacros},
-        addProject: {enabled: commands.addProject},
-        matchingBrace: {enabled: commands.matchingBrace},
-        joinLines: {enabled: commands.joinLines},
-        parentModule: {enabled: commands.parentModule},
-        syntaxTree: {enabled: commands.syntaxTree},
-        viewHir: {enabled: commands.viewHir},
-        viewMir: {enabled: commands.viewMir},
+        analyzerStatus: { enabled: commands.analyzerStatus },
+        memoryUsage: { enabled: commands.memoryUsage },
+        shuffleCrateGraph: { enabled: commands.shuffleCrateGraph },
+        reloadWorkspace: { enabled: commands.reloadWorkspace },
+        rebuildProcMacros: { enabled: commands.rebuildProcMacros },
+        addProject: { enabled: commands.addProject },
+        matchingBrace: { enabled: commands.matchingBrace },
+        joinLines: { enabled: commands.joinLines },
+        parentModule: { enabled: commands.parentModule },
+        syntaxTree: { enabled: commands.syntaxTree },
+        viewHir: { enabled: commands.viewHir },
+        viewMir: { enabled: commands.viewMir },
         interpretFunction: { enabled: commands.interpretFunction },
-        viewFileText: {enabled: commands.viewFileText},
-        viewItemTree: {enabled: commands.viewItemTree},
-        viewCrateGraph: {enabled: commands.viewCrateGraph},
-        viewFullCrateGraph: {enabled: commands.viewFullCrateGraph},
-        expandMacro: {enabled: commands.expandMacro},
-        run: {enabled: commands.run},
-        copyRunCommandLine: {enabled: commands.copyRunCommandLine},
-        debug: {enabled: commands.debug},
-        newDebugConfig: {enabled: commands.newDebugConfig},
-        openDocs: {enabled: commands.openDocs},
-        openCargoToml: {enabled: commands.openCargoToml},
-        peekTests: {enabled: commands.peekTests},
-        moveItemUp: {enabled: commands.moveItemUp},
-        moveItemDown: {enabled: commands.moveItemDown},
-        cancelFlycheck: {enabled: commands.cancelFlycheck},
-        clearFlycheck: {enabled: commands.clearFlycheck},
-        runFlycheck: {enabled: commands.runFlycheck},
-        ssr: {enabled: commands.ssr},
-        serverVersion: {enabled: commands.serverVersion},
+        viewFileText: { enabled: commands.viewFileText },
+        viewItemTree: { enabled: commands.viewItemTree },
+        viewCrateGraph: { enabled: commands.viewCrateGraph },
+        viewFullCrateGraph: { enabled: commands.viewFullCrateGraph },
+        expandMacro: { enabled: commands.expandMacro },
+        run: { enabled: commands.run },
+        copyRunCommandLine: { enabled: commands.copyRunCommandLine },
+        debug: { enabled: commands.debug },
+        newDebugConfig: { enabled: commands.newDebugConfig },
+        openDocs: { enabled: commands.openDocs },
+        openCargoToml: { enabled: commands.openCargoToml },
+        peekTests: { enabled: commands.peekTests },
+        moveItemUp: { enabled: commands.moveItemUp },
+        moveItemDown: { enabled: commands.moveItemDown },
+        cancelFlycheck: { enabled: commands.cancelFlycheck },
+        clearFlycheck: { enabled: commands.clearFlycheck },
+        runFlycheck: { enabled: commands.runFlycheck },
+        ssr: { enabled: commands.ssr },
+        serverVersion: { enabled: commands.serverVersion },
         // Internal commands which are invoked by the server.
-        applyActionGroup: {enabled: commands.applyActionGroup},
-        applySnippetWorkspaceEdit: {enabled: commands.applySnippetWorkspaceEditCommand},
-        debugSingle: {enabled: commands.debugSingle},
-        gotoLocation: {enabled: commands.gotoLocation},
-        linkToCommand: {enabled: commands.linkToCommand},
-        resolveCodeAction: {enabled: commands.resolveCodeAction},
-        runSingle: {enabled: commands.runSingle},
-        showReferences: {enabled: commands.showReferences},
-        triggerParameterHints: {enabled: commands.triggerParameterHints},
-        openLogs: {enabled: commands.openLogs},
-        revealDependency: {enabled: commands.revealDependency}
+        applyActionGroup: { enabled: commands.applyActionGroup },
+        applySnippetWorkspaceEdit: { enabled: commands.applySnippetWorkspaceEditCommand },
+        debugSingle: { enabled: commands.debugSingle },
+        gotoLocation: { enabled: commands.gotoLocation },
+        linkToCommand: { enabled: commands.linkToCommand },
+        resolveCodeAction: { enabled: commands.resolveCodeAction },
+        runSingle: { enabled: commands.runSingle },
+        showReferences: { enabled: commands.showReferences },
+        triggerParameterHints: { enabled: commands.triggerParameterHints },
+        openLogs: { enabled: commands.openLogs },
+        revealDependency: { enabled: commands.revealDependency },
     };
 }
diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts
index 8c2e55bcc26..9c5c88c49e5 100644
--- a/editors/code/src/toolchain.ts
+++ b/editors/code/src/toolchain.ts
@@ -3,7 +3,7 @@ import * as os from "os";
 import * as path from "path";
 import * as readline from "readline";
 import * as vscode from "vscode";
-import {execute, log, memoizeAsync} from "./util";
+import { execute, log, memoizeAsync } from "./util";
 
 interface CompilationArtifact {
     fileName: string;
@@ -42,7 +42,7 @@ export class Cargo {
             }
         }
 
-        const result: ArtifactSpec = {cargoArgs: cargoArgs};
+        const result: ArtifactSpec = { cargoArgs: cargoArgs };
         if (cargoArgs[0] === "test" || cargoArgs[0] === "bench") {
             // for instance, `crates\rust-analyzer\tests\heavy_tests\main.rs` tests
             // produce 2 artifacts: {"kind": "bin"} and {"kind": "test"}
@@ -147,7 +147,7 @@ export class Cargo {
 
             cargo.stderr.on("data", (chunk) => onStderrString(chunk.toString()));
 
-            const rl = readline.createInterface({input: cargo.stdout});
+            const rl = readline.createInterface({ input: cargo.stdout });
             rl.on("line", (line) => {
                 const message = JSON.parse(line);
                 onStdoutJson(message);
@@ -189,14 +189,14 @@ export async function getSysroot(dir: string): Promise<string> {
     const rustcPath = await getPathForExecutable("rustc");
 
     // do not memoize the result because the toolchain may change between runs
-    return await execute(`${rustcPath} --print sysroot`, {cwd: dir});
+    return await execute(`${rustcPath} --print sysroot`, { cwd: dir });
 }
 
 export async function getRustcId(dir: string): Promise<string> {
     const rustcPath = await getPathForExecutable("rustc");
 
     // do not memoize the result because the toolchain may change between runs
-    const data = await execute(`${rustcPath} -V -v`, {cwd: dir});
+    const data = await execute(`${rustcPath} -V -v`, { cwd: dir });
     const rx = /commit-hash:\s(.*)$/m;
 
     return rx.exec(data)![1];