Package org.eclipse.jdt.ui.refactoring
Class RenameSupport
java.lang.Object
org.eclipse.jdt.ui.refactoring.RenameSupport
Central access point to execute rename refactorings.
Note: this class is not intended to be subclassed or instantiated.
- Since:
- 2.1
- Restriction:
- This class is not intended to be subclassed by clients.
- Restriction:
- This class is not intended to be instantiated by clients.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Flag indication that no additional update is to be performed.static final int
Flag indicating that the getter method is to be updated as well.static final int
Deprecated.use UPDATE_REFERENCES or UPDATE_TEXTUAL_MATCHES or both.static final int
Flag indicating that references are to be updated as well.static final int
Deprecated.use UPDATE_TEXTUAL_MATCHESstatic final int
Flag indicating that the setter method is to be updated as well.static final int
Deprecated.use UPDATE_TEXTUAL_MATCHESstatic final int
Flag indicating that textual matches in comments and in string literals are to be updated as well. -
Method Summary
Modifier and TypeMethodDescriptionstatic RenameSupport
create
(ICompilationUnit unit, String newName, int flags) Creates a new rename support for the givenICompilationUnit
.static RenameSupport
Creates a new rename support for the givenIField
.static RenameSupport
create
(IJavaProject project, String newName, int flags) Creates a new rename support for the givenIJavaProject
.static RenameSupport
create
(ILocalVariable variable, String newName, int flags) Creates a new rename support for the givenILocalVariable
.static RenameSupport
Creates a new rename support for the givenIMethod
.static RenameSupport
create
(IModuleDescription module, String newName, int flags) Creates a new rename support for the givenIModuleDescription
.static RenameSupport
create
(IPackageFragment fragment, String newName, int flags) Creates a new rename support for the givenIPackageFragment
.static RenameSupport
create
(IPackageFragmentRoot root, String newName) Creates a new rename support for the givenIPackageFragmentRoot
.static RenameSupport
create
(ITypeParameter parameter, String newName, int flags) Creates a new rename support for the givenITypeParameter
.static RenameSupport
Creates a new rename support for the givenIType
.static RenameSupport
create
(RenameJavaElementDescriptor descriptor) Creates a new rename support for the givenRenameJavaElementDescriptor
.void
openDialog
(org.eclipse.swt.widgets.Shell parent) Opens the refactoring dialog for this rename support.boolean
openDialog
(org.eclipse.swt.widgets.Shell parent, boolean showPreviewOnly) Opens the refactoring dialog for this rename support.void
perform
(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context) Executes the rename refactoring without showing a dialog to gather additional user input (for example the new name of theIJavaElement
).org.eclipse.core.runtime.IStatus
preCheck()
Executes some light weight precondition checking.
-
Field Details
-
NONE
public static final int NONEFlag indication that no additional update is to be performed.- See Also:
-
UPDATE_REFERENCES
public static final int UPDATE_REFERENCESFlag indicating that references are to be updated as well.- See Also:
-
UPDATE_JAVADOC_COMMENTS
Deprecated.use UPDATE_REFERENCES or UPDATE_TEXTUAL_MATCHES or both.Flag indicating that Javadoc comments are to be updated as well.- See Also:
-
UPDATE_REGULAR_COMMENTS
Deprecated.use UPDATE_TEXTUAL_MATCHESFlag indicating that regular comments are to be updated as well.- See Also:
-
UPDATE_STRING_LITERALS
Deprecated.use UPDATE_TEXTUAL_MATCHESFlag indicating that string literals are to be updated as well.- See Also:
-
UPDATE_TEXTUAL_MATCHES
public static final int UPDATE_TEXTUAL_MATCHESFlag indicating that textual matches in comments and in string literals are to be updated as well.- Since:
- 3.0
- See Also:
-
UPDATE_GETTER_METHOD
public static final int UPDATE_GETTER_METHODFlag indicating that the getter method is to be updated as well.- See Also:
-
UPDATE_SETTER_METHOD
public static final int UPDATE_SETTER_METHODFlag indicating that the setter method is to be updated as well.- See Also:
-
-
Method Details
-
preCheck
public org.eclipse.core.runtime.IStatus preCheck() throws org.eclipse.core.runtime.CoreExceptionExecutes some light weight precondition checking. If the returned status is an error then the refactoring can't be executed at all. However, returning an OK status doesn't guarantee that the refactoring can be executed. It may still fail while performing the exhaustive precondition checking done inside the methodsopenDialog
orperform
. The method is mainly used to determine enable/disablement of actions.- Returns:
- the result of the light weight precondition checking.
- Throws:
org.eclipse.core.runtime.CoreException
- if an unexpected exception occurs while performing the checking.- See Also:
-
openDialog
public void openDialog(org.eclipse.swt.widgets.Shell parent) throws org.eclipse.core.runtime.CoreException Opens the refactoring dialog for this rename support.- Parameters:
parent
- a shell used as a parent for the refactoring dialog.- Throws:
org.eclipse.core.runtime.CoreException
- if an unexpected exception occurs while opening the dialog.- See Also:
-
openDialog
public boolean openDialog(org.eclipse.swt.widgets.Shell parent, boolean showPreviewOnly) throws org.eclipse.core.runtime.CoreException Opens the refactoring dialog for this rename support.This method has to be called from within the UI thread.
- Parameters:
parent
- a shell used as a parent for the refactoring, preview, or error dialogshowPreviewOnly
- iftrue
, the dialog skips all user input pages and directly shows the preview or error page. Otherwise, shows all pages.- Returns:
true
if the refactoring has been executed successfully,false
if it has been canceled or if an error has happened during initial conditions checking.- Throws:
org.eclipse.core.runtime.CoreException
- if an error occurred while executing the operation.- Since:
- 3.3
- See Also:
-
perform
public void perform(org.eclipse.swt.widgets.Shell parent, org.eclipse.jface.operation.IRunnableContext context) throws InterruptedException, InvocationTargetException Executes the rename refactoring without showing a dialog to gather additional user input (for example the new name of theIJavaElement
). Only an error dialog is shown (if necessary) to present the result of the refactoring's full precondition checking.The method has to be called from within the UI thread.
- Parameters:
parent
- a shell used as a parent for the error dialog.context
- aIRunnableContext
to execute the operation.- Throws:
InterruptedException
- if the operation has been canceled by the user.InvocationTargetException
- if an error occurred while executing the operation.- See Also:
-
openDialog(Shell)
IRunnableContext.run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress)
-
create
public static RenameSupport create(RenameJavaElementDescriptor descriptor) throws org.eclipse.core.runtime.CoreException Creates a new rename support for the givenRenameJavaElementDescriptor
.- Parameters:
descriptor
- theRenameJavaElementDescriptor
to create aRenameSupport
for. The caller is responsible for configuring the descriptor before it is passed.- Returns:
- the
RenameSupport
. - Throws:
org.eclipse.core.runtime.CoreException
- if an unexpected error occurred while creating theRenameSupport
.- Since:
- 3.3
-
create
public static RenameSupport create(IJavaProject project, String newName, int flags) throws org.eclipse.core.runtime.CoreException Creates a new rename support for the givenIJavaProject
.- Parameters:
project
- theIJavaProject
to be renamed.newName
- the project's new name.null
is a valid value indicating that no new name is provided.flags
- flags controlling additional parameters. Valid flags areUPDATE_REFERENCES
orNONE
.- Returns:
- the
RenameSupport
. - Throws:
org.eclipse.core.runtime.CoreException
- if an unexpected error occurred while creating theRenameSupport
.
-
create
public static RenameSupport create(IPackageFragmentRoot root, String newName) throws org.eclipse.core.runtime.CoreException Creates a new rename support for the givenIPackageFragmentRoot
.- Parameters:
root
- theIPackageFragmentRoot
to be renamed.newName
- the package fragment root's new name.null
is a valid value indicating that no new name is provided.- Returns:
- the
RenameSupport
. - Throws:
org.eclipse.core.runtime.CoreException
- if an unexpected error occurred while creating theRenameSupport
.
-
create
public static RenameSupport create(IPackageFragment fragment, String newName, int flags) throws org.eclipse.core.runtime.CoreException Creates a new rename support for the givenIPackageFragment
.- Parameters:
fragment
- theIPackageFragment
to be renamed.newName
- the package fragment's new name.null
is a valid value indicating that no new name is provided.flags
- flags controlling additional parameters. Valid flags areUPDATE_REFERENCES
, andUPDATE_TEXTUAL_MATCHES
, or their bitwise OR, orNONE
.- Returns:
- the
RenameSupport
. - Throws:
org.eclipse.core.runtime.CoreException
- if an unexpected error occurred while creating theRenameSupport
.
-
create
public static RenameSupport create(ICompilationUnit unit, String newName, int flags) throws org.eclipse.core.runtime.CoreException Creates a new rename support for the givenICompilationUnit
.- Parameters:
unit
- theICompilationUnit
to be renamed.newName
- the compilation unit's new name.null
is a valid value indicating that no new name is provided.flags
- flags controlling additional parameters. Valid flags areUPDATE_REFERENCES
, andUPDATE_TEXTUAL_MATCHES
, or their bitwise OR, orNONE
.- Returns:
- the
RenameSupport
. - Throws:
org.eclipse.core.runtime.CoreException
- if an unexpected error occurred while creating theRenameSupport
.
-
create
public static RenameSupport create(IType type, String newName, int flags) throws org.eclipse.core.runtime.CoreException Creates a new rename support for the givenIType
.- Parameters:
type
- theIType
to be renamed.newName
- the type's new name.null
is a valid value indicating that no new name is provided.flags
- flags controlling additional parameters. Valid flags areUPDATE_REFERENCES
, andUPDATE_TEXTUAL_MATCHES
, or their bitwise OR, orNONE
.- Returns:
- the
RenameSupport
. - Throws:
org.eclipse.core.runtime.CoreException
- if an unexpected error occurred while creating theRenameSupport
.
-
create
public static RenameSupport create(IMethod method, String newName, int flags) throws org.eclipse.core.runtime.CoreException Creates a new rename support for the givenIMethod
.- Parameters:
method
- theIMethod
to be renamed.newName
- the method's new name.null
is a valid value indicating that no new name is provided.flags
- flags controlling additional parameters. Valid flags areUPDATE_REFERENCES
orNONE
.- Returns:
- the
RenameSupport
. - Throws:
org.eclipse.core.runtime.CoreException
- if an unexpected error occurred while creating theRenameSupport
.
-
create
public static RenameSupport create(IField field, String newName, int flags) throws org.eclipse.core.runtime.CoreException Creates a new rename support for the givenIField
.- Parameters:
field
- theIField
to be renamed.newName
- the field's new name.null
is a valid value indicating that no new name is provided.flags
- flags controlling additional parameters. Valid flags areUPDATE_REFERENCES
,UPDATE_TEXTUAL_MATCHES
,UPDATE_GETTER_METHOD
, andUPDATE_SETTER_METHOD
, or their bitwise OR, orNONE
.- Returns:
- the
RenameSupport
. - Throws:
org.eclipse.core.runtime.CoreException
- if an unexpected error occurred while creating theRenameSupport
.
-
create
public static RenameSupport create(ITypeParameter parameter, String newName, int flags) throws org.eclipse.core.runtime.CoreException Creates a new rename support for the givenITypeParameter
.- Parameters:
parameter
- theITypeParameter
to be renamed.newName
- the parameter's new name.null
is a valid value indicating that no new name is provided.flags
- flags controlling additional parameters. Valid flags areUPDATE_REFERENCES
, orNONE
.- Returns:
- the
RenameSupport
. - Throws:
org.eclipse.core.runtime.CoreException
- if an unexpected error occurred while creating theRenameSupport
.- Since:
- 3.1
-
create
public static RenameSupport create(ILocalVariable variable, String newName, int flags) throws org.eclipse.core.runtime.CoreException Creates a new rename support for the givenILocalVariable
.- Parameters:
variable
- theILocalVariable
to be renamed.newName
- the variable's new name.null
is a valid value indicating that no new name is provided.flags
- flags controlling additional parameters. Valid flags areUPDATE_REFERENCES
, orNONE
.- Returns:
- the
RenameSupport
. - Throws:
org.eclipse.core.runtime.CoreException
- if an unexpected error occurred while creating theRenameSupport
.- Since:
- 3.1
-
create
public static RenameSupport create(IModuleDescription module, String newName, int flags) throws org.eclipse.core.runtime.CoreException Creates a new rename support for the givenIModuleDescription
.- Parameters:
module
- theIModuleDescription
to be renamed.newName
- the module's new name.null
is not a valid valueflags
- flags controlling additional parameters. Valid flags areUPDATE_REFERENCES
, orNONE
.- Returns:
- the
RenameSupport
. - Throws:
org.eclipse.core.runtime.CoreException
- if an unexpected error occurred while creating theRenameSupport
.- Since:
- 3.24
-