use of org.apache.groovy.parser.antlr4.GroovyParser.PostfixExprAltContext in project groovy by apache.
the class SemanticPredicates method isFollowingArgumentsOrClosure.
/**
* Check whether following a method name of command expression.
* Method name should not end with "2: arguments" and "3: closure"
*
* @param context the preceding expression
*/
public static boolean isFollowingArgumentsOrClosure(ExpressionContext context) {
if (context instanceof PostfixExprAltContext) {
List<ParseTree> peacChildren = ((PostfixExprAltContext) context).children;
try {
ParseTree peacChild = peacChildren.get(0);
List<ParseTree> pecChildren = ((PostfixExpressionContext) peacChild).children;
ParseTree pecChild = pecChildren.get(0);
PathExpressionContext pec = (PathExpressionContext) pecChild;
int t = pec.t;
return (2 == t || 3 == t);
} catch (IndexOutOfBoundsException | ClassCastException e) {
throw new GroovyBugError("Unexpected structure of expression context: " + context, e);
}
}
return false;
}
Aggregations