-
Notifications
You must be signed in to change notification settings - Fork 9
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
Process parse errors (including error nodes) in TextDocumentState
#492
Process parse errors (including error nodes) in TextDocumentState
#492
Conversation
…ostics-in-document-state
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.
Additional comments
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/TextDocumentState.java
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/TextDocumentState.java
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/TextDocumentState.java
Show resolved
Hide resolved
rascal-lsp/src/main/java/org/rascalmpl/vscode/lsp/rascal/RascalTextDocumentService.java
Show resolved
Hide resolved
Looking good! Maybe you can move the |
.whenComplete((t, e) -> { | ||
|
||
// Prepare result values for futures | ||
var tree = new Versioned<>(version, t); |
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.
As a <tree,diagnostics>
pair seem to belong together (not suprisingly), would ik make sense to have one Versioned
object with a version and a pair of <tree,diagnostics>
?
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.
In principle, yes, it would. However, in many places in the project (including the Parametric...
classes), a Versioned<ITree>
is currently expected, so it seems quite an invasive change to supply a Versioned<Pair<ITree,List<Diagnostic>>
instead. I'm not worried about the complicated type parameter btw (i.e., we could hide the structure with an auxiliary class). But it's just a lot of changes to places that we don't really need/hope to touch right now 😉.
At the same time, I imagine the reporting of diagnostics can be streamlined a bit more if the diagnostics become accessible in some places where currently there's only a parse tree. Tt requires a bit more thought, though. I think I'd prefer to do that in a separate PR.
Before this PR, parse trees were processed twice to find error nodes (i.e., the exact same computation was repeated a second time): first in
TextDocumentState
(to figure out iflastTreeWithoutErrors
should be updated), and next inRascalTextDocumentService
(to translate error nodes to LSP diagnostics).After this PR, all processing of parse errors (including error nodes) is moved out of
RascalTextDocumentService
intoTextDocumentState
. There is a new API callgetCurrentDiagnosticsAsync
(optionally with a debounce delay) for consumers to get diagnostics, similar to the existinggetCurrentTreeAsync
.