public class SourceRoot extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
SourceRoot.Callback |
Constructor and Description |
---|
SourceRoot(Path root) |
Modifier and Type | Method and Description |
---|---|
SourceRoot |
add(CompilationUnit compilationUnit)
Add a newly created Java file to this source root.
|
SourceRoot |
add(String pkg,
String filename,
CompilationUnit compilationUnit)
Add a newly created Java file to this source root.
|
List<ParseResult<CompilationUnit>> |
getCache()
The Java files that have been parsed by this source root object,
or have been added manually.
|
List<CompilationUnit> |
getCompilationUnits()
The CompilationUnits of the Java files that have been parsed succesfully by this source root object,
or have been added manually.
|
JavaParser |
getJavaParser() |
Function<CompilationUnit,String> |
getPrinter() |
Path |
getRoot()
The path that was passed in the constructor.
|
SourceRoot |
parse(String startPackage,
JavaParser javaParser,
SourceRoot.Callback callback)
Parses a package recursively with a callback.
|
CompilationUnit |
parse(String packag,
String filename)
Try to parse a single Java file and return it.
|
SourceRoot |
saveAll()
Save all files back to where they were found.
|
SourceRoot |
saveAll(Path root)
Save all files back to another path.
|
SourceRoot |
setJavaParser(JavaParser javaParser)
Set the parser that is used for parsing by default.
|
SourceRoot |
setPrinter(Function<CompilationUnit,String> printer)
Set the printing function that transforms compilation units into a string to save.
|
List<ParseResult<CompilationUnit>> |
tryToParse()
Try to parse every .java file in this source root.
|
List<ParseResult<CompilationUnit>> |
tryToParse(String startPackage)
Tries to parse all .java files in a package recursively, caches them, and returns all files ever parsed with this source
root.
|
ParseResult<CompilationUnit> |
tryToParse(String packag,
String filename)
Try to parse a single Java file and return the result of parsing.
|
public SourceRoot(Path root)
public List<ParseResult<CompilationUnit>> tryToParse(String startPackage) throws IOException
IOException
public SourceRoot parse(String startPackage, JavaParser javaParser, SourceRoot.Callback callback) throws IOException
IOException
public List<ParseResult<CompilationUnit>> tryToParse() throws IOException
IOException
public SourceRoot saveAll()
public SourceRoot saveAll(Path root)
public List<ParseResult<CompilationUnit>> getCache()
public List<CompilationUnit> getCompilationUnits()
public ParseResult<CompilationUnit> tryToParse(String packag, String filename) throws IOException
IOException
public CompilationUnit parse(String packag, String filename)
ParseProblemException
- when something went wrong.public SourceRoot add(String pkg, String filename, CompilationUnit compilationUnit)
public SourceRoot add(CompilationUnit compilationUnit)
public Path getRoot()
public JavaParser getJavaParser()
public SourceRoot setJavaParser(JavaParser javaParser)
public SourceRoot setPrinter(Function<CompilationUnit,String> printer)
public Function<CompilationUnit,String> getPrinter()
Copyright © 2007–2017. All rights reserved.