@@ -32,7 +32,8 @@ import { DatabaseUI } from './databases-ui';
3232import {
3333 TemplateQueryDefinitionProvider ,
3434 TemplateQueryReferenceProvider ,
35- TemplatePrintAstProvider
35+ TemplatePrintAstProvider ,
36+ TemplatePrintCfgProvider
3637} from './contextual/templateProvider' ;
3738import {
3839 DEFAULT_DISTRIBUTION_VERSION_RANGE ,
@@ -68,6 +69,7 @@ import {
6869 ProgressUpdate
6970} from './commandRunner' ;
7071import { CodeQlStatusBarHandler } from './status-bar' ;
72+ import * as messages from './pure/messages' ;
7173
7274/**
7375 * extension.ts
@@ -457,6 +459,7 @@ async function activateWithInstalledDistribution(
457459 selectedQuery : Uri | undefined ,
458460 progress : ProgressCallback ,
459461 token : CancellationToken ,
462+ templates ?: messages . TemplateDefinitions ,
460463 ) : Promise < void > {
461464 if ( qs !== undefined ) {
462465 const dbItem = await databaseUI . getDatabaseItem ( progress , token ) ;
@@ -470,7 +473,8 @@ async function activateWithInstalledDistribution(
470473 quickEval ,
471474 selectedQuery ,
472475 progress ,
473- token
476+ token ,
477+ templates
474478 ) ;
475479 const item = qhm . buildCompletedQuery ( info ) ;
476480 await showResultsForCompletedQuery ( item , WebviewReveal . NotForced ) ;
@@ -675,6 +679,26 @@ async function activateWithInstalledDistribution(
675679 commandRunner ( 'codeQL.openDocumentation' , async ( ) =>
676680 env . openExternal ( Uri . parse ( 'https://codeql.github.com/docs/' ) ) ) ) ;
677681
682+ ctx . subscriptions . push (
683+ commandRunnerWithProgress (
684+ 'codeQL.viewCfg' ,
685+ async (
686+ progress : ProgressCallback ,
687+ token : CancellationToken
688+ ) => {
689+ const res = await new TemplatePrintCfgProvider ( cliServer , dbm )
690+ . provideCfgUri ( window . activeTextEditor ?. document ) ;
691+ if ( res ) {
692+ await compileAndRunQuery ( false , res [ 0 ] , progress , token , res [ 1 ] ) ;
693+ }
694+ } ,
695+ {
696+ title : 'Calculate CFG' ,
697+ cancellable : true
698+ }
699+ )
700+ ) ;
701+
678702 logger . log ( 'Starting language server.' ) ;
679703 ctx . subscriptions . push ( client . start ( ) ) ;
680704
0 commit comments