parse

open fun <N : Node?> parse(start: ParseStart<N>, provider: Provider): ParseResult<N>(source)

Parses source code. It takes the source code from a Provider. The start indicates what can be found in the source code (compilation unit, block, import...)

Return

the parse result, a collection of encountered problems, and some extra data.

Parameters

start

refer to the constants in ParseStart to see what can be parsed.

provider

refer to Providers to see how you can read source. The provider will be closed after parsing.

<N>

the subclass of Node that is the result of parsing in the start.


Parses the Java code contained in the InputStream and returns a CompilationUnit that represents it.

Return

CompilationUnit representing the Java source code

Parameters

in

InputStream containing Java source code. It will be closed after parsing.

encoding

encoding of the source code


Parses the Java code contained in the InputStream and returns a CompilationUnit that represents it.

Return

CompilationUnit representing the Java source code

Parameters

in

InputStream containing Java source code. It will be closed after parsing.


Parses the Java code contained in a File and returns a CompilationUnit that represents it.

Return

CompilationUnit representing the Java source code

Parameters

file

File containing Java source code. It will be closed after parsing.

Throws

the file was not found


Parses the Java code contained in a file and returns a CompilationUnit that represents it.

Return

CompilationUnit representing the Java source code

Parameters

path

path to a file containing Java source code

Throws

the path could not be accessed


Parses Java code from a Reader and returns a CompilationUnit that represents it.

Return

CompilationUnit representing the Java source code

Parameters

reader

the reader containing Java source code. It will be closed after parsing.


Parses the Java code contained in code and returns a CompilationUnit that represents it.

Return

CompilationUnit representing the Java source code

Parameters

code

Java source code


open fun parse(file: File, encoding: Charset): ParseResult<CompilationUnit>(source)

Deprecated

set the encoding in the ParserConfiguration

Parses the Java code contained in a File and returns a CompilationUnit that represents it.

Return

CompilationUnit representing the Java source code

Parameters

file

File containing Java source code. It will be closed after parsing.

encoding

encoding of the source code

Throws

the file was not found


open fun parse(path: Path, encoding: Charset): ParseResult<CompilationUnit>(source)

Deprecated

set the encoding in the ParserConfiguration

Parses the Java code contained in a file and returns a CompilationUnit that represents it.

Return

CompilationUnit representing the Java source code

Parameters

path

path to a file containing Java source code

encoding

encoding of the source code

Throws

the path could not be accessed