SourceRoot
A collection of Java source files located in one directory and its subdirectories on the file system. The root directory corresponds to the root of the package structure of the source files within. Files can be parsed and written back one by one or all together. Note that the internal cache used is thread-safe.
- methods called "tryToParse..." will return their result inside a "ParseResult", which supports parse successes and failures.
- methods called "parse..." will return "CompilationUnit"s. If a file fails to parse, an exception is thrown.
- methods ending in "...Parallelized" will speed up parsing by using multiple threads.
Functions
Link copied to clipboard
Add a newly created Java file to the cache of this source root.
Link copied to clipboard
The Java files that have been parsed by this source root object, or have been added manually.
Link copied to clipboard
The CompilationUnits of the Java files that have been parsed succesfully by this source root object, or have been added manually.
Link copied to clipboard
Parses a .java files under the source root and returns its CompilationUnit.
open fun parse(startPackage: String, configuration: ParserConfiguration, callback: SourceRoot.Callback): SourceRoot
Tries to parse all .java files in a package recursively and passes them one by one to the callback.
Parses the provided .java file and passes it to the callback.
open fun parse(startPackage: String, filename: String, configuration: ParserConfiguration, callback: SourceRoot.Callback): SourceRoot
Locates the .java file with the provided package and file name, parses it and passes it to the callback.
Link copied to clipboard
Tries to parse all .java files recursively using multiple threads, and passes them one by one to the callback.
open fun parseParallelized(startPackage: String, configuration: ParserConfiguration, callback: SourceRoot.Callback): SourceRoot
Tries to parse all .java files in a package recursively using multiple threads, and passes them one by one to the callback.
Link copied to clipboard
Save all previously parsed files back to where they were found.
Save all previously parsed files back to where they were found, with the given encoding.
Save all previously parsed files back to a new path.
Saves all cached compilation units to the specified root directory.
Link copied to clipboard
Tries to parse all .java files under the source root recursively, and returns all files ever parsed with this source root.
Tries to parse all .java files in a package recursively, and returns all files ever parsed with this source root.
open fun tryToParse(startPackage: String, filename: String, configuration: ParserConfiguration): ParseResult<CompilationUnit>
Tries to parse a .java files under the source root and returns the ParseResult.
Link copied to clipboard
Tries to parse all .java files under the source root recursively using multiple threads, and returns all files ever parsed with this source root.
Tries to parse all .java files in a package recursively using multiple threads, and returns all files ever parsed with this source root.