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 new UseTargetNewOperator #403

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jevanlingen
Copy link
Contributor

@jevanlingen jevanlingen commented Dec 5, 2024

What's changed?

Add a UseTargetNewOperator recipe as C# variant of Java's UseDiamondOperator recipe.

What's your motivation?

There was an idea of using the UseDiamondOperator, but it turns out it's way easier to just make a new recipe for the target-typed new operator instead..

What is does:

It covers both variable declaration and assignments:

image

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

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@jevanlingen
Copy link
Contributor Author

Todo:

  • There Is still a case left, the code IList<int> a = new List<int>(); cannot be simplified
  • Unit tests

Comment on lines +26 to +27
import org.openrewrite.java.tree.TypeUtils;
import org.openrewrite.marker.Markers;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import org.openrewrite.java.tree.TypeUtils;
import org.openrewrite.marker.Markers;

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

Successfully merging this pull request may close these issues.

1 participant