Class TreeParser
java.lang.Object
org.checkerframework.javacutil.trees.TreeParser
A utility class for parsing Java expression snippets, and converting them to proper Javac AST
nodes.
This is useful for parsing EnsuresNonNull*
, and KeyFor
values.
Currently, it handles four tree types only:
- Identifier tree (e.g.
id
) - Literal tree (e.g. 2, 3)
- Method invocation tree (e.g.
method(2, 3)
) - Member select tree (e.g.
Class.field
,instance.method()
) - Array access tree (e.g.
array[id]
)
It's implemented via a Recursive-Descend parser.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionParses the snippet in the string as an internal Javac AST expression node.
-
Constructor Details
-
TreeParser
Create a TreeParser.
-
-
Method Details
-
parseTree
Parses the snippet in the string as an internal Javac AST expression node.- Parameters:
s
- the Java snippet- Returns:
- the AST corresponding to the snippet
-