@@ -5,7 +5,7 @@ import { Ctx, Cmd } from '../ctx';
5
5
6
6
// Shows status of rust-analyzer (for debugging)
7
7
export function analyzerStatus ( ctx : Ctx ) : Cmd {
8
- let poller : NodeJS . Timer | null = null ;
8
+ let poller : NodeJS . Timer | undefined = undefined ;
9
9
const tdcp = new TextDocumentContentProvider ( ctx ) ;
10
10
11
11
ctx . pushCleanup (
@@ -17,41 +17,32 @@ export function analyzerStatus(ctx: Ctx): Cmd {
17
17
18
18
ctx . pushCleanup ( {
19
19
dispose ( ) {
20
- if ( poller != null ) {
20
+ if ( poller !== undefined ) {
21
21
clearInterval ( poller ) ;
22
22
}
23
23
} ,
24
24
} ) ;
25
25
26
- return async function handle ( ) {
27
- if ( poller == null ) {
26
+ return async ( ) => {
27
+ if ( poller === undefined ) {
28
28
poller = setInterval ( ( ) => tdcp . eventEmitter . fire ( tdcp . uri ) , 1000 ) ;
29
29
}
30
30
const document = await vscode . workspace . openTextDocument ( tdcp . uri ) ;
31
- return vscode . window . showTextDocument (
32
- document ,
33
- vscode . ViewColumn . Two ,
34
- true ,
35
- ) ;
31
+ return vscode . window . showTextDocument ( document , vscode . ViewColumn . Two , true ) ;
36
32
} ;
37
33
}
38
34
39
- class TextDocumentContentProvider
40
- implements vscode . TextDocumentContentProvider {
41
- uri = vscode . Uri . parse ( 'rust-analyzer-status://status' ) ;
42
- eventEmitter = new vscode . EventEmitter < vscode . Uri > ( ) ;
35
+ class TextDocumentContentProvider implements vscode . TextDocumentContentProvider {
36
+ readonly uri = vscode . Uri . parse ( 'rust-analyzer-status://status' ) ;
37
+ readonly eventEmitter = new vscode . EventEmitter < vscode . Uri > ( ) ;
43
38
44
39
constructor ( private readonly ctx : Ctx ) {
45
40
}
46
41
47
- provideTextDocumentContent (
48
- _uri : vscode . Uri ,
49
- ) : vscode . ProviderResult < string > {
50
- const editor = vscode . window . activeTextEditor ;
51
- const client = this . ctx . client ;
52
- if ( ! editor || ! client ) return '' ;
42
+ provideTextDocumentContent ( _uri : vscode . Uri ) : vscode . ProviderResult < string > {
43
+ if ( ! vscode . window . activeTextEditor ) return '' ;
53
44
54
- return client . sendRequest ( ra . analyzerStatus , null ) ;
45
+ return this . ctx . client . sendRequest ( ra . analyzerStatus , null ) ;
55
46
}
56
47
57
48
get onDidChange ( ) : vscode . Event < vscode . Uri > {
0 commit comments