aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenČ›iu Nicola <[email protected]>2019-12-09 18:57:55 +0000
committerLaurenČ›iu Nicola <[email protected]>2019-12-09 19:07:19 +0000
commit273299693b85996878907ad256ed55f072ec3f1a (patch)
tree16d7de77952895b4cebf1cbb7a18652eaf4d98b6
parent897b550049d8889804bb476e305427d07879cd63 (diff)
Code: enable prettier trailing commas
-rw-r--r--editors/code/package.json3
-rw-r--r--editors/code/src/commands/analyzer_status.ts14
-rw-r--r--editors/code/src/commands/apply_source_change.ts8
-rw-r--r--editors/code/src/commands/cargo_watch.ts34
-rw-r--r--editors/code/src/commands/expand_macro.ts10
-rw-r--r--editors/code/src/commands/index.ts2
-rw-r--r--editors/code/src/commands/inlay_hints.ts34
-rw-r--r--editors/code/src/commands/join_lines.ts6
-rw-r--r--editors/code/src/commands/matching_brace.ts6
-rw-r--r--editors/code/src/commands/on_enter.ts8
-rw-r--r--editors/code/src/commands/parent_module.ts6
-rw-r--r--editors/code/src/commands/runnables.ts36
-rw-r--r--editors/code/src/commands/syntaxTree.ts10
-rw-r--r--editors/code/src/commands/watch_status.ts2
-rw-r--r--editors/code/src/config.ts22
-rw-r--r--editors/code/src/events/change_active_text_editor.ts6
-rw-r--r--editors/code/src/events/change_text_document.ts2
-rw-r--r--editors/code/src/extension.ts56
-rw-r--r--editors/code/src/highlighting.ts16
-rw-r--r--editors/code/src/notifications/publish_decorations.ts2
-rw-r--r--editors/code/src/server.ts22
-rw-r--r--editors/code/src/test/utils/diagnotics/SuggestedFix.test.ts26
-rw-r--r--editors/code/src/test/utils/diagnotics/SuggestedFixCollection.test.ts20
-rw-r--r--editors/code/src/test/utils/diagnotics/rust.test.ts52
-rw-r--r--editors/code/src/test/utils/diagnotics/vscode.test.ts24
-rw-r--r--editors/code/src/test/utils/index.ts2
-rw-r--r--editors/code/src/utils/diagnostics/SuggestedFix.ts4
-rw-r--r--editors/code/src/utils/diagnostics/SuggestedFixCollection.ts6
-rw-r--r--editors/code/src/utils/diagnostics/rust.ts20
-rw-r--r--editors/code/src/utils/diagnostics/vscode.ts2
-rw-r--r--editors/code/src/utils/processes.ts4
31 files changed, 233 insertions, 232 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index ae2049c57..7bc08ec31 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -27,8 +27,9 @@
27 "travis": "npm run compile && npm run test && npm run lint && npm run prettier -- --write && git diff --exit-code" 27 "travis": "npm run compile && npm run test && npm run lint && npm run prettier -- --write && git diff --exit-code"
28 }, 28 },
29 "prettier": { 29 "prettier": {
30 "singleQuote": true,
30 "tabWidth": 4, 31 "tabWidth": 4,
31 "singleQuote": true 32 "trailingComma": "all"
32 }, 33 },
33 "dependencies": { 34 "dependencies": {
34 "lookpath": "^1.0.3", 35 "lookpath": "^1.0.3",
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
12export async function handle(change: SourceChange) { 12export 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
10import { 10import {
11 mapRustDiagnosticToVsCode, 11 mapRustDiagnosticToVsCode,
12 RustDiagnostic 12 RustDiagnostic,
13} from '../utils/diagnostics/rust'; 13} from '../utils/diagnostics/rust';
14import SuggestedFixCollection from '../utils/diagnostics/SuggestedFixCollection'; 14import SuggestedFixCollection from '../utils/diagnostics/SuggestedFixCollection';
15import { areDiagnosticsEqual } from '../utils/diagnostics/vscode'; 15import { areDiagnosticsEqual } from '../utils/diagnostics/vscode';
16 16
17export async function registerCargoWatchProvider( 17export 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';
3import { Server } from '../server'; 3import { Server } from '../server';
4 4
5export const expandMacroUri = vscode.Uri.parse( 5export const expandMacroUri = vscode.Uri.parse(
6 'rust-analyzer://expandMacro/[EXPANSION].rs' 6 'rust-analyzer://expandMacro/[EXPANSION].rs',
7); 7);
8 8
9export class ExpandMacroContentProvider 9export 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
16const typeHintDecorationType = vscode.window.createTextEditorDecorationType({ 16const 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
22export class HintsUpdater { 22export 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';
4import { Server } from '../server'; 4import { Server } from '../server';
5import { 5import {
6 handle as applySourceChange, 6 handle as applySourceChange,
7 SourceChange 7 SourceChange,
8} from './apply_source_change'; 8} from './apply_source_change';
9 9
10interface JoinLinesParams { 10interface 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';
3import { Server } from '../server'; 3import { Server } from '../server';
4import { 4import {
5 handle as applySourceChange, 5 handle as applySourceChange,
6 SourceChange 6 SourceChange,
7} from './apply_source_change'; 7} from './apply_source_change';
8 8
9export async function handle(event: { text: string }): Promise<boolean> { 9export 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 */
138export async function interactivelyStartCargoWatch( 138export 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
159export async function startCargoWatch( 159export 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();
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index fb9e55dd6..2d3b6a54e 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -33,14 +33,14 @@ export class Config {
33 trace: 'off', 33 trace: 'off',
34 arguments: '', 34 arguments: '',
35 command: '', 35 command: '',
36 ignore: [] 36 ignore: [],
37 }; 37 };
38 38
39 private prevEnhancedTyping: null | boolean = null; 39 private prevEnhancedTyping: null | boolean = null;
40 40
41 constructor() { 41 constructor() {
42 vscode.workspace.onDidChangeConfiguration(_ => 42 vscode.workspace.onDidChangeConfiguration(_ =>
43 this.userConfigChanged() 43 this.userConfigChanged(),
44 ); 44 );
45 this.userConfigChanged(); 45 this.userConfigChanged();
46 } 46 }
@@ -53,7 +53,7 @@ export class Config {
53 53
54 if (config.has('rainbowHighlightingOn')) { 54 if (config.has('rainbowHighlightingOn')) {
55 this.rainbowHighlightingOn = config.get( 55 this.rainbowHighlightingOn = config.get(
56 'rainbowHighlightingOn' 56 'rainbowHighlightingOn',
57 ) as boolean; 57 ) as boolean;
58 } 58 }
59 59
@@ -63,7 +63,7 @@ export class Config {
63 63
64 if (config.has('enableEnhancedTyping')) { 64 if (config.has('enableEnhancedTyping')) {
65 this.enableEnhancedTyping = config.get( 65 this.enableEnhancedTyping = config.get(
66 'enableEnhancedTyping' 66 'enableEnhancedTyping',
67 ) as boolean; 67 ) as boolean;
68 68
69 if (this.prevEnhancedTyping === null) { 69 if (this.prevEnhancedTyping === null) {
@@ -78,12 +78,12 @@ export class Config {
78 vscode.window 78 vscode.window
79 .showInformationMessage( 79 .showInformationMessage(
80 'Changing enhanced typing setting requires a reload', 80 'Changing enhanced typing setting requires a reload',
81 reloadAction 81 reloadAction,
82 ) 82 )
83 .then(selectedAction => { 83 .then(selectedAction => {
84 if (selectedAction === reloadAction) { 84 if (selectedAction === reloadAction) {
85 vscode.commands.executeCommand( 85 vscode.commands.executeCommand(
86 'workbench.action.reloadWindow' 86 'workbench.action.reloadWindow',
87 ); 87 );
88 } 88 }
89 }); 89 });
@@ -104,28 +104,28 @@ export class Config {
104 if (config.has('trace.cargo-watch')) { 104 if (config.has('trace.cargo-watch')) {
105 this.cargoWatchOptions.trace = config.get<CargoWatchTraceOptions>( 105 this.cargoWatchOptions.trace = config.get<CargoWatchTraceOptions>(
106 'trace.cargo-watch', 106 'trace.cargo-watch',
107 'off' 107 'off',
108 ); 108 );
109 } 109 }
110 110
111 if (config.has('cargo-watch.arguments')) { 111 if (config.has('cargo-watch.arguments')) {
112 this.cargoWatchOptions.arguments = config.get<string>( 112 this.cargoWatchOptions.arguments = config.get<string>(
113 'cargo-watch.arguments', 113 'cargo-watch.arguments',
114 '' 114 '',
115 ); 115 );
116 } 116 }
117 117
118 if (config.has('cargo-watch.command')) { 118 if (config.has('cargo-watch.command')) {
119 this.cargoWatchOptions.command = config.get<string>( 119 this.cargoWatchOptions.command = config.get<string>(
120 'cargo-watch.command', 120 'cargo-watch.command',
121 '' 121 '',
122 ); 122 );
123 } 123 }
124 124
125 if (config.has('cargo-watch.ignore')) { 125 if (config.has('cargo-watch.ignore')) {
126 this.cargoWatchOptions.ignore = config.get<string[]>( 126 this.cargoWatchOptions.ignore = config.get<string[]>(
127 'cargo-watch.ignore', 127 'cargo-watch.ignore',
128 [] 128 [],
129 ); 129 );
130 } 130 }
131 131
@@ -138,7 +138,7 @@ export class Config {
138 } 138 }
139 if (config.has('maxInlayHintLength')) { 139 if (config.has('maxInlayHintLength')) {
140 this.maxInlayHintLength = config.get( 140 this.maxInlayHintLength = config.get(
141 'maxInlayHintLength' 141 'maxInlayHintLength',
142 ) as number; 142 ) as number;
143 } 143 }
144 if (config.has('excludeGlobs')) { 144 if (config.has('excludeGlobs')) {
diff --git a/editors/code/src/events/change_active_text_editor.ts b/editors/code/src/events/change_active_text_editor.ts
index 64be56225..74b91bd48 100644
--- a/editors/code/src/events/change_active_text_editor.ts
+++ b/editors/code/src/events/change_active_text_editor.ts
@@ -3,7 +3,7 @@ import { TextDocumentIdentifier } from 'vscode-languageclient';
3 3
4import { 4import {
5 SyntaxTreeContentProvider, 5 SyntaxTreeContentProvider,
6 syntaxTreeUri 6 syntaxTreeUri,
7} from '../commands/syntaxTree'; 7} from '../commands/syntaxTree';
8import { Decoration } from '../highlighting'; 8import { Decoration } from '../highlighting';
9import { Server } from '../server'; 9import { Server } from '../server';
@@ -21,11 +21,11 @@ export function makeHandler(syntaxTreeProvider: SyntaxTreeContentProvider) {
21 } 21 }
22 22
23 const params: TextDocumentIdentifier = { 23 const params: TextDocumentIdentifier = {
24 uri: editor.document.uri.toString() 24 uri: editor.document.uri.toString(),
25 }; 25 };
26 const decorations = await Server.client.sendRequest<Decoration[]>( 26 const decorations = await Server.client.sendRequest<Decoration[]>(
27 'rust-analyzer/decorationsRequest', 27 'rust-analyzer/decorationsRequest',
28 params 28 params,
29 ); 29 );
30 Server.highlighter.setHighlights(editor, decorations); 30 Server.highlighter.setHighlights(editor, decorations);
31 }; 31 };
diff --git a/editors/code/src/events/change_text_document.ts b/editors/code/src/events/change_text_document.ts
index 89488bc61..2e998e889 100644
--- a/editors/code/src/events/change_text_document.ts
+++ b/editors/code/src/events/change_text_document.ts
@@ -2,7 +2,7 @@ import * as vscode from 'vscode';
2 2
3import { 3import {
4 SyntaxTreeContentProvider, 4 SyntaxTreeContentProvider,
5 syntaxTreeUri 5 syntaxTreeUri,
6} from '../commands/syntaxTree'; 6} from '../commands/syntaxTree';
7 7
8export function createHandler(syntaxTreeProvider: SyntaxTreeContentProvider) { 8export function createHandler(syntaxTreeProvider: SyntaxTreeContentProvider) {
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts
index a78aa3b42..815f3692c 100644
--- a/editors/code/src/extension.ts
+++ b/editors/code/src/extension.ts
@@ -7,7 +7,7 @@ import { ExpandMacroContentProvider } from './commands/expand_macro';
7import { HintsUpdater } from './commands/inlay_hints'; 7import { HintsUpdater } from './commands/inlay_hints';
8import { 8import {
9 interactivelyStartCargoWatch, 9 interactivelyStartCargoWatch,
10 startCargoWatch 10 startCargoWatch,
11} from './commands/runnables'; 11} from './commands/runnables';
12import { SyntaxTreeContentProvider } from './commands/syntaxTree'; 12import { SyntaxTreeContentProvider } from './commands/syntaxTree';
13import * as events from './events'; 13import * as events from './events';
@@ -24,7 +24,7 @@ export async function activate(context: vscode.ExtensionContext) {
24 } 24 }
25 function overrideCommand( 25 function overrideCommand(
26 name: string, 26 name: string,
27 f: (...args: any[]) => Promise<boolean> 27 f: (...args: any[]) => Promise<boolean>,
28 ) { 28 ) {
29 const defaultCmd = `default:${name}`; 29 const defaultCmd = `default:${name}`;
30 const original = (...args: any[]) => 30 const original = (...args: any[]) =>
@@ -46,7 +46,7 @@ export async function activate(context: vscode.ExtensionContext) {
46 }); 46 });
47 } catch (_) { 47 } catch (_) {
48 vscode.window.showWarningMessage( 48 vscode.window.showWarningMessage(
49 'Enhanced typing feature is disabled because of incompatibility with VIM extension, consider turning off rust-analyzer.enableEnhancedTyping: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/README.md#settings' 49 'Enhanced typing feature is disabled because of incompatibility with VIM extension, consider turning off rust-analyzer.enableEnhancedTyping: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/README.md#settings',
50 ); 50 );
51 } 51 }
52 } 52 }
@@ -54,14 +54,14 @@ export async function activate(context: vscode.ExtensionContext) {
54 // Commands are requests from vscode to the language server 54 // Commands are requests from vscode to the language server
55 registerCommand( 55 registerCommand(
56 'rust-analyzer.analyzerStatus', 56 'rust-analyzer.analyzerStatus',
57 commands.analyzerStatus.makeCommand(context) 57 commands.analyzerStatus.makeCommand(context),
58 ); 58 );
59 registerCommand('rust-analyzer.collectGarbage', () => 59 registerCommand('rust-analyzer.collectGarbage', () =>
60 Server.client.sendRequest<null>('rust-analyzer/collectGarbage', null) 60 Server.client.sendRequest<null>('rust-analyzer/collectGarbage', null),
61 ); 61 );
62 registerCommand( 62 registerCommand(
63 'rust-analyzer.matchingBrace', 63 'rust-analyzer.matchingBrace',
64 commands.matchingBrace.handle 64 commands.matchingBrace.handle,
65 ); 65 );
66 registerCommand('rust-analyzer.joinLines', commands.joinLines.handle); 66 registerCommand('rust-analyzer.joinLines', commands.joinLines.handle);
67 registerCommand('rust-analyzer.parentModule', commands.parentModule.handle); 67 registerCommand('rust-analyzer.parentModule', commands.parentModule.handle);
@@ -70,7 +70,7 @@ export async function activate(context: vscode.ExtensionContext) {
70 registerCommand('rust-analyzer.runSingle', commands.runnables.handleSingle); 70 registerCommand('rust-analyzer.runSingle', commands.runnables.handleSingle);
71 registerCommand( 71 registerCommand(
72 'rust-analyzer.applySourceChange', 72 'rust-analyzer.applySourceChange',
73 commands.applySourceChange.handle 73 commands.applySourceChange.handle,
74 ); 74 );
75 registerCommand( 75 registerCommand(
76 'rust-analyzer.showReferences', 76 'rust-analyzer.showReferences',
@@ -79,9 +79,9 @@ export async function activate(context: vscode.ExtensionContext) {
79 'editor.action.showReferences', 79 'editor.action.showReferences',
80 vscode.Uri.parse(uri), 80 vscode.Uri.parse(uri),
81 Server.client.protocol2CodeConverter.asPosition(position), 81 Server.client.protocol2CodeConverter.asPosition(position),
82 locations.map(Server.client.protocol2CodeConverter.asLocation) 82 locations.map(Server.client.protocol2CodeConverter.asLocation),
83 ); 83 );
84 } 84 },
85 ); 85 );
86 86
87 if (Server.config.enableEnhancedTyping) { 87 if (Server.config.enableEnhancedTyping) {
@@ -91,47 +91,47 @@ export async function activate(context: vscode.ExtensionContext) {
91 // Notifications are events triggered by the language server 91 // Notifications are events triggered by the language server
92 const allNotifications: Iterable<[ 92 const allNotifications: Iterable<[
93 string, 93 string,
94 lc.GenericNotificationHandler 94 lc.GenericNotificationHandler,
95 ]> = [ 95 ]> = [
96 [ 96 [
97 'rust-analyzer/publishDecorations', 97 'rust-analyzer/publishDecorations',
98 notifications.publishDecorations.handle 98 notifications.publishDecorations.handle,
99 ] 99 ],
100 ]; 100 ];
101 const syntaxTreeContentProvider = new SyntaxTreeContentProvider(); 101 const syntaxTreeContentProvider = new SyntaxTreeContentProvider();
102 const expandMacroContentProvider = new ExpandMacroContentProvider(); 102 const expandMacroContentProvider = new ExpandMacroContentProvider();
103 103
104 // The events below are plain old javascript events, triggered and handled by vscode 104 // The events below are plain old javascript events, triggered and handled by vscode
105 vscode.window.onDidChangeActiveTextEditor( 105 vscode.window.onDidChangeActiveTextEditor(
106 events.changeActiveTextEditor.makeHandler(syntaxTreeContentProvider) 106 events.changeActiveTextEditor.makeHandler(syntaxTreeContentProvider),
107 ); 107 );
108 108
109 disposeOnDeactivation( 109 disposeOnDeactivation(
110 vscode.workspace.registerTextDocumentContentProvider( 110 vscode.workspace.registerTextDocumentContentProvider(
111 'rust-analyzer', 111 'rust-analyzer',
112 syntaxTreeContentProvider 112 syntaxTreeContentProvider,
113 ) 113 ),
114 ); 114 );
115 disposeOnDeactivation( 115 disposeOnDeactivation(
116 vscode.workspace.registerTextDocumentContentProvider( 116 vscode.workspace.registerTextDocumentContentProvider(
117 'rust-analyzer', 117 'rust-analyzer',
118 expandMacroContentProvider 118 expandMacroContentProvider,
119 ) 119 ),
120 ); 120 );
121 121
122 registerCommand( 122 registerCommand(
123 'rust-analyzer.syntaxTree', 123 'rust-analyzer.syntaxTree',
124 commands.syntaxTree.createHandle(syntaxTreeContentProvider) 124 commands.syntaxTree.createHandle(syntaxTreeContentProvider),
125 ); 125 );
126 registerCommand( 126 registerCommand(
127 'rust-analyzer.expandMacro', 127 'rust-analyzer.expandMacro',
128 commands.expandMacro.createHandle(expandMacroContentProvider) 128 commands.expandMacro.createHandle(expandMacroContentProvider),
129 ); 129 );
130 130
131 vscode.workspace.onDidChangeTextDocument( 131 vscode.workspace.onDidChangeTextDocument(
132 events.changeTextDocument.createHandler(syntaxTreeContentProvider), 132 events.changeTextDocument.createHandler(syntaxTreeContentProvider),
133 null, 133 null,
134 context.subscriptions 134 context.subscriptions,
135 ); 135 );
136 136
137 const startServer = () => Server.start(allNotifications); 137 const startServer = () => Server.start(allNotifications);
@@ -178,25 +178,25 @@ export async function activate(context: vscode.ExtensionContext) {
178 editorChangeDisposable.dispose(); 178 editorChangeDisposable.dispose();
179 } 179 }
180 return hintsUpdater.refreshHintsForVisibleEditors(); 180 return hintsUpdater.refreshHintsForVisibleEditors();
181 } 181 },
182 ); 182 );
183 183
184 disposeOnDeactivation( 184 disposeOnDeactivation(
185 vscode.window.onDidChangeVisibleTextEditors(_ => 185 vscode.window.onDidChangeVisibleTextEditors(_ =>
186 hintsUpdater.refreshHintsForVisibleEditors() 186 hintsUpdater.refreshHintsForVisibleEditors(),
187 ) 187 ),
188 ); 188 );
189 disposeOnDeactivation( 189 disposeOnDeactivation(
190 vscode.workspace.onDidChangeTextDocument(e => 190 vscode.workspace.onDidChangeTextDocument(e =>
191 hintsUpdater.refreshHintsForVisibleEditors(e) 191 hintsUpdater.refreshHintsForVisibleEditors(e),
192 ) 192 ),
193 ); 193 );
194 disposeOnDeactivation( 194 disposeOnDeactivation(
195 vscode.workspace.onDidChangeConfiguration(_ => 195 vscode.workspace.onDidChangeConfiguration(_ =>
196 hintsUpdater.toggleHintsDisplay( 196 hintsUpdater.toggleHintsDisplay(
197 Server.config.displayInlayHints 197 Server.config.displayInlayHints,
198 ) 198 ),
199 ) 199 ),
200 ); 200 );
201 }); 201 });
202 } 202 }
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index 48f2a2547..6d50a2f2d 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -30,19 +30,19 @@ export class Highlighter {
30 > { 30 > {
31 const decoration = ( 31 const decoration = (
32 tag: string, 32 tag: string,
33 textDecoration?: string 33 textDecoration?: string,
34 ): [string, vscode.TextEditorDecorationType] => { 34 ): [string, vscode.TextEditorDecorationType] => {
35 const color = new vscode.ThemeColor('ralsp.' + tag); 35 const color = new vscode.ThemeColor('ralsp.' + tag);
36 const decor = vscode.window.createTextEditorDecorationType({ 36 const decor = vscode.window.createTextEditorDecorationType({
37 color, 37 color,
38 textDecoration 38 textDecoration,
39 }); 39 });
40 return [tag, decor]; 40 return [tag, decor];
41 }; 41 };
42 42
43 const decorations: Iterable<[ 43 const decorations: Iterable<[
44 string, 44 string,
45 vscode.TextEditorDecorationType 45 vscode.TextEditorDecorationType,
46 ]> = [ 46 ]> = [
47 decoration('comment'), 47 decoration('comment'),
48 decoration('string'), 48 decoration('string'),
@@ -61,7 +61,7 @@ export class Highlighter {
61 decoration('variable'), 61 decoration('variable'),
62 decoration('variable.mut', 'underline'), 62 decoration('variable.mut', 'underline'),
63 decoration('field'), 63 decoration('field'),
64 decoration('module') 64 decoration('module'),
65 ]; 65 ];
66 66
67 return new Map<string, vscode.TextEditorDecorationType>(decorations); 67 return new Map<string, vscode.TextEditorDecorationType>(decorations);
@@ -118,20 +118,20 @@ export class Highlighter {
118 colorfulIdents 118 colorfulIdents
119 .get(d.bindingHash)![0] 119 .get(d.bindingHash)![0]
120 .push( 120 .push(
121 Server.client.protocol2CodeConverter.asRange(d.range) 121 Server.client.protocol2CodeConverter.asRange(d.range),
122 ); 122 );
123 } else { 123 } else {
124 byTag 124 byTag
125 .get(d.tag)! 125 .get(d.tag)!
126 .push( 126 .push(
127 Server.client.protocol2CodeConverter.asRange(d.range) 127 Server.client.protocol2CodeConverter.asRange(d.range),
128 ); 128 );
129 } 129 }
130 } 130 }
131 131
132 for (const tag of byTag.keys()) { 132 for (const tag of byTag.keys()) {
133 const dec = this.decorations.get( 133 const dec = this.decorations.get(
134 tag 134 tag,
135 ) as vscode.TextEditorDecorationType; 135 ) as vscode.TextEditorDecorationType;
136 const ranges = byTag.get(tag)!; 136 const ranges = byTag.get(tag)!;
137 editor.setDecorations(dec, ranges); 137 editor.setDecorations(dec, ranges);
@@ -141,7 +141,7 @@ export class Highlighter {
141 const textDecoration = mut ? 'underline' : undefined; 141 const textDecoration = mut ? 'underline' : undefined;
142 const dec = vscode.window.createTextEditorDecorationType({ 142 const dec = vscode.window.createTextEditorDecorationType({
143 light: { color: fancify(hash, 'light'), textDecoration }, 143 light: { color: fancify(hash, 'light'), textDecoration },
144 dark: { color: fancify(hash, 'dark'), textDecoration } 144 dark: { color: fancify(hash, 'dark'), textDecoration },
145 }); 145 });
146 editor.setDecorations(dec, ranges); 146 editor.setDecorations(dec, ranges);
147 } 147 }
diff --git a/editors/code/src/notifications/publish_decorations.ts b/editors/code/src/notifications/publish_decorations.ts
index 3180019b7..00ffb7776 100644
--- a/editors/code/src/notifications/publish_decorations.ts
+++ b/editors/code/src/notifications/publish_decorations.ts
@@ -10,7 +10,7 @@ export interface PublishDecorationsParams {
10 10
11export function handle(params: PublishDecorationsParams) { 11export function handle(params: PublishDecorationsParams) {
12 const targetEditor = vscode.window.visibleTextEditors.find( 12 const targetEditor = vscode.window.visibleTextEditors.find(
13 editor => editor.document.uri.toString() === params.uri 13 editor => editor.document.uri.toString() === params.uri,
14 ); 14 );
15 if (!Server.config.highlightingOn || !targetEditor) { 15 if (!Server.config.highlightingOn || !targetEditor) {
16 return; 16 return;
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts
index e767b6f1b..2fe45f1ed 100644
--- a/editors/code/src/server.ts
+++ b/editors/code/src/server.ts
@@ -19,7 +19,7 @@ export class Server {
19 public static client: lc.LanguageClient; 19 public static client: lc.LanguageClient;
20 20
21 public static async start( 21 public static async start(
22 notificationHandlers: Iterable<[string, lc.GenericNotificationHandler]> 22 notificationHandlers: Iterable<[string, lc.GenericNotificationHandler]>,
23 ) { 23 ) {
24 // '.' Is the fallback if no folder is open 24 // '.' Is the fallback if no folder is open
25 // TODO?: Workspace folders support Uri's (eg: file://test.txt). It might be a good idea to test if the uri points to a file. 25 // TODO?: Workspace folders support Uri's (eg: file://test.txt). It might be a good idea to test if the uri points to a file.
@@ -34,20 +34,20 @@ export class Server {
34 if (platform() !== 'win32') { 34 if (platform() !== 'win32') {
35 if (!(await lookpath(command))) { 35 if (!(await lookpath(command))) {
36 throw new Error( 36 throw new Error(
37 `Cannot find rust-analyzer server \`${command}\` in PATH.` 37 `Cannot find rust-analyzer server \`${command}\` in PATH.`,
38 ); 38 );
39 } 39 }
40 } 40 }
41 const run: lc.Executable = { 41 const run: lc.Executable = {
42 command, 42 command,
43 options: { cwd: folder } 43 options: { cwd: folder },
44 }; 44 };
45 const serverOptions: lc.ServerOptions = { 45 const serverOptions: lc.ServerOptions = {
46 run, 46 run,
47 debug: run 47 debug: run,
48 }; 48 };
49 const traceOutputChannel = window.createOutputChannel( 49 const traceOutputChannel = window.createOutputChannel(
50 'Rust Analyzer Language Server Trace' 50 'Rust Analyzer Language Server Trace',
51 ); 51 );
52 const clientOptions: lc.LanguageClientOptions = { 52 const clientOptions: lc.LanguageClientOptions = {
53 documentSelector: [{ scheme: 'file', language: 'rust' }], 53 documentSelector: [{ scheme: 'file', language: 'rust' }],
@@ -58,16 +58,16 @@ export class Server {
58 excludeGlobs: Server.config.excludeGlobs, 58 excludeGlobs: Server.config.excludeGlobs,
59 useClientWatching: Server.config.useClientWatching, 59 useClientWatching: Server.config.useClientWatching,
60 featureFlags: Server.config.featureFlags, 60 featureFlags: Server.config.featureFlags,
61 withSysroot: Server.config.withSysroot 61 withSysroot: Server.config.withSysroot,
62 }, 62 },
63 traceOutputChannel 63 traceOutputChannel,
64 }; 64 };
65 65
66 Server.client = new lc.LanguageClient( 66 Server.client = new lc.LanguageClient(
67 'rust-analyzer', 67 'rust-analyzer',
68 'Rust Analyzer Language Server', 68 'Rust Analyzer Language Server',
69 serverOptions, 69 serverOptions,
70 clientOptions 70 clientOptions,
71 ); 71 );
72 // HACK: This is an awful way of filtering out the decorations notifications 72 // HACK: This is an awful way of filtering out the decorations notifications
73 // However, pending proper support, this is the most effecitve approach 73 // However, pending proper support, this is the most effecitve approach
@@ -80,10 +80,10 @@ export class Server {
80 if (typeof messageOrDataObject === 'string') { 80 if (typeof messageOrDataObject === 'string') {
81 if ( 81 if (
82 messageOrDataObject.includes( 82 messageOrDataObject.includes(
83 'rust-analyzer/publishDecorations' 83 'rust-analyzer/publishDecorations',
84 ) || 84 ) ||
85 messageOrDataObject.includes( 85 messageOrDataObject.includes(
86 'rust-analyzer/decorationsRequest' 86 'rust-analyzer/decorationsRequest',
87 ) 87 )
88 ) { 88 ) {
89 // Don't log publish decorations requests 89 // Don't log publish decorations requests
@@ -95,7 +95,7 @@ export class Server {
95 // @ts-ignore 95 // @ts-ignore
96 Server.client.logObjectTrace(messageOrDataObject); 96 Server.client.logObjectTrace(messageOrDataObject);
97 } 97 }
98 } 98 },
99 }; 99 };
100 Server.client.registerProposedFeatures(); 100 Server.client.registerProposedFeatures();
101 Server.client.onReady().then(() => { 101 Server.client.onReady().then(() => {
diff --git a/editors/code/src/test/utils/diagnotics/SuggestedFix.test.ts b/editors/code/src/test/utils/diagnotics/SuggestedFix.test.ts
index 6c7f436f3..96ec8c614 100644
--- a/editors/code/src/test/utils/diagnotics/SuggestedFix.test.ts
+++ b/editors/code/src/test/utils/diagnotics/SuggestedFix.test.ts
@@ -6,12 +6,12 @@ import SuggestedFix from '../../../utils/diagnostics/SuggestedFix';
6 6
7const location1 = new vscode.Location( 7const location1 = new vscode.Location(
8 vscode.Uri.file('/file/1'), 8 vscode.Uri.file('/file/1'),
9 new vscode.Range(new vscode.Position(1, 2), new vscode.Position(3, 4)) 9 new vscode.Range(new vscode.Position(1, 2), new vscode.Position(3, 4)),
10); 10);
11 11
12const location2 = new vscode.Location( 12const location2 = new vscode.Location(
13 vscode.Uri.file('/file/2'), 13 vscode.Uri.file('/file/2'),
14 new vscode.Range(new vscode.Position(5, 6), new vscode.Position(7, 8)) 14 new vscode.Range(new vscode.Position(5, 6), new vscode.Position(7, 8)),
15); 15);
16 16
17describe('SuggestedFix', () => { 17describe('SuggestedFix', () => {
@@ -20,13 +20,13 @@ describe('SuggestedFix', () => {
20 const suggestion1 = new SuggestedFix( 20 const suggestion1 = new SuggestedFix(
21 'Replace me!', 21 'Replace me!',
22 location1, 22 location1,
23 'With this!' 23 'With this!',
24 ); 24 );
25 25
26 const suggestion2 = new SuggestedFix( 26 const suggestion2 = new SuggestedFix(
27 'Replace me!', 27 'Replace me!',
28 location1, 28 location1,
29 'With this!' 29 'With this!',
30 ); 30 );
31 31
32 assert(suggestion1.isEqual(suggestion2)); 32 assert(suggestion1.isEqual(suggestion2));
@@ -36,13 +36,13 @@ describe('SuggestedFix', () => {
36 const suggestion1 = new SuggestedFix( 36 const suggestion1 = new SuggestedFix(
37 'Replace me!', 37 'Replace me!',
38 location1, 38 location1,
39 'With this!' 39 'With this!',
40 ); 40 );
41 41
42 const suggestion2 = new SuggestedFix( 42 const suggestion2 = new SuggestedFix(
43 'Not the same title!', 43 'Not the same title!',
44 location1, 44 location1,
45 'With this!' 45 'With this!',
46 ); 46 );
47 47
48 assert(!suggestion1.isEqual(suggestion2)); 48 assert(!suggestion1.isEqual(suggestion2));
@@ -52,13 +52,13 @@ describe('SuggestedFix', () => {
52 const suggestion1 = new SuggestedFix( 52 const suggestion1 = new SuggestedFix(
53 'Replace me!', 53 'Replace me!',
54 location1, 54 location1,
55 'With this!' 55 'With this!',
56 ); 56 );
57 57
58 const suggestion2 = new SuggestedFix( 58 const suggestion2 = new SuggestedFix(
59 'Replace me!', 59 'Replace me!',
60 location1, 60 location1,
61 'With something else!' 61 'With something else!',
62 ); 62 );
63 63
64 assert(!suggestion1.isEqual(suggestion2)); 64 assert(!suggestion1.isEqual(suggestion2));
@@ -68,13 +68,13 @@ describe('SuggestedFix', () => {
68 const suggestion1 = new SuggestedFix( 68 const suggestion1 = new SuggestedFix(
69 'Replace me!', 69 'Replace me!',
70 location1, 70 location1,
71 'With this!' 71 'With this!',
72 ); 72 );
73 73
74 const suggestion2 = new SuggestedFix( 74 const suggestion2 = new SuggestedFix(
75 'Replace me!', 75 'Replace me!',
76 location2, 76 location2,
77 'With this!' 77 'With this!',
78 ); 78 );
79 79
80 assert(!suggestion1.isEqual(suggestion2)); 80 assert(!suggestion1.isEqual(suggestion2));
@@ -85,14 +85,14 @@ describe('SuggestedFix', () => {
85 'Replace me!', 85 'Replace me!',
86 location1, 86 location1,
87 'With this!', 87 'With this!',
88 SuggestionApplicability.MachineApplicable 88 SuggestionApplicability.MachineApplicable,
89 ); 89 );
90 90
91 const suggestion2 = new SuggestedFix( 91 const suggestion2 = new SuggestedFix(
92 'Replace me!', 92 'Replace me!',
93 location2, 93 location2,
94 'With this!', 94 'With this!',
95 SuggestionApplicability.HasPlaceholders 95 SuggestionApplicability.HasPlaceholders,
96 ); 96 );
97 97
98 assert(!suggestion1.isEqual(suggestion2)); 98 assert(!suggestion1.isEqual(suggestion2));
@@ -104,7 +104,7 @@ describe('SuggestedFix', () => {
104 const suggestion = new SuggestedFix( 104 const suggestion = new SuggestedFix(
105 'Replace me!', 105 'Replace me!',
106 location1, 106 location1,
107 'With this!' 107 'With this!',
108 ); 108 );
109 109
110 const codeAction = suggestion.toCodeAction(); 110 const codeAction = suggestion.toCodeAction();
diff --git a/editors/code/src/test/utils/diagnotics/SuggestedFixCollection.test.ts b/editors/code/src/test/utils/diagnotics/SuggestedFixCollection.test.ts
index f0328893e..4c1467b57 100644
--- a/editors/code/src/test/utils/diagnotics/SuggestedFixCollection.test.ts
+++ b/editors/code/src/test/utils/diagnotics/SuggestedFixCollection.test.ts
@@ -8,20 +8,20 @@ const uri1 = vscode.Uri.file('/file/1');
8const uri2 = vscode.Uri.file('/file/2'); 8const uri2 = vscode.Uri.file('/file/2');
9 9
10const mockDocument1 = ({ 10const mockDocument1 = ({
11 uri: uri1 11 uri: uri1,
12} as unknown) as vscode.TextDocument; 12} as unknown) as vscode.TextDocument;
13 13
14const mockDocument2 = ({ 14const mockDocument2 = ({
15 uri: uri2 15 uri: uri2,
16} as unknown) as vscode.TextDocument; 16} as unknown) as vscode.TextDocument;
17 17
18const range1 = new vscode.Range( 18const range1 = new vscode.Range(
19 new vscode.Position(1, 2), 19 new vscode.Position(1, 2),
20 new vscode.Position(3, 4) 20 new vscode.Position(3, 4),
21); 21);
22const range2 = new vscode.Range( 22const range2 = new vscode.Range(
23 new vscode.Position(5, 6), 23 new vscode.Position(5, 6),
24 new vscode.Position(7, 8) 24 new vscode.Position(7, 8),
25); 25);
26 26
27const diagnostic1 = new vscode.Diagnostic(range1, 'First diagnostic'); 27const diagnostic1 = new vscode.Diagnostic(range1, 'First diagnostic');
@@ -32,7 +32,7 @@ function suggestion1(): SuggestedFix {
32 return new SuggestedFix( 32 return new SuggestedFix(
33 'Replace me!', 33 'Replace me!',
34 new vscode.Location(uri1, range1), 34 new vscode.Location(uri1, range1),
35 'With this!' 35 'With this!',
36 ); 36 );
37} 37}
38 38
@@ -44,7 +44,7 @@ describe('SuggestedFixCollection', () => {
44 // Specify the document and range that exactly matches 44 // Specify the document and range that exactly matches
45 const codeActions = suggestedFixes.provideCodeActions( 45 const codeActions = suggestedFixes.provideCodeActions(
46 mockDocument1, 46 mockDocument1,
47 range1 47 range1,
48 ); 48 );
49 49
50 assert.strictEqual(codeActions.length, 1); 50 assert.strictEqual(codeActions.length, 1);
@@ -66,7 +66,7 @@ describe('SuggestedFixCollection', () => {
66 66
67 const codeActions = suggestedFixes.provideCodeActions( 67 const codeActions = suggestedFixes.provideCodeActions(
68 mockDocument1, 68 mockDocument1,
69 range2 69 range2,
70 ); 70 );
71 71
72 assert(!codeActions || codeActions.length === 0); 72 assert(!codeActions || codeActions.length === 0);
@@ -78,7 +78,7 @@ describe('SuggestedFixCollection', () => {
78 78
79 const codeActions = suggestedFixes.provideCodeActions( 79 const codeActions = suggestedFixes.provideCodeActions(
80 mockDocument2, 80 mockDocument2,
81 range1 81 range1,
82 ); 82 );
83 83
84 assert(!codeActions || codeActions.length === 0); 84 assert(!codeActions || codeActions.length === 0);
@@ -91,7 +91,7 @@ describe('SuggestedFixCollection', () => {
91 91
92 const codeActions = suggestedFixes.provideCodeActions( 92 const codeActions = suggestedFixes.provideCodeActions(
93 mockDocument1, 93 mockDocument1,
94 range1 94 range1,
95 ); 95 );
96 96
97 assert(!codeActions || codeActions.length === 0); 97 assert(!codeActions || codeActions.length === 0);
@@ -106,7 +106,7 @@ describe('SuggestedFixCollection', () => {
106 106
107 const codeActions = suggestedFixes.provideCodeActions( 107 const codeActions = suggestedFixes.provideCodeActions(
108 mockDocument1, 108 mockDocument1,
109 range1 109 range1,
110 ); 110 );
111 111
112 assert.strictEqual(codeActions.length, 1); 112 assert.strictEqual(codeActions.length, 1);
diff --git a/editors/code/src/test/utils/diagnotics/rust.test.ts b/editors/code/src/test/utils/diagnotics/rust.test.ts
index 327d15046..cee59061f 100644
--- a/editors/code/src/test/utils/diagnotics/rust.test.ts
+++ b/editors/code/src/test/utils/diagnotics/rust.test.ts
@@ -6,14 +6,14 @@ import {
6 MappedRustDiagnostic, 6 MappedRustDiagnostic,
7 mapRustDiagnosticToVsCode, 7 mapRustDiagnosticToVsCode,
8 RustDiagnostic, 8 RustDiagnostic,
9 SuggestionApplicability 9 SuggestionApplicability,
10} from '../../../utils/diagnostics/rust'; 10} from '../../../utils/diagnostics/rust';
11 11
12function loadDiagnosticFixture(name: string): RustDiagnostic { 12function loadDiagnosticFixture(name: string): RustDiagnostic {
13 const jsonText = fs 13 const jsonText = fs
14 .readFileSync( 14 .readFileSync(
15 // We're actually in our JavaScript output directory, climb out 15 // We're actually in our JavaScript output directory, climb out
16 `${__dirname}/../../../../src/test/fixtures/rust-diagnostics/${name}.json` 16 `${__dirname}/../../../../src/test/fixtures/rust-diagnostics/${name}.json`,
17 ) 17 )
18 .toString(); 18 .toString();
19 19
@@ -33,12 +33,12 @@ function mapFixtureToVsCode(name: string): MappedRustDiagnostic {
33describe('mapRustDiagnosticToVsCode', () => { 33describe('mapRustDiagnosticToVsCode', () => {
34 it('should map an incompatible type for trait error', () => { 34 it('should map an incompatible type for trait error', () => {
35 const { diagnostic, suggestedFixes } = mapFixtureToVsCode( 35 const { diagnostic, suggestedFixes } = mapFixtureToVsCode(
36 'error/E0053' 36 'error/E0053',
37 ); 37 );
38 38
39 assert.strictEqual( 39 assert.strictEqual(
40 diagnostic.severity, 40 diagnostic.severity,
41 vscode.DiagnosticSeverity.Error 41 vscode.DiagnosticSeverity.Error,
42 ); 42 );
43 assert.strictEqual(diagnostic.source, 'rustc'); 43 assert.strictEqual(diagnostic.source, 'rustc');
44 assert.strictEqual( 44 assert.strictEqual(
@@ -46,8 +46,8 @@ describe('mapRustDiagnosticToVsCode', () => {
46 [ 46 [
47 `method \`next\` has an incompatible type for trait`, 47 `method \`next\` has an incompatible type for trait`,
48 `expected type \`fn(&mut ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&ty::Ref<M>>\``, 48 `expected type \`fn(&mut ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&ty::Ref<M>>\``,
49 ` found type \`fn(&ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&'list ty::Ref<M>>\`` 49 ` found type \`fn(&ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&'list ty::Ref<M>>\``,
50 ].join('\n') 50 ].join('\n'),
51 ); 51 );
52 assert.strictEqual(diagnostic.code, 'E0053'); 52 assert.strictEqual(diagnostic.code, 'E0053');
53 assert.deepStrictEqual(diagnostic.tags, []); 53 assert.deepStrictEqual(diagnostic.tags, []);
@@ -61,24 +61,24 @@ describe('mapRustDiagnosticToVsCode', () => {
61 61
62 it('should map an unused variable warning', () => { 62 it('should map an unused variable warning', () => {
63 const { diagnostic, suggestedFixes } = mapFixtureToVsCode( 63 const { diagnostic, suggestedFixes } = mapFixtureToVsCode(
64 'warning/unused_variables' 64 'warning/unused_variables',
65 ); 65 );
66 66
67 assert.strictEqual( 67 assert.strictEqual(
68 diagnostic.severity, 68 diagnostic.severity,
69 vscode.DiagnosticSeverity.Warning 69 vscode.DiagnosticSeverity.Warning,
70 ); 70 );
71 assert.strictEqual( 71 assert.strictEqual(
72 diagnostic.message, 72 diagnostic.message,
73 [ 73 [
74 'unused variable: `foo`', 74 'unused variable: `foo`',
75 '#[warn(unused_variables)] on by default' 75 '#[warn(unused_variables)] on by default',
76 ].join('\n') 76 ].join('\n'),
77 ); 77 );
78 assert.strictEqual(diagnostic.code, 'unused_variables'); 78 assert.strictEqual(diagnostic.code, 'unused_variables');
79 assert.strictEqual(diagnostic.source, 'rustc'); 79 assert.strictEqual(diagnostic.source, 'rustc');
80 assert.deepStrictEqual(diagnostic.tags, [ 80 assert.deepStrictEqual(diagnostic.tags, [
81 vscode.DiagnosticTag.Unnecessary 81 vscode.DiagnosticTag.Unnecessary,
82 ]); 82 ]);
83 83
84 // No related information 84 // No related information
@@ -89,29 +89,29 @@ describe('mapRustDiagnosticToVsCode', () => {
89 const [suggestedFix] = suggestedFixes; 89 const [suggestedFix] = suggestedFixes;
90 assert.strictEqual( 90 assert.strictEqual(
91 suggestedFix.title, 91 suggestedFix.title,
92 'consider prefixing with an underscore: `_foo`' 92 'consider prefixing with an underscore: `_foo`',
93 ); 93 );
94 assert.strictEqual( 94 assert.strictEqual(
95 suggestedFix.applicability, 95 suggestedFix.applicability,
96 SuggestionApplicability.MachineApplicable 96 SuggestionApplicability.MachineApplicable,
97 ); 97 );
98 }); 98 });
99 99
100 it('should map a wrong number of parameters error', () => { 100 it('should map a wrong number of parameters error', () => {
101 const { diagnostic, suggestedFixes } = mapFixtureToVsCode( 101 const { diagnostic, suggestedFixes } = mapFixtureToVsCode(
102 'error/E0061' 102 'error/E0061',
103 ); 103 );
104 104
105 assert.strictEqual( 105 assert.strictEqual(
106 diagnostic.severity, 106 diagnostic.severity,
107 vscode.DiagnosticSeverity.Error 107 vscode.DiagnosticSeverity.Error,
108 ); 108 );
109 assert.strictEqual( 109 assert.strictEqual(
110 diagnostic.message, 110 diagnostic.message,
111 [ 111 [
112 'this function takes 2 parameters but 3 parameters were supplied', 112 'this function takes 2 parameters but 3 parameters were supplied',
113 'expected 2 parameters' 113 'expected 2 parameters',
114 ].join('\n') 114 ].join('\n'),
115 ); 115 );
116 assert.strictEqual(diagnostic.code, 'E0061'); 116 assert.strictEqual(diagnostic.code, 'E0061');
117 assert.strictEqual(diagnostic.source, 'rustc'); 117 assert.strictEqual(diagnostic.source, 'rustc');
@@ -132,12 +132,12 @@ describe('mapRustDiagnosticToVsCode', () => {
132 132
133 it('should map a Clippy copy pass by ref warning', () => { 133 it('should map a Clippy copy pass by ref warning', () => {
134 const { diagnostic, suggestedFixes } = mapFixtureToVsCode( 134 const { diagnostic, suggestedFixes } = mapFixtureToVsCode(
135 'clippy/trivially_copy_pass_by_ref' 135 'clippy/trivially_copy_pass_by_ref',
136 ); 136 );
137 137
138 assert.strictEqual( 138 assert.strictEqual(
139 diagnostic.severity, 139 diagnostic.severity,
140 vscode.DiagnosticSeverity.Warning 140 vscode.DiagnosticSeverity.Warning,
141 ); 141 );
142 assert.strictEqual(diagnostic.source, 'clippy'); 142 assert.strictEqual(diagnostic.source, 'clippy');
143 assert.strictEqual( 143 assert.strictEqual(
@@ -145,8 +145,8 @@ describe('mapRustDiagnosticToVsCode', () => {
145 [ 145 [
146 'this argument is passed by reference, but would be more efficient if passed by value', 146 'this argument is passed by reference, but would be more efficient if passed by value',
147 '#[warn(clippy::trivially_copy_pass_by_ref)] implied by #[warn(clippy::all)]', 147 '#[warn(clippy::trivially_copy_pass_by_ref)] implied by #[warn(clippy::all)]',
148 'for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref' 148 'for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref',
149 ].join('\n') 149 ].join('\n'),
150 ); 150 );
151 assert.strictEqual(diagnostic.code, 'trivially_copy_pass_by_ref'); 151 assert.strictEqual(diagnostic.code, 'trivially_copy_pass_by_ref');
152 assert.deepStrictEqual(diagnostic.tags, []); 152 assert.deepStrictEqual(diagnostic.tags, []);
@@ -165,27 +165,27 @@ describe('mapRustDiagnosticToVsCode', () => {
165 const [suggestedFix] = suggestedFixes; 165 const [suggestedFix] = suggestedFixes;
166 assert.strictEqual( 166 assert.strictEqual(
167 suggestedFix.title, 167 suggestedFix.title,
168 'consider passing by value instead: `self`' 168 'consider passing by value instead: `self`',
169 ); 169 );
170 // Clippy does not mark this with any applicability 170 // Clippy does not mark this with any applicability
171 assert.strictEqual( 171 assert.strictEqual(
172 suggestedFix.applicability, 172 suggestedFix.applicability,
173 SuggestionApplicability.Unspecified 173 SuggestionApplicability.Unspecified,
174 ); 174 );
175 }); 175 });
176 176
177 it('should map a mismatched type error', () => { 177 it('should map a mismatched type error', () => {
178 const { diagnostic, suggestedFixes } = mapFixtureToVsCode( 178 const { diagnostic, suggestedFixes } = mapFixtureToVsCode(
179 'error/E0308' 179 'error/E0308',
180 ); 180 );
181 181
182 assert.strictEqual( 182 assert.strictEqual(
183 diagnostic.severity, 183 diagnostic.severity,
184 vscode.DiagnosticSeverity.Error 184 vscode.DiagnosticSeverity.Error,
185 ); 185 );
186 assert.strictEqual( 186 assert.strictEqual(
187 diagnostic.message, 187 diagnostic.message,
188 ['mismatched types', 'expected usize, found u32'].join('\n') 188 ['mismatched types', 'expected usize, found u32'].join('\n'),
189 ); 189 );
190 assert.strictEqual(diagnostic.code, 'E0308'); 190 assert.strictEqual(diagnostic.code, 'E0308');
191 assert.strictEqual(diagnostic.source, 'rustc'); 191 assert.strictEqual(diagnostic.source, 'rustc');
diff --git a/editors/code/src/test/utils/diagnotics/vscode.test.ts b/editors/code/src/test/utils/diagnotics/vscode.test.ts
index 542dec1f5..4944dd032 100644
--- a/editors/code/src/test/utils/diagnotics/vscode.test.ts
+++ b/editors/code/src/test/utils/diagnotics/vscode.test.ts
@@ -5,12 +5,12 @@ import { areDiagnosticsEqual } from '../../../utils/diagnostics/vscode';
5 5
6const range1 = new vscode.Range( 6const range1 = new vscode.Range(
7 new vscode.Position(1, 2), 7 new vscode.Position(1, 2),
8 new vscode.Position(3, 4) 8 new vscode.Position(3, 4),
9); 9);
10 10
11const range2 = new vscode.Range( 11const range2 = new vscode.Range(
12 new vscode.Position(5, 6), 12 new vscode.Position(5, 6),
13 new vscode.Position(7, 8) 13 new vscode.Position(7, 8),
14); 14);
15 15
16describe('areDiagnosticsEqual', () => { 16describe('areDiagnosticsEqual', () => {
@@ -18,13 +18,13 @@ describe('areDiagnosticsEqual', () => {
18 const diagnostic1 = new vscode.Diagnostic( 18 const diagnostic1 = new vscode.Diagnostic(
19 range1, 19 range1,
20 'Hello, world!', 20 'Hello, world!',
21 vscode.DiagnosticSeverity.Error 21 vscode.DiagnosticSeverity.Error,
22 ); 22 );
23 23
24 const diagnostic2 = new vscode.Diagnostic( 24 const diagnostic2 = new vscode.Diagnostic(
25 range1, 25 range1,
26 'Hello, world!', 26 'Hello, world!',
27 vscode.DiagnosticSeverity.Error 27 vscode.DiagnosticSeverity.Error,
28 ); 28 );
29 29
30 assert(areDiagnosticsEqual(diagnostic1, diagnostic2)); 30 assert(areDiagnosticsEqual(diagnostic1, diagnostic2));
@@ -34,14 +34,14 @@ describe('areDiagnosticsEqual', () => {
34 const diagnostic1 = new vscode.Diagnostic( 34 const diagnostic1 = new vscode.Diagnostic(
35 range1, 35 range1,
36 'Hello, world!', 36 'Hello, world!',
37 vscode.DiagnosticSeverity.Error 37 vscode.DiagnosticSeverity.Error,
38 ); 38 );
39 diagnostic1.source = 'rustc'; 39 diagnostic1.source = 'rustc';
40 40
41 const diagnostic2 = new vscode.Diagnostic( 41 const diagnostic2 = new vscode.Diagnostic(
42 range1, 42 range1,
43 'Hello, world!', 43 'Hello, world!',
44 vscode.DiagnosticSeverity.Error 44 vscode.DiagnosticSeverity.Error,
45 ); 45 );
46 diagnostic2.source = 'clippy'; 46 diagnostic2.source = 'clippy';
47 47
@@ -52,13 +52,13 @@ describe('areDiagnosticsEqual', () => {
52 const diagnostic1 = new vscode.Diagnostic( 52 const diagnostic1 = new vscode.Diagnostic(
53 range1, 53 range1,
54 'Hello, world!', 54 'Hello, world!',
55 vscode.DiagnosticSeverity.Error 55 vscode.DiagnosticSeverity.Error,
56 ); 56 );
57 57
58 const diagnostic2 = new vscode.Diagnostic( 58 const diagnostic2 = new vscode.Diagnostic(
59 range2, 59 range2,
60 'Hello, world!', 60 'Hello, world!',
61 vscode.DiagnosticSeverity.Error 61 vscode.DiagnosticSeverity.Error,
62 ); 62 );
63 63
64 assert(!areDiagnosticsEqual(diagnostic1, diagnostic2)); 64 assert(!areDiagnosticsEqual(diagnostic1, diagnostic2));
@@ -68,13 +68,13 @@ describe('areDiagnosticsEqual', () => {
68 const diagnostic1 = new vscode.Diagnostic( 68 const diagnostic1 = new vscode.Diagnostic(
69 range1, 69 range1,
70 'Hello, world!', 70 'Hello, world!',
71 vscode.DiagnosticSeverity.Error 71 vscode.DiagnosticSeverity.Error,
72 ); 72 );
73 73
74 const diagnostic2 = new vscode.Diagnostic( 74 const diagnostic2 = new vscode.Diagnostic(
75 range1, 75 range1,
76 'Goodbye!, world!', 76 'Goodbye!, world!',
77 vscode.DiagnosticSeverity.Error 77 vscode.DiagnosticSeverity.Error,
78 ); 78 );
79 79
80 assert(!areDiagnosticsEqual(diagnostic1, diagnostic2)); 80 assert(!areDiagnosticsEqual(diagnostic1, diagnostic2));
@@ -84,13 +84,13 @@ describe('areDiagnosticsEqual', () => {
84 const diagnostic1 = new vscode.Diagnostic( 84 const diagnostic1 = new vscode.Diagnostic(
85 range1, 85 range1,
86 'Hello, world!', 86 'Hello, world!',
87 vscode.DiagnosticSeverity.Warning 87 vscode.DiagnosticSeverity.Warning,
88 ); 88 );
89 89
90 const diagnostic2 = new vscode.Diagnostic( 90 const diagnostic2 = new vscode.Diagnostic(
91 range1, 91 range1,
92 'Hello, world!', 92 'Hello, world!',
93 vscode.DiagnosticSeverity.Error 93 vscode.DiagnosticSeverity.Error,
94 ); 94 );
95 95
96 assert(!areDiagnosticsEqual(diagnostic1, diagnostic2)); 96 assert(!areDiagnosticsEqual(diagnostic1, diagnostic2));
diff --git a/editors/code/src/test/utils/index.ts b/editors/code/src/test/utils/index.ts
index 16715a286..9927daaf6 100644
--- a/editors/code/src/test/utils/index.ts
+++ b/editors/code/src/test/utils/index.ts
@@ -17,7 +17,7 @@ import * as path from 'path';
17export function run(): Promise<void> { 17export function run(): Promise<void> {
18 // Create the mocha test 18 // Create the mocha test
19 const mocha = new Mocha({ 19 const mocha = new Mocha({
20 ui: 'bdd' 20 ui: 'bdd',
21 }); 21 });
22 mocha.useColors(true); 22 mocha.useColors(true);
23 23
diff --git a/editors/code/src/utils/diagnostics/SuggestedFix.ts b/editors/code/src/utils/diagnostics/SuggestedFix.ts
index b1be2a225..6e660bb61 100644
--- a/editors/code/src/utils/diagnostics/SuggestedFix.ts
+++ b/editors/code/src/utils/diagnostics/SuggestedFix.ts
@@ -24,7 +24,7 @@ export default class SuggestedFix {
24 title: string, 24 title: string,
25 location: vscode.Location, 25 location: vscode.Location,
26 replacement: string, 26 replacement: string,
27 applicability: SuggestionApplicability = SuggestionApplicability.Unspecified 27 applicability: SuggestionApplicability = SuggestionApplicability.Unspecified,
28 ) { 28 ) {
29 this.title = title; 29 this.title = title;
30 this.location = location; 30 this.location = location;
@@ -51,7 +51,7 @@ export default class SuggestedFix {
51 public toCodeAction(): vscode.CodeAction { 51 public toCodeAction(): vscode.CodeAction {
52 const codeAction = new vscode.CodeAction( 52 const codeAction = new vscode.CodeAction(
53 this.title, 53 this.title,
54 vscode.CodeActionKind.QuickFix 54 vscode.CodeActionKind.QuickFix,
55 ); 55 );
56 56
57 const edit = new vscode.WorkspaceEdit(); 57 const edit = new vscode.WorkspaceEdit();
diff --git a/editors/code/src/utils/diagnostics/SuggestedFixCollection.ts b/editors/code/src/utils/diagnostics/SuggestedFixCollection.ts
index 132ce12f8..57c9856cf 100644
--- a/editors/code/src/utils/diagnostics/SuggestedFixCollection.ts
+++ b/editors/code/src/utils/diagnostics/SuggestedFixCollection.ts
@@ -38,13 +38,13 @@ export default class SuggestedFixCollection
38 */ 38 */
39 public addSuggestedFixForDiagnostic( 39 public addSuggestedFixForDiagnostic(
40 suggestedFix: SuggestedFix, 40 suggestedFix: SuggestedFix,
41 diagnostic: vscode.Diagnostic 41 diagnostic: vscode.Diagnostic,
42 ): void { 42 ): void {
43 const fileUriString = suggestedFix.location.uri.toString(); 43 const fileUriString = suggestedFix.location.uri.toString();
44 const fileSuggestions = this.suggestedFixes.get(fileUriString) || []; 44 const fileSuggestions = this.suggestedFixes.get(fileUriString) || [];
45 45
46 const existingSuggestion = fileSuggestions.find(s => 46 const existingSuggestion = fileSuggestions.find(s =>
47 s.isEqual(suggestedFix) 47 s.isEqual(suggestedFix),
48 ); 48 );
49 49
50 if (existingSuggestion) { 50 if (existingSuggestion) {
@@ -65,7 +65,7 @@ export default class SuggestedFixCollection
65 */ 65 */
66 public provideCodeActions( 66 public provideCodeActions(
67 document: vscode.TextDocument, 67 document: vscode.TextDocument,
68 range: vscode.Range 68 range: vscode.Range,
69 ): vscode.CodeAction[] { 69 ): vscode.CodeAction[] {
70 const documentUriString = document.uri.toString(); 70 const documentUriString = document.uri.toString();
71 71
diff --git a/editors/code/src/utils/diagnostics/rust.ts b/editors/code/src/utils/diagnostics/rust.ts
index 0550d0372..b6efc0f56 100644
--- a/editors/code/src/utils/diagnostics/rust.ts
+++ b/editors/code/src/utils/diagnostics/rust.ts
@@ -7,7 +7,7 @@ export enum SuggestionApplicability {
7 MachineApplicable = 'MachineApplicable', 7 MachineApplicable = 'MachineApplicable',
8 HasPlaceholders = 'HasPlaceholders', 8 HasPlaceholders = 'HasPlaceholders',
9 MaybeIncorrect = 'MaybeIncorrect', 9 MaybeIncorrect = 'MaybeIncorrect',
10 Unspecified = 'Unspecified' 10 Unspecified = 'Unspecified',
11} 11}
12 12
13// Reference: 13// Reference:
@@ -69,7 +69,7 @@ function mapSpanToLocation(span: RustDiagnosticSpan): vscode.Location {
69 69
70 const range = new vscode.Range( 70 const range = new vscode.Range(
71 new vscode.Position(span.line_start - 1, span.column_start - 1), 71 new vscode.Position(span.line_start - 1, span.column_start - 1),
72 new vscode.Position(span.line_end - 1, span.column_end - 1) 72 new vscode.Position(span.line_end - 1, span.column_end - 1),
73 ); 73 );
74 74
75 return new vscode.Location(fileUri, range); 75 return new vscode.Location(fileUri, range);
@@ -81,7 +81,7 @@ function mapSpanToLocation(span: RustDiagnosticSpan): vscode.Location {
81 * If the span is unlabelled this will return `undefined`. 81 * If the span is unlabelled this will return `undefined`.
82 */ 82 */
83function mapSecondarySpanToRelated( 83function mapSecondarySpanToRelated(
84 span: RustDiagnosticSpan 84 span: RustDiagnosticSpan,
85): vscode.DiagnosticRelatedInformation | undefined { 85): vscode.DiagnosticRelatedInformation | undefined {
86 if (!span.label) { 86 if (!span.label) {
87 // Nothing to label this with 87 // Nothing to label this with
@@ -107,7 +107,7 @@ function isUnusedOrUnnecessary(rd: RustDiagnostic): boolean {
107 'unused_attributes', 107 'unused_attributes',
108 'unused_imports', 108 'unused_imports',
109 'unused_macros', 109 'unused_macros',
110 'unused_variables' 110 'unused_variables',
111 ].includes(rd.code.code); 111 ].includes(rd.code.code);
112} 112}
113 113
@@ -157,13 +157,13 @@ function mapRustChildDiagnostic(rd: RustDiagnostic): MappedRustChildDiagnostic {
157 title, 157 title,
158 location, 158 location,
159 span.suggested_replacement, 159 span.suggested_replacement,
160 span.suggestion_applicability 160 span.suggestion_applicability,
161 ) 161 ),
162 }; 162 };
163 } else { 163 } else {
164 const related = new vscode.DiagnosticRelatedInformation( 164 const related = new vscode.DiagnosticRelatedInformation(
165 location, 165 location,
166 rd.message 166 rd.message,
167 ); 167 );
168 168
169 return { related }; 169 return { related };
@@ -183,7 +183,7 @@ function mapRustChildDiagnostic(rd: RustDiagnostic): MappedRustChildDiagnostic {
183 * If the diagnostic has no primary span this will return `undefined` 183 * If the diagnostic has no primary span this will return `undefined`
184 */ 184 */
185export function mapRustDiagnosticToVsCode( 185export function mapRustDiagnosticToVsCode(
186 rd: RustDiagnostic 186 rd: RustDiagnostic,
187): MappedRustDiagnostic | undefined { 187): MappedRustDiagnostic | undefined {
188 const primarySpan = rd.spans.find(s => s.is_primary); 188 const primarySpan = rd.spans.find(s => s.is_primary);
189 if (!primarySpan) { 189 if (!primarySpan) {
@@ -223,7 +223,7 @@ export function mapRustDiagnosticToVsCode(
223 const suggestedFixes = []; 223 const suggestedFixes = [];
224 for (const child of rd.children) { 224 for (const child of rd.children) {
225 const { related, suggestedFix, messageLine } = mapRustChildDiagnostic( 225 const { related, suggestedFix, messageLine } = mapRustChildDiagnostic(
226 child 226 child,
227 ); 227 );
228 228
229 if (related) { 229 if (related) {
@@ -256,6 +256,6 @@ export function mapRustDiagnosticToVsCode(
256 return { 256 return {
257 location, 257 location,
258 diagnostic: vd, 258 diagnostic: vd,
259 suggestedFixes 259 suggestedFixes,
260 }; 260 };
261} 261}
diff --git a/editors/code/src/utils/diagnostics/vscode.ts b/editors/code/src/utils/diagnostics/vscode.ts
index d8b85b720..f4a5450e2 100644
--- a/editors/code/src/utils/diagnostics/vscode.ts
+++ b/editors/code/src/utils/diagnostics/vscode.ts
@@ -3,7 +3,7 @@ import * as vscode from 'vscode';
3/** Compares two `vscode.Diagnostic`s for equality */ 3/** Compares two `vscode.Diagnostic`s for equality */
4export function areDiagnosticsEqual( 4export function areDiagnosticsEqual(
5 left: vscode.Diagnostic, 5 left: vscode.Diagnostic,
6 right: vscode.Diagnostic 6 right: vscode.Diagnostic,
7): boolean { 7): boolean {
8 return ( 8 return (
9 left.source === right.source && 9 left.source === right.source &&
diff --git a/editors/code/src/utils/processes.ts b/editors/code/src/utils/processes.ts
index da8be9eb1..a1d6b7eaf 100644
--- a/editors/code/src/utils/processes.ts
+++ b/editors/code/src/utils/processes.ts
@@ -22,7 +22,7 @@ export function terminate(process: ChildProcess, cwd?: string): boolean {
22 // Ignore stderr since this is otherwise piped to parent.stderr 22 // Ignore stderr since this is otherwise piped to parent.stderr
23 // which might be already closed. 23 // which might be already closed.
24 const options: any = { 24 const options: any = {
25 stdio: ['pipe', 'pipe', 'ignore'] 25 stdio: ['pipe', 'pipe', 'ignore'],
26 }; 26 };
27 if (cwd) { 27 if (cwd) {
28 options.cwd = cwd; 28 options.cwd = cwd;
@@ -30,7 +30,7 @@ export function terminate(process: ChildProcess, cwd?: string): boolean {
30 cp.execFileSync( 30 cp.execFileSync(
31 'taskkill', 31 'taskkill',
32 ['/T', '/F', '/PID', process.pid.toString()], 32 ['/T', '/F', '/PID', process.pid.toString()],
33 options 33 options,
34 ); 34 );
35 return true; 35 return true;
36 } catch (err) { 36 } catch (err) {