File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
1010 TextDocument ,
1111 Uri
1212} from 'vscode' ;
13+ import * as path from 'path' ;
1314
1415import { decodeSourceArchiveUri , encodeArchiveBasePath , zipArchiveScheme } from '../archive-filesystem-provider' ;
1516import { CodeQLCliServer } from '../cli' ;
@@ -142,19 +143,19 @@ export class TemplatePrintAstProvider {
142143 async provideAst (
143144 progress : ProgressCallback ,
144145 token : CancellationToken ,
145- document ?: TextDocument
146+ fileUri ?: Uri
146147 ) : Promise < AstBuilder | undefined > {
147- if ( ! document ) {
148+ if ( ! fileUri ) {
148149 throw new Error ( 'Cannot view the AST. Please select a valid source file inside a CodeQL database.' ) ;
149150 }
150151 const { query, dbUri } = this . shouldCache ( )
151- ? await this . cache . get ( document . uri . toString ( ) , progress , token )
152- : await this . getAst ( document . uri . toString ( ) , progress , token ) ;
152+ ? await this . cache . get ( fileUri . toString ( ) , progress , token )
153+ : await this . getAst ( fileUri . toString ( ) , progress , token ) ;
153154
154155 return new AstBuilder (
155156 query , this . cli ,
156157 this . dbm . findDatabaseItem ( dbUri ) ! ,
157- document . fileName
158+ path . basename ( fileUri . fsPath ) ,
158159 ) ;
159160 }
160161
Original file line number Diff line number Diff line change @@ -974,9 +974,11 @@ async function activateWithInstalledDistribution(
974974 }
975975 ) ) ;
976976
977- commands . registerCommand ( 'codeQL.showLogs' , ( ) => {
978- logger . show ( ) ;
979- } ) ;
977+ ctx . subscriptions . push (
978+ commandRunner ( 'codeQL.showLogs' , async ( ) => {
979+ logger . show ( ) ;
980+ } )
981+ ) ;
980982
981983 void logger . log ( 'Starting language server.' ) ;
982984 ctx . subscriptions . push ( client . start ( ) ) ;
@@ -999,12 +1001,14 @@ async function activateWithInstalledDistribution(
9991001 ctx . subscriptions . push ( astViewer ) ;
10001002 ctx . subscriptions . push ( commandRunnerWithProgress ( 'codeQL.viewAst' , async (
10011003 progress : ProgressCallback ,
1002- token : CancellationToken
1004+ token : CancellationToken ,
1005+ selectedFile : Uri ,
10031006 ) => {
1007+
10041008 const ast = await templateProvider . provideAst (
10051009 progress ,
10061010 token ,
1007- window . activeTextEditor ?. document ,
1011+ selectedFile ?? window . activeTextEditor ?. document . uri ,
10081012 ) ;
10091013 if ( ast ) {
10101014 astViewer . updateRoots ( await ast . getRoots ( ) , ast . db , ast . fileName ) ;
You can’t perform that action at this time.
0 commit comments