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 @@ -968,9 +968,11 @@ async function activateWithInstalledDistribution(
968968 }
969969 ) ) ;
970970
971- commands . registerCommand ( 'codeQL.showLogs' , ( ) => {
972- logger . show ( ) ;
973- } ) ;
971+ ctx . subscriptions . push (
972+ commandRunner ( 'codeQL.showLogs' , async ( ) => {
973+ logger . show ( ) ;
974+ } )
975+ ) ;
974976
975977 void logger . log ( 'Starting language server.' ) ;
976978 ctx . subscriptions . push ( client . start ( ) ) ;
@@ -993,12 +995,14 @@ async function activateWithInstalledDistribution(
993995 ctx . subscriptions . push ( astViewer ) ;
994996 ctx . subscriptions . push ( commandRunnerWithProgress ( 'codeQL.viewAst' , async (
995997 progress : ProgressCallback ,
996- token : CancellationToken
998+ token : CancellationToken ,
999+ selectedFile : Uri ,
9971000 ) => {
1001+
9981002 const ast = await templateProvider . provideAst (
9991003 progress ,
10001004 token ,
1001- window . activeTextEditor ?. document ,
1005+ selectedFile ?? window . activeTextEditor ?. document . uri ,
10021006 ) ;
10031007 if ( ast ) {
10041008 astViewer . updateRoots ( await ast . getRoots ( ) , ast . db , ast . fileName ) ;
You can’t perform that action at this time.
0 commit comments