Class Refactoring


  • public final class Refactoring
    extends Object
    Contains all methods to refactor code elements in the AST.
    • 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.
      • 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 see removeDeprecatedMethods(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.