-
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
Add API for collecting problems without building AST to ICompilationUnitResolver #947
Conversation
29fee85
to
7f0b7b0
Compare
I would really like to avoid creating/changing API is we can avoid it.
That is not per se an issue. The conversion of AST is a cheap and easy operation and is neglectable compared to many other processing steps involved earlier to get Javac errors, it's not worth changing the API to avoid it.
Isn't it "just" a bug in the ProblemConverter? |
Yes it is. Converting the javac AST to the JDT AST is cheap but for some reason it's causing issues in jdt.ls : eclipse-jdtls/eclipse.jdt.ls#3322 (comment) . I don't understand exactly what the problem is. I think it has something to do with AST caching but I'm not sure. Perhaps @snjeza can explain?
I guess, but until it's solved, my current implementation won't handle Javadoc errors properly. We can split out collecting the Javadoc errors into a separate visit of the javac AST, and indeed I'll need to do that if we go forward with this PR. |
…nitResolver Limitations: - The method of collecting Javadoc errors requires converting the AST, so the current implementation for collecting errors using javac doesn't collect Javadoc erros Signed-off-by: David Thompson <[email protected]>
7f0b7b0
to
6cee4e3
Compare
I still believe that we shouldn't try to change the API until we don't know what exact problem we're trying to fix. |
When opening or activating a file, Java LS calls the following code:
This code calls
ECJ doesn't create AST if astLevel == 0 javac creates AST twice If we replace
See eclipse-jdtls/eclipse.jdt.ls#3322 (comment) The AST will be saved and not be created when calling |
But it still parses and resolves; whether an AST is created or not doesn't matter. What matters is whether the AST is stored or not.
Why twice? Parsing and resolution are still run only once per call as far as I can see; just like with JDT.
then we always keep a copy of the AST and get memory retained while the request was really to not store the AST. That's not really what's desired. |
JDT/ECJ calls |
ok. I understand. |
I'm starting to think we should ignore NO_AST and always build and set the AST (to avoid the double parse) However, looking at the code, it seems that there is some callback that is invoked when the AST is created. Maybe this is what the if (this.ast != null) {
if (this.deltaBuilder.delta == null) {
this.deltaBuilder.delta = new JavaElementDelta(workingCopy);
}
this.deltaBuilder.delta.changedAST(this.ast);
} |
Okay wait I think I get it now, my bad: ECJ doesn't avoid the double parse itself, right? So it should be okay if the DOM_BASED_OPERATIONS doesn't avoid double parsing. |
My understanding is that it does not prevent either from re-parsing same content in case makeConsistent is called multiple time and NO_AST is set. |
Okay cool. I guess this isn't needed, we can keep the existing behaviour. |
Limitations: