redhat-developer / redhat-developer/vscode-java

Organize Imports should be smarter about single-letter types

Đang mở
#1,438 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

code action
Ngôn ngữ chính
TypeScript
Star
2.3k
Fork
546
Merge trung bình
20 giờ 1 phút
Pull request đã merge (30 ngày)
11

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu từ điểm vào của Organize Imports và tái hiện hành vi bằng đoạn mã Java trong issue này, sử dụng một kiểu chỉ gồm một chữ cái như T có sẵn để import. Công việc hoàn tất khi extension không còn import mù quáng kiểu chỉ gồm một chữ cái mà thay vào đó báo cáo vấn đề thiếu biến kiểu hoặc yêu cầu xác nhận.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java, typescript, vscode
Lĩnh vực
developer-experience, tooling
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
42/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.