Skip to content

Offer code improvement suggestions #4095

Open

Description

@rcsilva83

I'm trying to migrate from IntelliJ and one of the best features it has is the code improvement suggestions. For example, if I'm using JDK7+ and my code is not using the "diamond operator", it offers me to convert the code to this cleaner version. And it does this for:

  1. Convert to try-with-resources on JDK7+
  2. Convert to lambda on JDK8+

And a lot more.

I know this issue is very broad and probably each of theses code refactoring should have its own issue linked to this one. But first I want to check what the core developers think of this.

Activity

  1. datho7561 commented on Jun 17, 2026

    @datho7561
    Contributor

    We should have "quickfixes" available, which work similar to how you are suggesting. They can be activated by placing the cursor on a problem, then pressing Ctrl+., or clicking on the lightbulb that appears. Are there any quickfixes in particular you think are missing? If so, feel free to file a specific issue for it.

    There might be some quickfixes available for which the corresponding warning isn't enabled by default. Because there's no problem to attach the "fix" to, the "fix" isn't suggested. VS Code provides a mechanism to allow the quickfixes even when there isn't a problem, but then it's harder for the end user to know it's available. Maybe we can enable some more of the compiler warnings in order to make the fixes more visible.

    Upstream in Eclipse, there's also the concept of "cleanups", which are similar to quickfixes in that they try and improve the code, but they are designed to be performed on the whole file at once instead of just one problem. They are activated in Eclipse when a dropdown menu item is clicked or, if enabled, on file save. We might be able to refactor some of the cleanup logic and repurpose it for quickfixes that are missing in vscode-java.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions