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 for yaml #4698

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

nielsdebruin
Copy link
Contributor

@nielsdebruin nielsdebruin commented Nov 21, 2024

What's changed?

This adds initial support for generating references to java type from a Yaml fine in a similar fashion, and with similar limitations, as in:

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 focus points are almost on to one with the previously referenced implementation of references to Java type in .properties files.

Anyone you would like to review specifically?

@timtebeek @Laurens-W

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 self-assigned this Nov 21, 2024
@nielsdebruin nielsdebruin changed the title Add initial support for java references for yaml scalars Add initial support for java references for yaml Nov 21, 2024
@nielsdebruin nielsdebruin linked an issue Nov 21, 2024 that may be closed by this pull request
@nielsdebruin nielsdebruin marked this pull request as ready for review November 22, 2024 09:50
Copy link
Contributor

@knutwannheden knutwannheden left a comment

Choose a reason for hiding this comment

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

I would have expected this PR to only contain the SourceFileWithReferences implementation in Yaml.Documents and not a generic Reference.Provider implementation. But possibly I have missed something here.


@Incubating(since = "8.40.3")
@Value
class YamlReference implements Reference {
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAICT this will now try to match any YAML scalar values against the regexp we have for Java identifiers. This seems wrong to me. I don't think there is any need to add this class here. Instead I would expect "domain-specific" implementations like SpringReference which look for type references in specific YAML documents (matching some given file name or similar).

AFAIK Spring also allows config to be in YAML, so maybe we could provide an implementation for that.

@timtebeek
Copy link
Contributor

I'd applied some light polish to the parallel PR in 713ced2 ; would be good to apply those same changes here as well, and resolve the conflicts.

# Conflicts:
#	rewrite-java-test/src/test/java/org/openrewrite/java/ChangeTypeTest.java
#	rewrite-java/src/main/java/org/openrewrite/java/TypeMatcher.java
@knutwannheden
Copy link
Contributor

Yes, would be good to update this PR now that the dust has settled a bit regarding the rename refactoring.

# Conflicts:
#	rewrite-java/src/main/java/org/openrewrite/java/PackageMatcher.java
#	rewrite-java/src/main/java/org/openrewrite/java/TypeMatcher.java
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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
Status: Ready to Review
Development

Successfully merging this pull request may close these issues.

Expand Reference to include .properties and .yml
4 participants