Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2004, 2012 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
 
 
 package org.eclipse.jdt.core.dom;
 
 import java.util.List;

AST node for a parameter within a method reference (MethodRef). These nodes only occur within doc comments (Javadoc). For JLS2:
 MethodRefParameter:
   Type [ Identifier ]
 
For JLS3, the variable arity indicator was added:
 MethodRefParameter:
   Type [ ... ] [ Identifier ]
 

Note: The 1.5 spec for the Javadoc tool does not mention the possibility of a variable arity indicator in method references. However, the 1.5 Javadoc tool itself does indeed support it. Since it makes sense to have a way to explicitly refer to variable arity methods, it seems more likely that the Javadoc spec is wrong in this case.

Since:
3.0
See also:
Javadoc
Noinstantiate:
This class is not intended to be instantiated by clients.
 
 public class MethodRefParameter extends ASTNode {

The "type" structural property of this node type (child type: Type).

Since:
3.0
 
 	public static final ChildPropertyDescriptor TYPE_PROPERTY =
 		new ChildPropertyDescriptor(MethodRefParameter.class"type"Type.class); //$NON-NLS-1$
 
The "varargs" structural property of this node type (type: java.lang.Boolean) (added in JLS3 API).

Since:
3.1
 
 	public static final SimplePropertyDescriptor VARARGS_PROPERTY =
 		new SimplePropertyDescriptor(MethodRefParameter.class"varargs"boolean.class); //$NON-NLS-1$
 
The "name" structural property of this node type (child type: SimpleName).

Since:
3.0
 
 	public static final ChildPropertyDescriptor NAME_PROPERTY =
 		new ChildPropertyDescriptor(MethodRefParameter.class"name"SimpleName.class); //$NON-NLS-1$
 
A list of property descriptors (element type: StructuralPropertyDescriptor), or null if uninitialized.

Since:
3.0
 
 	private static final List PROPERTY_DESCRIPTORS_2_0;

A list of property descriptors (element type: StructuralPropertyDescriptor), or null if uninitialized.

Since:
3.1
 
 	private static final List PROPERTY_DESCRIPTORS_3_0;
 
 	static {
 		List properyList = new ArrayList(3);
 		createPropertyList(MethodRefParameter.classproperyList);
 		addProperty(properyList);
 		addProperty(properyList);
 
 		properyList = new ArrayList(3);
 		createPropertyList(MethodRefParameter.classproperyList);
 		addProperty(properyList);
 		addProperty(properyList);
 		addProperty(properyList);
 	}

Returns a list of structural property descriptors for this node type. Clients must not modify the result.

Parameters:
apiLevel the API level; one of the AST.JLS* constants
Returns:
a list of property descriptors (element type: StructuralPropertyDescriptor)
Since:
3.0
	public static List propertyDescriptors(int apiLevel) {
		if (apiLevel == .) {
else {
		}
	}

The type; lazily initialized; defaults to a unspecified, legal type.
	private Type type = null;

Indicates the last parameter of a variable arity method; defaults to false.

Since:
3.1
	private boolean variableArity = false;

The parameter name, or null if none; none by default.
	private SimpleName optionalParameterName = null;

Creates a new AST node for a method referenece parameter owned by the given AST. By default, the node has an unspecified (but legal) type, not variable arity, and no parameter name.

N.B. This constructor is package-private.

Parameters:
ast the AST that is to own this node
		super(ast);
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	final List internalStructuralPropertiesForType(int apiLevel) {
		return propertyDescriptors(apiLevel);
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor propertyboolean getASTNode child) {
		if (property == ) {
			if (get) {
				return getType();
else {
				setType((Typechild);
				return null;
			}
		}
		if (property == ) {
			if (get) {
				return getName();
else {
				return null;
			}
		}
		// allow default implementation to flag the error
		return super.internalGetSetChildProperty(propertygetchild);
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	final boolean internalGetSetBooleanProperty(SimplePropertyDescriptor propertyboolean getboolean value) {
		if (property == ) {
			if (get) {
				return isVarargs();
else {
				setVarargs(value);
				return false;
			}
		}
		// allow default implementation to flag the error
		return super.internalGetSetBooleanProperty(propertygetvalue);
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	final int getNodeType0() {
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	ASTNode clone0(AST target) {
		MethodRefParameter result = new MethodRefParameter(target);
		result.setType((Type) ASTNode.copySubtree(targetgetType()));
		if (this.. >= .) {
		}
		result.setName((SimpleName) ASTNode.copySubtree(targetgetName()));
		return result;
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	final boolean subtreeMatch0(ASTMatcher matcherObject other) {
		// dispatch to correct overloaded match method
		return matcher.match(thisother);
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	void accept0(ASTVisitor visitor) {
		boolean visitChildren = visitor.visit(this);
		if (visitChildren) {
			// visit children in normal left to right reading order
			acceptChild(visitorgetType());
			acceptChild(visitorgetName());
		}
		visitor.endVisit(this);
	}

Returns the paramter type.

Returns:
the parameter type
	public Type getType() {
		if (this. == null) {
			// lazy init must be thread-safe for readers
			synchronized (this) {
				if (this. == null) {
				}
			}
		}
		return this.;
	}

Sets the paramter type to the given type.

Parameters:
type the new type
Throws:
java.lang.IllegalArgumentException if:
  • the type is null
  • the node belongs to a different AST
  • the node already has a parent
	public void setType(Type type) {
		if (type == null) {
		}
		ASTNode oldChild = this.;
		preReplaceChild(oldChildtype);
		this. = type;
		postReplaceChild(oldChildtype);
	}

Returns whether this method reference parameter is for the last parameter of a variable arity method (added in JLS3 API).

Note that the binding for the type Fooin the vararg method reference #fun(Foo...) is always for the type as written; i.e., the type binding for Foo. However, if you navigate from the MethodRef to its method binding to the type binding for its last parameter, the type binding for the vararg parameter is always an array type (i.e., Foo[]) reflecting the way vararg methods get compiled.

Returns:
true if this is a variable arity parameter, and false otherwise
Throws:
java.lang.UnsupportedOperationException if this operation is used in a JLS2 AST
Since:
3.1
	public boolean isVarargs() {
		return this.;
	}

Sets whether this method reference parameter is for the last parameter of a variable arity method (added in JLS3 API).

Parameters:
variableArity true if this is a variable arity parameter, and false otherwise
Since:
3.1
	public void setVarargs(boolean variableArity) {
		this. = variableArity;
	}

Returns the parameter name, or null if there is none.

Returns:
the parameter name node, or null if there is none
	public SimpleName getName() {
	}

Sets or clears the parameter name.

Parameters:
name the parameter name node, or null if there is none
Throws:
java.lang.IllegalArgumentException if:
  • the node belongs to a different AST
  • the node already has a parent
	public void setName(SimpleName name) {
		ASTNode oldChild = this.;
		preReplaceChild(oldChildname);
		this. = name;
		postReplaceChild(oldChildname);
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	int memSize() {
		return  + 2 * 5;
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	int treeSize() {
		return
			+ (this. == null ? 0 : getType().treeSize())
			+ (this. == null ? 0 : getName().treeSize());
	}
New to GrepCode? Check out our FAQ X