aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/syntaxTree.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/commands/syntaxTree.ts')
-rw-r--r--editors/code/src/commands/syntaxTree.ts24
1 files changed, 18 insertions, 6 deletions
diff --git a/editors/code/src/commands/syntaxTree.ts b/editors/code/src/commands/syntaxTree.ts
index dcb721eee..5d5cdd7a0 100644
--- a/editors/code/src/commands/syntaxTree.ts
+++ b/editors/code/src/commands/syntaxTree.ts
@@ -5,17 +5,25 @@ import { Server } from '../server';
5 5
6export const syntaxTreeUri = vscode.Uri.parse('ra-lsp://syntaxtree'); 6export const syntaxTreeUri = vscode.Uri.parse('ra-lsp://syntaxtree');
7 7
8export class TextDocumentContentProvider implements vscode.TextDocumentContentProvider { 8export class TextDocumentContentProvider
9 implements vscode.TextDocumentContentProvider {
9 public eventEmitter = new vscode.EventEmitter<vscode.Uri>(); 10 public eventEmitter = new vscode.EventEmitter<vscode.Uri>();
10 public syntaxTree: string = 'Not available'; 11 public syntaxTree: string = 'Not available';
11 12
12 public provideTextDocumentContent(uri: vscode.Uri): vscode.ProviderResult<string> { 13 public provideTextDocumentContent(
14 uri: vscode.Uri
15 ): vscode.ProviderResult<string> {
13 const editor = vscode.window.activeTextEditor; 16 const editor = vscode.window.activeTextEditor;
14 if (editor == null) { return ''; } 17 if (editor == null) {
18 return '';
19 }
15 const request: SyntaxTreeParams = { 20 const request: SyntaxTreeParams = {
16 textDocument: { uri: editor.document.uri.toString() }, 21 textDocument: { uri: editor.document.uri.toString() }
17 }; 22 };
18 return Server.client.sendRequest<SyntaxTreeResult>('m/syntaxTree', request); 23 return Server.client.sendRequest<SyntaxTreeResult>(
24 'm/syntaxTree',
25 request
26 );
19 } 27 }
20 28
21 get onDidChange(): vscode.Event<vscode.Uri> { 29 get onDidChange(): vscode.Event<vscode.Uri> {
@@ -34,5 +42,9 @@ type SyntaxTreeResult = string;
34// The contents of the file come from the `TextDocumentContentProvider` 42// The contents of the file come from the `TextDocumentContentProvider`
35export async function handle() { 43export async function handle() {
36 const document = await vscode.workspace.openTextDocument(syntaxTreeUri); 44 const document = await vscode.workspace.openTextDocument(syntaxTreeUri);
37 return vscode.window.showTextDocument(document, vscode.ViewColumn.Two, true); 45 return vscode.window.showTextDocument(
46 document,
47 vscode.ViewColumn.Two,
48 true
49 );
38} 50}