forked from openrewrite/rewrite
-
Notifications
You must be signed in to change notification settings - Fork 0
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
preserve annotation values when parsing compiled classes #1
Draft
zexblue01
wants to merge
108
commits into
main
Choose a base branch
from
eason-preserve_annotation_values
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.xml.security.UpdateOwaspSuppressionDate?organizationId=T3BlblJld3JpdGU%3D#defaults=W3sidmFsdWUiOlsiQ1ZFLTIwMTctMTI2MjYiLCJDVkUtMjAxOS0xNTA1MiIsIkNWRS0yMDIzLTM1OTQ3ICIsIkNWRS0yMDIxLTI5NDI4IiwiQ1ZFLTIwMjAtMTE5NzkiLCJDVkUtMjAyMS0zMjc1MSIsIkNWRS0yMDIzLTQ1MTYxIiwiQ1ZFLTIwMjMtNDUxNjMiLCJDVkUtMjAyMy01OTY0ICIsIkNWRS0yMDE5LTExNDAyIiwiQ1ZFLTIwMTktMTE0MDMiLCJDVkUtMjAyMS00MTU4OSIsIkNWRS0yMDIzLTQ5MjM4IiwiQ1ZFLTIwMjItMjUzNjQiLCJDVkUtMjAyMi0xNDcxIiwiQ1ZFLTIwMTgtMTI1OCJdLCJuYW1lIjoiY3ZlTGlzdCJ9XQ== Co-authored-by: Moderne <team@moderne.io>
zexblue01
force-pushed
the
eason-preserve_annotation_values
branch
from
December 4, 2024 01:46
aa1a97f
to
7774567
Compare
…endency is unavailable
zexblue01
force-pushed
the
eason-preserve_annotation_values
branch
from
December 4, 2024 04:13
7774567
to
5b4e72b
Compare
zexblue01
force-pushed
the
eason-preserve_annotation_values
branch
2 times, most recently
from
December 4, 2024 19:27
7efac83
to
49c43df
Compare
zexblue01
force-pushed
the
eason-preserve_annotation_values
branch
from
December 4, 2024 20:07
49c43df
to
4ce0454
Compare
zexblue01
force-pushed
the
eason-preserve_annotation_values
branch
from
December 4, 2024 21:15
4ce0454
to
334b9e2
Compare
Co-authored-by: Tim te Beek <timtebeek@gmail.com>
* Fix AddImport match variable's name * Apply formatter * Run a single test * Simplify if/else --------- Co-authored-by: Tim te Beek <tim@moderne.io>
* feat: Added option to comment out property in yaml Refs: openrewrite#4740 * Update rewrite-yaml/src/main/java/org/openrewrite/yaml/CommentOutProperty.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update rewrite-yaml/src/main/java/org/openrewrite/yaml/CommentOutProperty.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Handle nullable Boolean correctly for usage from rewrite.yml * Drop unused default * Prevent double negation * Adopt `else if` --------- Co-authored-by: Andrei Shakirin <ashakirin@vmware.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Tim te Beek <tim@moderne.io>
…t "def" preceding declaration type
* Add ability to change value using RegExp * Add regex login in separate visitor * Fix formatting * Limit new public API by using a nested dedicated `RegexReplaceVisitor` * Add test for missed case * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: Antho Durairaj <andurairaj@paypal.com> Co-authored-by: Tim te Beek <tim@moderne.io> Co-authored-by: Tim te Beek <timtebeek@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Add initial support for java references for yaml scalars * Add incubation annotation * Add extra test * Add rename support in YamlReference * Add NullMarked Package info * Restrict to application files and rename provider * Fix paths in tests * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Knut Wannheden <knut@moderne.io> * Minimize diff between Yaml and Properties type references --------- Co-authored-by: Tim te Beek <tim@moderne.io> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Knut Wannheden <knut@moderne.io>
* Adding master password decrypting * Remove redundant nonnull * Reorder methods to read top down and use ListUtils * Start off with a minimize public API * Moving the decryption routing inside MavenSettings so it's always executed. * Added tests * Adding newline * Remove unused and failing ChangeParentPom2Test.java * Move decryption to MavenSecuritySettings * Polish MavenSettingsSecurityTest * Implement relocation --------- Co-authored-by: Tim te Beek <tim@moderne.io>
…e#4806) * JavaTemplate bug when inserting `final var` into for-each * Split variable declarations when they contain stop comment
…ewrite#4793) * Basic implementation to find image over multiple sources * Formatting * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Improvement * Improvement * Add TODO removal comments * Add DockerImageReference * Add DockerImageReference * Add DockerImageReference * Introduce AbstractProvider * Improve DockerImageReference * work on it * first impl * Extra yaml test * working example * working example * working example * revert lost * Fix * Support --from and --platform and ignore comments for dockerfile * Merge branch 'main' into introduce-image-reference-and-recipe * Remove files (will be places in rewrite-docker) * Remove files (will be places in rewrite-docker) * Cleanup `findMatches` * Make SourceFileWithReferences `abstract`, so we can define `getReferences` once * Make SourceFileWithReferences `abstract`, so we can define `getReferences` once * Make SourceFileWithReferences `abstract`, so we can define `getReferences` once * Make SourceFileWithReferences `abstract`, so we can define `getReferences` once * Revert `SourceFileWithReferences` as interface * Make matchers static singletons in the provider classes * Update description * Fix tests * Revert implements of File class * Pattern.asPredicate() acts as `find`, not `matches()` --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Tim te Beek <tim@moderne.io>
* Add support for lombok @Builder.Default Annotation * Update rewrite-java-lombok/src/main/java/org/openrewrite/java/lombok/BuilderHandler.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: Tim te Beek <timtebeek@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…d support for varargs (openrewrite#4819) * Revert "Revert parenthesis changes (openrewrite#4818)" This reverts commit b91499c. * Add some real world tests * Add some real world tests * support method invocation called from object in object * ExpectedToFail "Anonymous inner class is not yet supported" * support modifiers in for loop * ExpectedToFail "Java style class argument is not yet supported" * Support varargs * Support varargs * Support varargs (improve test, show code breaking) * Support varargs * Add test for pattern operator * Format cleanup * Format cleanup * Varargs improvements * Varargs improvements * Varargs improvements * Update rewrite-groovy/src/test/java/org/openrewrite/groovy/tree/RealWorldGroovyTest.java Co-authored-by: Tim te Beek <tim@moderne.io> * Adjust other links as well * Small safety improvements * Small safety improvements * Small safety improvements * Cleanup --------- Co-authored-by: Tim te Beek <tim@moderne.io>
* Support `.class` as part of the ClassExpression * Support `.class` as part of the ClassExpression
…roperty (openrewrite#4822) * Add test to reproduce issue with annotation processors * Add a second test and looking any variable version * Update version tag if possible --------- Co-authored-by: Tim te Beek <tim@moderne.io>
* Add lombok support for java-11 * Handle erroneous nodes in open rewrite (openrewrite#4412) * Handle erroneous nodes in a tree * Add visitErroneous to all java parser visitors * Override the visitVariable to handle erroneous identifier names set by JavacParser * retain name and suffix for erroneous varDecl * override the visitVariable to handle error identifiers in all java parser visitors * Remove sysout * Update rewrite-java-test/src/test/java/org/openrewrite/java/JavaParserTest.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update rewrite-java-test/src/test/java/org/openrewrite/java/JavaParserTest.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * handle errors in method params, variable declarations, fix tests * Add missing license headers * fix compilation error * fix compilation error in Java8ParserVisitor * Apply code suggestions from bot * fix cases for statementDelim * fix block statement template generator to handle adding semicolon * fix ChangeStaticFieldToMethod recipe * Record compiler errors from erroneous LST nodes * Adjustments for comments * Java 17 parser adjustment alos in 8, 11 and 21 * Add `FindCompileErrorsTest` & move away from deprecated `print()` --------- Co-authored-by: Jonathan Schnéider <jkschneider@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Tim te Beek <tim@moderne.io> Co-authored-by: aboyko <aboyko@vmware.com> * Make Groovy Parser correctly handle nested parenthesis (openrewrite#4801) * WIP * Format * Format * Move grabbing of whitespace and resetting cursor to where it is actually required * Extra check is not required * Use toString * Add `emptyListLiteralWithParentheses` test * Add `insideFourParenthesesAndEnters` test * Move list tests all to ListTest * Add `emptyMapLiteralWithParentheses` * Review feedback and fix new testcases * Add `attributeWithParentheses` * Improve AttributeTest * Improve AttributeTest * Improve AttributeTest * Improve AttributeTest * Improve AttributeTest * Review fix new testcases * Revert edit to testcase * Add and fix testcase with newline * Add JavaDoc and move logic regarding whitespace and resetting cursor --------- Co-authored-by: lingenj <jacob.van.lingen@moderne.io> * suppress javax.json (openrewrite#4804) * suppress javax.json * Update suppressions.xml * Refactor SpringReference (openrewrite#4805) * Separating and clearer naming * Add license header * Review feedback * refactor: Update Gradle wrapper (openrewrite#4808) Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.gradle.UpdateGradleWrapper?organizationId=T3BlblJld3JpdGU%3D#defaults=W3sibmFtZSI6ImFkZElmTWlzc2luZyIsInZhbHVlIjoiRmFsc2UifV0= Co-authored-by: Moderne <team@moderne.io> * Add recipe to remove Gradle Enterprise and Develocity (openrewrite#4809) * Add recipe to remove Gradle Enterprise and Develocity * Remove left over java plugin * Add a UsesType precondition to ReplaceConstant * Allow file scheme in `RemoteArchive` to simplify testing (openrewrite#4791) * Allow file scheme in `RemoteArchive` to simplify testing While it might look a bit controversial, the file scheme can also point to a remote (for instance a mounted network share) file. By allowing the `file://` scheme we can use `RemoteArchive` for those files. As a useful side effect, this makes testing RemoteArchive handling a lot easier. * fix test * Update rewrite-core/src/test/java/org/openrewrite/remote/RemoteArchiveTest.java Co-authored-by: Sam Snyder <sam@moderne.io> --------- Co-authored-by: Sam Snyder <sam@moderne.io> * Try alternative way of determining parenthesis level for `BinaryExpression` when AST doesn't provide `_INSIDE_PARENTHESES_LEVEL` flag (openrewrite#4807) * Add a `isClassAvailable` method to the ReflectionUtils (openrewrite#4810) * Add a `isClassAvailable` method to the ReflectionUtils * Add a `isClassAvailable` method to the ReflectionUtils * Add a `isClassAvailable` method to the ReflectionUtils * Update rewrite.yml to enforce CompareEnumsWithEqualityOperator * Correctly map generic return and parameter types in `JavaReflectionTypeMapping` (openrewrite#4812) * Polish formatting * Add more scenarios to JavaTypeGoat for simply typed fields and methods that return exceptions. * Support mapping of generic thrown exception types (openrewrite#4813) * refactor: Enum values should be compared with "==" (openrewrite#4811) Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.staticanalysis.CompareEnumsWithEqualityOperator?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne <team@moderne.io> * Keep the names of generic type variables defined by methods. (openrewrite#4814) * Make the same performance improvement to parameter names allocations that we previously made to Java 17/21 in openrewrite#3345. * Fix Java reflection mapping of generic typed fields. (openrewrite#4815) * Revert parenthesis changes (openrewrite#4818) * Revert "Try alternative way of determining parenthesis level for `BinaryExpression` when AST doesn't provide `_INSIDE_PARENTHESES_LEVEL` flag (openrewrite#4807)" This reverts commit e59e48b. * Revert "Make Groovy Parser correctly handle nested parenthesis (openrewrite#4801)" This reverts commit 91a031a. * JavaTemplate bug when inserting `final var` into for-each (openrewrite#4806) * JavaTemplate bug when inserting `final var` into for-each * Split variable declarations when they contain stop comment * Reduce accidental changes between Java 11 and 17 parsers * Add missing import --------- Co-authored-by: Udayani Vaka <79973862+vudayani@users.noreply.github.com> Co-authored-by: Jonathan Schnéider <jkschneider@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Tim te Beek <tim@moderne.io> Co-authored-by: aboyko <aboyko@vmware.com> Co-authored-by: Laurens Westerlaken <laurens.westerlaken@jdriven.com> Co-authored-by: lingenj <jacob.van.lingen@moderne.io> Co-authored-by: Peter Streef <peter@moderne.io> Co-authored-by: Shannon Pamperl <shanman190@gmail.com> Co-authored-by: Moderne <team@moderne.io> Co-authored-by: Sam Snyder <sam@moderne.io>
Co-authored-by: Anshuman Mishra <119983081+amishra-u@users.noreply.github.com>
* Support inner classes * Better text * Improvement * Support nested class without arguments * Improve test * Improvement * Improvement * Support anonymous inner classes
… arguments (openrewrite#4832) * Support nested annotations with properties * Support annotation with empty arguments
* Allowing for expressions on LHS of objectelem * Allowing for expressions on LHS of objectelem --------- Co-authored-by: Greg Oledzki <greg@Mac.lan>
* Fixing handling of multi-line empty maps * Apply formatter --------- Co-authored-by: Tim te Beek <tim@moderne.io>
* Cleanup groovy parser - Remove `def` check for visitTypeTree - Remove unnecessary RedundantDef marker for DeclarationExpression - Made RedundantDef function more specific for MethodNodes - Use `skip` function as much as possible * Cleanup groovy parser - Remove `def` check for visitTypeTree - Remove unnecessary RedundantDef marker for DeclarationExpression - Made RedundantDef function more specific for MethodNodes - Use `skip` function as much as possible * Support for `def` keyword for constructors * Improvement
) * Fix parsing of string literals with linebreaks and spaces * Use `getDelimiter` for GStringExpression * Improve stringLiteralInParentheses test * Remove temporary moreParenthesesStuff test * Revert escapeCharacters test * Remove `lengthAccordingToAst`, use same trick for ConstantExpression in GString * Fix typo
* Add TOML language parser * Polish and address bot review comments * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update rewrite-toml/src/main/java/org/openrewrite/toml/internal/grammar/TomlParserVisitor.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: Tim te Beek <tim@moderne.io> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Adding option cutOffDate to RemoveOwaspSuppressions There are cases were we want to only remove suppressions up to a specific date, this allows a cut off date to be provided when removed expired suppressions * Update rewrite-xml/src/main/java/org/openrewrite/xml/security/RemoveOwaspSuppressions.java Co-authored-by: Tim te Beek <tim@moderne.io> --------- Co-authored-by: Tim te Beek <tim@moderne.io>
* Skip parsing groovy generated transform methods * Skip parsing groovy generated transform methods * Skip parsing groovy generated transform methods * Skip parsing groovy generated transform methods * improvement * improvement * improvement * improvement
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's changed?
This PR adds ability to preserve annotation values parsed by JavaParsers (I updated all existing Java parser versions: 8, 11, 17, 21).
It adds a new subclass
Annotation
ofFullyQualified
in JavaType. It delegates most functionality to annotation'sJavaType.Class
object but stores list of value attribute pairs as part of the structure.What's your motivation?
In the recipe I'm working on I need to be able to access annotation values on the method invoked in the source file (method could be defined in a dependency in the classpath instead of being as part of the source file input).
openrewrite#4745
Have you considered any alternatives or workarounds?
I don't think there is a workaround with OpenRewrite. I worked around in my solution by loading all classes and use reflection to inspect the actual annotation values, which is a bit cumbersome.
Checklist