Azioni del menu Refactor

Refactor menu commands:

Nome

Descrizione

Rinomina

Renames the selected element and (if enabled) corrects all references to the elements (also in other files).
Disponibili: Methods, method parameters, fields, local variables, types, type parameters, enum constants, compilation units, packages, source folders, projects and on a text selection resolving to one of these element types
Shortcut: Alt + Maiusc + R
Opzioni: Renaming a type does allow to rename similarly named variables and methods. Enable 'Update similarly named variables and methods' in the Rename Type dialog. Select 'Configure...' to configure the strategy for matching type names.

Renaming a package does allow to rename its subpackages. Enable 'Rename subpackages' in the Rename Package dialog.

Sposta

Moves the selected elements and (if enabled) corrects all references to the elements (also in other files).
Disponibili: Instance method (which can be moved to a component), one or more static methods, static fields, types, compilation units, packages, source folders and projects and on a text selection resolving to one of these element types
Shortcut: Alt + Maiusc + V
Opzioni: You can use Drag & Drop in the Package Explorer to start this refactoring.
Modifica firma metodo Modifica i nomi, i tipi e l'ordine dei parametri e aggiorna tutti i riferimenti al metodo corrispondente. I parametri possono essere, inoltre, rimossi o aggiunti e il tipo di ritorno metodo e la sua visibilità possono essere modificati.
Disponibili: Methods or on text selection resolving to a method
Opzioni: Enable 'Keep original method as delegate to changed method' in the Change Method Signature dialog to keep the original method.
Estrai metodo Crea un nuovo metodo che contenga le istruzioni o l'espressione attualmente selezionate e sostituisce la selezione con un riferimento al nuovo metodo. Tale funzione è utile per semplificare metodi troppo lunghi o complessi.
Disponibili: È possibile utilizzare Espandi selezione dal menu Modifica per ottenere un intervallo di selezione valido.
Shortcut: Alt + Maiusc + M
Estrai variabile locale Crea una nuova variabile assegnata all'espressione attualmente selezionata e sostituisce la selezione con un riferimento a tale variabile.
Disponibili: Text selections that resolve to local variables. You can use Expand Selection to from the Edit menu to get a valid selection range.
Shortcut: Alt + Maiusc + L
Estrai costante Consente di creare un campo finale static dall'espressione selezionata, di sostituire il riferimento a un campo e, facoltativamente, di utilizzare altre posizioni laddove si presenta la stessa espressione.
Disponibili: Constant expressions or text selections which resolve to constant expressions
Inline Incorpora variabili locali, metodi o costanti.
Disponibili: Methods, static final fields and text selections that resolve to methods, static final fields or local variables
Shortcut: Alt + Maiusc + I
Converti classe anonima in nidificata Converts an anonymous inner class to a member class.
Disponibili: Anonymous inner classes
Converti tipo di membro in livello superiore Crea una nuova unità di compilazione Java per il tipo di membro selezionato, aggiornando tutti i riferimenti in base alla necessità. Per i tipi di membri non statici, viene aggiunto un campo per consentire l'accesso all'istanza di inclusione precedente, se necessario.
Disponibili: Member types or text resolving to a member type
Converti variabile locale in campo Consente di convertire una variabile locale in campo. Se la variabile viene inizializzata al momento della creazione, l'operazione sposta l'inizializzazione alla dichiarazione del nuovo campo o ai costruttori della classe.
Disponibili: Text selections that resolve to local variables
Estrazione superclasse Extracts a common superclass from a set of sibling types. The selected sibling types become direct subclasses of the extracted superclass after applying the refactoring.
Disponibili: Tipi
Opzioni: Enable 'Use the extracted class where possible' to use the newly created class wherever possible. See Use Supertype Where Possible.
Estrai interfaccia Creates a new interface with a set of methods and makes the selected class implement the interface.
Disponibili: Tipi
Opzioni: Enable 'Use the extracted interface type where possible' to use the newly created interface wherever possible. See Use Supertype Where Possible.
Utilizza Supertipo laddove possibile Replaces occurrences of a type with one of its supertypes after identifying all places where this replacement is possible.
Disponibili: Tipi
Sposta a un livello inferiore Consente di spostare un insieme di metodi e campi da una classe alle relative sottoclassi.
Disponibili: One or more methods and fields declared in the same type or on a text selection inside a field or method
Sposta a un livello superiore Consente di spostare un campo o metodo in una superclasse della classe dichiarata o (nel caso dei metodi), dichiara il metodo come abstract nella superclasse.
Disponibili: One or more methods, fields and member types declared in the same type or on a text selection inside a field, method or member type
Introduci riferimenti indiretti Creates a static indirection method delegating to the selected method.
Disponibili: Methods or on text selection resolving to a method
Opzioni: Enable 'Redirect all method invocations' to replace all calls to the original method by calls to the indirection method.
Introduci factory Creates a new factory method, which will call a selected constructor and return the created object. Tutti i riferimenti al costruttore verranno sostituiti da chiamate al nuovo metodo factory.
Disponibili: Dichiarazioni di costruttore
Introduci parametro Sostituisce un'espressione con un riferimento ad un nuovo parametro di metodo ed aggiorna tutti i chiamanti del metodo in modo che trasmettano le espressioni come valore di tale parametro.
Disponibili: Text selections that resolve to expressions
Incapsula campo Sostituisce tutti i riferimenti a un campo con i metodi getting e setting.
Disponibili: Field or a text selection resolving to a field
Generalizzazione tipo dichiarato Consente all'utente di scegliere un supertipo del tipo di riferimento corrente. Se è possibile modificare il riferimento nel nuovo tipo, l'operazione viene eseguita.
Disponibili: Type references and declarations of fields, local variables, and parameters with reference types
Deduci argomenti di tipo generico Replaces raw type occurrences of generic types by parameterized types after identifying all places where this replacement is possible.
Disponibili: Projects, packages, and types
Opzioni: 'Assume clone() returns an instance of the receiver type'. Well-behaved classes generally respect this rule, but if you know that your code violates it, uncheck the box.

'Leave unconstrained type arguments raw (rather than inferring <?>)'. If there are no constraints on the elements of e.g. ArrayList a, unchecking this box will cause Eclipse to still provide a wildcard parameter, replacing the reference with ArrayList<?>.
Migra file JAR Migrates a JAR File on the build path of a project in your workspace to a newer version, possibly using refactoring information stored in the new JAR File to avoid breaking changes.
Disponibili: JAR Files on build path
Crea script Creates a script of the refactorings that have been applied in the workspace. Refactoring scripts can either be saved to a file or copied to the clipboard. See Apply Script.
Disponibili: Sempre
Applica script Applies a refactoring script to projects in your workspace. Refactoring scripts can either be loaded from a file or from the clipboard. See Create Script.
Disponibili: Sempre
Cronologia Browses the workspace refactoring history and offers the option to delete refactorings from the refactoring history.
Disponibili: Sempre

I comandi di refactoring sono disponibili anche dai menu di scelta rapida di numerose viste e dell'editor Java.

Argomenti correlati

Supporto refactoring

Riferimenti correlati

Finestra di dialogo di Refactoring
Preferenze Java