/******************************************************************************* * Copyright (c) 2003, 2008 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 net.sourceforge.phpdt.core.dom; import java.util.ArrayList; import java.util.List; /** * Type node for a qualified type (added in JLS3 API). *
* QualifiedType: * Type . SimpleName **
* Not all node arragements will represent legal Java constructs. In particular, * it is nonsense if the type is an array type or primitive type. The normal use * is when the type is a simple or parameterized type. *
** A type like "A.B" can be represented either of two ways: *
QualifiedType(SimpleType(SimpleName("A")),SimpleName("B"))
* SimpleType(QualifiedName(SimpleName("A"),SimpleName("B")))
* AST.JLS*
constants
* @return a list of property descriptors (element type:
* {@link StructuralPropertyDescriptor})
*/
public static List propertyDescriptors(int apiLevel) {
return PROPERTY_DESCRIPTORS;
}
/**
* The type node; lazily initialized; defaults to a type with
* an unspecfied, but legal, simple name.
*/
private Type qualifier = null;
/**
* The name being qualified; lazily initialized; defaults to a unspecified,
* legal Java identifier.
*/
private SimpleName name = null;
/**
* Creates a new unparented node for a qualified type owned by the
* given AST. By default, an unspecified, but legal, qualifier and name.
* * N.B. This constructor is package-private. *
* * @param ast the AST that is to own this node */ QualifiedType(AST ast) { super(ast); unsupportedIn2(); } /* (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 property, boolean get, ASTNode child) { if (property == QUALIFIER_PROPERTY) { if (get) { return getQualifier(); } else { setQualifier((Type) child); return null; } } if (property == NAME_PROPERTY) { if (get) { return getName(); } else { setName((SimpleName) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); } /* (omit javadoc for this method) * Method declared on ASTNode. */ final int getNodeType0() { return QUALIFIED_TYPE; } /* (omit javadoc for this method) * Method declared on ASTNode. */ ASTNode clone0(AST target) { QualifiedType result = new QualifiedType(target); result.setSourceRange(this.getStartPosition(), this.getLength()); result.setQualifier((Type) ((ASTNode) getQualifier()).clone(target)); result.setName((SimpleName) ((ASTNode) getName()).clone(target)); return result; } /* (omit javadoc for this method) * Method declared on ASTNode. */ final boolean subtreeMatch0(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) { // visit children in normal left to right reading order acceptChild(visitor, getQualifier()); acceptChild(visitor, getName()); } visitor.endVisit(this); } /** * Returns the qualifier of this qualified type. * * @return the qualifier of this qualified type */ public Type getQualifier() { if (this.qualifier == null) { // lazy init must be thread-safe for readers synchronized (this) { if (this.qualifier == null) { preLazyInit(); this.qualifier = new SimpleType(this.ast); postLazyInit(this.qualifier, QUALIFIER_PROPERTY); } } } return this.qualifier; } /** * Sets the qualifier of this qualified type to the given type. * * @param type the new qualifier of this qualified type * @exception IllegalArgumentException if: *