@@ -8,7 +8,8 @@ import type { Log } from "sarif";
8
8
import { SemVer } from "semver" ;
9
9
import type { Readable } from "stream" ;
10
10
import tk from "tree-kill" ;
11
- import type { CancellationToken , Disposable , Uri } from "vscode" ;
11
+ import type { CancellationToken , Disposable } from "vscode" ;
12
+ import { Uri } from "vscode" ;
12
13
13
14
import type {
14
15
BqrsInfo ,
@@ -37,6 +38,11 @@ import { LOGGING_FLAGS } from "./cli-command";
37
38
import type { CliFeatures , VersionAndFeatures } from "./cli-version" ;
38
39
import { ExitCodeError , getCliError } from "./cli-errors" ;
39
40
import { UserCancellationException } from "../common/vscode/progress" ;
41
+ import type { LanguageClient } from "vscode-languageclient/node" ;
42
+ import {
43
+ DidChangeWatchedFilesNotification ,
44
+ FileChangeType ,
45
+ } from "vscode-languageclient/node" ;
40
46
41
47
/**
42
48
* The version of the SARIF format that we are using.
@@ -277,6 +283,7 @@ export class CodeQLCliServer implements Disposable {
277
283
278
284
constructor (
279
285
private readonly app : App ,
286
+ private readonly languageClient : LanguageClient ,
280
287
private distributionProvider : DistributionProvider ,
281
288
private cliConfig : CliConfig ,
282
289
public readonly logger : Logger ,
@@ -1584,11 +1591,13 @@ export class CodeQLCliServer implements Disposable {
1584
1591
async packAdd ( dir : string , queryLanguage : QueryLanguage ) {
1585
1592
const args = [ "--dir" , dir ] ;
1586
1593
args . push ( `codeql/${ queryLanguage } -all` ) ;
1587
- return this . runCodeQlCliCommand (
1594
+ const ret = await this . runCodeQlCliCommand (
1588
1595
[ "pack" , "add" ] ,
1589
1596
args ,
1590
1597
`Adding and installing ${ queryLanguage } pack dependency.` ,
1591
1598
) ;
1599
+ await this . notifyPackChanged ( dir ) ;
1600
+ return ret ;
1592
1601
}
1593
1602
1594
1603
/**
@@ -1628,11 +1637,13 @@ export class CodeQLCliServer implements Disposable {
1628
1637
...this . getAdditionalPacksArg ( workspaceFolders ) ,
1629
1638
) ;
1630
1639
}
1631
- return this . runJsonCodeQlCliCommandWithAuthentication (
1640
+ const ret = await this . runJsonCodeQlCliCommandWithAuthentication (
1632
1641
[ "pack" , "install" ] ,
1633
1642
args ,
1634
1643
"Installing pack dependencies" ,
1635
1644
) ;
1645
+ await this . notifyPackChanged ( dir ) ;
1646
+ return ret ;
1636
1647
}
1637
1648
1638
1649
/**
@@ -1750,6 +1761,21 @@ export class CodeQLCliServer implements Disposable {
1750
1761
this . _versionChangedListeners . push ( listener ) ;
1751
1762
}
1752
1763
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
+
1753
1779
private async refreshVersion ( ) : Promise < VersionAndFeatures > {
1754
1780
const distribution = await this . distributionProvider . getDistribution ( ) ;
1755
1781
switch ( distribution . kind ) {
0 commit comments