public class JavaExpressionParseUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
JavaExpressionParseUtil.JavaExpressionContext
Context used to parse a Java expression.
|
static class |
JavaExpressionParseUtil.JavaExpressionParseException
An exception that indicates a parse error.
|
Modifier and Type | Field and Description |
---|---|
protected static Pattern |
ANCHORED_PARAMETER_PATTERN
Anchored pattern for a formal parameter use.
|
protected static String |
PARAMETER_REGEX
Regular expression for a formal parameter use.
|
protected static Pattern |
UNANCHORED_PARAMETER_PATTERN
Unanchored; can be used to find all formal parameter uses.
|
Constructor and Description |
---|
JavaExpressionParseUtil() |
Modifier and Type | Method and Description |
---|---|
static JavaExpression |
fromVariableTree(AnnotatedTypeFactory provider,
VariableTree tree) |
static List<Integer> |
parameterIndices(String s)
Returns a list of 1-based indices of all formal parameters that occur in
s . |
static JavaExpression |
parse(String expression,
JavaExpressionParseUtil.JavaExpressionContext context,
TreePath localScope,
boolean useLocalScope)
Parse a string and return its representation as a
JavaExpression , or throw an JavaExpressionParseUtil.JavaExpressionParseException . |
protected static final String PARAMETER_REGEX
protected static final Pattern ANCHORED_PARAMETER_PATTERN
protected static final Pattern UNANCHORED_PARAMETER_PATTERN
public static JavaExpression parse(String expression, JavaExpressionParseUtil.JavaExpressionContext context, TreePath localScope, boolean useLocalScope) throws JavaExpressionParseUtil.JavaExpressionParseException
JavaExpression
, or throw an JavaExpressionParseUtil.JavaExpressionParseException
.expression
- a Java expression to parsecontext
- information about any receiver and argumentslocalScope
- path to local scope to useuseLocalScope
- whether localScope
should be used to resolve identifiersJavaExpressionParseUtil.JavaExpressionParseException
public static List<Integer> parameterIndices(String s)
s
. Each
formal parameter occurs in s as a string like "#1" or "#4". This routine does not do proper
parsing; for instance, if "#2" appears within a string in s, then 2 would be in the result
list.s
- a Java expressions
public static JavaExpression fromVariableTree(AnnotatedTypeFactory provider, VariableTree tree) throws JavaExpressionParseUtil.JavaExpressionParseException