From 45f747b609433d2d937f2ab180dcd226c3332a67 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Fri, 30 Aug 2024 14:24:46 +0200 Subject: [PATCH 1/6] pick up on namespace-entry --- analysis/src/FindFiles.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/analysis/src/FindFiles.ml b/analysis/src/FindFiles.ml index fc3556e0a..7efdeab64 100644 --- a/analysis/src/FindFiles.ml +++ b/analysis/src/FindFiles.ml @@ -95,6 +95,7 @@ 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) @@ -102,7 +103,10 @@ let getNamespace config = 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) From 0dc31b8e2f60ddaaeee3b83f8f74c254e9e2930e Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Fri, 30 Aug 2024 14:26:00 +0200 Subject: [PATCH 2/6] fix workspace lookup --- server/src/incrementalCompilation.ts | 2 +- server/src/utils.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/incrementalCompilation.ts b/server/src/incrementalCompilation.ts index 3684f9d92..eec9c5041 100644 --- a/server/src/incrementalCompilation.ts +++ b/server/src/incrementalCompilation.ts @@ -376,7 +376,7 @@ function triggerIncrementalCompilationOfFile( return; } const workspaceRootPath = projectRootPath - ? utils.findProjectRootOfFile(projectRootPath) + ? utils.findProjectRootOfFileInDir(projectRootPath) : null; const bscBinaryLocation = project.bscBinaryLocation; diff --git a/server/src/utils.ts b/server/src/utils.ts index d8df66cd8..bdb5e7add 100644 --- a/server/src/utils.ts +++ b/server/src/utils.ts @@ -25,7 +25,7 @@ export let createFileInTempDir = (extension = "") => { return path.join(os.tmpdir(), tempFileName); }; -let findProjectRootOfFileInDir = ( +export let findProjectRootOfFileInDir = ( source: p.DocumentUri ): null | p.DocumentUri => { let dir = path.dirname(source); From 1580d4e9724bf73e94fee277ec26f59d403ec6fc Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Fri, 30 Aug 2024 14:26:25 +0200 Subject: [PATCH 3/6] fix crash when log file dissappears --- server/src/server.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/server/src/server.ts b/server/src/server.ts index 9a925a695..31f413b0e 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -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"); } } }); From aced35c68fc5d631dd0f1a4b94e7bb5c58e536f5 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Fri, 30 Aug 2024 15:50:34 +0200 Subject: [PATCH 4/6] fix --- server/src/incrementalCompilation.ts | 3 ++- server/src/utils.ts | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/src/incrementalCompilation.ts b/server/src/incrementalCompilation.ts index eec9c5041..20961f3f1 100644 --- a/server/src/incrementalCompilation.ts +++ b/server/src/incrementalCompilation.ts @@ -376,8 +376,9 @@ function triggerIncrementalCompilationOfFile( return; } const workspaceRootPath = projectRootPath - ? utils.findProjectRootOfFileInDir(projectRootPath) + ? utils.findProjectRootOfFile(projectRootPath, true) : null; + console.log("Workspace root path: " + workspaceRootPath); const bscBinaryLocation = project.bscBinaryLocation; if (bscBinaryLocation == null) { diff --git a/server/src/utils.ts b/server/src/utils.ts index bdb5e7add..46c1afbec 100644 --- a/server/src/utils.ts +++ b/server/src/utils.ts @@ -25,7 +25,7 @@ export let createFileInTempDir = (extension = "") => { return path.join(os.tmpdir(), tempFileName); }; -export let findProjectRootOfFileInDir = ( +let findProjectRootOfFileInDir = ( source: p.DocumentUri ): null | p.DocumentUri => { let dir = path.dirname(source); @@ -47,13 +47,14 @@ export 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 || From 3897e1e448a76cb07ba51daa8d461d59fe945a54 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Fri, 30 Aug 2024 22:52:58 +0200 Subject: [PATCH 5/6] remove log --- server/src/incrementalCompilation.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/incrementalCompilation.ts b/server/src/incrementalCompilation.ts index 20961f3f1..0fad494a6 100644 --- a/server/src/incrementalCompilation.ts +++ b/server/src/incrementalCompilation.ts @@ -378,7 +378,6 @@ function triggerIncrementalCompilationOfFile( const workspaceRootPath = projectRootPath ? utils.findProjectRootOfFile(projectRootPath, true) : null; - console.log("Workspace root path: " + workspaceRootPath); const bscBinaryLocation = project.bscBinaryLocation; if (bscBinaryLocation == null) { From 7ff8e71509c7dda85dca522a3869c6ccf45722c4 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Fri, 30 Aug 2024 23:05:06 +0200 Subject: [PATCH 6/6] add changelog items --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87a8db194..c0228c0f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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