Package spoon.refactoring
Class CtRenameLocalVariableRefactoring
java.lang.Object
spoon.refactoring.AbstractRenameRefactoring<CtLocalVariable<?>>
spoon.refactoring.CtRenameLocalVariableRefactoring
- All Implemented Interfaces:
CtRefactoring,CtRenameRefactoring<CtLocalVariable<?>>
Spoon model refactoring function which renames `target` local variable to `newName`
This refactoring will throw
This refactoring will throw
RefactoringException if the model would be not consistent after rename to new name.
The exception is thrown before the model modificatons are started.
CtLocalVariable anLocalVariable = ...
RenameLocalVariableRefactor refactor = new RenameLocalVariableRefactor();
refactor.setTarget(anLocalVariable);
refactor.setNewName("someNewName");
try {
refactor.refactor();
} catch (RefactoringException e) {
//handle name conflict or name shadowing problem
}
-
Field Summary
FieldsFields inherited from class spoon.refactoring.AbstractRenameRefactoring
javaIdentifierRE, newName, newNameValidationRE, target -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcreateNameConflictIssue(CtVariable<?> conflictVar)Override this method to get access to details about this refactoring issueprotected voidcreateNameConflictIssue(CtVariable<?> conflictVar, CtVariableReference<?> shadowedVarRef)Override this method to get access to details about this refactoring issueprotected voidclient may implement this method to check whetherAbstractRenameRefactoring.newNameis in conflict with names of other model elementsprotected voidMethods inherited from class spoon.refactoring.AbstractRenameRefactoring
checkNewNameIsValid, detectIssues, getNewName, getTarget, isJavaIdentifier, refactor, setNewName, setTarget
-
Field Details
-
validVariableNameRE
-
-
Constructor Details
-
CtRenameLocalVariableRefactoring
public CtRenameLocalVariableRefactoring()
-
-
Method Details
-
refactorNoCheck
protected void refactorNoCheck()- Specified by:
refactorNoCheckin classAbstractRenameRefactoring<CtLocalVariable<?>>
-
detectNameConflicts
protected void detectNameConflicts()Description copied from class:AbstractRenameRefactoringclient may implement this method to check whetherAbstractRenameRefactoring.newNameis in conflict with names of other model elements- Overrides:
detectNameConflictsin classAbstractRenameRefactoring<CtLocalVariable<?>>
-
createNameConflictIssue
Override this method to get access to details about this refactoring issue- Parameters:
conflictVar- - variable which would be in conflict with the `targetVariable` after it's rename to new name
-
createNameConflictIssue
protected void createNameConflictIssue(CtVariable<?> conflictVar, CtVariableReference<?> shadowedVarRef)Override this method to get access to details about this refactoring issue- Parameters:
conflictVar- - variable which would shadow reference to `targetVariable` after it's rename to new nameshadowedVarRef- - the reference to `targetVariable`, which would be shadowed by `conflictVar`
-