Package com.github.javaparser.ast
Class CompilationUnit.Storage
- java.lang.Object
-
- com.github.javaparser.ast.CompilationUnit.Storage
-
- Enclosing class:
- CompilationUnit
public static class CompilationUnit.Storage extends java.lang.ObjectInformation about where this compilation unit was loaded from. This class only stores the absolute location. For more flexibility use SourceRoot.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompilationUnitgetCompilationUnit()java.nio.file.PathgetDirectory()java.nio.charset.CharsetgetEncoding()java.lang.StringgetFileName()java.nio.file.PathgetPath()java.nio.file.PathgetSourceRoot()ParseResult<CompilationUnit>reparse(JavaParser javaParser)voidsave()Saves the compilation unit to its original locationvoidsave(java.util.function.Function<CompilationUnit,java.lang.String> makeOutput)Saves a compilation unit to its original location with formatting according to the function passed as a parameter.voidsave(java.util.function.Function<CompilationUnit,java.lang.String> makeOutput, java.nio.charset.Charset encoding)Saves a compilation unit to its original location with formatting and encoding according to the function and encoding passed as a parameter.
-
-
-
Method Detail
-
getPath
public java.nio.file.Path getPath()
- Returns:
- the path to the source for this CompilationUnit
-
getCompilationUnit
public CompilationUnit getCompilationUnit()
- Returns:
- the CompilationUnit this Storage is about.
-
getEncoding
public java.nio.charset.Charset getEncoding()
- Returns:
- the encoding used to read the file.
-
getSourceRoot
public java.nio.file.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 java.lang.String getFileName()
-
getDirectory
public java.nio.file.Path getDirectory()
-
save
public void save()
Saves the compilation unit to its original location
-
save
public void save(java.util.function.Function<CompilationUnit,java.lang.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(java.util.function.Function<CompilationUnit,java.lang.String> makeOutput, java.nio.charset.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 unitencoding- the encoding to use for the saved file
-
reparse
public ParseResult<CompilationUnit> reparse(JavaParser javaParser)
-
-