blob: 64be562250e18fb2bb40eb5b70b48b9d0b445c46 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import { TextEditor } from 'vscode';
import { TextDocumentIdentifier } from 'vscode-languageclient';
import {
SyntaxTreeContentProvider,
syntaxTreeUri
} from '../commands/syntaxTree';
import { Decoration } from '../highlighting';
import { Server } from '../server';
export function makeHandler(syntaxTreeProvider: SyntaxTreeContentProvider) {
return async function handle(editor: TextEditor | undefined) {
if (!editor || editor.document.languageId !== 'rust') {
return;
}
syntaxTreeProvider.eventEmitter.fire(syntaxTreeUri);
if (!Server.config.highlightingOn) {
return;
}
const params: TextDocumentIdentifier = {
uri: editor.document.uri.toString()
};
const decorations = await Server.client.sendRequest<Decoration[]>(
'rust-analyzer/decorationsRequest',
params
);
Server.highlighter.setHighlights(editor, decorations);
};
}
|