Class JavaRefactorer

java.lang.Object
eu.solven.cleanthat.engine.java.refactorer.AAstRefactorer<com.github.javaparser.ast.Node,com.github.javaparser.JavaParser,com.github.javaparser.ast.Node,IJavaparserAstMutator>
eu.solven.cleanthat.engine.java.refactorer.JavaRefactorer
All Implemented Interfaces:
IHasId, ILintFixer, ILintFixerWithId, ILintFixerWithPath

public class JavaRefactorer extends AAstRefactorer<com.github.javaparser.ast.Node,com.github.javaparser.JavaParser,com.github.javaparser.ast.Node,IJavaparserAstMutator>
This class is dedicated to refactoring. Most mutators will refactor code to a better (e.g. shorter, faster, safer, etc) but with [strictly|roughly] equivalent runtime behavior.
Author:
Benoit Lacelle
  • Field Details

  • Constructor Details

    • JavaRefactorer

      public JavaRefactorer(eu.solven.cleanthat.language.IEngineProperties engineProperties, JavaRefactorerProperties properties)
  • Method Details

    • getAllIncluded

      public static final Set<String> getAllIncluded()
    • getId

      public String getId()
    • doFormat

      @Deprecated(since="Not used anymore. Kept for retrocompatiblity of users (e.g. Spotless)", forRemoval=true) public String doFormat(String dirtyCode, LineEnding eol) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Throws:
      IOException
    • doFormat

      public String doFormat(PathAndContent pathAndContent) throws IOException
      Specified by:
      doFormat in interface ILintFixerWithPath
      Overrides:
      doFormat in class AAstRefactorer<com.github.javaparser.ast.Node,com.github.javaparser.JavaParser,com.github.javaparser.ast.Node,IJavaparserAstMutator>
      Throws:
      IOException
    • parseSourceCode

      public Optional<com.github.javaparser.ast.Node> parseSourceCode(com.github.javaparser.JavaParser parser, String sourceCode)
      Specified by:
      parseSourceCode in class AAstRefactorer<com.github.javaparser.ast.Node,com.github.javaparser.JavaParser,com.github.javaparser.ast.Node,IJavaparserAstMutator>
    • makeAstParser

      protected com.github.javaparser.JavaParser makeAstParser()
      Specified by:
      makeAstParser in class AAstRefactorer<com.github.javaparser.ast.Node,com.github.javaparser.JavaParser,com.github.javaparser.ast.Node,IJavaparserAstMutator>
    • fixJavaparserUnexpectedChanges

      protected String fixJavaparserUnexpectedChanges(String dirtyCode, String cleanCode) throws IOException
      Throws:
      IOException
    • computeFixedDelta

      public List<com.github.difflib.patch.AbstractDelta<String>> computeFixedDelta(com.github.difflib.patch.Patch<String> diff)
    • assertPatchIsValid

      protected void assertPatchIsValid(List<String> dirtyRows, List<String> cleanRows, com.github.difflib.patch.Patch<String> diff)
    • toString

      protected String toString(com.github.javaparser.ast.Node compilationUnit)
      Specified by:
      toString in class AAstRefactorer<com.github.javaparser.ast.Node,com.github.javaparser.JavaParser,com.github.javaparser.ast.Node,IJavaparserAstMutator>
    • makeDefaultTypeSolver

      public static com.github.javaparser.resolution.TypeSolver makeDefaultTypeSolver(boolean jreOnly)
    • makeDefaultJavaParser

      public static com.github.javaparser.JavaParser makeDefaultJavaParser(boolean jreOnly)
    • makeDefaultJavaParser

      public static com.github.javaparser.JavaParser makeDefaultJavaParser(boolean jreOnly, com.github.javaparser.ParserConfiguration.LanguageLevel languageLevel)
    • isValidResultString

      protected boolean isValidResultString(com.github.javaparser.JavaParser parser, String resultAsString)
      Specified by:
      isValidResultString in class AAstRefactorer<com.github.javaparser.ast.Node,com.github.javaparser.JavaParser,com.github.javaparser.ast.Node,IJavaparserAstMutator>