@@ -1125,27 +1125,48 @@ async function activateWithInstalledDistribution(
11251125 ) ,
11261126 ) ;
11271127
1128- // The "runVariantAnalysis" command is internal-only.
1128+ async function runVariantAnalysis (
1129+ progress : ProgressCallback ,
1130+ token : CancellationToken ,
1131+ uri : Uri | undefined ,
1132+ ) : Promise < void > {
1133+ progress ( {
1134+ maxStep : 5 ,
1135+ step : 0 ,
1136+ message : "Getting credentials" ,
1137+ } ) ;
1138+
1139+ await variantAnalysisManager . runVariantAnalysis (
1140+ uri || window . activeTextEditor ?. document . uri ,
1141+ progress ,
1142+ token ,
1143+ ) ;
1144+ }
1145+
11291146 ctx . subscriptions . push (
11301147 commandRunnerWithProgress (
11311148 "codeQL.runVariantAnalysis" ,
11321149 async (
11331150 progress : ProgressCallback ,
11341151 token : CancellationToken ,
11351152 uri : Uri | undefined ,
1136- ) => {
1137- progress ( {
1138- maxStep : 5 ,
1139- step : 0 ,
1140- message : "Getting credentials" ,
1141- } ) ;
1142-
1143- await variantAnalysisManager . runVariantAnalysis (
1144- uri || window . activeTextEditor ?. document . uri ,
1145- progress ,
1146- token ,
1147- ) ;
1153+ ) => await runVariantAnalysis ( progress , token , uri ) ,
1154+ {
1155+ title : "Run Variant Analysis" ,
1156+ cancellable : true ,
11481157 } ,
1158+ ) ,
1159+ ) ;
1160+
1161+ // Since we are tracking extension usage through commands, this command mirrors the "codeQL.runVariantAnalysis" command
1162+ ctx . subscriptions . push (
1163+ commandRunnerWithProgress (
1164+ "codeQL.runVariantAnalysisContextEditor" ,
1165+ async (
1166+ progress : ProgressCallback ,
1167+ token : CancellationToken ,
1168+ uri : Uri | undefined ,
1169+ ) => await runVariantAnalysis ( progress , token , uri ) ,
11491170 {
11501171 title : "Run Variant Analysis" ,
11511172 cancellable : true ,
@@ -1474,23 +1495,62 @@ async function activateWithInstalledDistribution(
14741495 const cfgTemplateProvider = new TemplatePrintCfgProvider ( cliServer , dbm ) ;
14751496
14761497 ctx . subscriptions . push ( astViewer ) ;
1498+
1499+ async function viewAst (
1500+ progress : ProgressCallback ,
1501+ token : CancellationToken ,
1502+ selectedFile : Uri ,
1503+ ) : Promise < void > {
1504+ const ast = await printAstTemplateProvider . provideAst (
1505+ progress ,
1506+ token ,
1507+ selectedFile ?? window . activeTextEditor ?. document . uri ,
1508+ ) ;
1509+ if ( ast ) {
1510+ astViewer . updateRoots ( await ast . getRoots ( ) , ast . db , ast . fileName ) ;
1511+ }
1512+ }
1513+
14771514 ctx . subscriptions . push (
14781515 commandRunnerWithProgress (
14791516 "codeQL.viewAst" ,
14801517 async (
14811518 progress : ProgressCallback ,
14821519 token : CancellationToken ,
14831520 selectedFile : Uri ,
1484- ) => {
1485- const ast = await printAstTemplateProvider . provideAst (
1486- progress ,
1487- token ,
1488- selectedFile ?? window . activeTextEditor ?. document . uri ,
1489- ) ;
1490- if ( ast ) {
1491- astViewer . updateRoots ( await ast . getRoots ( ) , ast . db , ast . fileName ) ;
1492- }
1521+ ) => await viewAst ( progress , token , selectedFile ) ,
1522+ {
1523+ cancellable : true ,
1524+ title : "Calculate AST" ,
1525+ } ,
1526+ ) ,
1527+ ) ;
1528+
1529+ // Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewAst" command
1530+ ctx . subscriptions . push (
1531+ commandRunnerWithProgress (
1532+ "codeQL.viewAstContextExplorer" ,
1533+ async (
1534+ progress : ProgressCallback ,
1535+ token : CancellationToken ,
1536+ selectedFile : Uri ,
1537+ ) => await viewAst ( progress , token , selectedFile ) ,
1538+ {
1539+ cancellable : true ,
1540+ title : "Calculate AST" ,
14931541 } ,
1542+ ) ,
1543+ ) ;
1544+
1545+ // Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewAst" command
1546+ ctx . subscriptions . push (
1547+ commandRunnerWithProgress (
1548+ "codeQL.viewAstContextEditor" ,
1549+ async (
1550+ progress : ProgressCallback ,
1551+ token : CancellationToken ,
1552+ selectedFile : Uri ,
1553+ ) => await viewAst ( progress , token , selectedFile ) ,
14941554 {
14951555 cancellable : true ,
14961556 title : "Calculate AST" ,
0 commit comments