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

Improve addAll suggestion by inlining the expression into the constructor invocation, when possible #570

Open
Luro02 opened this issue Jul 14, 2024 · 0 comments
Labels
enhancement New feature or request low-priority message Messages that can be improved, are hard to understand or lack context

Comments

@Luro02
Copy link
Collaborator

Luro02 commented Jul 14, 2024

Description

Instead of suggesting

List<T> list = new ArrayList<>();
list.addAll(otherList);

one could suggest

List<T> list = new ArrayList<>(otherList);

Implementation should be simple;

  • look at the previous statement
  • if it is the declaration, then look if it already has an argument in the constructor invocation
  • if not, check if there is a constructor which takes the expression as an argument
    -> make the suggestion
@Luro02 Luro02 added enhancement New feature or request message Messages that can be improved, are hard to understand or lack context low-priority labels Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request low-priority message Messages that can be improved, are hard to understand or lack context
Projects
None yet
Development

No branches or pull requests

1 participant