| /******************************************************************************* |
| * Copyright (c) 2000, 2003 IBM Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Common Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/cpl-v10.html |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.jdt.core.dom; |
| |
| import java.util.List; |
| |
| /** |
| * Alternate constructor invocation statement AST node type. |
| * |
| * <pre> |
| * ConstructorInvocation: |
| * <b>this</b> <b>(</b> [ Expression { <b>,</b> Expression } ] <b>)</b> <b>;</b> |
| * </pre> |
| * |
| * @since 2.0 |
| */ |
| public class ConstructorInvocation extends Statement { |
| |
| /** |
| * The list of argument expressions (element type: |
| * <code>Expression</code>). Defaults to an empty list. |
| */ |
| private ASTNode.NodeList arguments = |
| new ASTNode.NodeList(true, Expression.class); |
| |
| /** |
| * Creates a new AST node for an alternate constructor invocation statement |
| * owned by the given AST. By default, an empty list of arguments. |
| * |
| * @param ast the AST that is to own this node |
| */ |
| ConstructorInvocation(AST ast) { |
| super(ast); |
| } |
| |
| /* (omit javadoc for this method) |
| * Method declared on ASTNode. |
| */ |
| public int getNodeType() { |
| return CONSTRUCTOR_INVOCATION; |
| } |
| |
| /* (omit javadoc for this method) |
| * Method declared on ASTNode. |
| */ |
| ASTNode clone(AST target) { |
| ConstructorInvocation result = new ConstructorInvocation(target); |
| result.setSourceRange(this.getStartPosition(), this.getLength()); |
| result.copyLeadingComment(this); |
| result.arguments().addAll(ASTNode.copySubtrees(target, arguments())); |
| return result; |
| } |
| |
| /* (omit javadoc for this method) |
| * Method declared on ASTNode. |
| */ |
| public boolean subtreeMatch(ASTMatcher matcher, Object other) { |
| // dispatch to correct overloaded match method |
| return matcher.match(this, other); |
| } |
| |
| /* (omit javadoc for this method) |
| * Method declared on ASTNode. |
| */ |
| void accept0(ASTVisitor visitor) { |
| boolean visitChildren = visitor.visit(this); |
| if (visitChildren) { |
| acceptChildren(visitor, arguments); |
| } |
| visitor.endVisit(this); |
| } |
| |
| /** |
| * Returns the live ordered list of argument expressions in this alternate |
| * constructor invocation statement. |
| * |
| * @return the live list of argument expressions |
| * (element type: <code>Expression</code>) |
| */ |
| public List arguments() { |
| return arguments; |
| } |
| |
| /** |
| * Resolves and returns the binding for the constructor invoked by this |
| * expression. |
| * <p> |
| * Note that bindings are generally unavailable unless requested when the |
| * AST is being built. |
| * </p> |
| * |
| * @return the constructor binding, or <code>null</code> if the binding |
| * cannot be resolved |
| */ |
| public IMethodBinding resolveConstructorBinding() { |
| return getAST().getBindingResolver().resolveConstructor(this); |
| } |
| |
| /* (omit javadoc for this method) |
| * Method declared on ASTNode. |
| */ |
| int memSize() { |
| // treat Code as free |
| return BASE_NODE_SIZE + 1 * 4; |
| } |
| |
| /* (omit javadoc for this method) |
| * Method declared on ASTNode. |
| */ |
| int treeSize() { |
| return |
| memSize() |
| + arguments.listSize(); |
| } |
| } |
| |