@@ -167,9 +167,9 @@ export class VariantAnalysisManager
167167 "codeQL.openVariantAnalysisLogs" : this . openVariantAnalysisLogs . bind ( this ) ,
168168 "codeQL.openVariantAnalysisView" : this . showView . bind ( this ) ,
169169 "codeQL.runVariantAnalysis" :
170- this . runVariantAnalysisFromCommand . bind ( this ) ,
170+ this . runVariantAnalysisFromCommandPalette . bind ( this ) ,
171171 "codeQL.runVariantAnalysisContextEditor" :
172- this . runVariantAnalysisFromCommand . bind ( this ) ,
172+ this . runVariantAnalysisFromContextEditor . bind ( this ) ,
173173 "codeQL.runVariantAnalysisContextExplorer" : createMultiSelectionCommand (
174174 this . runVariantAnalysisFromExplorer . bind ( this ) ,
175175 ) ,
@@ -184,44 +184,53 @@ export class VariantAnalysisManager
184184 return this . app . commands ;
185185 }
186186
187- private async runVariantAnalysisFromCommand ( uri ?: Uri ) {
188- return withProgress (
189- async ( progress , token ) =>
190- this . runVariantAnalysis (
191- uri || Window . activeTextEditor ?. document . uri ,
192- progress ,
193- token ,
194- ) ,
195- {
196- title : "Run Variant Analysis" ,
197- cancellable : true ,
198- } ,
199- ) ;
187+ private async runVariantAnalysisFromCommandPalette ( ) {
188+ const fileUri = Window . activeTextEditor ?. document . uri ;
189+ if ( ! fileUri ) {
190+ throw new Error ( "Please select a .ql file to run as a variant analysis" ) ;
191+ }
192+
193+ await this . runVariantAnalysisCommand ( fileUri ) ;
194+ }
195+
196+ private async runVariantAnalysisFromContextEditor ( uri : Uri ) {
197+ await this . runVariantAnalysisCommand ( uri ) ;
200198 }
201199
202200 private async runVariantAnalysisFromExplorer ( fileURIs : Uri [ ] ) : Promise < void > {
203201 if ( fileURIs . length !== 1 ) {
204202 throw new Error ( "Can only run a single query at a time" ) ;
205203 }
206- return this . runVariantAnalysisFromCommand ( fileURIs [ 0 ] ) ;
204+
205+ return this . runVariantAnalysisCommand ( fileURIs [ 0 ] ) ;
207206 }
208207
209208 private async runVariantAnalysisFromQueriesPanel (
210209 queryTreeViewItem : QueryTreeViewItem ,
211210 ) : Promise < void > {
212211 if ( queryTreeViewItem . path !== undefined ) {
213- await this . runVariantAnalysisFromCommand (
214- Uri . file ( queryTreeViewItem . path ) ,
215- ) ;
212+ await this . runVariantAnalysisCommand ( Uri . file ( queryTreeViewItem . path ) ) ;
216213 }
217214 }
218215
219216 private async runVariantAnalysisFromPublishedPack ( ) : Promise < void > {
220217 throw new Error ( "Command not yet implemented" ) ;
221218 }
222219
220+ private async runVariantAnalysisCommand ( uri : Uri ) : Promise < void > {
221+ return withProgress (
222+ async ( progress , token ) => {
223+ await this . runVariantAnalysis ( uri , progress , token ) ;
224+ } ,
225+ {
226+ title : "Run Variant Analysis" ,
227+ cancellable : true ,
228+ } ,
229+ ) ;
230+ }
231+
223232 public async runVariantAnalysis (
224- uri : Uri | undefined ,
233+ uri : Uri ,
225234 progress : ProgressCallback ,
226235 token : CancellationToken ,
227236 ) : Promise < void > {
0 commit comments