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

Recipe to comment imports #3935

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

Conversation

ammachado
Copy link
Contributor

What's changed?

Added a new recipe to comment imports

What's your motivation?

Add a comment to types that were removed

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

  • The import statement is not included in the comment as expected
  • The failing test output is not showing the diffs anymore

Anyone you would like to review specifically?

@timtebeek

Have you considered any alternatives or workarounds?

No

Any additional context

No

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

@timtebeek timtebeek added the recipe Requested Recipe label Feb 24, 2024
Comment on lines +82 to +83
return import_.withComments(ListUtils.concat(import_.getComments(), comment))
.withMarkers(import_.getMarkers().add(new ImportAlreadyCommented(UUID.randomUUID())));
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at this now it appears you'd want to comment out the original import, instead of adding comment to the import; is that correct? In that case I think you'd have to remove this import, find whatever is the next LST element, and merge any comments on this import, that next LST element and a commented out import there.

Slightly more involved; but we'd used similar logic when we for instance add or remove an import: that also needs to shuffle around any existing comments and tag them onto the intuitively right LST element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Requested Recipe
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

None yet

3 participants