@@ -8,7 +8,8 @@ import type { Log } from "sarif";
88import { SemVer } from "semver" ;
99import type { Readable } from "stream" ;
1010import tk from "tree-kill" ;
11- import type { CancellationToken , Disposable , Uri } from "vscode" ;
11+ import type { CancellationToken , Disposable } from "vscode" ;
12+ import { Uri } from "vscode" ;
1213
1314import type {
1415 BqrsInfo ,
@@ -37,6 +38,11 @@ import { LOGGING_FLAGS } from "./cli-command";
3738import type { CliFeatures , VersionAndFeatures } from "./cli-version" ;
3839import { ExitCodeError , getCliError } from "./cli-errors" ;
3940import { UserCancellationException } from "../common/vscode/progress" ;
41+ import type { LanguageClient } from "vscode-languageclient/node" ;
42+ import {
43+ DidChangeWatchedFilesNotification ,
44+ FileChangeType ,
45+ } from "vscode-languageclient/node" ;
4046
4147/**
4248 * The version of the SARIF format that we are using.
@@ -277,6 +283,7 @@ export class CodeQLCliServer implements Disposable {
277283
278284 constructor (
279285 private readonly app : App ,
286+ private readonly languageClient : LanguageClient ,
280287 private distributionProvider : DistributionProvider ,
281288 private cliConfig : CliConfig ,
282289 public readonly logger : Logger ,
@@ -1584,11 +1591,13 @@ export class CodeQLCliServer implements Disposable {
15841591 async packAdd ( dir : string , queryLanguage : QueryLanguage ) {
15851592 const args = [ "--dir" , dir ] ;
15861593 args . push ( `codeql/${ queryLanguage } -all` ) ;
1587- return this . runCodeQlCliCommand (
1594+ const ret = await this . runCodeQlCliCommand (
15881595 [ "pack" , "add" ] ,
15891596 args ,
15901597 `Adding and installing ${ queryLanguage } pack dependency.` ,
15911598 ) ;
1599+ await this . notifyPackChanged ( dir ) ;
1600+ return ret ;
15921601 }
15931602
15941603 /**
@@ -1628,11 +1637,13 @@ export class CodeQLCliServer implements Disposable {
16281637 ...this . getAdditionalPacksArg ( workspaceFolders ) ,
16291638 ) ;
16301639 }
1631- return this . runJsonCodeQlCliCommandWithAuthentication (
1640+ const ret = await this . runJsonCodeQlCliCommandWithAuthentication (
16321641 [ "pack" , "install" ] ,
16331642 args ,
16341643 "Installing pack dependencies" ,
16351644 ) ;
1645+ await this . notifyPackChanged ( dir ) ;
1646+ return ret ;
16361647 }
16371648
16381649 /**
@@ -1750,6 +1761,21 @@ export class CodeQLCliServer implements Disposable {
17501761 this . _versionChangedListeners . push ( listener ) ;
17511762 }
17521763
1764+ private async notifyPackChanged ( packDir : string ) {
1765+ const packFilePath = join ( packDir , "codeql-pack.yml" ) ;
1766+ await this . languageClient . sendNotification (
1767+ DidChangeWatchedFilesNotification . type ,
1768+ {
1769+ changes : [
1770+ {
1771+ type : FileChangeType . Changed ,
1772+ uri : Uri . file ( packFilePath ) . toString ( ) ,
1773+ } ,
1774+ ] ,
1775+ } ,
1776+ ) ;
1777+ }
1778+
17531779 private async refreshVersion ( ) : Promise < VersionAndFeatures > {
17541780 const distribution = await this . distributionProvider . getDistribution ( ) ;
17551781 switch ( distribution . kind ) {
0 commit comments