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
Fields inherited from class spoon.refactoring.AbstractRenameRefactoring
javaIdentifierRE, newName, newNameValidationRE, target
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
createNameConflictIssue(CtVariable<?> conflictVar)
Override this method to get access to details about this refactoring issueprotected void
createNameConflictIssue(CtVariable<?> conflictVar, CtVariableReference<?> shadowedVarRef)
Override this method to get access to details about this refactoring issueprotected void
client may implement this method to check whetherAbstractRenameRefactoring.newName
is in conflict with names of other model elementsprotected void
Methods 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:
refactorNoCheck
in classAbstractRenameRefactoring<CtLocalVariable<?>>
-
detectNameConflicts
protected void detectNameConflicts()Description copied from class:AbstractRenameRefactoring
client may implement this method to check whetherAbstractRenameRefactoring.newName
is in conflict with names of other model elements- Overrides:
detectNameConflicts
in 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`
-