/******************************************************************************* * Copyright (c) 2000, 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; /** * AST node for a qualified name. A qualified name is defined recursively * as a simple name preceded by a name, which qualifies it. Expressing it this * way means that the qualifier and the simple name get their own AST nodes. *
* QualifiedName: * Name . SimpleName **
* See FieldAccess
for guidelines on handling other expressions
* that resemble qualified names.
*
AST.JLS*
constants
* @return a list of property descriptors (element type:
* {@link StructuralPropertyDescriptor})
* @since 3.0
*/
public static List propertyDescriptors(int apiLevel) {
return PROPERTY_DESCRIPTORS;
}
/**
* The identifier; lazily initialized; defaults to a unspecified, legal
* Java identifier.
*/
private Name qualifier = null;
/**
* The name being qualified; lazily initialized; defaults to a unspecified,
* legal Java identifier.
*/
private SimpleName name = null;
/**
* Creates a new AST node for a qualified name owned by the given AST.
* * N.B. This constructor is package-private; all subclasses must be * declared in the same package; clients are unable to declare * additional subclasses. *
* * @param ast the AST that is to own this node */ QualifiedName(AST ast) { 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 property, boolean get, ASTNode child) { if (property == QUALIFIER_PROPERTY) { if (get) { return getQualifier(); } else { setQualifier((Name) 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_NAME; } /* (omit javadoc for this method) * Method declared on ASTNode. */ ASTNode clone0(AST target) { QualifiedName result = new QualifiedName(target); result.setSourceRange(this.getStartPosition(), this.getLength()); result.setQualifier((Name) getQualifier().clone(target)); result.setName((SimpleName) 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 part of this qualified name. * * @return the qualifier part of this qualified name */ public Name getQualifier() { if (this.qualifier == null) { // lazy init must be thread-safe for readers synchronized (this) { if (this.qualifier == null) { preLazyInit(); this.qualifier = new SimpleName(this.ast); postLazyInit(this.qualifier, QUALIFIER_PROPERTY); } } } return this.qualifier; } /** * Sets the qualifier of this qualified name to the given name. * * @param qualifier the qualifier of this qualified name * @exception IllegalArgumentException if: *