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

When merging yaml files comments on the last element of existing block are placed at the wrong line #4671

Merged

Conversation

jevanlingen
Copy link
Contributor

@jevanlingen jevanlingen commented Nov 14, 2024

What's changed?

After merge of two yam files, the comments will be placed at the right position.

What's your motivation?

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

@jevanlingen jevanlingen linked an issue Nov 14, 2024 that may be closed by this pull request
@jevanlingen jevanlingen self-assigned this Nov 14, 2024
@jevanlingen jevanlingen added bug Something isn't working recipe Requested Recipe labels Nov 14, 2024
@jevanlingen jevanlingen changed the title 2218 mergeyamlvisitor inline comments not taken into account When merging yaml files comments on the last element of existing block are placed at the wrong line Nov 14, 2024
@jevanlingen jevanlingen force-pushed the 2218-mergeyamlvisitor-inline-comments-not-taken-into-account branch from 65f8e16 to bd350d8 Compare November 18, 2024 09:31
new MergeYamlVisitor<>(document.getBlock(), yaml, Boolean.TRUE.equals(acceptTheirs), objectIdentifyingProperty)
.visitNonNull(document.getBlock(), ctx, getCursor())
);
return getCursor().getMessage(REMOVE_PREFIX, false) ? d.withEnd(d.getEnd().withPrefix("")) : d;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually don't like very much that I needed to put this here; I would rather keep the cursor messages locked in the MergeYamlVisitor class. I couldn't make it work though, because the visitDocument will not be called in that class.

If I overlooked something please let me know! It would be really nice to let this MergeYaml visitor file untouched.

@jevanlingen jevanlingen force-pushed the 2218-mergeyamlvisitor-inline-comments-not-taken-into-account branch from 0f7e1b0 to 35948c7 Compare November 22, 2024 08:36
sambsnyd and others added 3 commits November 22, 2024 00:46
…count' of github.com:openrewrite/rewrite into 2218-mergeyamlvisitor-inline-comments-not-taken-into-account

# Conflicts:
#	rewrite-yaml/src/main/java/org/openrewrite/yaml/MergeYamlVisitor.java
@sambsnyd sambsnyd merged commit a586c31 into main Nov 22, 2024
2 checks passed
@sambsnyd sambsnyd deleted the 2218-mergeyamlvisitor-inline-comments-not-taken-into-account branch November 22, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working recipe Requested Recipe
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

MergeYamlVisitor - inline comments not taken into account
4 participants