-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
…uilder`. This commit upgrades workspace errors to `SourceCodeState` errors right from the get-go if `fileURI` is defined in the compilation error.
There was a problem hiding this 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.
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. |
There was a problem hiding this comment.
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.
…RI` as function parameter.
implicit val fileURI:java.net.URI = file | ||
|
||
val statefulParser = new SourceFileStatefulParser()(Some(fileURI)) | ||
import statefulParser._ |
There was a problem hiding this comment.
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
Split `SourceCodeState.ErrorSource`
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.