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
183
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 <[email protected]>
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 <[email protected]>
* Fix AddImport match variable's name * Apply formatter * Run a single test * Simplify if/else --------- Co-authored-by: Tim te Beek <[email protected]>
* 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 <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Tim te Beek <[email protected]>
…t "def" preceding declaration type
) * Update get classpath by artifact name to support bazel * Remove string concatenation and add `else` for clarity --------- Co-authored-by: Tim te Beek <[email protected]>
* 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 <[email protected]> Co-authored-by: Tim te Beek <[email protected]> Co-authored-by: Tim te Beek <[email protected]> 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 <[email protected]> * Minimize diff between Yaml and Properties type references --------- Co-authored-by: Tim te Beek <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Knut Wannheden <[email protected]>
* 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 <[email protected]>
openrewrite#4888) * Fixed missing version on multiple dependency management sections in multi-module projects and fixed ignored classifiers when choosing snapshot timestamp * Formatted code, add unit test * Added issue annotation to test * Formatted * Minor polish * Further polish * Generalize comment on continue * Test for snapshot downloading issue * Minor polish --------- Co-authored-by: Tobias Hübner <[email protected]> Co-authored-by: Tim te Beek <[email protected]>
…ncy without onlyIfUsing constraint.
* Fix parser * restore build files * Restore build file * Put arguments on new line for readability * Add test case (even though not reproducible) --------- Co-authored-by: Tim te Beek <[email protected]> Co-authored-by: Knut Wannheden <[email protected]>
* Groovy parser fail with Jenkinsfile and single line comment * Minimize example * Update rewrite-groovy/src/test/java/org/openrewrite/groovy/JenkinsFileTest.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Fix `StringUtils#indexOfNextNonWhitespace()` A `//` sequence inside a multi-line comment caused trouble. --------- Co-authored-by: Tim te Beek <[email protected]> Co-authored-by: Tim te Beek <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Knut Wannheden <[email protected]>
…e#4661) * Add full blown support for Switch pattern matching * Add print idempotency for Record pattern matching --------- Co-authored-by: Laurens Westerlaken <[email protected]> Co-authored-by: Tim te Beek <[email protected]>
* Pull up recipes from rewrite-migrate-java * Also pull up `UpdateMavenProjectPropertyJavaVersion` * Apply formatter
* feat: recipe for adding a key value pair to a json * Slight polish * Slight polish * Strive for better formatting after insertion * Improve some existing cases already * Update test as suggested * Refactoring, extract normalizeNewLines() * Autoformat visitor for JSON * Removing @NotNull annotations * Basic tests for Autodetect * Basic tests for NormalizeLineBreaksVisitor * No public classifier Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Copy&paste typo Co-authored-by: Knut Wannheden <[email protected]> * Copy&paste typo Co-authored-by: Knut Wannheden <[email protected]> * Rename FindLineFormatJsonVisitor * Adding package-info.java files * Parsing the value parameter to JSON * Fixed description * Removing unneeded unQuote method --------- Co-authored-by: dpozinen <[email protected]> Co-authored-by: Tim te Beek <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Knut Wannheden <[email protected]>
…#4923) * Support Groovy methods declaring generic type parameters * Enable some working tests Using `@ExpectedToFail` I found a bunch of tests which appear to have been fixed. I enabled those and replaced `@Disabled` with `@ExpectedToFail` on others.
While a class extending `groovy.lang.Script` typically represents the synthetic class representing the Groovy script as a whole, this is not necessarily the reason. Additionally, also fix parsing of classes extending `Object` as well as correct type attribution for parsed classes with a super class (the `JavType.Class` should not declare any inherited methods).
* Map the type information provided by the compiler instead of trying to determine the type
In case a method's return type and method name contain the type and name of the method's first parameter (as in `public String foobar(String foo, String bar)`), the parameter alignment formatting could go wrong.
* Add backwards compatibility constructors For the two recent changes to `J.Case` and `J.SwitchExpression` which both added new fields, the constructor changed and no constructor was added for API backwards compatibility. This commit adds the corresponding constructors and annotates them both as `@Deprecated` and as `@ScheduledForRemoval` (from the JetBrains annotations). For the latter we provide a date value for the `inVersion` attribute as in `@ScheduledForRemoval(inVersion = "2025-05-01")`. This will allow us to implement some simple tooling to weed these constructors out again, without this chore getting forgotten. * Polish
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