@@ -5,7 +5,7 @@ import { Ctx, Cmd } from '../ctx';
55
66// Shows status of rust-analyzer (for debugging)
77export function analyzerStatus ( ctx : Ctx ) : Cmd {
8- let poller : NodeJS . Timer | null = null ;
8+ let poller : NodeJS . Timer | undefined = undefined ;
99 const tdcp = new TextDocumentContentProvider ( ctx ) ;
1010
1111 ctx . pushCleanup (
@@ -17,41 +17,32 @@ export function analyzerStatus(ctx: Ctx): Cmd {
1717
1818 ctx . pushCleanup ( {
1919 dispose ( ) {
20- if ( poller != null ) {
20+ if ( poller !== undefined ) {
2121 clearInterval ( poller ) ;
2222 }
2323 } ,
2424 } ) ;
2525
26- return async function handle ( ) {
27- if ( poller == null ) {
26+ return async ( ) => {
27+ if ( poller === undefined ) {
2828 poller = setInterval ( ( ) => tdcp . eventEmitter . fire ( tdcp . uri ) , 1000 ) ;
2929 }
3030 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 ) ;
3632 } ;
3733}
3834
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 > ( ) ;
4338
4439 constructor ( private readonly ctx : Ctx ) {
4540 }
4641
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 '' ;
5344
54- return client . sendRequest ( ra . analyzerStatus , null ) ;
45+ return this . ctx . client . sendRequest ( ra . analyzerStatus , null ) ;
5546 }
5647
5748 get onDidChange ( ) : vscode . Event < vscode . Uri > {
0 commit comments