@@ -37,6 +37,7 @@ import { LOGGING_FLAGS } from "./cli-command";
3737import type { CliFeatures , VersionAndFeatures } from "./cli-version" ;
3838import { ExitCodeError , getCliError } from "./cli-errors" ;
3939import { UserCancellationException } from "../common/vscode/progress" ;
40+ import type { LanguageClient } from "vscode-languageclient/node" ;
4041
4142/**
4243 * The version of the SARIF format that we are using.
@@ -277,6 +278,7 @@ export class CodeQLCliServer implements Disposable {
277278
278279 constructor (
279280 private readonly app : App ,
281+ private readonly languageClient : LanguageClient ,
280282 private distributionProvider : DistributionProvider ,
281283 private cliConfig : CliConfig ,
282284 public readonly logger : Logger ,
@@ -1584,11 +1586,13 @@ export class CodeQLCliServer implements Disposable {
15841586 async packAdd ( dir : string , queryLanguage : QueryLanguage ) {
15851587 const args = [ "--dir" , dir ] ;
15861588 args . push ( `codeql/${ queryLanguage } -all` ) ;
1587- return this . runCodeQlCliCommand (
1589+ const ret = await this . runCodeQlCliCommand (
15881590 [ "pack" , "add" ] ,
15891591 args ,
15901592 `Adding and installing ${ queryLanguage } pack dependency.` ,
15911593 ) ;
1594+ await this . notifyPackInstalled ( ) ;
1595+ return ret ;
15921596 }
15931597
15941598 /**
@@ -1623,16 +1627,18 @@ export class CodeQLCliServer implements Disposable {
16231627 args . push (
16241628 // Allow prerelease packs from the ql submodule.
16251629 "--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
16271631 "--no-strict-mode" ,
16281632 ...this . getAdditionalPacksArg ( workspaceFolders ) ,
16291633 ) ;
16301634 }
1631- return this . runJsonCodeQlCliCommandWithAuthentication (
1635+ const ret = await this . runJsonCodeQlCliCommandWithAuthentication (
16321636 [ "pack" , "install" ] ,
16331637 args ,
16341638 "Installing pack dependencies" ,
16351639 ) ;
1640+ await this . notifyPackInstalled ( ) ;
1641+ return ret ;
16361642 }
16371643
16381644 /**
@@ -1750,6 +1756,17 @@ export class CodeQLCliServer implements Disposable {
17501756 this . _versionChangedListeners . push ( listener ) ;
17511757 }
17521758
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+
17531770 private async refreshVersion ( ) : Promise < VersionAndFeatures > {
17541771 const distribution = await this . distributionProvider . getDistribution ( ) ;
17551772 switch ( distribution . kind ) {
0 commit comments