From 273299693b85996878907ad256ed55f072ec3f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 9 Dec 2019 20:57:55 +0200 Subject: Code: enable prettier trailing commas --- editors/code/src/commands/analyzer_status.ts | 14 ++++----- editors/code/src/commands/apply_source_change.ts | 8 +++--- editors/code/src/commands/cargo_watch.ts | 34 +++++++++++----------- editors/code/src/commands/expand_macro.ts | 10 +++---- editors/code/src/commands/index.ts | 2 +- editors/code/src/commands/inlay_hints.ts | 34 +++++++++++----------- editors/code/src/commands/join_lines.ts | 6 ++-- editors/code/src/commands/matching_brace.ts | 6 ++-- editors/code/src/commands/on_enter.ts | 8 +++--- editors/code/src/commands/parent_module.ts | 6 ++-- editors/code/src/commands/runnables.ts | 36 ++++++++++++------------ editors/code/src/commands/syntaxTree.ts | 10 +++---- editors/code/src/commands/watch_status.ts | 2 +- 13 files changed, 88 insertions(+), 88 deletions(-) (limited to 'editors/code/src/commands') diff --git a/editors/code/src/commands/analyzer_status.ts b/editors/code/src/commands/analyzer_status.ts index 63f82c92d..9e4ce0eb3 100644 --- a/editors/code/src/commands/analyzer_status.ts +++ b/editors/code/src/commands/analyzer_status.ts @@ -9,7 +9,7 @@ export class TextDocumentContentProvider public syntaxTree: string = 'Not available'; public provideTextDocumentContent( - uri: vscode.Uri + uri: vscode.Uri, ): vscode.ProviderResult { const editor = vscode.window.activeTextEditor; if (editor == null) { @@ -17,7 +17,7 @@ export class TextDocumentContentProvider } return Server.client.sendRequest( 'rust-analyzer/analyzerStatus', - null + null, ); } @@ -35,8 +35,8 @@ export function makeCommand(context: vscode.ExtensionContext) { context.subscriptions.push( vscode.workspace.registerTextDocumentContentProvider( 'rust-analyzer-status', - textDocumentContentProvider - ) + textDocumentContentProvider, + ), ); context.subscriptions.push({ @@ -44,21 +44,21 @@ export function makeCommand(context: vscode.ExtensionContext) { if (poller != null) { clearInterval(poller); } - } + }, }); return async function handle() { if (poller == null) { poller = setInterval( () => textDocumentContentProvider.eventEmitter.fire(statusUri), - 1000 + 1000, ); } const document = await vscode.workspace.openTextDocument(statusUri); return vscode.window.showTextDocument( document, vscode.ViewColumn.Two, - true + true, ); }; } diff --git a/editors/code/src/commands/apply_source_change.ts b/editors/code/src/commands/apply_source_change.ts index dcd074b8b..8167398b1 100644 --- a/editors/code/src/commands/apply_source_change.ts +++ b/editors/code/src/commands/apply_source_change.ts @@ -11,7 +11,7 @@ export interface SourceChange { export async function handle(change: SourceChange) { const wsEdit = Server.client.protocol2CodeConverter.asWorkspaceEdit( - change.workspaceEdit + change.workspaceEdit, ); let created; let moved; @@ -33,10 +33,10 @@ export async function handle(change: SourceChange) { await vscode.window.showTextDocument(doc); } else if (toReveal) { const uri = Server.client.protocol2CodeConverter.asUri( - toReveal.textDocument.uri + toReveal.textDocument.uri, ); const position = Server.client.protocol2CodeConverter.asPosition( - toReveal.position + toReveal.position, ); const editor = vscode.window.activeTextEditor; if (!editor || editor.document.uri.toString() !== uri.toString()) { @@ -48,7 +48,7 @@ export async function handle(change: SourceChange) { editor.selection = new vscode.Selection(position, position); editor.revealRange( new vscode.Range(position, position), - vscode.TextEditorRevealType.Default + vscode.TextEditorRevealType.Default, ); } } diff --git a/editors/code/src/commands/cargo_watch.ts b/editors/code/src/commands/cargo_watch.ts index 59d4ba97a..512362eb1 100644 --- a/editors/code/src/commands/cargo_watch.ts +++ b/editors/code/src/commands/cargo_watch.ts @@ -9,13 +9,13 @@ import { StatusDisplay } from './watch_status'; import { mapRustDiagnosticToVsCode, - RustDiagnostic + RustDiagnostic, } from '../utils/diagnostics/rust'; import SuggestedFixCollection from '../utils/diagnostics/SuggestedFixCollection'; import { areDiagnosticsEqual } from '../utils/diagnostics/vscode'; export async function registerCargoWatchProvider( - subscriptions: vscode.Disposable[] + subscriptions: vscode.Disposable[], ): Promise { let cargoExists = false; @@ -30,7 +30,7 @@ export async function registerCargoWatchProvider( if (!cargoExists) { vscode.window.showErrorMessage( - `Couldn\'t find \'Cargo.toml\' at ${cargoTomlPath}` + `Couldn\'t find \'Cargo.toml\' at ${cargoTomlPath}`, ); return; } @@ -52,13 +52,13 @@ export class CargoWatchProvider implements vscode.Disposable { constructor() { this.diagnosticCollection = vscode.languages.createDiagnosticCollection( - 'rustc' + 'rustc', ); this.statusDisplay = new StatusDisplay( - Server.config.cargoWatchOptions.command + Server.config.cargoWatchOptions.command, ); this.outputChannel = vscode.window.createOutputChannel( - 'Cargo Watch Trace' + 'Cargo Watch Trace', ); // Track `rustc`'s suggested fixes so we can convert them to code actions @@ -68,15 +68,15 @@ export class CargoWatchProvider implements vscode.Disposable { this.suggestedFixCollection, { providedCodeActionKinds: - SuggestedFixCollection.PROVIDED_CODE_ACTION_KINDS - } + SuggestedFixCollection.PROVIDED_CODE_ACTION_KINDS, + }, ); } public start() { if (this.cargoProcess) { vscode.window.showInformationMessage( - 'Cargo Watch is already running' + 'Cargo Watch is already running', ); return; } @@ -95,7 +95,7 @@ export class CargoWatchProvider implements vscode.Disposable { const ignoreFlags = Server.config.cargoWatchOptions.ignore.reduce( (flags, pattern) => [...flags, '--ignore', pattern], - [] as string[] + [] as string[], ); // Start the cargo watch with json message @@ -105,8 +105,8 @@ export class CargoWatchProvider implements vscode.Disposable { { stdio: ['ignore', 'pipe', 'pipe'], cwd: vscode.workspace.rootPath, - windowsVerbatimArguments: true - } + windowsVerbatimArguments: true, + }, ); const stdoutData = new LineBuffer(); @@ -130,7 +130,7 @@ export class CargoWatchProvider implements vscode.Disposable { this.cargoProcess.on('error', (err: Error) => { this.logError( - 'Error on cargo-watch process : {\n' + err.message + '}\n' + 'Error on cargo-watch process : {\n' + err.message + '}\n', ); }); @@ -223,12 +223,12 @@ export class CargoWatchProvider implements vscode.Disposable { const fileUri = location.uri; const diagnostics: vscode.Diagnostic[] = [ - ...(this.diagnosticCollection!.get(fileUri) || []) + ...(this.diagnosticCollection!.get(fileUri) || []), ]; // If we're building multiple targets it's possible we've already seen this diagnostic const isDuplicate = diagnostics.some(d => - areDiagnosticsEqual(d, diagnostic) + areDiagnosticsEqual(d, diagnostic), ); if (isDuplicate) { return; @@ -241,7 +241,7 @@ export class CargoWatchProvider implements vscode.Disposable { for (const suggestedFix of suggestedFixes) { this.suggestedFixCollection.addSuggestedFixForDiagnostic( suggestedFix, - diagnostic + diagnostic, ); } @@ -249,7 +249,7 @@ export class CargoWatchProvider implements vscode.Disposable { vscode.commands.executeCommand( 'vscode.executeCodeActionProvider', fileUri, - diagnostic.range + diagnostic.range, ); } } diff --git a/editors/code/src/commands/expand_macro.ts b/editors/code/src/commands/expand_macro.ts index 34e0c8fb3..842898020 100644 --- a/editors/code/src/commands/expand_macro.ts +++ b/editors/code/src/commands/expand_macro.ts @@ -3,7 +3,7 @@ import { Position, TextDocumentIdentifier } from 'vscode-languageclient'; import { Server } from '../server'; export const expandMacroUri = vscode.Uri.parse( - 'rust-analyzer://expandMacro/[EXPANSION].rs' + 'rust-analyzer://expandMacro/[EXPANSION].rs', ); export class ExpandMacroContentProvider @@ -11,7 +11,7 @@ export class ExpandMacroContentProvider public eventEmitter = new vscode.EventEmitter(); public provideTextDocumentContent( - uri: vscode.Uri + uri: vscode.Uri, ): vscode.ProviderResult { async function handle() { const editor = vscode.window.activeTextEditor; @@ -22,11 +22,11 @@ export class ExpandMacroContentProvider const position = editor.selection.active; const request: MacroExpandParams = { textDocument: { uri: editor.document.uri.toString() }, - position + position, }; const expanded = await Server.client.sendRequest( 'rust-analyzer/expandMacro', - request + request, ); if (expanded == null) { @@ -58,7 +58,7 @@ export function createHandle(provider: ExpandMacroContentProvider) { return vscode.window.showTextDocument( document, vscode.ViewColumn.Two, - true + true, ); }; } diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index 2ade6d331..13a696758 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts @@ -19,5 +19,5 @@ export { runnables, syntaxTree, onEnter, - inlayHints + inlayHints, }; diff --git a/editors/code/src/commands/inlay_hints.ts b/editors/code/src/commands/inlay_hints.ts index 0dbdd94fb..ac7dcce60 100644 --- a/editors/code/src/commands/inlay_hints.ts +++ b/editors/code/src/commands/inlay_hints.ts @@ -15,8 +15,8 @@ interface InlayHint { const typeHintDecorationType = vscode.window.createTextEditorDecorationType({ after: { - color: new vscode.ThemeColor('ralsp.inlayHint') - } + color: new vscode.ThemeColor('ralsp.inlayHint'), + }, }); export class HintsUpdater { @@ -26,13 +26,13 @@ export class HintsUpdater { if (this.displayHints !== displayHints) { this.displayHints = displayHints; return this.refreshVisibleEditorsHints( - displayHints ? undefined : [] + displayHints ? undefined : [], ); } } public async refreshHintsForVisibleEditors( - cause?: TextDocumentChangeEvent + cause?: TextDocumentChangeEvent, ): Promise { if (!this.displayHints) { return; @@ -48,21 +48,21 @@ export class HintsUpdater { } private async refreshVisibleEditorsHints( - newDecorations?: vscode.DecorationOptions[] + newDecorations?: vscode.DecorationOptions[], ) { const promises: Array> = []; for (const rustEditor of vscode.window.visibleTextEditors.filter( - editor => this.isRustDocument(editor.document) + editor => this.isRustDocument(editor.document), )) { if (newDecorations !== undefined) { promises.push( Promise.resolve( rustEditor.setDecorations( typeHintDecorationType, - newDecorations - ) - ) + newDecorations, + ), + ), ); } else { promises.push(this.updateDecorationsFromServer(rustEditor)); @@ -79,7 +79,7 @@ export class HintsUpdater { } private async updateDecorationsFromServer( - editor: TextEditor + editor: TextEditor, ): Promise { const newHints = await this.queryHints(editor.document.uri.toString()); if (newHints !== null) { @@ -87,20 +87,20 @@ export class HintsUpdater { range: hint.range, renderOptions: { after: { - contentText: `: ${hint.label}` - } - } + contentText: `: ${hint.label}`, + }, + }, })); return editor.setDecorations( typeHintDecorationType, - newDecorations + newDecorations, ); } } private async queryHints(documentUri: string): Promise { const request: InlayHintsParams = { - textDocument: { uri: documentUri } + textDocument: { uri: documentUri }, }; const client = Server.client; return client @@ -108,8 +108,8 @@ export class HintsUpdater { .then(() => client.sendRequest( 'rust-analyzer/inlayHints', - request - ) + request, + ), ); } } diff --git a/editors/code/src/commands/join_lines.ts b/editors/code/src/commands/join_lines.ts index 0d4b12f4d..134ddc801 100644 --- a/editors/code/src/commands/join_lines.ts +++ b/editors/code/src/commands/join_lines.ts @@ -4,7 +4,7 @@ import { Range, TextDocumentIdentifier } from 'vscode-languageclient'; import { Server } from '../server'; import { handle as applySourceChange, - SourceChange + SourceChange, } from './apply_source_change'; interface JoinLinesParams { @@ -19,11 +19,11 @@ export async function handle() { } const request: JoinLinesParams = { range: Server.client.code2ProtocolConverter.asRange(editor.selection), - textDocument: { uri: editor.document.uri.toString() } + textDocument: { uri: editor.document.uri.toString() }, }; const change = await Server.client.sendRequest( 'rust-analyzer/joinLines', - request + request, ); await applySourceChange(change); } diff --git a/editors/code/src/commands/matching_brace.ts b/editors/code/src/commands/matching_brace.ts index d86faf405..364208cc7 100644 --- a/editors/code/src/commands/matching_brace.ts +++ b/editors/code/src/commands/matching_brace.ts @@ -17,15 +17,15 @@ export async function handle() { textDocument: { uri: editor.document.uri.toString() }, offsets: editor.selections.map(s => { return Server.client.code2ProtocolConverter.asPosition(s.active); - }) + }), }; const response = await Server.client.sendRequest( 'rust-analyzer/findMatchingBrace', - request + request, ); editor.selections = editor.selections.map((sel, idx) => { const active = Server.client.protocol2CodeConverter.asPosition( - response[idx] + response[idx], ); const anchor = sel.isEmpty ? active : sel.anchor; return new vscode.Selection(anchor, active); diff --git a/editors/code/src/commands/on_enter.ts b/editors/code/src/commands/on_enter.ts index 16dcb70c8..772c64b3c 100644 --- a/editors/code/src/commands/on_enter.ts +++ b/editors/code/src/commands/on_enter.ts @@ -3,7 +3,7 @@ import * as lc from 'vscode-languageclient'; import { Server } from '../server'; import { handle as applySourceChange, - SourceChange + SourceChange, } from './apply_source_change'; export async function handle(event: { text: string }): Promise { @@ -18,12 +18,12 @@ export async function handle(event: { text: string }): Promise { const request: lc.TextDocumentPositionParams = { textDocument: { uri: editor.document.uri.toString() }, position: Server.client.code2ProtocolConverter.asPosition( - editor.selection.active - ) + editor.selection.active, + ), }; const change = await Server.client.sendRequest( 'rust-analyzer/onEnter', - request + request, ); if (!change) { return false; diff --git a/editors/code/src/commands/parent_module.ts b/editors/code/src/commands/parent_module.ts index 9d30b7b59..ad49e1bdb 100644 --- a/editors/code/src/commands/parent_module.ts +++ b/editors/code/src/commands/parent_module.ts @@ -11,12 +11,12 @@ export async function handle() { const request: lc.TextDocumentPositionParams = { textDocument: { uri: editor.document.uri.toString() }, position: Server.client.code2ProtocolConverter.asPosition( - editor.selection.active - ) + editor.selection.active, + ), }; const response = await Server.client.sendRequest( 'rust-analyzer/parentModule', - request + request, ); const loc = response[0]; if (loc == null) { diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index ac59bf60d..9b1c6643d 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -46,17 +46,17 @@ function createTask(spec: Runnable): vscode.Task { label: spec.label, command: spec.bin, args: spec.args, - env: spec.env + env: spec.env, }; const execOption: vscode.ShellExecutionOptions = { cwd: spec.cwd || '.', - env: definition.env + env: definition.env, }; const exec = new vscode.ShellExecution( definition.command, definition.args, - execOption + execOption, ); const f = vscode.workspace.workspaceFolders![0]; @@ -66,7 +66,7 @@ function createTask(spec: Runnable): vscode.Task { definition.label, TASK_SOURCE, exec, - ['$rustc'] + ['$rustc'], ); t.presentationOptions.clear = true; return t; @@ -79,17 +79,17 @@ export async function handle() { return; } const textDocument: lc.TextDocumentIdentifier = { - uri: editor.document.uri.toString() + uri: editor.document.uri.toString(), }; const params: RunnablesParams = { textDocument, position: Server.client.code2ProtocolConverter.asPosition( - editor.selection.active - ) + editor.selection.active, + ), }; const runnables = await Server.client.sendRequest( 'rust-analyzer/runnables', - params + params, ); const items: RunnableQuickPick[] = []; if (prevRunnable) { @@ -124,7 +124,7 @@ export async function handleSingle(runnable: Runnable) { task.presentationOptions = { reveal: vscode.TaskRevealKind.Always, panel: vscode.TaskPanelKind.Dedicated, - clear: true + clear: true, }; return vscode.tasks.executeTask(task); @@ -136,7 +136,7 @@ export async function handleSingle(runnable: Runnable) { * that, when accepted, allow us to `cargo install cargo-watch` and then run it. */ export async function interactivelyStartCargoWatch( - context: vscode.ExtensionContext + context: vscode.ExtensionContext, ): Promise { if (Server.config.cargoWatchOptions.enableOnStartup === 'disabled') { return; @@ -146,7 +146,7 @@ export async function interactivelyStartCargoWatch( const watch = await vscode.window.showInformationMessage( 'Start watching changes with cargo? (Executes `cargo watch`, provides inline diagnostics)', 'yes', - 'no' + 'no', ); if (watch !== 'yes') { return; @@ -157,12 +157,12 @@ export async function interactivelyStartCargoWatch( } export async function startCargoWatch( - context: vscode.ExtensionContext + context: vscode.ExtensionContext, ): Promise { const execPromise = util.promisify(child_process.exec); const { stderr, code = 0 } = await execPromise( - 'cargo watch --version' + 'cargo watch --version', ).catch(e => e); if (stderr.includes('no such subcommand: `watch`')) { @@ -171,7 +171,7 @@ export async function startCargoWatch( const install = await vscode.window.showInformationMessage( msg, 'yes', - 'no' + 'no', ); if (install !== 'yes') { return; @@ -192,20 +192,20 @@ export async function startCargoWatch( label, bin: 'cargo', args: ['install', 'cargo-watch'], - env: {} - }) + env: {}, + }), ); await taskFinished; const output = await execPromise('cargo watch --version').catch(e => e); if (output.stderr !== '') { vscode.window.showErrorMessage( - `Couldn't install \`cargo-\`watch: ${output.stderr}` + `Couldn't install \`cargo-\`watch: ${output.stderr}`, ); return; } } else if (code !== 0) { vscode.window.showErrorMessage( - `\`cargo watch\` failed with ${code}: ${stderr}` + `\`cargo watch\` failed with ${code}: ${stderr}`, ); return; } diff --git a/editors/code/src/commands/syntaxTree.ts b/editors/code/src/commands/syntaxTree.ts index 2f50fe14b..89a80550c 100644 --- a/editors/code/src/commands/syntaxTree.ts +++ b/editors/code/src/commands/syntaxTree.ts @@ -11,7 +11,7 @@ export class SyntaxTreeContentProvider public syntaxTree: string = 'Not available'; public provideTextDocumentContent( - uri: vscode.Uri + uri: vscode.Uri, ): vscode.ProviderResult { const editor = vscode.window.activeTextEditor; if (editor == null) { @@ -25,17 +25,17 @@ export class SyntaxTreeContentProvider range = editor.selection.isEmpty ? undefined : Server.client.code2ProtocolConverter.asRange( - editor.selection + editor.selection, ); } const request: SyntaxTreeParams = { textDocument: { uri: editor.document.uri.toString() }, - range + range, }; return Server.client.sendRequest( 'rust-analyzer/syntaxTree', - request + request, ); } @@ -70,7 +70,7 @@ export function createHandle(provider: SyntaxTreeContentProvider) { return vscode.window.showTextDocument( document, vscode.ViewColumn.Two, - true + true, ); }; } diff --git a/editors/code/src/commands/watch_status.ts b/editors/code/src/commands/watch_status.ts index 6c1f9041b..8d64394c7 100644 --- a/editors/code/src/commands/watch_status.ts +++ b/editors/code/src/commands/watch_status.ts @@ -13,7 +13,7 @@ export class StatusDisplay implements vscode.Disposable { constructor(command: string) { this.statusBarItem = vscode.window.createStatusBarItem( vscode.StatusBarAlignment.Left, - 10 + 10, ); this.command = command; this.statusBarItem.hide(); -- cgit v1.2.3