Package spoon.refactoring
Class Refactoring
java.lang.Object
spoon.refactoring.Refactoring
Contains all methods to refactor code elements in the AST.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
changeLocalVariableName(CtLocalVariable<?> localVariable, String newName)
Changes name of aCtLocalVariable
.static void
changeMethodName(CtMethod<?> method, String newName)
Changes name of a method, propagates the change in the executable references of the model.static void
changeTypeName(CtType<?> type, String name)
Changes name of a type element.static CtMethod<?>
copyMethod(CtMethod<?> method)
See doc inCtMethod.copyMethod()
static CtType<?>
See doc inCtType.copyType()
static void
removeDeprecatedMethods(String path)
Removes all deprecated methods for all java files in the given path.static void
removeDeprecatedMethods(String input, String resultPath)
Removes all deprecated methods for all java files in the given path.
-
Method Details
-
changeTypeName
Changes name of a type element.- Parameters:
type
- Type in the AST.name
- New name of the element.
-
changeMethodName
Changes name of a method, propagates the change in the executable references of the model. -
copyMethod
See doc inCtMethod.copyMethod()
-
copyType
See doc inCtType.copyType()
-
changeLocalVariableName
public static void changeLocalVariableName(CtLocalVariable<?> localVariable, String newName) throws RefactoringExceptionChanges name of aCtLocalVariable
.- Parameters:
localVariable
- to be renamedCtLocalVariable
in the AST.newName
- New name of the element.- Throws:
RefactoringException
- when rename to newName would cause model inconsistency, like ambiguity, shadowing of other variables, etc.
-
removeDeprecatedMethods
Removes all deprecated methods for all java files in the given path. Only use it if you have > jdk8. Older jdk versions may result in wrong results. Only removes deprecated methods, that are no longer invoked by any method or field. If a deprecated method is invoked by a deprecated method only, which can be removed, the deprecated method is removed too. Result is written to /$Path/$Package. For different output folder seeremoveDeprecatedMethods(String, String)
.- Parameters:
input
- Path to java files in folder.
-
removeDeprecatedMethods
Removes all deprecated methods for all java files in the given path. Only use it if you have > jdk8. Older jdk versions may result in wrong results. Only removes deprecated methods, that are no longer invoked by any method or field. If a deprecated method is invoked by a deprecated method only, which can be removed, the deprecated method is removed too.- Parameters:
input
- Path to java files in folder.resultPath
- Path for the refactored java files.
-