aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/syntax_tree.ts
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-12-31 17:51:08 +0000
committerGitHub <[email protected]>2019-12-31 17:51:08 +0000
commitc8b98c46675396c4f9d26c6b001e01c81d84b89e (patch)
tree40582f9bb4331676a0a469b728a5e6cfe1df5300 /editors/code/src/commands/syntax_tree.ts
parent6d23140ba03c77b28d94e042c94155899baba9da (diff)
parentcb41ffbbbdea66d3a0abae4d270da1224a5de91c (diff)
Merge #2710
2710: Fix NPEs r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'editors/code/src/commands/syntax_tree.ts')
-rw-r--r--editors/code/src/commands/syntax_tree.ts9
1 files changed, 4 insertions, 5 deletions
diff --git a/editors/code/src/commands/syntax_tree.ts b/editors/code/src/commands/syntax_tree.ts
index 5b8f6e4d9..2ee80f910 100644
--- a/editors/code/src/commands/syntax_tree.ts
+++ b/editors/code/src/commands/syntax_tree.ts
@@ -76,7 +76,8 @@ class TextDocumentContentProvider
76 76
77 provideTextDocumentContent(uri: vscode.Uri): vscode.ProviderResult<string> { 77 provideTextDocumentContent(uri: vscode.Uri): vscode.ProviderResult<string> {
78 const editor = vscode.window.activeTextEditor; 78 const editor = vscode.window.activeTextEditor;
79 if (editor == null) return ''; 79 const client = this.ctx.client
80 if (!editor || !client) return '';
80 81
81 let range: lc.Range | undefined; 82 let range: lc.Range | undefined;
82 83
@@ -84,16 +85,14 @@ class TextDocumentContentProvider
84 if (uri.query === 'range=true') { 85 if (uri.query === 'range=true') {
85 range = editor.selection.isEmpty 86 range = editor.selection.isEmpty
86 ? undefined 87 ? undefined
87 : this.ctx.client.code2ProtocolConverter.asRange( 88 : client.code2ProtocolConverter.asRange(editor.selection);
88 editor.selection,
89 );
90 } 89 }
91 90
92 const request: SyntaxTreeParams = { 91 const request: SyntaxTreeParams = {
93 textDocument: { uri: editor.document.uri.toString() }, 92 textDocument: { uri: editor.document.uri.toString() },
94 range, 93 range,
95 }; 94 };
96 return this.ctx.client.sendRequest<string>( 95 return client.sendRequest<string>(
97 'rust-analyzer/syntaxTree', 96 'rust-analyzer/syntaxTree',
98 request, 97 request,
99 ); 98 );