microsoft / microsoft/TypeScript
Extract to constant in enclosing scope should optionally also replace later usage
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.4k
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 117
Mô tả
Given this code:
public setParts(lineNumber: number, parts: GhostTextPart[]): void {
const foreground = this.themeService.getColorTheme().getColor(ghostTextForeground);
let opacity: string | undefined = undefined;
let color: string | undefined = undefined;
if (foreground) {
opacity = String(foreground.rgba.a);
color = Color.Format.CSS.format(opaque(foreground))!;
}
const borderColor = this.themeService.getColorTheme().getColor(ghostTextBorder);
let border: string | undefined = undefined;
if (borderColor) {
border = `2px dashed ${borderColor}`;
}
I would like to factor our this.themeService.getColorTheme() and extract it into its own constant. This should include all later usages.
Since there could be side effects in between, I suggest to do it only if later occurences are also selected.
This is my current workflow and I don't feel smart doing it like that. Multicursors don't really help here.

Also, it would be nice if the name of the new local is heuristically derived from the expression ((...).getFooBar(...) -> fooBar`).
I'm willing to do a PR if I get some pointers.
Let's make the editing experience in VS Code even more amazing 😉
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng việc tìm triển khai của phép tái cấu trúc extract-to-constant và các bài kiểm thử của nó trong kho lưu trữ TypeScript. Tái hiện ví dụ TypeScript được hiển thị, sau đó theo dõi cách các ranh giới lựa chọn và những lần xuất hiện về sau được xử lý. Được xem là hoàn tất khi việc trích xuất phạm vi bao quanh tùy chọn chỉ có thể bao gồm các lần sử dụng về sau khi chúng được chọn, còn việc đặt tên theo heuristic được xem xét riêng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript
- Lĩnh vực
- tooling
- Loại issue
- Tính năng
- Độ 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
- 35/100