microsoft / microsoft/TypeScript
Preferred refactorings
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ả
Problems
-
Refactorings such as
extract functionandextract constantmay return multiple possible locations where the code could be extracted to. In many cases however, the user would just like to quick extract something to a reliable location and continue on. -
extract functionis always returned alongsideextract constant. However it is often desirable to extract to a constant instead of a function when possible.
Proposal
In the TS Server protocol, mark some refactoring as a preferred refactorings. Editors could use this information to automatically select the preferred refactoring in the list or even quick apply it without any user input (see https://github.com/Microsoft/vscode/issues/62110 for VS Code's proposal on this)
Preferred refactorings would let users set up actions such as extract constant that reliably extract to the nearest scope with a single action or keyboard shortcut. The UX behavior for this type of action:
-
If only a single
isPreferredrefactoring is returned, apply it automatically. -
If multiple preferred refactorings are returned, show a list of the preferred refactorings that the user can select from
The normal refactor context menu with full list of refactorings would continue to display the full list of refactorings.
We can start conservative with which refactorings are preferred:
- For
extract constant, extract to local const - For
extract function, extract to function at the scope of the parent function - For
extract functionin a method, extract to a method
Related to a similar proposal for quick fixes #29450
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 cách xem xét phản hồi về việc tái cấu trúc giao thức TS Server và đề xuất quick-fix liên quan trong issue #29450. Theo dõi cách biểu diễn kết quả của extract constant và extract function, sau đó xác định hành vi tái cấu trúc được ưu tiên được mô tả ở đây và xác nhận rằng danh sách tái cấu trúc đầy đủ vẫn khả dụ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ó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- 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