public boolean isPattern() { ParseTree parseTree = this; while (parseTree.type == ParseTreeType.PAREN_EXPRESSION) { parseTree = parseTree.asParenExpression().expression; } switch (parseTree.type) { case ARRAY_PATTERN: case OBJECT_PATTERN: return true; default: return false; } }
public boolean isValidAssignmentTarget() { ParseTree parseTree = this; while (parseTree.type == ParseTreeType.PAREN_EXPRESSION) { parseTree = parseTree.asParenExpression().expression; } switch (parseTree.type) { case IDENTIFIER_EXPRESSION: case MEMBER_EXPRESSION: case MEMBER_LOOKUP_EXPRESSION: case ARRAY_PATTERN: case OBJECT_PATTERN: case DEFAULT_PARAMETER: return true; default: return false; } }