From e26071d96e1ff56289213dbe78415f836de8a70e Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Mon, 8 Oct 2018 22:38:33 +0100 Subject: Run prettier on all files --- editors/code/src/commands/apply_source_change.ts | 24 ++++++++++++----- editors/code/src/commands/extend_selection.ts | 13 +++++++--- editors/code/src/commands/index.ts | 2 +- editors/code/src/commands/join_lines.ts | 16 +++++++++--- editors/code/src/commands/matching_brace.ts | 17 ++++++++---- editors/code/src/commands/parent_module.ts | 15 ++++++++--- editors/code/src/commands/runnables.ts | 33 ++++++++++++++++++------ editors/code/src/commands/syntaxTree.ts | 24 ++++++++++++----- 8 files changed, 106 insertions(+), 38 deletions(-) (limited to 'editors/code/src/commands') diff --git a/editors/code/src/commands/apply_source_change.ts b/editors/code/src/commands/apply_source_change.ts index 67765e5a3..cf921e3ac 100644 --- a/editors/code/src/commands/apply_source_change.ts +++ b/editors/code/src/commands/apply_source_change.ts @@ -20,8 +20,12 @@ export interface SourceChange { export async function handle(change: SourceChange) { const wsEdit = new vscode.WorkspaceEdit(); for (const sourceEdit of change.sourceFileEdits) { - const uri = Server.client.protocol2CodeConverter.asUri(sourceEdit.textDocument.uri); - const edits = Server.client.protocol2CodeConverter.asTextEdits(sourceEdit.edits); + const uri = Server.client.protocol2CodeConverter.asUri( + sourceEdit.textDocument.uri + ); + const edits = Server.client.protocol2CodeConverter.asTextEdits( + sourceEdit.edits + ); wsEdit.set(uri, edits); } let created; @@ -48,11 +52,19 @@ export async function handle(change: SourceChange) { const doc = await vscode.workspace.openTextDocument(toOpen); await vscode.window.showTextDocument(doc); } else if (toReveal) { - const uri = Server.client.protocol2CodeConverter.asUri(toReveal.textDocument.uri); - const position = Server.client.protocol2CodeConverter.asPosition(toReveal.position); + const uri = Server.client.protocol2CodeConverter.asUri( + toReveal.textDocument.uri + ); + const position = Server.client.protocol2CodeConverter.asPosition( + toReveal.position + ); const editor = vscode.window.activeTextEditor; - if (!editor || editor.document.uri.toString() !== uri.toString()) { return; } - if (!editor.selection.isEmpty) { return; } + if (!editor || editor.document.uri.toString() !== uri.toString()) { + return; + } + if (!editor.selection.isEmpty) { + return; + } editor!.selection = new vscode.Selection(position, position); } } diff --git a/editors/code/src/commands/extend_selection.ts b/editors/code/src/commands/extend_selection.ts index cdc3d10fb..0ee6bd11d 100644 --- a/editors/code/src/commands/extend_selection.ts +++ b/editors/code/src/commands/extend_selection.ts @@ -14,14 +14,19 @@ interface ExtendSelectionResult { export async function handle() { const editor = vscode.window.activeTextEditor; - if (editor == null || editor.document.languageId !== 'rust') { return; } + if (editor == null || editor.document.languageId !== 'rust') { + return; + } const request: ExtendSelectionParams = { - selections: editor.selections.map((s) => { + selections: editor.selections.map(s => { return Server.client.code2ProtocolConverter.asRange(s); }), - textDocument: { uri: editor.document.uri.toString() }, + textDocument: { uri: editor.document.uri.toString() } }; - const response = await Server.client.sendRequest('m/extendSelection', request); + const response = await Server.client.sendRequest( + 'm/extendSelection', + request + ); editor.selections = response.selections.map((range: Range) => { const r = Server.client.protocol2CodeConverter.asRange(range); return new vscode.Selection(r.start, r.end); diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index dfdcd6454..2496c7ff8 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts @@ -13,5 +13,5 @@ export { matchingBrace, parentModule, runnables, - syntaxTree, + syntaxTree }; diff --git a/editors/code/src/commands/join_lines.ts b/editors/code/src/commands/join_lines.ts index 526b698cc..27d263b8a 100644 --- a/editors/code/src/commands/join_lines.ts +++ b/editors/code/src/commands/join_lines.ts @@ -2,7 +2,10 @@ import * as vscode from 'vscode'; import { Range, TextDocumentIdentifier } from 'vscode-languageclient'; import { Server } from '../server'; -import { handle as applySourceChange, SourceChange } from './apply_source_change'; +import { + handle as applySourceChange, + SourceChange +} from './apply_source_change'; interface JoinLinesParams { textDocument: TextDocumentIdentifier; @@ -11,11 +14,16 @@ interface JoinLinesParams { export async function handle() { const editor = vscode.window.activeTextEditor; - if (editor == null || editor.document.languageId !== 'rust') { return; } + if (editor == null || editor.document.languageId !== 'rust') { + return; + } 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('m/joinLines', request); + const change = await Server.client.sendRequest( + 'm/joinLines', + request + ); await applySourceChange(change); } diff --git a/editors/code/src/commands/matching_brace.ts b/editors/code/src/commands/matching_brace.ts index a80446a8f..5e6638e82 100644 --- a/editors/code/src/commands/matching_brace.ts +++ b/editors/code/src/commands/matching_brace.ts @@ -10,16 +10,23 @@ interface FindMatchingBraceParams { export async function handle() { const editor = vscode.window.activeTextEditor; - if (editor == null || editor.document.languageId !== 'rust') { return; } + if (editor == null || editor.document.languageId !== 'rust') { + return; + } const request: FindMatchingBraceParams = { textDocument: { uri: editor.document.uri.toString() }, - offsets: editor.selections.map((s) => { + offsets: editor.selections.map(s => { return Server.client.code2ProtocolConverter.asPosition(s.active); - }), + }) }; - const response = await Server.client.sendRequest('m/findMatchingBrace', request); + const response = await Server.client.sendRequest( + 'm/findMatchingBrace', + request + ); editor.selections = editor.selections.map((sel, idx) => { - const active = Server.client.protocol2CodeConverter.asPosition(response[idx]); + const active = Server.client.protocol2CodeConverter.asPosition( + response[idx] + ); const anchor = sel.isEmpty ? active : sel.anchor; return new vscode.Selection(anchor, active); }); diff --git a/editors/code/src/commands/parent_module.ts b/editors/code/src/commands/parent_module.ts index d66fb3026..4bb92eb96 100644 --- a/editors/code/src/commands/parent_module.ts +++ b/editors/code/src/commands/parent_module.ts @@ -5,13 +5,20 @@ import { Server } from '../server'; export async function handle() { const editor = vscode.window.activeTextEditor; - if (editor == null || editor.document.languageId !== 'rust') { return; } + if (editor == null || editor.document.languageId !== 'rust') { + return; + } const request: TextDocumentIdentifier = { - uri: editor.document.uri.toString(), + uri: editor.document.uri.toString() }; - const response = await Server.client.sendRequest('m/parentModule', request); + const response = await Server.client.sendRequest( + 'm/parentModule', + request + ); const loc = response[0]; - if (loc == null) { return; } + if (loc == null) { + return; + } const uri = Server.client.protocol2CodeConverter.asUri(loc.uri); const range = Server.client.protocol2CodeConverter.asRange(loc.range); diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 40f590dce..c234bfaec 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -41,39 +41,56 @@ function createTask(spec: Runnable): vscode.Task { label: 'cargo', command: spec.bin, args: spec.args, - env: spec.env, + env: spec.env }; const execCmd = `${definition.command} ${definition.args.join(' ')}`; const execOption: vscode.ShellExecutionOptions = { cwd: '.', - env: definition.env, + env: definition.env }; const exec = new vscode.ShellExecution(`clear; ${execCmd}`, execOption); const f = vscode.workspace.workspaceFolders![0]; - const t = new vscode.Task(definition, f, definition.label, TASK_SOURCE, exec, ['$rustc']); + const t = new vscode.Task( + definition, + f, + definition.label, + TASK_SOURCE, + exec, + ['$rustc'] + ); return t; } let prevRunnable: RunnableQuickPick | undefined; export async function handle() { const editor = vscode.window.activeTextEditor; - if (editor == null || editor.document.languageId !== 'rust') { return; } + if (editor == null || editor.document.languageId !== 'rust') { + 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), + position: Server.client.code2ProtocolConverter.asPosition( + editor.selection.active + ) }; - const runnables = await Server.client.sendRequest('m/runnables', params); + const runnables = await Server.client.sendRequest( + 'm/runnables', + params + ); const items: RunnableQuickPick[] = []; if (prevRunnable) { items.push(prevRunnable); } for (const r of runnables) { - if (prevRunnable && JSON.stringify(prevRunnable.runnable) === JSON.stringify(r)) { + if ( + prevRunnable && + JSON.stringify(prevRunnable.runnable) === JSON.stringify(r) + ) { continue; } items.push(new RunnableQuickPick(r)); diff --git a/editors/code/src/commands/syntaxTree.ts b/editors/code/src/commands/syntaxTree.ts index dcb721eee..5d5cdd7a0 100644 --- a/editors/code/src/commands/syntaxTree.ts +++ b/editors/code/src/commands/syntaxTree.ts @@ -5,17 +5,25 @@ import { Server } from '../server'; export const syntaxTreeUri = vscode.Uri.parse('ra-lsp://syntaxtree'); -export class TextDocumentContentProvider implements vscode.TextDocumentContentProvider { +export class TextDocumentContentProvider + implements vscode.TextDocumentContentProvider { public eventEmitter = new vscode.EventEmitter(); public syntaxTree: string = 'Not available'; - public provideTextDocumentContent(uri: vscode.Uri): vscode.ProviderResult { + public provideTextDocumentContent( + uri: vscode.Uri + ): vscode.ProviderResult { const editor = vscode.window.activeTextEditor; - if (editor == null) { return ''; } + if (editor == null) { + return ''; + } const request: SyntaxTreeParams = { - textDocument: { uri: editor.document.uri.toString() }, + textDocument: { uri: editor.document.uri.toString() } }; - return Server.client.sendRequest('m/syntaxTree', request); + return Server.client.sendRequest( + 'm/syntaxTree', + request + ); } get onDidChange(): vscode.Event { @@ -34,5 +42,9 @@ type SyntaxTreeResult = string; // The contents of the file come from the `TextDocumentContentProvider` export async function handle() { const document = await vscode.workspace.openTextDocument(syntaxTreeUri); - return vscode.window.showTextDocument(document, vscode.ViewColumn.Two, true); + return vscode.window.showTextDocument( + document, + vscode.ViewColumn.Two, + true + ); } -- cgit v1.2.3