Skip to content

Organize Imports should be smarter about single-letter types #1438

Open

Description

When there's an unresolved single-letter type usage in the code, doing Organize Imports should not blindly import a type it finds

Environment
  • Operating System: Windows 10
  • JDK version: 14
  • Visual Studio Code version: 1.45.0
  • Java extension version: 0.61.0
Steps To Reproduce
  1. do Organize Imports on the code below, while there's a single type T available for import (in my case it was inside Apache POI, but you could just create a trivial T.java file
import java.util.Map;

//import org.apache.poi.ss.formula.functions.T;

public class Bar {

    public void print(Comparable<T> bar, Map<Integer, T> whatever) {

    }

}
Current Result

the type T is imported

Expected Result

the actual issue here is that I forgot to specify the type variable T. Ideally, the extension would give a single error saying exactly that. If that's not feasible, it should at least ask confirmation before importing single-letter types, even if there's only a single one available: the chances that the user actually wants to import such a type are much smaller than the chance that there's an error w.r.t. type variables

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

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