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

SourceIndex and compiler erros fileURI #128

Merged
merged 14 commits into from
Mar 13, 2024
Merged

SourceIndex and compiler erros fileURI #128

merged 14 commits into from
Mar 13, 2024

Conversation

tdroxler
Copy link
Member

@tdroxler tdroxler commented Mar 8, 2024

Still waiting for a release from the node, but I think we could already ope the discussion.

From test and all my manual testing it seems to work fine, but as always I might miss some place.

The important change is in second commit.

As the fileURI in errors are optional, it's good to keep all you work you did to have fileURI mandatory where we can.

tdroxler and others added 3 commits March 8, 2024 11:38
…uilder`. This commit upgrades workspace errors to `SourceCodeState` errors right from the get-go if `fileURI` is defined in the compilation error.
Copy link
Member

@simerplaha simerplaha left a comment

Choose a reason for hiding this comment

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

Awesome!!!! 🚀

The errors look good 👍🏼.

Just a few minor things. I've submitted PRs for them to this branch.

Comment on lines 232 to 241
def toWorkspaceDiagnostics(workspace: WorkspaceState.IsSourceAware): Iterable[FileDiagnostic] = {
workspace match {
case compiled: WorkspaceState.Errored =>
// Group by fileURI provided errors
compiled.workspaceErrors groupBy(_.index.fileURI) map {
case (Some(fileURI), errors) =>
// fileURI is known, we try to find the source code.
compiled.sourceCode.find(_.fileURI == fileURI) match {
case Some(source) =>
// Source code is known, we report errors at source-code level.
Copy link
Member

@simerplaha simerplaha Mar 11, 2024

Choose a reason for hiding this comment

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

This is great! Just a minor adjustment: we can move this logic to execute immediately after we compile the contracts. This way, compilation errors containing fileURI won't be transformed into workspaceErrors at all. So they will be recognised as regular errors associated with a file throughout the code from the get-go and we can test it everywhere, rather than only when responding to the client in diagnostics.

I've submitted PR #130 to this branch with the change and this is the function.

Comment on lines 12 to 15
implicit val fileURI:java.net.URI = file

val statefulParser = new SourceFileStatefulParser()(Some(fileURI))
import statefulParser._
Copy link
Member

@simerplaha simerplaha Mar 11, 2024

Choose a reason for hiding this comment

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

SourceFileStatefulParser 👍🏼 .

Just minor adjustment: We can remove implicit fileURI and just pass it around as a function parameter where needed.

Implemented in PR #131.

Transform compilation errors to `SourceCode` errors immediately, if `SourceIndex.fileURI` exists
Remove `implicit fileURI` and pass it as a function parameter.
Mandatory `fileURI` for internal `SourceIndex` related functions
@simerplaha simerplaha mentioned this pull request Mar 12, 2024
@tdroxler tdroxler merged commit 4ab1d12 into master Mar 13, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants