@@ -23,11 +23,11 @@ import {
2323 isWholeFileLoc ,
2424 isLineColumnLoc ,
2525} from "./pure/bqrs-utils" ;
26- import { commandRunner } from "./commandRunner" ;
2726import { DisposableObject } from "./pure/disposable-object" ;
2827import { showAndLogExceptionWithTelemetry } from "./helpers" ;
2928import { asError , getErrorMessage } from "./pure/helpers-pure" ;
3029import { redactableError } from "./pure/errors" ;
30+ import { AstViewerCommands } from "./common/commands" ;
3131
3232export interface AstItem {
3333 id : BqrsId ;
@@ -55,15 +55,6 @@ class AstViewerDataProvider
5555 readonly onDidChangeTreeData : Event < AstItem | undefined > =
5656 this . _onDidChangeTreeData . event ;
5757
58- constructor ( ) {
59- super ( ) ;
60- this . push (
61- commandRunner ( "codeQLAstViewer.gotoCode" , async ( item : AstItem ) => {
62- await showLocation ( item . fileLocation ) ;
63- } ) ,
64- ) ;
65- }
66-
6758 refresh ( ) : void {
6859 this . _onDidChangeTreeData . fire ( undefined ) ;
6960 }
@@ -126,16 +117,20 @@ export class AstViewer extends DisposableObject {
126117
127118 this . push ( this . treeView ) ;
128119 this . push ( this . treeDataProvider ) ;
129- this . push (
130- commandRunner ( "codeQLAstViewer.clear" , async ( ) => {
131- this . clear ( ) ;
132- } ) ,
133- ) ;
134120 this . push (
135121 window . onDidChangeTextEditorSelection ( this . updateTreeSelection , this ) ,
136122 ) ;
137123 }
138124
125+ getCommands ( ) : AstViewerCommands {
126+ return {
127+ "codeQLAstViewer.clear" : async ( ) => this . clear ( ) ,
128+ "codeQLAstViewer.gotoCode" : async ( item : AstItem ) => {
129+ await showLocation ( item . fileLocation ) ;
130+ } ,
131+ } ;
132+ }
133+
139134 updateRoots ( roots : AstItem [ ] , db : DatabaseItem , fileUri : Uri ) {
140135 this . treeDataProvider . roots = roots ;
141136 this . treeDataProvider . db = db ;
0 commit comments