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 the cache of this source root.
|
SourceRoot |
add(String pkg,
String filename,
CompilationUnit compilationUnit)
Add a newly created Java file to the cache of 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)
Tries to parse all .java files in a package recursively and passes them one by one to the callback.
|
CompilationUnit |
parse(String pkg,
String filename)
Parses a .java files under the source root and returns its CompilationUnit.
|
SourceRoot |
saveAll()
Save all previously parsed files back to where they were found.
|
SourceRoot |
saveAll(Path root)
Save all previously parsed files back to a new 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()
Tries to parse all .java files under the source root recursively, and returns all files ever parsed with this source root.
|
List<ParseResult<CompilationUnit>> |
tryToParse(String startPackage)
Tries to parse all .java files in a package recursively, and returns all files ever parsed with this source root.
|
ParseResult<CompilationUnit> |
tryToParse(String pkg,
String filename)
Tries to parse a .java files under the source root and returns the ParseResult.
|
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 pkg, String filename) throws IOException
IOException
public CompilationUnit parse(String pkg, 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.