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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CompilationUnitprivate final Charsetprivate final Path -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateStorage(CompilationUnit compilationUnit, Path path) privateStorage(CompilationUnit compilationUnit, Path path, Charset encoding) -
Method Summary
Modifier and TypeMethodDescriptiongetPath()reparse(JavaParser javaParser) voidsave()Saves the compilation unit to its original locationvoidsave(Function<CompilationUnit, String> makeOutput) Saves a compilation unit to its original location with formatting according to the function passed as a parameter.voidsave(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.
-
Field Details
-
compilationUnit
-
path
-
encoding
-
-
Constructor Details
-
Storage
-
Storage
-
-
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
-