aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r--editors/code/src/commands/analyzer_status.ts10
-rw-r--r--editors/code/src/commands/index.ts8
-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.ts7
-rw-r--r--editors/code/src/commands/parent_module.ts2
6 files changed, 17 insertions, 22 deletions
diff --git a/editors/code/src/commands/analyzer_status.ts b/editors/code/src/commands/analyzer_status.ts
index 849c2ec6c..830e40e8f 100644
--- a/editors/code/src/commands/analyzer_status.ts
+++ b/editors/code/src/commands/analyzer_status.ts
@@ -23,10 +23,7 @@ export function analyzerStatus(ctx: Ctx): Cmd {
23 23
24 return async function handle() { 24 return async function handle() {
25 if (poller == null) { 25 if (poller == null) {
26 poller = setInterval( 26 poller = setInterval(() => tdcp.eventEmitter.fire(tdcp.uri), 1000);
27 () => tdcp.eventEmitter.fire(tdcp.uri),
28 1000,
29 );
30 } 27 }
31 const document = await vscode.workspace.openTextDocument(tdcp.uri); 28 const document = await vscode.workspace.openTextDocument(tdcp.uri);
32 return vscode.window.showTextDocument( 29 return vscode.window.showTextDocument(
@@ -39,13 +36,12 @@ export function analyzerStatus(ctx: Ctx): Cmd {
39 36
40class TextDocumentContentProvider 37class TextDocumentContentProvider
41 implements vscode.TextDocumentContentProvider { 38 implements vscode.TextDocumentContentProvider {
42 39 ctx: Ctx;
43 ctx: Ctx
44 uri = vscode.Uri.parse('rust-analyzer-status://status'); 40 uri = vscode.Uri.parse('rust-analyzer-status://status');
45 eventEmitter = new vscode.EventEmitter<vscode.Uri>(); 41 eventEmitter = new vscode.EventEmitter<vscode.Uri>();
46 42
47 constructor(ctx: Ctx) { 43 constructor(ctx: Ctx) {
48 this.ctx = ctx 44 this.ctx = ctx;
49 } 45 }
50 46
51 provideTextDocumentContent( 47 provideTextDocumentContent(
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts
index 03ca58210..a7f3bc4c1 100644
--- a/editors/code/src/commands/index.ts
+++ b/editors/code/src/commands/index.ts
@@ -1,4 +1,4 @@
1import { Ctx, Cmd } from '../ctx' 1import { Ctx, Cmd } from '../ctx';
2 2
3import { analyzerStatus } from './analyzer_status'; 3import { analyzerStatus } from './analyzer_status';
4import { matchingBrace } from './matching_brace'; 4import { matchingBrace } from './matching_brace';
@@ -11,7 +11,9 @@ import * as runnables from './runnables';
11import * as syntaxTree from './syntaxTree'; 11import * as syntaxTree from './syntaxTree';
12 12
13function collectGarbage(ctx: Ctx): Cmd { 13function collectGarbage(ctx: Ctx): Cmd {
14 return async () => { ctx.client.sendRequest<null>('rust-analyzer/collectGarbage', null) } 14 return async () => {
15 ctx.client.sendRequest<null>('rust-analyzer/collectGarbage', null);
16 };
15} 17}
16 18
17export { 19export {
@@ -24,5 +26,5 @@ export {
24 syntaxTree, 26 syntaxTree,
25 onEnter, 27 onEnter,
26 inlayHints, 28 inlayHints,
27 collectGarbage 29 collectGarbage,
28}; 30};
diff --git a/editors/code/src/commands/join_lines.ts b/editors/code/src/commands/join_lines.ts
index 1a4b8a2d8..e906759c1 100644
--- a/editors/code/src/commands/join_lines.ts
+++ b/editors/code/src/commands/join_lines.ts
@@ -1,8 +1,6 @@
1import { Range, TextDocumentIdentifier } from 'vscode-languageclient'; 1import { Range, TextDocumentIdentifier } from 'vscode-languageclient';
2import { Ctx, Cmd } from '../ctx'; 2import { Ctx, Cmd } from '../ctx';
3import { 3import { applySourceChange, SourceChange } from '../source_change';
4 applySourceChange, SourceChange
5} from '../source_change';
6 4
7export function joinLines(ctx: Ctx): Cmd { 5export function joinLines(ctx: Ctx): Cmd {
8 return async () => { 6 return async () => {
@@ -18,7 +16,7 @@ export function joinLines(ctx: Ctx): Cmd {
18 request, 16 request,
19 ); 17 );
20 await applySourceChange(ctx, change); 18 await applySourceChange(ctx, change);
21 } 19 };
22} 20}
23 21
24interface JoinLinesParams { 22interface JoinLinesParams {
diff --git a/editors/code/src/commands/matching_brace.ts b/editors/code/src/commands/matching_brace.ts
index 665b0c33c..a3febc5f4 100644
--- a/editors/code/src/commands/matching_brace.ts
+++ b/editors/code/src/commands/matching_brace.ts
@@ -10,7 +10,9 @@ export function matchingBrace(ctx: Ctx): Cmd {
10 } 10 }
11 const request: FindMatchingBraceParams = { 11 const request: FindMatchingBraceParams = {
12 textDocument: { uri: editor.document.uri.toString() }, 12 textDocument: { uri: editor.document.uri.toString() },
13 offsets: editor.selections.map(s => ctx.client.code2ProtocolConverter.asPosition(s.active)), 13 offsets: editor.selections.map(s =>
14 ctx.client.code2ProtocolConverter.asPosition(s.active),
15 ),
14 }; 16 };
15 const response = await ctx.client.sendRequest<Position[]>( 17 const response = await ctx.client.sendRequest<Position[]>(
16 'rust-analyzer/findMatchingBrace', 18 'rust-analyzer/findMatchingBrace',
@@ -24,7 +26,7 @@ export function matchingBrace(ctx: Ctx): Cmd {
24 return new vscode.Selection(anchor, active); 26 return new vscode.Selection(anchor, active);
25 }); 27 });
26 editor.revealRange(editor.selection); 28 editor.revealRange(editor.selection);
27 } 29 };
28} 30}
29 31
30interface FindMatchingBraceParams { 32interface FindMatchingBraceParams {
diff --git a/editors/code/src/commands/on_enter.ts b/editors/code/src/commands/on_enter.ts
index 4503e13f0..efc0dfe1d 100644
--- a/editors/code/src/commands/on_enter.ts
+++ b/editors/code/src/commands/on_enter.ts
@@ -1,8 +1,5 @@
1import * as lc from 'vscode-languageclient'; 1import * as lc from 'vscode-languageclient';
2import { 2import { applySourceChange, SourceChange } from '../source_change';
3 applySourceChange,
4 SourceChange,
5} from '../source_change';
6import { Cmd, Ctx } from '../ctx'; 3import { Cmd, Ctx } from '../ctx';
7 4
8export function onEnter(ctx: Ctx): Cmd { 5export function onEnter(ctx: Ctx): Cmd {
@@ -24,5 +21,5 @@ export function onEnter(ctx: Ctx): Cmd {
24 21
25 await applySourceChange(ctx, change); 22 await applySourceChange(ctx, change);
26 return true; 23 return true;
27 } 24 };
28} 25}
diff --git a/editors/code/src/commands/parent_module.ts b/editors/code/src/commands/parent_module.ts
index 2f986009e..d641181fa 100644
--- a/editors/code/src/commands/parent_module.ts
+++ b/editors/code/src/commands/parent_module.ts
@@ -28,5 +28,5 @@ export function parentModule(ctx: Ctx): Cmd {
28 const e = await vscode.window.showTextDocument(doc); 28 const e = await vscode.window.showTextDocument(doc);
29 e.selection = new vscode.Selection(range.start, range.start); 29 e.selection = new vscode.Selection(range.start, range.start);
30 e.revealRange(range, vscode.TextEditorRevealType.InCenter); 30 e.revealRange(range, vscode.TextEditorRevealType.InCenter);
31 } 31 };
32} 32}