@@ -8,10 +8,7 @@ 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 } from "vscode" ;
12
- import { Uri } from "vscode" ;
13
-
14
- import { existsSync } from "fs" ;
11
+ import type { CancellationToken , Disposable , Uri } from "vscode" ;
15
12
16
13
import type {
17
14
BqrsInfo ,
@@ -41,10 +38,6 @@ import type { CliFeatures, VersionAndFeatures } from "./cli-version";
41
38
import { ExitCodeError , getCliError } from "./cli-errors" ;
42
39
import { UserCancellationException } from "../common/vscode/progress" ;
43
40
import type { LanguageClient } from "vscode-languageclient/node" ;
44
- import {
45
- DidChangeWatchedFilesNotification ,
46
- FileChangeType ,
47
- } from "vscode-languageclient/node" ;
48
41
49
42
/**
50
43
* The version of the SARIF format that we are using.
@@ -1598,7 +1591,7 @@ export class CodeQLCliServer implements Disposable {
1598
1591
args ,
1599
1592
`Adding and installing ${ queryLanguage } pack dependency.` ,
1600
1593
) ;
1601
- await this . notifyPackChanged ( dir ) ;
1594
+ await this . notifyPackInstalled ( ) ;
1602
1595
return ret ;
1603
1596
}
1604
1597
@@ -1644,7 +1637,7 @@ export class CodeQLCliServer implements Disposable {
1644
1637
args ,
1645
1638
"Installing pack dependencies" ,
1646
1639
) ;
1647
- await this . notifyPackChanged ( dir ) ;
1640
+ await this . notifyPackInstalled ( ) ;
1648
1641
return ret ;
1649
1642
}
1650
1643
@@ -1763,26 +1756,14 @@ export class CodeQLCliServer implements Disposable {
1763
1756
this . _versionChangedListeners . push ( listener ) ;
1764
1757
}
1765
1758
1766
- private async notifyPackChanged ( packDir : string ) {
1767
- const packFilePath = join ( packDir , "codeql-pack.yml" ) ;
1768
- if ( ! existsSync ( packFilePath ) ) {
1769
- throw new Error ( `Pack file ${ packFilePath } does not exist` ) ;
1770
- }
1771
- await this . languageClient . sendNotification (
1772
- DidChangeWatchedFilesNotification . type ,
1773
- {
1774
- changes : [
1775
- {
1776
- type : FileChangeType . Changed ,
1777
- uri : Uri . file ( packFilePath ) . toString ( ) ,
1778
- } ,
1779
- ] ,
1780
- } ,
1781
- ) ;
1782
-
1783
- // restarting the language client has the effect of removing compilation
1784
- // errors in open ql/qll files that are caused by the pack not having been
1785
- // installed previously:
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 ( ) {
1786
1767
await this . languageClient . restart ( ) ;
1787
1768
}
1788
1769
0 commit comments