diff options
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r-- | editors/code/src/commands/analyzer_status.ts | 14 | ||||
-rw-r--r-- | editors/code/src/commands/apply_source_change.ts | 8 | ||||
-rw-r--r-- | editors/code/src/commands/cargo_watch.ts | 34 | ||||
-rw-r--r-- | editors/code/src/commands/expand_macro.ts | 10 | ||||
-rw-r--r-- | editors/code/src/commands/index.ts | 2 | ||||
-rw-r--r-- | editors/code/src/commands/inlay_hints.ts | 34 | ||||
-rw-r--r-- | editors/code/src/commands/join_lines.ts | 6 | ||||
-rw-r--r-- | editors/code/src/commands/matching_brace.ts | 6 | ||||
-rw-r--r-- | editors/code/src/commands/on_enter.ts | 8 | ||||
-rw-r--r-- | editors/code/src/commands/parent_module.ts | 6 | ||||
-rw-r--r-- | editors/code/src/commands/runnables.ts | 36 | ||||
-rw-r--r-- | editors/code/src/commands/syntaxTree.ts | 10 | ||||
-rw-r--r-- | editors/code/src/commands/watch_status.ts | 2 |
13 files changed, 88 insertions, 88 deletions
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 | |||
9 | public syntaxTree: string = 'Not available'; | 9 | public syntaxTree: string = 'Not available'; |
10 | 10 | ||
11 | public provideTextDocumentContent( | 11 | public provideTextDocumentContent( |
12 | uri: vscode.Uri | 12 | uri: vscode.Uri, |
13 | ): vscode.ProviderResult<string> { | 13 | ): vscode.ProviderResult<string> { |
14 | const editor = vscode.window.activeTextEditor; | 14 | const editor = vscode.window.activeTextEditor; |
15 | if (editor == null) { | 15 | if (editor == null) { |
@@ -17,7 +17,7 @@ export class TextDocumentContentProvider | |||
17 | } | 17 | } |
18 | return Server.client.sendRequest<string>( | 18 | return Server.client.sendRequest<string>( |
19 | 'rust-analyzer/analyzerStatus', | 19 | 'rust-analyzer/analyzerStatus', |
20 | null | 20 | null, |
21 | ); | 21 | ); |
22 | } | 22 | } |
23 | 23 | ||
@@ -35,8 +35,8 @@ export function makeCommand(context: vscode.ExtensionContext) { | |||
35 | context.subscriptions.push( | 35 | context.subscriptions.push( |
36 | vscode.workspace.registerTextDocumentContentProvider( | 36 | vscode.workspace.registerTextDocumentContentProvider( |
37 | 'rust-analyzer-status', | 37 | 'rust-analyzer-status', |
38 | textDocumentContentProvider | 38 | textDocumentContentProvider, |
39 | ) | 39 | ), |
40 | ); | 40 | ); |
41 | 41 | ||
42 | context.subscriptions.push({ | 42 | context.subscriptions.push({ |
@@ -44,21 +44,21 @@ export function makeCommand(context: vscode.ExtensionContext) { | |||
44 | if (poller != null) { | 44 | if (poller != null) { |
45 | clearInterval(poller); | 45 | clearInterval(poller); |
46 | } | 46 | } |
47 | } | 47 | }, |
48 | }); | 48 | }); |
49 | 49 | ||
50 | return async function handle() { | 50 | return async function handle() { |
51 | if (poller == null) { | 51 | if (poller == null) { |
52 | poller = setInterval( | 52 | poller = setInterval( |
53 | () => textDocumentContentProvider.eventEmitter.fire(statusUri), | 53 | () => textDocumentContentProvider.eventEmitter.fire(statusUri), |
54 | 1000 | 54 | 1000, |
55 | ); | 55 | ); |
56 | } | 56 | } |
57 | const document = await vscode.workspace.openTextDocument(statusUri); | 57 | const document = await vscode.workspace.openTextDocument(statusUri); |
58 | return vscode.window.showTextDocument( | 58 | return vscode.window.showTextDocument( |
59 | document, | 59 | document, |
60 | vscode.ViewColumn.Two, | 60 | vscode.ViewColumn.Two, |
61 | true | 61 | true, |
62 | ); | 62 | ); |
63 | }; | 63 | }; |
64 | } | 64 | } |
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 { | |||
11 | 11 | ||
12 | export async function handle(change: SourceChange) { | 12 | export async function handle(change: SourceChange) { |
13 | const wsEdit = Server.client.protocol2CodeConverter.asWorkspaceEdit( | 13 | const wsEdit = Server.client.protocol2CodeConverter.asWorkspaceEdit( |
14 | change.workspaceEdit | 14 | change.workspaceEdit, |
15 | ); | 15 | ); |
16 | let created; | 16 | let created; |
17 | let moved; | 17 | let moved; |
@@ -33,10 +33,10 @@ export async function handle(change: SourceChange) { | |||
33 | await vscode.window.showTextDocument(doc); | 33 | await vscode.window.showTextDocument(doc); |
34 | } else if (toReveal) { | 34 | } else if (toReveal) { |
35 | const uri = Server.client.protocol2CodeConverter.asUri( | 35 | const uri = Server.client.protocol2CodeConverter.asUri( |
36 | toReveal.textDocument.uri | 36 | toReveal.textDocument.uri, |
37 | ); | 37 | ); |
38 | const position = Server.client.protocol2CodeConverter.asPosition( | 38 | const position = Server.client.protocol2CodeConverter.asPosition( |
39 | toReveal.position | 39 | toReveal.position, |
40 | ); | 40 | ); |
41 | const editor = vscode.window.activeTextEditor; | 41 | const editor = vscode.window.activeTextEditor; |
42 | if (!editor || editor.document.uri.toString() !== uri.toString()) { | 42 | if (!editor || editor.document.uri.toString() !== uri.toString()) { |
@@ -48,7 +48,7 @@ export async function handle(change: SourceChange) { | |||
48 | editor.selection = new vscode.Selection(position, position); | 48 | editor.selection = new vscode.Selection(position, position); |
49 | editor.revealRange( | 49 | editor.revealRange( |
50 | new vscode.Range(position, position), | 50 | new vscode.Range(position, position), |
51 | vscode.TextEditorRevealType.Default | 51 | vscode.TextEditorRevealType.Default, |
52 | ); | 52 | ); |
53 | } | 53 | } |
54 | } | 54 | } |
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'; | |||
9 | 9 | ||
10 | import { | 10 | import { |
11 | mapRustDiagnosticToVsCode, | 11 | mapRustDiagnosticToVsCode, |
12 | RustDiagnostic | 12 | RustDiagnostic, |
13 | } from '../utils/diagnostics/rust'; | 13 | } from '../utils/diagnostics/rust'; |
14 | import SuggestedFixCollection from '../utils/diagnostics/SuggestedFixCollection'; | 14 | import SuggestedFixCollection from '../utils/diagnostics/SuggestedFixCollection'; |
15 | import { areDiagnosticsEqual } from '../utils/diagnostics/vscode'; | 15 | import { areDiagnosticsEqual } from '../utils/diagnostics/vscode'; |
16 | 16 | ||
17 | export async function registerCargoWatchProvider( | 17 | export async function registerCargoWatchProvider( |
18 | subscriptions: vscode.Disposable[] | 18 | subscriptions: vscode.Disposable[], |
19 | ): Promise<CargoWatchProvider | undefined> { | 19 | ): Promise<CargoWatchProvider | undefined> { |
20 | let cargoExists = false; | 20 | let cargoExists = false; |
21 | 21 | ||
@@ -30,7 +30,7 @@ export async function registerCargoWatchProvider( | |||
30 | 30 | ||
31 | if (!cargoExists) { | 31 | if (!cargoExists) { |
32 | vscode.window.showErrorMessage( | 32 | vscode.window.showErrorMessage( |
33 | `Couldn\'t find \'Cargo.toml\' at ${cargoTomlPath}` | 33 | `Couldn\'t find \'Cargo.toml\' at ${cargoTomlPath}`, |
34 | ); | 34 | ); |
35 | return; | 35 | return; |
36 | } | 36 | } |
@@ -52,13 +52,13 @@ export class CargoWatchProvider implements vscode.Disposable { | |||
52 | 52 | ||
53 | constructor() { | 53 | constructor() { |
54 | this.diagnosticCollection = vscode.languages.createDiagnosticCollection( | 54 | this.diagnosticCollection = vscode.languages.createDiagnosticCollection( |
55 | 'rustc' | 55 | 'rustc', |
56 | ); | 56 | ); |
57 | this.statusDisplay = new StatusDisplay( | 57 | this.statusDisplay = new StatusDisplay( |
58 | Server.config.cargoWatchOptions.command | 58 | Server.config.cargoWatchOptions.command, |
59 | ); | 59 | ); |
60 | this.outputChannel = vscode.window.createOutputChannel( | 60 | this.outputChannel = vscode.window.createOutputChannel( |
61 | 'Cargo Watch Trace' | 61 | 'Cargo Watch Trace', |
62 | ); | 62 | ); |
63 | 63 | ||
64 | // Track `rustc`'s suggested fixes so we can convert them to code actions | 64 | // Track `rustc`'s suggested fixes so we can convert them to code actions |
@@ -68,15 +68,15 @@ export class CargoWatchProvider implements vscode.Disposable { | |||
68 | this.suggestedFixCollection, | 68 | this.suggestedFixCollection, |
69 | { | 69 | { |
70 | providedCodeActionKinds: | 70 | providedCodeActionKinds: |
71 | SuggestedFixCollection.PROVIDED_CODE_ACTION_KINDS | 71 | SuggestedFixCollection.PROVIDED_CODE_ACTION_KINDS, |
72 | } | 72 | }, |
73 | ); | 73 | ); |
74 | } | 74 | } |
75 | 75 | ||
76 | public start() { | 76 | public start() { |
77 | if (this.cargoProcess) { | 77 | if (this.cargoProcess) { |
78 | vscode.window.showInformationMessage( | 78 | vscode.window.showInformationMessage( |
79 | 'Cargo Watch is already running' | 79 | 'Cargo Watch is already running', |
80 | ); | 80 | ); |
81 | return; | 81 | return; |
82 | } | 82 | } |
@@ -95,7 +95,7 @@ export class CargoWatchProvider implements vscode.Disposable { | |||
95 | 95 | ||
96 | const ignoreFlags = Server.config.cargoWatchOptions.ignore.reduce( | 96 | const ignoreFlags = Server.config.cargoWatchOptions.ignore.reduce( |
97 | (flags, pattern) => [...flags, '--ignore', pattern], | 97 | (flags, pattern) => [...flags, '--ignore', pattern], |
98 | [] as string[] | 98 | [] as string[], |
99 | ); | 99 | ); |
100 | 100 | ||
101 | // Start the cargo watch with json message | 101 | // Start the cargo watch with json message |
@@ -105,8 +105,8 @@ export class CargoWatchProvider implements vscode.Disposable { | |||
105 | { | 105 | { |
106 | stdio: ['ignore', 'pipe', 'pipe'], | 106 | stdio: ['ignore', 'pipe', 'pipe'], |
107 | cwd: vscode.workspace.rootPath, | 107 | cwd: vscode.workspace.rootPath, |
108 | windowsVerbatimArguments: true | 108 | windowsVerbatimArguments: true, |
109 | } | 109 | }, |
110 | ); | 110 | ); |
111 | 111 | ||
112 | const stdoutData = new LineBuffer(); | 112 | const stdoutData = new LineBuffer(); |
@@ -130,7 +130,7 @@ export class CargoWatchProvider implements vscode.Disposable { | |||
130 | 130 | ||
131 | this.cargoProcess.on('error', (err: Error) => { | 131 | this.cargoProcess.on('error', (err: Error) => { |
132 | this.logError( | 132 | this.logError( |
133 | 'Error on cargo-watch process : {\n' + err.message + '}\n' | 133 | 'Error on cargo-watch process : {\n' + err.message + '}\n', |
134 | ); | 134 | ); |
135 | }); | 135 | }); |
136 | 136 | ||
@@ -223,12 +223,12 @@ export class CargoWatchProvider implements vscode.Disposable { | |||
223 | const fileUri = location.uri; | 223 | const fileUri = location.uri; |
224 | 224 | ||
225 | const diagnostics: vscode.Diagnostic[] = [ | 225 | const diagnostics: vscode.Diagnostic[] = [ |
226 | ...(this.diagnosticCollection!.get(fileUri) || []) | 226 | ...(this.diagnosticCollection!.get(fileUri) || []), |
227 | ]; | 227 | ]; |
228 | 228 | ||
229 | // If we're building multiple targets it's possible we've already seen this diagnostic | 229 | // If we're building multiple targets it's possible we've already seen this diagnostic |
230 | const isDuplicate = diagnostics.some(d => | 230 | const isDuplicate = diagnostics.some(d => |
231 | areDiagnosticsEqual(d, diagnostic) | 231 | areDiagnosticsEqual(d, diagnostic), |
232 | ); | 232 | ); |
233 | if (isDuplicate) { | 233 | if (isDuplicate) { |
234 | return; | 234 | return; |
@@ -241,7 +241,7 @@ export class CargoWatchProvider implements vscode.Disposable { | |||
241 | for (const suggestedFix of suggestedFixes) { | 241 | for (const suggestedFix of suggestedFixes) { |
242 | this.suggestedFixCollection.addSuggestedFixForDiagnostic( | 242 | this.suggestedFixCollection.addSuggestedFixForDiagnostic( |
243 | suggestedFix, | 243 | suggestedFix, |
244 | diagnostic | 244 | diagnostic, |
245 | ); | 245 | ); |
246 | } | 246 | } |
247 | 247 | ||
@@ -249,7 +249,7 @@ export class CargoWatchProvider implements vscode.Disposable { | |||
249 | vscode.commands.executeCommand( | 249 | vscode.commands.executeCommand( |
250 | 'vscode.executeCodeActionProvider', | 250 | 'vscode.executeCodeActionProvider', |
251 | fileUri, | 251 | fileUri, |
252 | diagnostic.range | 252 | diagnostic.range, |
253 | ); | 253 | ); |
254 | } | 254 | } |
255 | } | 255 | } |
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'; | |||
3 | import { Server } from '../server'; | 3 | import { Server } from '../server'; |
4 | 4 | ||
5 | export const expandMacroUri = vscode.Uri.parse( | 5 | export const expandMacroUri = vscode.Uri.parse( |
6 | 'rust-analyzer://expandMacro/[EXPANSION].rs' | 6 | 'rust-analyzer://expandMacro/[EXPANSION].rs', |
7 | ); | 7 | ); |
8 | 8 | ||
9 | export class ExpandMacroContentProvider | 9 | export class ExpandMacroContentProvider |
@@ -11,7 +11,7 @@ export class ExpandMacroContentProvider | |||
11 | public eventEmitter = new vscode.EventEmitter<vscode.Uri>(); | 11 | public eventEmitter = new vscode.EventEmitter<vscode.Uri>(); |
12 | 12 | ||
13 | public provideTextDocumentContent( | 13 | public provideTextDocumentContent( |
14 | uri: vscode.Uri | 14 | uri: vscode.Uri, |
15 | ): vscode.ProviderResult<string> { | 15 | ): vscode.ProviderResult<string> { |
16 | async function handle() { | 16 | async function handle() { |
17 | const editor = vscode.window.activeTextEditor; | 17 | const editor = vscode.window.activeTextEditor; |
@@ -22,11 +22,11 @@ export class ExpandMacroContentProvider | |||
22 | const position = editor.selection.active; | 22 | const position = editor.selection.active; |
23 | const request: MacroExpandParams = { | 23 | const request: MacroExpandParams = { |
24 | textDocument: { uri: editor.document.uri.toString() }, | 24 | textDocument: { uri: editor.document.uri.toString() }, |
25 | position | 25 | position, |
26 | }; | 26 | }; |
27 | const expanded = await Server.client.sendRequest<ExpandedMacro>( | 27 | const expanded = await Server.client.sendRequest<ExpandedMacro>( |
28 | 'rust-analyzer/expandMacro', | 28 | 'rust-analyzer/expandMacro', |
29 | request | 29 | request, |
30 | ); | 30 | ); |
31 | 31 | ||
32 | if (expanded == null) { | 32 | if (expanded == null) { |
@@ -58,7 +58,7 @@ export function createHandle(provider: ExpandMacroContentProvider) { | |||
58 | return vscode.window.showTextDocument( | 58 | return vscode.window.showTextDocument( |
59 | document, | 59 | document, |
60 | vscode.ViewColumn.Two, | 60 | vscode.ViewColumn.Two, |
61 | true | 61 | true, |
62 | ); | 62 | ); |
63 | }; | 63 | }; |
64 | } | 64 | } |
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 { | |||
19 | runnables, | 19 | runnables, |
20 | syntaxTree, | 20 | syntaxTree, |
21 | onEnter, | 21 | onEnter, |
22 | inlayHints | 22 | inlayHints, |
23 | }; | 23 | }; |
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 { | |||
15 | 15 | ||
16 | const typeHintDecorationType = vscode.window.createTextEditorDecorationType({ | 16 | const typeHintDecorationType = vscode.window.createTextEditorDecorationType({ |
17 | after: { | 17 | after: { |
18 | color: new vscode.ThemeColor('ralsp.inlayHint') | 18 | color: new vscode.ThemeColor('ralsp.inlayHint'), |
19 | } | 19 | }, |
20 | }); | 20 | }); |
21 | 21 | ||
22 | export class HintsUpdater { | 22 | export class HintsUpdater { |
@@ -26,13 +26,13 @@ export class HintsUpdater { | |||
26 | if (this.displayHints !== displayHints) { | 26 | if (this.displayHints !== displayHints) { |
27 | this.displayHints = displayHints; | 27 | this.displayHints = displayHints; |
28 | return this.refreshVisibleEditorsHints( | 28 | return this.refreshVisibleEditorsHints( |
29 | displayHints ? undefined : [] | 29 | displayHints ? undefined : [], |
30 | ); | 30 | ); |
31 | } | 31 | } |
32 | } | 32 | } |
33 | 33 | ||
34 | public async refreshHintsForVisibleEditors( | 34 | public async refreshHintsForVisibleEditors( |
35 | cause?: TextDocumentChangeEvent | 35 | cause?: TextDocumentChangeEvent, |
36 | ): Promise<void> { | 36 | ): Promise<void> { |
37 | if (!this.displayHints) { | 37 | if (!this.displayHints) { |
38 | return; | 38 | return; |
@@ -48,21 +48,21 @@ export class HintsUpdater { | |||
48 | } | 48 | } |
49 | 49 | ||
50 | private async refreshVisibleEditorsHints( | 50 | private async refreshVisibleEditorsHints( |
51 | newDecorations?: vscode.DecorationOptions[] | 51 | newDecorations?: vscode.DecorationOptions[], |
52 | ) { | 52 | ) { |
53 | const promises: Array<Promise<void>> = []; | 53 | const promises: Array<Promise<void>> = []; |
54 | 54 | ||
55 | for (const rustEditor of vscode.window.visibleTextEditors.filter( | 55 | for (const rustEditor of vscode.window.visibleTextEditors.filter( |
56 | editor => this.isRustDocument(editor.document) | 56 | editor => this.isRustDocument(editor.document), |
57 | )) { | 57 | )) { |
58 | if (newDecorations !== undefined) { | 58 | if (newDecorations !== undefined) { |
59 | promises.push( | 59 | promises.push( |
60 | Promise.resolve( | 60 | Promise.resolve( |
61 | rustEditor.setDecorations( | 61 | rustEditor.setDecorations( |
62 | typeHintDecorationType, | 62 | typeHintDecorationType, |
63 | newDecorations | 63 | newDecorations, |
64 | ) | 64 | ), |
65 | ) | 65 | ), |
66 | ); | 66 | ); |
67 | } else { | 67 | } else { |
68 | promises.push(this.updateDecorationsFromServer(rustEditor)); | 68 | promises.push(this.updateDecorationsFromServer(rustEditor)); |
@@ -79,7 +79,7 @@ export class HintsUpdater { | |||
79 | } | 79 | } |
80 | 80 | ||
81 | private async updateDecorationsFromServer( | 81 | private async updateDecorationsFromServer( |
82 | editor: TextEditor | 82 | editor: TextEditor, |
83 | ): Promise<void> { | 83 | ): Promise<void> { |
84 | const newHints = await this.queryHints(editor.document.uri.toString()); | 84 | const newHints = await this.queryHints(editor.document.uri.toString()); |
85 | if (newHints !== null) { | 85 | if (newHints !== null) { |
@@ -87,20 +87,20 @@ export class HintsUpdater { | |||
87 | range: hint.range, | 87 | range: hint.range, |
88 | renderOptions: { | 88 | renderOptions: { |
89 | after: { | 89 | after: { |
90 | contentText: `: ${hint.label}` | 90 | contentText: `: ${hint.label}`, |
91 | } | 91 | }, |
92 | } | 92 | }, |
93 | })); | 93 | })); |
94 | return editor.setDecorations( | 94 | return editor.setDecorations( |
95 | typeHintDecorationType, | 95 | typeHintDecorationType, |
96 | newDecorations | 96 | newDecorations, |
97 | ); | 97 | ); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | private async queryHints(documentUri: string): Promise<InlayHint[] | null> { | 101 | private async queryHints(documentUri: string): Promise<InlayHint[] | null> { |
102 | const request: InlayHintsParams = { | 102 | const request: InlayHintsParams = { |
103 | textDocument: { uri: documentUri } | 103 | textDocument: { uri: documentUri }, |
104 | }; | 104 | }; |
105 | const client = Server.client; | 105 | const client = Server.client; |
106 | return client | 106 | return client |
@@ -108,8 +108,8 @@ export class HintsUpdater { | |||
108 | .then(() => | 108 | .then(() => |
109 | client.sendRequest<InlayHint[] | null>( | 109 | client.sendRequest<InlayHint[] | null>( |
110 | 'rust-analyzer/inlayHints', | 110 | 'rust-analyzer/inlayHints', |
111 | request | 111 | request, |
112 | ) | 112 | ), |
113 | ); | 113 | ); |
114 | } | 114 | } |
115 | } | 115 | } |
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'; | |||
4 | import { Server } from '../server'; | 4 | import { Server } from '../server'; |
5 | import { | 5 | import { |
6 | handle as applySourceChange, | 6 | handle as applySourceChange, |
7 | SourceChange | 7 | SourceChange, |
8 | } from './apply_source_change'; | 8 | } from './apply_source_change'; |
9 | 9 | ||
10 | interface JoinLinesParams { | 10 | interface JoinLinesParams { |
@@ -19,11 +19,11 @@ export async function handle() { | |||
19 | } | 19 | } |
20 | const request: JoinLinesParams = { | 20 | const request: JoinLinesParams = { |
21 | range: Server.client.code2ProtocolConverter.asRange(editor.selection), | 21 | range: Server.client.code2ProtocolConverter.asRange(editor.selection), |
22 | textDocument: { uri: editor.document.uri.toString() } | 22 | textDocument: { uri: editor.document.uri.toString() }, |
23 | }; | 23 | }; |
24 | const change = await Server.client.sendRequest<SourceChange>( | 24 | const change = await Server.client.sendRequest<SourceChange>( |
25 | 'rust-analyzer/joinLines', | 25 | 'rust-analyzer/joinLines', |
26 | request | 26 | request, |
27 | ); | 27 | ); |
28 | await applySourceChange(change); | 28 | await applySourceChange(change); |
29 | } | 29 | } |
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() { | |||
17 | textDocument: { uri: editor.document.uri.toString() }, | 17 | textDocument: { uri: editor.document.uri.toString() }, |
18 | offsets: editor.selections.map(s => { | 18 | offsets: editor.selections.map(s => { |
19 | return Server.client.code2ProtocolConverter.asPosition(s.active); | 19 | return Server.client.code2ProtocolConverter.asPosition(s.active); |
20 | }) | 20 | }), |
21 | }; | 21 | }; |
22 | const response = await Server.client.sendRequest<Position[]>( | 22 | const response = await Server.client.sendRequest<Position[]>( |
23 | 'rust-analyzer/findMatchingBrace', | 23 | 'rust-analyzer/findMatchingBrace', |
24 | request | 24 | request, |
25 | ); | 25 | ); |
26 | editor.selections = editor.selections.map((sel, idx) => { | 26 | editor.selections = editor.selections.map((sel, idx) => { |
27 | const active = Server.client.protocol2CodeConverter.asPosition( | 27 | const active = Server.client.protocol2CodeConverter.asPosition( |
28 | response[idx] | 28 | response[idx], |
29 | ); | 29 | ); |
30 | const anchor = sel.isEmpty ? active : sel.anchor; | 30 | const anchor = sel.isEmpty ? active : sel.anchor; |
31 | return new vscode.Selection(anchor, active); | 31 | 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'; | |||
3 | import { Server } from '../server'; | 3 | import { Server } from '../server'; |
4 | import { | 4 | import { |
5 | handle as applySourceChange, | 5 | handle as applySourceChange, |
6 | SourceChange | 6 | SourceChange, |
7 | } from './apply_source_change'; | 7 | } from './apply_source_change'; |
8 | 8 | ||
9 | export async function handle(event: { text: string }): Promise<boolean> { | 9 | export async function handle(event: { text: string }): Promise<boolean> { |
@@ -18,12 +18,12 @@ export async function handle(event: { text: string }): Promise<boolean> { | |||
18 | const request: lc.TextDocumentPositionParams = { | 18 | const request: lc.TextDocumentPositionParams = { |
19 | textDocument: { uri: editor.document.uri.toString() }, | 19 | textDocument: { uri: editor.document.uri.toString() }, |
20 | position: Server.client.code2ProtocolConverter.asPosition( | 20 | position: Server.client.code2ProtocolConverter.asPosition( |
21 | editor.selection.active | 21 | editor.selection.active, |
22 | ) | 22 | ), |
23 | }; | 23 | }; |
24 | const change = await Server.client.sendRequest<undefined | SourceChange>( | 24 | const change = await Server.client.sendRequest<undefined | SourceChange>( |
25 | 'rust-analyzer/onEnter', | 25 | 'rust-analyzer/onEnter', |
26 | request | 26 | request, |
27 | ); | 27 | ); |
28 | if (!change) { | 28 | if (!change) { |
29 | return false; | 29 | 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() { | |||
11 | const request: lc.TextDocumentPositionParams = { | 11 | const request: lc.TextDocumentPositionParams = { |
12 | textDocument: { uri: editor.document.uri.toString() }, | 12 | textDocument: { uri: editor.document.uri.toString() }, |
13 | position: Server.client.code2ProtocolConverter.asPosition( | 13 | position: Server.client.code2ProtocolConverter.asPosition( |
14 | editor.selection.active | 14 | editor.selection.active, |
15 | ) | 15 | ), |
16 | }; | 16 | }; |
17 | const response = await Server.client.sendRequest<lc.Location[]>( | 17 | const response = await Server.client.sendRequest<lc.Location[]>( |
18 | 'rust-analyzer/parentModule', | 18 | 'rust-analyzer/parentModule', |
19 | request | 19 | request, |
20 | ); | 20 | ); |
21 | const loc = response[0]; | 21 | const loc = response[0]; |
22 | if (loc == null) { | 22 | 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 { | |||
46 | label: spec.label, | 46 | label: spec.label, |
47 | command: spec.bin, | 47 | command: spec.bin, |
48 | args: spec.args, | 48 | args: spec.args, |
49 | env: spec.env | 49 | env: spec.env, |
50 | }; | 50 | }; |
51 | 51 | ||
52 | const execOption: vscode.ShellExecutionOptions = { | 52 | const execOption: vscode.ShellExecutionOptions = { |
53 | cwd: spec.cwd || '.', | 53 | cwd: spec.cwd || '.', |
54 | env: definition.env | 54 | env: definition.env, |
55 | }; | 55 | }; |
56 | const exec = new vscode.ShellExecution( | 56 | const exec = new vscode.ShellExecution( |
57 | definition.command, | 57 | definition.command, |
58 | definition.args, | 58 | definition.args, |
59 | execOption | 59 | execOption, |
60 | ); | 60 | ); |
61 | 61 | ||
62 | const f = vscode.workspace.workspaceFolders![0]; | 62 | const f = vscode.workspace.workspaceFolders![0]; |
@@ -66,7 +66,7 @@ function createTask(spec: Runnable): vscode.Task { | |||
66 | definition.label, | 66 | definition.label, |
67 | TASK_SOURCE, | 67 | TASK_SOURCE, |
68 | exec, | 68 | exec, |
69 | ['$rustc'] | 69 | ['$rustc'], |
70 | ); | 70 | ); |
71 | t.presentationOptions.clear = true; | 71 | t.presentationOptions.clear = true; |
72 | return t; | 72 | return t; |
@@ -79,17 +79,17 @@ export async function handle() { | |||
79 | return; | 79 | return; |
80 | } | 80 | } |
81 | const textDocument: lc.TextDocumentIdentifier = { | 81 | const textDocument: lc.TextDocumentIdentifier = { |
82 | uri: editor.document.uri.toString() | 82 | uri: editor.document.uri.toString(), |
83 | }; | 83 | }; |
84 | const params: RunnablesParams = { | 84 | const params: RunnablesParams = { |
85 | textDocument, | 85 | textDocument, |
86 | position: Server.client.code2ProtocolConverter.asPosition( | 86 | position: Server.client.code2ProtocolConverter.asPosition( |
87 | editor.selection.active | 87 | editor.selection.active, |
88 | ) | 88 | ), |
89 | }; | 89 | }; |
90 | const runnables = await Server.client.sendRequest<Runnable[]>( | 90 | const runnables = await Server.client.sendRequest<Runnable[]>( |
91 | 'rust-analyzer/runnables', | 91 | 'rust-analyzer/runnables', |
92 | params | 92 | params, |
93 | ); | 93 | ); |
94 | const items: RunnableQuickPick[] = []; | 94 | const items: RunnableQuickPick[] = []; |
95 | if (prevRunnable) { | 95 | if (prevRunnable) { |
@@ -124,7 +124,7 @@ export async function handleSingle(runnable: Runnable) { | |||
124 | task.presentationOptions = { | 124 | task.presentationOptions = { |
125 | reveal: vscode.TaskRevealKind.Always, | 125 | reveal: vscode.TaskRevealKind.Always, |
126 | panel: vscode.TaskPanelKind.Dedicated, | 126 | panel: vscode.TaskPanelKind.Dedicated, |
127 | clear: true | 127 | clear: true, |
128 | }; | 128 | }; |
129 | 129 | ||
130 | return vscode.tasks.executeTask(task); | 130 | return vscode.tasks.executeTask(task); |
@@ -136,7 +136,7 @@ export async function handleSingle(runnable: Runnable) { | |||
136 | * that, when accepted, allow us to `cargo install cargo-watch` and then run it. | 136 | * that, when accepted, allow us to `cargo install cargo-watch` and then run it. |
137 | */ | 137 | */ |
138 | export async function interactivelyStartCargoWatch( | 138 | export async function interactivelyStartCargoWatch( |
139 | context: vscode.ExtensionContext | 139 | context: vscode.ExtensionContext, |
140 | ): Promise<CargoWatchProvider | undefined> { | 140 | ): Promise<CargoWatchProvider | undefined> { |
141 | if (Server.config.cargoWatchOptions.enableOnStartup === 'disabled') { | 141 | if (Server.config.cargoWatchOptions.enableOnStartup === 'disabled') { |
142 | return; | 142 | return; |
@@ -146,7 +146,7 @@ export async function interactivelyStartCargoWatch( | |||
146 | const watch = await vscode.window.showInformationMessage( | 146 | const watch = await vscode.window.showInformationMessage( |
147 | 'Start watching changes with cargo? (Executes `cargo watch`, provides inline diagnostics)', | 147 | 'Start watching changes with cargo? (Executes `cargo watch`, provides inline diagnostics)', |
148 | 'yes', | 148 | 'yes', |
149 | 'no' | 149 | 'no', |
150 | ); | 150 | ); |
151 | if (watch !== 'yes') { | 151 | if (watch !== 'yes') { |
152 | return; | 152 | return; |
@@ -157,12 +157,12 @@ export async function interactivelyStartCargoWatch( | |||
157 | } | 157 | } |
158 | 158 | ||
159 | export async function startCargoWatch( | 159 | export async function startCargoWatch( |
160 | context: vscode.ExtensionContext | 160 | context: vscode.ExtensionContext, |
161 | ): Promise<CargoWatchProvider | undefined> { | 161 | ): Promise<CargoWatchProvider | undefined> { |
162 | const execPromise = util.promisify(child_process.exec); | 162 | const execPromise = util.promisify(child_process.exec); |
163 | 163 | ||
164 | const { stderr, code = 0 } = await execPromise( | 164 | const { stderr, code = 0 } = await execPromise( |
165 | 'cargo watch --version' | 165 | 'cargo watch --version', |
166 | ).catch(e => e); | 166 | ).catch(e => e); |
167 | 167 | ||
168 | if (stderr.includes('no such subcommand: `watch`')) { | 168 | if (stderr.includes('no such subcommand: `watch`')) { |
@@ -171,7 +171,7 @@ export async function startCargoWatch( | |||
171 | const install = await vscode.window.showInformationMessage( | 171 | const install = await vscode.window.showInformationMessage( |
172 | msg, | 172 | msg, |
173 | 'yes', | 173 | 'yes', |
174 | 'no' | 174 | 'no', |
175 | ); | 175 | ); |
176 | if (install !== 'yes') { | 176 | if (install !== 'yes') { |
177 | return; | 177 | return; |
@@ -192,20 +192,20 @@ export async function startCargoWatch( | |||
192 | label, | 192 | label, |
193 | bin: 'cargo', | 193 | bin: 'cargo', |
194 | args: ['install', 'cargo-watch'], | 194 | args: ['install', 'cargo-watch'], |
195 | env: {} | 195 | env: {}, |
196 | }) | 196 | }), |
197 | ); | 197 | ); |
198 | await taskFinished; | 198 | await taskFinished; |
199 | const output = await execPromise('cargo watch --version').catch(e => e); | 199 | const output = await execPromise('cargo watch --version').catch(e => e); |
200 | if (output.stderr !== '') { | 200 | if (output.stderr !== '') { |
201 | vscode.window.showErrorMessage( | 201 | vscode.window.showErrorMessage( |
202 | `Couldn't install \`cargo-\`watch: ${output.stderr}` | 202 | `Couldn't install \`cargo-\`watch: ${output.stderr}`, |
203 | ); | 203 | ); |
204 | return; | 204 | return; |
205 | } | 205 | } |
206 | } else if (code !== 0) { | 206 | } else if (code !== 0) { |
207 | vscode.window.showErrorMessage( | 207 | vscode.window.showErrorMessage( |
208 | `\`cargo watch\` failed with ${code}: ${stderr}` | 208 | `\`cargo watch\` failed with ${code}: ${stderr}`, |
209 | ); | 209 | ); |
210 | return; | 210 | return; |
211 | } | 211 | } |
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 | |||
11 | public syntaxTree: string = 'Not available'; | 11 | public syntaxTree: string = 'Not available'; |
12 | 12 | ||
13 | public provideTextDocumentContent( | 13 | public provideTextDocumentContent( |
14 | uri: vscode.Uri | 14 | uri: vscode.Uri, |
15 | ): vscode.ProviderResult<string> { | 15 | ): vscode.ProviderResult<string> { |
16 | const editor = vscode.window.activeTextEditor; | 16 | const editor = vscode.window.activeTextEditor; |
17 | if (editor == null) { | 17 | if (editor == null) { |
@@ -25,17 +25,17 @@ export class SyntaxTreeContentProvider | |||
25 | range = editor.selection.isEmpty | 25 | range = editor.selection.isEmpty |
26 | ? undefined | 26 | ? undefined |
27 | : Server.client.code2ProtocolConverter.asRange( | 27 | : Server.client.code2ProtocolConverter.asRange( |
28 | editor.selection | 28 | editor.selection, |
29 | ); | 29 | ); |
30 | } | 30 | } |
31 | 31 | ||
32 | const request: SyntaxTreeParams = { | 32 | const request: SyntaxTreeParams = { |
33 | textDocument: { uri: editor.document.uri.toString() }, | 33 | textDocument: { uri: editor.document.uri.toString() }, |
34 | range | 34 | range, |
35 | }; | 35 | }; |
36 | return Server.client.sendRequest<SyntaxTreeResult>( | 36 | return Server.client.sendRequest<SyntaxTreeResult>( |
37 | 'rust-analyzer/syntaxTree', | 37 | 'rust-analyzer/syntaxTree', |
38 | request | 38 | request, |
39 | ); | 39 | ); |
40 | } | 40 | } |
41 | 41 | ||
@@ -70,7 +70,7 @@ export function createHandle(provider: SyntaxTreeContentProvider) { | |||
70 | return vscode.window.showTextDocument( | 70 | return vscode.window.showTextDocument( |
71 | document, | 71 | document, |
72 | vscode.ViewColumn.Two, | 72 | vscode.ViewColumn.Two, |
73 | true | 73 | true, |
74 | ); | 74 | ); |
75 | }; | 75 | }; |
76 | } | 76 | } |
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 { | |||
13 | constructor(command: string) { | 13 | constructor(command: string) { |
14 | this.statusBarItem = vscode.window.createStatusBarItem( | 14 | this.statusBarItem = vscode.window.createStatusBarItem( |
15 | vscode.StatusBarAlignment.Left, | 15 | vscode.StatusBarAlignment.Left, |
16 | 10 | 16 | 10, |
17 | ); | 17 | ); |
18 | this.command = command; | 18 | this.command = command; |
19 | this.statusBarItem.hide(); | 19 | this.statusBarItem.hide(); |