Package com.github.javaparser
Class ParseResult<T>
- java.lang.Object
-
- com.github.javaparser.ParseResult<T>
-
public class ParseResult<T> extends Object
The results given when parsing with an instance of JavaParser.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ParseResult.PostProcessor
A post processor that can be added to ParserConfiguration to add some processing right after parsing.
-
Constructor Summary
Constructors Constructor Description ParseResult(T result, List<Problem> problems, List<JavaToken> tokens, CommentsCollection commentsCollection)
General constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Optional<CommentsCollection>
getCommentsCollection()
Problem
getProblem(int i)
List<Problem>
getProblems()
Optional<T>
getResult()
Optional<List<JavaToken>>
getTokens()
Deprecated.lists of tokens are now kept in every node.void
ifSuccessful(Consumer<T> consumer)
Calls the consumer with the result if parsing was succesful.boolean
isSuccessful()
String
toString()
-
-
-
Constructor Detail
-
ParseResult
public ParseResult(T result, List<Problem> problems, List<JavaToken> tokens, CommentsCollection commentsCollection)
General constructor.- Parameters:
result
- the AST, or empty if it wasn't created.problems
- a list of encountered parsing problems.tokens
- the complete list of tokens that were parsed, or empty if parsing failed completely.
-
-
Method Detail
-
isSuccessful
public boolean isSuccessful()
- Returns:
- if parsing was successful, meaning no errors of any kind were encountered.
-
ifSuccessful
public void ifSuccessful(Consumer<T> consumer)
Calls the consumer with the result if parsing was succesful.
-
getProblems
public List<Problem> getProblems()
- Returns:
- the list of encountered parsing problems. Empty when no problems were encountered.
-
getProblem
public Problem getProblem(int i)
- Returns:
- the
i
'th encountered parsing problem. May throwIndexOutOfBoundsException
.
-
getTokens
@Deprecated public Optional<List<JavaToken>> getTokens()
Deprecated.lists of tokens are now kept in every node. Calling this method is comparable to calling getResult().get().getTokenRange().get()- Returns:
- the complete list of tokens that were parsed, or empty if parsing failed completely.
-
getCommentsCollection
public Optional<CommentsCollection> getCommentsCollection()
- Returns:
- the complete collection of comments encountered while parsing.
-
getResult
public Optional<T> getResult()
- Returns:
- the AST of the parsed source code, or empty if parsing failed completely.
-
-