@@ -37,6 +37,7 @@ import { LOGGING_FLAGS } from "./cli-command";
37
37
import type { CliFeatures , VersionAndFeatures } from "./cli-version" ;
38
38
import { ExitCodeError , getCliError } from "./cli-errors" ;
39
39
import { UserCancellationException } from "../common/vscode/progress" ;
40
+ import type { LanguageClient } from "vscode-languageclient/node" ;
40
41
41
42
/**
42
43
* The version of the SARIF format that we are using.
@@ -277,6 +278,7 @@ export class CodeQLCliServer implements Disposable {
277
278
278
279
constructor (
279
280
private readonly app : App ,
281
+ private readonly languageClient : LanguageClient ,
280
282
private distributionProvider : DistributionProvider ,
281
283
private cliConfig : CliConfig ,
282
284
public readonly logger : Logger ,
@@ -1584,11 +1586,13 @@ export class CodeQLCliServer implements Disposable {
1584
1586
async packAdd ( dir : string , queryLanguage : QueryLanguage ) {
1585
1587
const args = [ "--dir" , dir ] ;
1586
1588
args . push ( `codeql/${ queryLanguage } -all` ) ;
1587
- return this . runCodeQlCliCommand (
1589
+ const ret = await this . runCodeQlCliCommand (
1588
1590
[ "pack" , "add" ] ,
1589
1591
args ,
1590
1592
`Adding and installing ${ queryLanguage } pack dependency.` ,
1591
1593
) ;
1594
+ await this . notifyPackInstalled ( ) ;
1595
+ return ret ;
1592
1596
}
1593
1597
1594
1598
/**
@@ -1623,16 +1627,18 @@ export class CodeQLCliServer implements Disposable {
1623
1627
args . push (
1624
1628
// Allow prerelease packs from the ql submodule.
1625
1629
"--allow-prerelease" ,
1626
- // Allow the use of --additional-packs argument without issueing a warning
1630
+ // Allow the use of --additional-packs argument without issuing a warning
1627
1631
"--no-strict-mode" ,
1628
1632
...this . getAdditionalPacksArg ( workspaceFolders ) ,
1629
1633
) ;
1630
1634
}
1631
- return this . runJsonCodeQlCliCommandWithAuthentication (
1635
+ const ret = await this . runJsonCodeQlCliCommandWithAuthentication (
1632
1636
[ "pack" , "install" ] ,
1633
1637
args ,
1634
1638
"Installing pack dependencies" ,
1635
1639
) ;
1640
+ await this . notifyPackInstalled ( ) ;
1641
+ return ret ;
1636
1642
}
1637
1643
1638
1644
/**
@@ -1750,6 +1756,17 @@ export class CodeQLCliServer implements Disposable {
1750
1756
this . _versionChangedListeners . push ( listener ) ;
1751
1757
}
1752
1758
1759
+ /**
1760
+ * This method should be called after a pack has been installed.
1761
+ *
1762
+ * This restarts the language client. Restarting the language client has the
1763
+ * effect of removing compilation errors in open ql/qll files that are caused
1764
+ * by the pack not having been installed previously.
1765
+ */
1766
+ private async notifyPackInstalled ( ) {
1767
+ await this . languageClient . restart ( ) ;
1768
+ }
1769
+
1753
1770
private async refreshVersion ( ) : Promise < VersionAndFeatures > {
1754
1771
const distribution = await this . distributionProvider . getDistribution ( ) ;
1755
1772
switch ( distribution . kind ) {
0 commit comments