microsoft / microsoft/TypeScript
Preferred refactorings
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、issue #29450 にある TS Server プロトコルのリファクタリングに関する回答と、関連する quick-fix の提案を確認します。extract constant と extract function の結果がどのように表現されるかを追跡し、次に、ここで説明されている優先リファクタリングの動作を定義し、リファクタリングの完全な一覧が引き続き利用可能であることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- tooling
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100