Package spoon.refactoring
Class Refactoring
- java.lang.Object
-
- spoon.refactoring.Refactoring
-
public final class Refactoring extends Object
Contains all methods to refactor code elements in the AST.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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<?>
copyType(CtType<?> type)
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 Detail
-
changeTypeName
public static void changeTypeName(CtType<?> type, String name)
Changes name of a type element.- Parameters:
type
- Type in the AST.name
- New name of the element.
-
changeMethodName
public static void changeMethodName(CtMethod<?> method, String newName)
Changes name of a method, propagates the change in the executable references of the model.
-
copyMethod
public static CtMethod<?> copyMethod(CtMethod<?> method)
See doc inCtMethod.copyMethod()
-
copyType
public static CtType<?> copyType(CtType<?> type)
See doc inCtType.copyType()
-
changeLocalVariableName
public static void changeLocalVariableName(CtLocalVariable<?> localVariable, String newName) throws RefactoringException
Changes 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
public static void removeDeprecatedMethods(String path)
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
public static void removeDeprecatedMethods(String input, String resultPath)
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.
-
-