Skip to content
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 initial support for java references in application properties file #4697

Merged
merged 12 commits into from
Nov 25, 2024

Conversation

nielsdebruin
Copy link
Contributor

@nielsdebruin nielsdebruin commented Nov 21, 2024

What's changed?

Add initial support for generating java type references from a application.*.properties file, support has only been added for the values, not the keys.

What's your motivation?

Adding this feature allows existing recipes that support references to be applied to .properties files. For more details see:

Anything in particular you'd like reviewers to focus on?

The current implementation is still rather limited in its functionality and many design choices are still to be made.

Currently, references of Kind.Type or Kind.Package are generated for either a Java package, e.g., com.openrewrite, or a fully qualified type, such as java.lang.Integer, but not Integer, using a regex derived from the current implementation of SpringReference. This matching is only done for the values in a properties file, not the keys. If this is not the case, nearly every key would likely qualify as a package since they usually contain at least a single ".". Is this as desired?

I have added support for renaming Properties.Entry in the TypeMatcher and PackageMatcher and added a test for ChangeType and ChangePackage recipes. It would perhaps be nice to have a list of all the classes which need to support properties, e.g. AnnotationMatcher?

Anyone you would like to review specifically?

@timtebeek @Laurens-W

Have you considered any alternatives or workarounds?

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@nielsdebruin nielsdebruin added the enhancement New feature or request label Nov 21, 2024
@nielsdebruin nielsdebruin linked an issue Nov 21, 2024 that may be closed by this pull request
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ait/PropertiesReference.java

Co-authored-by: Laurens Westerlaken <[email protected]>
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see! Approved already, but it's still marked as draft?

A quick glance from @knutwannheden would be appreciated, but not a hard requirement. Should we mark this as Incubating still?

@nielsdebruin nielsdebruin marked this pull request as ready for review November 22, 2024 08:57
@nielsdebruin
Copy link
Contributor Author

Great to see! Approved already, but it's still marked as draft?

A quick glance from @knutwannheden would be appreciated, but not a hard requirement. Should we mark this as Incubating still?

That might be wise, the code be considered incubating, as most of it implements interfaces that are marked as incubation. I added the incubation annotation.

@Laurens-W
Copy link
Contributor

I still think since the Reference interface is marked as incubating inherently the implementations are also subject to change and therefore might not have to specifically be annotated with incubating

@nielsdebruin
Copy link
Contributor Author

@Laurens-W I have no preference either way, and it's unclear what the convention is within this project. The SimpleTraitMatcher, extends 'TraitMatcherand implementsTrait. While the latter two are already marked incubating SimpleTraitMatcher` is also marked incubating...

@nielsdebruin nielsdebruin changed the title Add initial support for java references in properties file Add initial support for java references in application properties file Nov 25, 2024
@timtebeek timtebeek merged commit 804abca into main Nov 25, 2024
2 checks passed
@timtebeek timtebeek deleted the 4681-expand-reference-to-include-properties branch November 25, 2024 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Expand Reference to include .properties and .yml
3 participants