@@ -12,8 +12,8 @@ const AST_FILE_SCHEME = "rust-analyzer";
1212export function syntaxTree ( ctx : Ctx ) : Cmd {
1313 const tdcp = new TextDocumentContentProvider ( ctx ) ;
1414
15- ctx . pushCleanup ( new AstInspector ) ;
16- ctx . pushCleanup ( tdcp ) ;
15+ void new AstInspector ( ctx ) ;
16+
1717 ctx . pushCleanup ( vscode . workspace . registerTextDocumentContentProvider ( AST_FILE_SCHEME , tdcp ) ) ;
1818
1919 return async ( ) => {
@@ -35,17 +35,14 @@ export function syntaxTree(ctx: Ctx): Cmd {
3535 } ;
3636}
3737
38- class TextDocumentContentProvider implements vscode . TextDocumentContentProvider , Disposable {
38+ class TextDocumentContentProvider implements vscode . TextDocumentContentProvider {
3939 readonly uri = vscode . Uri . parse ( 'rust-analyzer://syntaxtree' ) ;
4040 readonly eventEmitter = new vscode . EventEmitter < vscode . Uri > ( ) ;
41- private readonly disposables : Disposable [ ] = [ ] ;
41+
4242
4343 constructor ( private readonly ctx : Ctx ) {
44- vscode . workspace . onDidChangeTextDocument ( this . onDidChangeTextDocument , this , this . disposables ) ;
45- vscode . window . onDidChangeActiveTextEditor ( this . onDidChangeActiveTextEditor , this , this . disposables ) ;
46- }
47- dispose ( ) {
48- this . disposables . forEach ( d => d . dispose ( ) ) ;
44+ vscode . workspace . onDidChangeTextDocument ( this . onDidChangeTextDocument , this , ctx . subscriptions ) ;
45+ vscode . window . onDidChangeActiveTextEditor ( this . onDidChangeActiveTextEditor , this , ctx . subscriptions ) ;
4946 }
5047
5148 private onDidChangeTextDocument ( event : vscode . TextDocumentChangeEvent ) {
@@ -88,16 +85,16 @@ class AstInspector implements vscode.HoverProvider, Disposable {
8885 border : "#ffffff 1px solid" ,
8986 } ) ;
9087 private rustEditor : undefined | RustEditor ;
91- private readonly disposables : Disposable [ ] = [ ] ;
9288
93- constructor ( ) {
94- this . disposables . push ( vscode . languages . registerHoverProvider ( { scheme : AST_FILE_SCHEME } , this ) ) ;
95- vscode . workspace . onDidCloseTextDocument ( this . onDidCloseTextDocument , this , this . disposables ) ;
96- vscode . window . onDidChangeVisibleTextEditors ( this . onDidChangeVisibleTextEditors , this , this . disposables ) ;
89+ constructor ( ctx : Ctx ) {
90+ ctx . pushCleanup ( vscode . languages . registerHoverProvider ( { scheme : AST_FILE_SCHEME } , this ) ) ;
91+ vscode . workspace . onDidCloseTextDocument ( this . onDidCloseTextDocument , this , ctx . subscriptions ) ;
92+ vscode . window . onDidChangeVisibleTextEditors ( this . onDidChangeVisibleTextEditors , this , ctx . subscriptions ) ;
93+
94+ ctx . pushCleanup ( this ) ;
9795 }
9896 dispose ( ) {
9997 this . setRustEditor ( undefined ) ;
100- this . disposables . forEach ( d => d . dispose ( ) ) ;
10198 }
10299
103100 private onDidCloseTextDocument ( doc : vscode . TextDocument ) {
0 commit comments