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
Modifier is removed when removing an annotation. #3588
Comments
Thank you for reporting this bug. I will try to look at this issue over the next few days. Thank you for your patience. |
It looks more complex than I thought because annotations can be placed before or after the modifier. I think it's related to the concrete syntax model declaration but I'm not sure. Also when we declare concrete syntax model differently (with a mix) we generate other errors on the tests related to the Lexical Preserving Printer (the end of line characters are no longer in conformity with what should be). Maybe @MysterAitch or @matozoid can help us to resolve this issue. |
I'm not touching that thing ever again :-) |
Fix issue #3588 Modifier is removed when removing an annotation
@jlerbsc should this issue be marked as fixed now? Thanks so much for digging in, we really appreciate it! |
Yes this issue is fixed. |
Hi all, thank you very much for resolving this issue, Lexical Preserving Printer is crucial for our tool. Please let me know if there is anything I can do to help. Thanks again for your great tool. |
@nimakarimipour - there is tons of work to do, if you want to help, come to the gitter channel and chat :-) |
# By Renovate Bot (8) and others # Via GitHub (2) and renovate[bot] (1) * upstream/master: chore(deps): update dependency biz.aqute.bnd:bnd-maven-plugin to v6.3.1 chore(deps): update dependency com.squareup.okhttp3:okhttp to v4.10.0 chore(deps): update dependency org.apache.maven.plugins:maven-surefire-plugin to v3.0.0-m7 chore(deps): update dependency org.mockito:mockito-inline to v4.6.1 Fix issue javaparser#3588 Modifier is removed when removing an annotation chore(deps): update dependency biz.aqute.bnd:bnd-maven-plugin to v6.3.0 chore(deps): update dependency org.assertj:assertj-core to v3.23.1 Fix lambda generic types that are always resolved to the first type param chore(deps): update dependency org.mockito:mockito-inline to v4.6.0 chore(deps): update dependency org.assertj:assertj-core to v3.23.0 # Conflicts: # javaparser-core/src/main/java/com/github/javaparser/printer/ConcreteSyntaxModel.java # pom.xml
When using
LexicalPreservation
printer, it mistakenly removes the modifier when we are removing an annotation from aNode
under the following circumstances:FieldDeclaration
.FieldDeclaration
contains a modifier.FieldDeclaraion
contains an annotation.public @Annot Object field;
).I tested the above issue with all modifiers (e.g.
public
,private
,static
and ...) and all cases had the same issue.Please find the code below where the error reported in this issue is reproduced:
The output of the code above is:
The annotation is not removed and the modifier is deleted. Please let me know if you recommend another way of removing annotation from
Node
s or need more information.Best,
Nima
The text was updated successfully, but these errors were encountered: