Skip to content

Commit

Permalink
Some rewatch fixes (#1033)
Browse files Browse the repository at this point in the history
* pick up on namespace-entry

* fix workspace lookup

* fix crash when log file dissappears

* fix

* remove log

* add changelog items
  • Loading branch information
jfrolich authored Aug 30, 2024
1 parent 1a61b15 commit 5497d1d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
## master

#### :bug: Bug Fix

- Fix a regression with incremental typechecking in monorepos with rewatch, where the workspace directory was not properly set.

#### :bug: Bug Fix

- When log files are deleted (due to a clean), the editor tooling doesn't crash anymore

#### :rocket: New Feature

- Support for the `namespace-entry` feature of rewatch, to allow entrypoint modules for namespaced packages.

## 1.54.0

#### :nail_care: Polish
Expand Down
6 changes: 5 additions & 1 deletion analysis/src/FindFiles.ml
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,18 @@ let nameSpaceToName n =

let getNamespace config =
let ns = config |> Json.get "namespace" in
let namespaceEntry = config |> Json.get "namespace-entry" in
let fromString = ns |> bind Json.string in
let isNamespaced =
ns |> bind Json.bool |> Option.value ~default:(fromString |> Option.is_some)
in
let either x y = if x = None then y else x in
if isNamespaced then
let fromName = config |> Json.get "name" |> bind Json.string in
either fromString fromName |> Option.map nameSpaceToName
let name = either fromString fromName |> Option.map nameSpaceToName in
match (namespaceEntry, name) with
| Some _, Some name -> Some ("@" ^ name)
| _ -> name
else None

module StringSet = Set.Make (String)
Expand Down
2 changes: 1 addition & 1 deletion server/src/incrementalCompilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ function triggerIncrementalCompilationOfFile(
return;
}
const workspaceRootPath = projectRootPath
? utils.findProjectRootOfFile(projectRootPath)
? utils.findProjectRootOfFile(projectRootPath, true)
: null;

const bscBinaryLocation = project.bscBinaryLocation;
Expand Down
18 changes: 11 additions & 7 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,17 @@ let compilerLogsWatcher = chokidar
}
}
} else {
sendUpdatedDiagnostics();
sendCompilationFinishedMessage();
if (config.extensionConfiguration.inlayHints?.enable === true) {
sendInlayHintsRefresh();
}
if (config.extensionConfiguration.codeLens === true) {
sendCodeLensRefresh();
try {
sendUpdatedDiagnostics();
sendCompilationFinishedMessage();
if (config.extensionConfiguration.inlayHints?.enable === true) {
sendInlayHintsRefresh();
}
if (config.extensionConfiguration.codeLens === true) {
sendCodeLensRefresh();
}
} catch {
console.log("Error while sending updated diagnostics");
}
}
});
Expand Down
5 changes: 3 additions & 2 deletions server/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ let findProjectRootOfFileInDir = (
// TODO: races here?
// TODO: this doesn't handle file:/// scheme
export let findProjectRootOfFile = (
source: p.DocumentUri
source: p.DocumentUri,
skipParent?: boolean
): null | p.DocumentUri => {
// First look in project files
let foundRootFromProjectFiles: string | null = null;

for (const rootPath of projectsFiles.keys()) {
if (source.startsWith(rootPath)) {
if (source.startsWith(rootPath) && (!skipParent || source !== rootPath)) {
// Prefer the longest path (most nested)
if (
foundRootFromProjectFiles == null ||
Expand Down

0 comments on commit 5497d1d

Please sign in to comment.