From af999f152bcec9a0fb9c792bbb14eba093ddeec8 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 17 Jul 2022 17:38:56 +0200 Subject: [PATCH] Reformat VSCode client code --- editors/code/src/commands.ts | 2 +- editors/code/src/ctx.ts | 17 +++++++---- editors/code/src/dependencies_provider.ts | 22 ++++++-------- editors/code/src/toolchain.ts | 36 ++++++++++------------- 4 files changed, 36 insertions(+), 41 deletions(-) diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index fb6778b687..7fe32754c9 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts @@ -8,7 +8,7 @@ import { applySnippetWorkspaceEdit, applySnippetTextEdits } from "./snippets"; import { spawnSync } from "child_process"; import { RunnableQuickPick, selectRunnable, createTask, createArgs } from "./run"; import { AstInspector } from "./ast_inspector"; -import { isRustDocument, isCargoTomlDocument, sleep, isRustEditor, RustEditor } from './util'; +import { isRustDocument, isCargoTomlDocument, sleep, isRustEditor, RustEditor } from "./util"; import { startDebugSession, makeDebugConfig } from "./debug"; import { LanguageClient } from "vscode-languageclient/node"; import { LINKED_COMMANDS } from "./client"; diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index ce70dfd2f6..ea42b249ff 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, @@ -12,10 +12,15 @@ import { LazyOutputChannel, log, RustEditor, -} from './util'; -import {ServerStatusParams} from './lsp_ext'; -import { Dependency, DependencyFile, RustDependenciesProvider, DependencyId } from './dependencies_provider'; -import { execRevealDependency } from './commands'; +} from "./util"; +import {ServerStatusParams} from "./lsp_ext"; +import { + Dependency, + DependencyFile, + RustDependenciesProvider, + DependencyId, +} from "./dependencies_provider"; +import { execRevealDependency } from "./commands"; import { Dependency, DependencyFile, diff --git a/editors/code/src/dependencies_provider.ts b/editors/code/src/dependencies_provider.ts index 028a2573cc..18a96be124 100644 --- a/editors/code/src/dependencies_provider.ts +++ b/editors/code/src/dependencies_provider.ts @@ -7,7 +7,9 @@ import { FetchDependencyGraphResult } from "./lsp_ext"; -export class RustDependenciesProvider implements vscode.TreeDataProvider{ +export class RustDependenciesProvider + implements vscode.TreeDataProvider +{ dependenciesMap: { [id: string]: Dependency | DependencyFile };ctx: CtxInit; @@ -49,7 +51,9 @@ export class RustDependenciesProvider implements vscode.TreeDataProvider { + getChildren( + element?: Dependency | DependencyFile + ): vscode.ProviderResult { return new Promise((resolve, _reject) => { if (!this.workspaceRoot) { void vscode.window.showInformationMessage("No dependency in empty workspace"); @@ -61,19 +65,12 @@ export class RustDependenciesProvider implements vscode.TreeDataProvider { const crates: Crate[] = []; - const cargo = cp.spawn(pathToCargo, ['tree', '--prefix', 'none'], { - stdio: ['ignore', 'pipe', 'pipe'], - cwd: this.rootFolder + const cargo = cp.spawn(pathToCargo, ["tree", "--prefix", "none"], { + stdio: ["ignore", "pipe", "pipe"], + cwd: this.rootFolder, }); const rl = readline.createInterface({ input: cargo.stdout }); - rl.on('line', line => { + rl.on("line", (line) => { const match = line.match(TREE_LINE_PATTERN); if (match) { const name = match[1]; @@ -121,18 +121,15 @@ export class Cargo { crates.push({ name, version }); } }); - cargo.on('exit', (exitCode, _) => { - if (exitCode === 0) - resolve(crates); - else - reject(new Error(`exit code: ${exitCode}.`)); + cargo.on("exit", (exitCode, _) => { + if (exitCode === 0) resolve(crates); + else reject(new Error(`exit code: ${exitCode}.`)); }); - }); } private shouldIgnore(extraInfo: string): boolean { - return extraInfo !== undefined && (extraInfo === '*' || path.isAbsolute(extraInfo)); + return extraInfo !== undefined && (extraInfo === "*" || path.isAbsolute(extraInfo)); } private async runCargo( @@ -169,26 +166,23 @@ export class Cargo { export async function activeToolchain(): Promise { const pathToRustup = await rustupPath(); return await new Promise((resolve, reject) => { - const execution = cp.spawn(pathToRustup, ['show', 'active-toolchain'], { - stdio: ['ignore', 'pipe', 'pipe'], - cwd: os.homedir() + const execution = cp.spawn(pathToRustup, ["show", "active-toolchain"], { + stdio: ["ignore", "pipe", "pipe"], + cwd: os.homedir(), }); const rl = readline.createInterface({ input: execution.stdout }); let currToolchain: string | undefined = undefined; - rl.on('line', line => { + rl.on("line", (line) => { const match = line.match(TOOLCHAIN_PATTERN); if (match) { currToolchain = match[1]; } }); - execution.on('exit', (exitCode, _) => { - if (exitCode === 0 && currToolchain) - resolve(currToolchain); - else - reject(new Error(`exit code: ${exitCode}.`)); + execution.on("exit", (exitCode, _) => { + if (exitCode === 0 && currToolchain) resolve(currToolchain); + else reject(new Error(`exit code: ${exitCode}.`)); }); - }); }