parse

open fun parse(startPackage: String, filename: String): CompilationUnit(source)

Parses a .java files under the source root and returns its CompilationUnit. It keeps track of the parsed file so you can write it out with the saveAll() call. Note that the cache grows with every file parsed, so if you don't need saveAll(), or you don't ask SourceRoot to parse files multiple times (where the cache is useful) you might want to use the parse method with a callback.

Parameters

startPackage

files in this package and deeper are parsed. Pass "" to parse all files.

Throws


open fun parse(startPackage: String, filename: String, configuration: ParserConfiguration, callback: SourceRoot.Callback): SourceRoot(source)

Locates the .java file with the provided package and file name, parses it and passes it to the callback. In comparison to the other parse methods, this is much more memory efficient, but saveAll() won't work.

Parameters

startPackage

The package containing the file

filename

The name of the file


open fun parse(startPackage: String, filename: String, callback: SourceRoot.Callback): SourceRoot(source)

Parses the provided .java file and passes it to the callback. In comparison to the other parse methods, this makes is much more memory efficient., but saveAll() won't work.


open fun parse(startPackage: String, configuration: ParserConfiguration, callback: SourceRoot.Callback): SourceRoot(source)

Tries to parse all .java files in a package recursively and passes them one by one to the callback. In comparison to the other parse methods, this is much more memory efficient, but saveAll() won't work.

Parameters

startPackage

files in this package and deeper are parsed. Pass "" to parse all files.


open fun parse(startPackage: String, callback: SourceRoot.Callback): SourceRoot(source)