Package com.github.javaparser.ast
Class CompilationUnit.Storage
java.lang.Object
com.github.javaparser.ast.CompilationUnit.Storage
- Enclosing class:
- CompilationUnit
Information about where this compilation unit was loaded from.
This class only stores the absolute location.
For more flexibility use SourceRoot.
-
Method Summary
Modifier and TypeMethodDescriptiongetPath()
reparse(JavaParser javaParser)
void
save()
Saves the compilation unit to its original locationvoid
save(Function<CompilationUnit,String> makeOutput)
Saves a compilation unit to its original location with formatting according to the function passed as a parameter.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.
-
Method Details
-
getPath
- Returns:
- the path to the source for this CompilationUnit
-
getCompilationUnit
- Returns:
- the CompilationUnit this Storage is about.
-
getEncoding
- Returns:
- the encoding used to read the file.
-
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
-
getDirectory
-
save
public void save()Saves the compilation unit to its original location -
save
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
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
-