Skip to content

Commit 5497d1d

Browse files
authored
Some rewatch fixes (#1033)
* pick up on namespace-entry * fix workspace lookup * fix crash when log file dissappears * fix * remove log * add changelog items
1 parent 1a61b15 commit 5497d1d

File tree

5 files changed

+32
-11
lines changed

5 files changed

+32
-11
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
1313
## master
1414

15+
#### :bug: Bug Fix
16+
17+
- Fix a regression with incremental typechecking in monorepos with rewatch, where the workspace directory was not properly set.
18+
19+
#### :bug: Bug Fix
20+
21+
- When log files are deleted (due to a clean), the editor tooling doesn't crash anymore
22+
23+
#### :rocket: New Feature
24+
25+
- Support for the `namespace-entry` feature of rewatch, to allow entrypoint modules for namespaced packages.
26+
1527
## 1.54.0
1628

1729
#### :nail_care: Polish

analysis/src/FindFiles.ml

+5-1
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,18 @@ let nameSpaceToName n =
9595

9696
let getNamespace config =
9797
let ns = config |> Json.get "namespace" in
98+
let namespaceEntry = config |> Json.get "namespace-entry" in
9899
let fromString = ns |> bind Json.string in
99100
let isNamespaced =
100101
ns |> bind Json.bool |> Option.value ~default:(fromString |> Option.is_some)
101102
in
102103
let either x y = if x = None then y else x in
103104
if isNamespaced then
104105
let fromName = config |> Json.get "name" |> bind Json.string in
105-
either fromString fromName |> Option.map nameSpaceToName
106+
let name = either fromString fromName |> Option.map nameSpaceToName in
107+
match (namespaceEntry, name) with
108+
| Some _, Some name -> Some ("@" ^ name)
109+
| _ -> name
106110
else None
107111

108112
module StringSet = Set.Make (String)

server/src/incrementalCompilation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ function triggerIncrementalCompilationOfFile(
376376
return;
377377
}
378378
const workspaceRootPath = projectRootPath
379-
? utils.findProjectRootOfFile(projectRootPath)
379+
? utils.findProjectRootOfFile(projectRootPath, true)
380380
: null;
381381

382382
const bscBinaryLocation = project.bscBinaryLocation;

server/src/server.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,17 @@ let compilerLogsWatcher = chokidar
227227
}
228228
}
229229
} else {
230-
sendUpdatedDiagnostics();
231-
sendCompilationFinishedMessage();
232-
if (config.extensionConfiguration.inlayHints?.enable === true) {
233-
sendInlayHintsRefresh();
234-
}
235-
if (config.extensionConfiguration.codeLens === true) {
236-
sendCodeLensRefresh();
230+
try {
231+
sendUpdatedDiagnostics();
232+
sendCompilationFinishedMessage();
233+
if (config.extensionConfiguration.inlayHints?.enable === true) {
234+
sendInlayHintsRefresh();
235+
}
236+
if (config.extensionConfiguration.codeLens === true) {
237+
sendCodeLensRefresh();
238+
}
239+
} catch {
240+
console.log("Error while sending updated diagnostics");
237241
}
238242
}
239243
});

server/src/utils.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@ let findProjectRootOfFileInDir = (
4747
// TODO: races here?
4848
// TODO: this doesn't handle file:/// scheme
4949
export let findProjectRootOfFile = (
50-
source: p.DocumentUri
50+
source: p.DocumentUri,
51+
skipParent?: boolean
5152
): null | p.DocumentUri => {
5253
// First look in project files
5354
let foundRootFromProjectFiles: string | null = null;
5455

5556
for (const rootPath of projectsFiles.keys()) {
56-
if (source.startsWith(rootPath)) {
57+
if (source.startsWith(rootPath) && (!skipParent || source !== rootPath)) {
5758
// Prefer the longest path (most nested)
5859
if (
5960
foundRootFromProjectFiles == null ||

0 commit comments

Comments
 (0)