Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some rewatch fixes #1033

Merged
merged 6 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow here, why is @ prepended?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a way to create a namespace entry (entry module for a namespace in rewatch) - a feature we created and use @ Walnut.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It allows you to have a namespace and create an entry module to the namespace, so not all modules are exposed. The @ is added to the normal namespace module, so it's impossible to import it syntaxwise, and it's opened in the entry module of the namespace, in that module it's possible to alias the modules that are exported from the package.

| _ -> 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.findProjectRootOfFileInDir(projectRootPath)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findProjectRootOfFile is used intentionally here, because it'll look up the project root in a way that doesn't touch the FS unless necessary. It's an optimization, because this is called frequently and it was causing pretty severe slowness at times.

So, the correct fix here would be to make findProjectRootOfFile work instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed now

: 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
2 changes: 1 addition & 1 deletion server/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down