aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/code/.vscodeignore2
-rw-r--r--editors/code/package.json2
-rw-r--r--editors/code/rollup.config.js4
-rw-r--r--editors/code/src/commands/analyzer_status.ts61
-rw-r--r--editors/code/src/main.ts (renamed from editors/code/src/extension.ts)0
5 files changed, 33 insertions, 36 deletions
diff --git a/editors/code/.vscodeignore b/editors/code/.vscodeignore
index f2c4d3307..9bcd28e61 100644
--- a/editors/code/.vscodeignore
+++ b/editors/code/.vscodeignore
@@ -1,4 +1,4 @@
1** 1**
2!out/extension.js 2!out/main.js
3!package.json 3!package.json
4!package-lock.json 4!package-lock.json
diff --git a/editors/code/package.json b/editors/code/package.json
index 8c480cc3f..d14a36f8c 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -43,7 +43,7 @@
43 "onCommand:rust-analyzer.collectGarbage", 43 "onCommand:rust-analyzer.collectGarbage",
44 "workspaceContains:**/Cargo.toml" 44 "workspaceContains:**/Cargo.toml"
45 ], 45 ],
46 "main": "./out/extension", 46 "main": "./out/main",
47 "contributes": { 47 "contributes": {
48 "taskDefinitions": [ 48 "taskDefinitions": [
49 { 49 {
diff --git a/editors/code/rollup.config.js b/editors/code/rollup.config.js
index e4b21afbd..4c001f899 100644
--- a/editors/code/rollup.config.js
+++ b/editors/code/rollup.config.js
@@ -4,7 +4,7 @@ import commonjs from '@rollup/plugin-commonjs';
4import nodeBuiltins from 'builtin-modules'; 4import nodeBuiltins from 'builtin-modules';
5 5
6export default { 6export default {
7 input: 'src/extension.ts', 7 input: 'src/main.ts',
8 plugins: [ 8 plugins: [
9 typescript(), 9 typescript(),
10 resolve({ 10 resolve({
@@ -19,7 +19,7 @@ export default {
19 ], 19 ],
20 external: [...nodeBuiltins, 'vscode'], 20 external: [...nodeBuiltins, 'vscode'],
21 output: { 21 output: {
22 file: './out/extension.js', 22 file: './out/main.js',
23 format: 'cjs' 23 format: 'cjs'
24 } 24 }
25}; 25};
diff --git a/editors/code/src/commands/analyzer_status.ts b/editors/code/src/commands/analyzer_status.ts
index 2777ced24..5840e8fc0 100644
--- a/editors/code/src/commands/analyzer_status.ts
+++ b/editors/code/src/commands/analyzer_status.ts
@@ -1,41 +1,15 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import { Server } from '../server'; 2import { Server } from '../server';
3
4const statusUri = vscode.Uri.parse('rust-analyzer-status://status');
5
6export class TextDocumentContentProvider
7 implements vscode.TextDocumentContentProvider {
8 public eventEmitter = new vscode.EventEmitter<vscode.Uri>();
9 public syntaxTree: string = 'Not available';
10
11 public provideTextDocumentContent(
12 _uri: vscode.Uri,
13 ): vscode.ProviderResult<string> {
14 const editor = vscode.window.activeTextEditor;
15 if (editor == null) {
16 return '';
17 }
18 return Server.client.sendRequest<string>(
19 'rust-analyzer/analyzerStatus',
20 null,
21 );
22 }
23
24 get onDidChange(): vscode.Event<vscode.Uri> {
25 return this.eventEmitter.event;
26 }
27}
28
29let poller: NodeJS.Timer | null = null;
30
31// Shows status of rust-analyzer (for debugging) 3// Shows status of rust-analyzer (for debugging)
32 4
33export function makeCommand(context: vscode.ExtensionContext) { 5export function makeCommand(context: vscode.ExtensionContext) {
34 const textDocumentContentProvider = new TextDocumentContentProvider(); 6 let poller: NodeJS.Timer | null = null;
7 const tdcp = new TextDocumentContentProvider();
8
35 context.subscriptions.push( 9 context.subscriptions.push(
36 vscode.workspace.registerTextDocumentContentProvider( 10 vscode.workspace.registerTextDocumentContentProvider(
37 'rust-analyzer-status', 11 'rust-analyzer-status',
38 textDocumentContentProvider, 12 tdcp,
39 ), 13 ),
40 ); 14 );
41 15
@@ -50,11 +24,11 @@ export function makeCommand(context: vscode.ExtensionContext) {
50 return async function handle() { 24 return async function handle() {
51 if (poller == null) { 25 if (poller == null) {
52 poller = setInterval( 26 poller = setInterval(
53 () => textDocumentContentProvider.eventEmitter.fire(statusUri), 27 () => tdcp.eventEmitter.fire(tdcp.uri),
54 1000, 28 1000,
55 ); 29 );
56 } 30 }
57 const document = await vscode.workspace.openTextDocument(statusUri); 31 const document = await vscode.workspace.openTextDocument(tdcp.uri);
58 return vscode.window.showTextDocument( 32 return vscode.window.showTextDocument(
59 document, 33 document,
60 vscode.ViewColumn.Two, 34 vscode.ViewColumn.Two,
@@ -62,3 +36,26 @@ export function makeCommand(context: vscode.ExtensionContext) {
62 ); 36 );
63 }; 37 };
64} 38}
39
40class TextDocumentContentProvider
41 implements vscode.TextDocumentContentProvider {
42 uri = vscode.Uri.parse('rust-analyzer-status://status');
43 eventEmitter = new vscode.EventEmitter<vscode.Uri>();
44
45 provideTextDocumentContent(
46 _uri: vscode.Uri,
47 ): vscode.ProviderResult<string> {
48 const editor = vscode.window.activeTextEditor;
49 if (editor == null) {
50 return '';
51 }
52 return Server.client.sendRequest<string>(
53 'rust-analyzer/analyzerStatus',
54 null,
55 );
56 }
57
58 get onDidChange(): vscode.Event<vscode.Uri> {
59 return this.eventEmitter.event;
60 }
61}
diff --git a/editors/code/src/extension.ts b/editors/code/src/main.ts
index 1da10ebd0..1da10ebd0 100644
--- a/editors/code/src/extension.ts
+++ b/editors/code/src/main.ts