microsoft / microsoft/TypeScript
Preferred refactorings
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia esaminando la risposta relativa al refactoring del protocollo TS Server e la proposta di quick-fix correlata nell’issue #29450. Traccia il modo in cui vengono rappresentati i risultati di extract constant e extract function, quindi definisci il comportamento di refactoring preferito descritto qui e conferma che l’elenco completo dei refactoring rimane disponibile.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100