Class CompilationUnit.Storage

java.lang.Object
com.github.javaparser.ast.CompilationUnit.Storage
Enclosing class:
CompilationUnit

public static class CompilationUnit.Storage extends Object
Information about where this compilation unit was loaded from. This class only stores the absolute location. For more flexibility use SourceRoot.
  • Method Details

    • getPath

      public Path getPath()
      Returns:
      the path to the source for this CompilationUnit
    • getCompilationUnit

      public CompilationUnit getCompilationUnit()
      Returns:
      the CompilationUnit this Storage is about.
    • getEncoding

      public Charset getEncoding()
      Returns:
      the encoding used to read the file.
    • getSourceRoot

      public Path getSourceRoot()
      Returns:
      the source root directory, calculated from the path of this compiation unit, and the package declaration of this compilation unit. If the package declaration is invalid (when it does not match the end of the path) a RuntimeException is thrown.
    • getFileName

      public String getFileName()
    • getDirectory

      public Path getDirectory()
    • save

      public void save()
      Saves the compilation unit to its original location
    • save

      public void save(Function<CompilationUnit,​String> makeOutput)
      Saves a compilation unit to its original location with formatting according to the function passed as a parameter.
      Parameters:
      makeOutput - a function that formats the compilation unit
    • save

      public void save(Function<CompilationUnit,​String> makeOutput, Charset encoding)
      Saves a compilation unit to its original location with formatting and encoding according to the function and encoding passed as a parameter.
      Parameters:
      makeOutput - a function that formats the compilation unit
      encoding - the encoding to use for the saved file
    • reparse

      public ParseResult<CompilationUnit> reparse(JavaParser javaParser)