[JEP 512] Add support for compact source files#4940
[JEP 512] Add support for compact source files#4940jlerbsc merged 13 commits intojavaparser:masterfrom
Conversation
|
@johannescoetzee The PR will be merged as soon as the errors have been corrected. A new version of JavaParser will then be released. JavaParserVariableDeclarationTest.javaBaseTypeFromImplicitCompactClassImport:171 » UnsolvedSymbol Unsolved symbol : List |
c6557c0 to
d043ca8
Compare
d043ca8 to
d780adb
Compare
d780adb to
266c0bb
Compare
|
I missed this testcase since I was running all the tests with Java 8, apparently. It's all fixed now |
| customInitialization(); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
I didn't really understand what the point of it was.
There was a problem hiding this comment.
I've updated the comment to simplify it somewhat. Please let me know if it's still unclear
| return SymbolReference.solved(JavaParserFacade.get(typeSolver).getTypeDeclaration(wrappedNode)); | ||
| } | ||
|
|
||
| if (this.wrappedNode.isClassOrInterfaceDeclaration() |
There was a problem hiding this comment.
Isn't this redundant with what is already done in the ClassOrInterfaceDeclarationContext class?
There was a problem hiding this comment.
What I did in the ClassOrInterfaceDeclarationContext class was actually incorrect. That logic was triggered for solving symbols as values (for example resolving the identifier listMember to the relevant member), so it was actually just attempting to resolve names like java.util.listMember. I've removed this logic from ClassOrInterfaceDeclarationContext and added a test to demonstrate that resolving such symbols works.
|
Have you finished this PR? |
|
I will have to be away for two or three days, but as soon as I am back, I will create a new version of JP. |
|
Thank you for this important new PR |
Resolves #4869 and replaces #4902 by @rpx99. I adapted the logic introduced to
java.jjin that PR to fix an issue with the ordering of the members of the compact class.This PR adds support for compact source files/classes introduced in Java 25. It does so by explicitly creating the
ClassOrInterfaceDeclarationnode for the compact class with a newisCompactfield set to true.Adding support for the LPP turned out to be quite complicated. Support for adding/removing members from a compact class was fairly straightforward, but I ran into lots of issues when adding support for converting a non-compact class a compact class and vice-versa. The implementation here still doesn't handle whitespace 100% correctly, but it's close to correct and I've already spent about as much time as I reasonably can debugging it. In my opinion this niche case should not be a blocker, especially considering the LPP does support "normal" operations on these classes.