Parse a new-expression, or if next token isn't Token#NEW, a primary expression. @param allowCallSyntax passed down to #memberExprTail
(boolean allowCallSyntax)
| 3105 | * @param allowCallSyntax passed down to {@link #memberExprTail} |
| 3106 | */ |
| 3107 | private AstNode memberExpr(boolean allowCallSyntax) throws IOException { |
| 3108 | int tt = peekToken(); |
| 3109 | AstNode pn; |
| 3110 | |
| 3111 | if (tt != Token.NEW) { |
| 3112 | pn = primaryExpr(); |
| 3113 | } else { |
| 3114 | consumeToken(); |
| 3115 | int pos = ts.tokenBeg, lineno = lineNumber(), column = columnNumber(); |
| 3116 | NewExpression nx = new NewExpression(pos); |
| 3117 | |
| 3118 | AstNode target = memberExpr(false); |
| 3119 | int end = getNodeEnd(target); |
| 3120 | nx.setTarget(target); |
| 3121 | nx.setLineColumnNumber(lineno, column); |
| 3122 | |
| 3123 | int lp = -1; |
| 3124 | if (matchToken(Token.LP, true)) { |
| 3125 | lp = ts.tokenBeg; |
| 3126 | List<AstNode> args = argumentList(); |
| 3127 | if (args != null && args.size() > ARGC_LIMIT) |
| 3128 | reportError("msg.too.many.constructor.args"); |
| 3129 | int rp = ts.tokenBeg; |
| 3130 | end = ts.tokenEnd; |
| 3131 | if (args != null) nx.setArguments(args); |
| 3132 | nx.setParens(lp - pos, rp - pos); |
| 3133 | } |
| 3134 | |
| 3135 | // Experimental syntax: allow an object literal to follow a new |
| 3136 | // expression, which will mean a kind of anonymous class built with |
| 3137 | // the JavaAdapter. the object literal will be passed as an |
| 3138 | // additional argument to the constructor. |
| 3139 | if (matchToken(Token.LC, true)) { |
| 3140 | ObjectLiteral initializer = objectLiteral(); |
| 3141 | end = getNodeEnd(initializer); |
| 3142 | nx.setInitializer(initializer); |
| 3143 | } |
| 3144 | nx.setLength(end - pos); |
| 3145 | pn = nx; |
| 3146 | } |
| 3147 | return memberExprTail(allowCallSyntax, pn); |
| 3148 | } |
| 3149 | |
| 3150 | /** |
| 3151 | * Parse any number of "(expr)", "[expr]" ".expr", "?.expr", "..expr", ".(expr)" or "?.(expr)" |
no test coverage detected