1 /*******************************************************************************
2 * Copyright (c) 2004, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.core.dom;
13 import java.util.ArrayList;
14 import java.util.List;
17 * Marker annotation node (added in JLS3 API). The marker annotation
18 * "@foo" is equivalent to the normal annotation "@foo()".
27 * @noinstantiate This class is not intended to be instantiated by clients.
29 public final class MarkerAnnotation extends Annotation {
32 * The "typeName" structural property of this node type.
34 public static final ChildPropertyDescriptor TYPE_NAME_PROPERTY =
35 internalTypeNamePropertyFactory(MarkerAnnotation.class);
38 * A list of property descriptors (element type:
39 * {@link StructuralPropertyDescriptor}),
40 * or null if uninitialized.
42 private static final List PROPERTY_DESCRIPTORS;
45 List propertyList = new ArrayList(2);
46 createPropertyList(MarkerAnnotation.class, propertyList);
47 addProperty(TYPE_NAME_PROPERTY, propertyList);
48 PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
52 * Returns a list of structural property descriptors for this node type.
53 * Clients must not modify the result.
55 * @param apiLevel the API level; one of the AST.JLS* constants
56 * @return a list of property descriptors (element type:
57 * {@link StructuralPropertyDescriptor})
59 public static List propertyDescriptors(int apiLevel) {
60 return PROPERTY_DESCRIPTORS;
64 * Creates a new unparented marker annotation node owned
65 * by the given AST. By default, the annotation has an
66 * unspecified type name .
68 * N.B. This constructor is package-private.
71 * @param ast the AST that is to own this node
73 MarkerAnnotation(AST ast) {
78 /* (omit javadoc for this method)
79 * Method declared on ASTNode.
81 final List internalStructuralPropertiesForType(int apiLevel) {
82 return propertyDescriptors(apiLevel);
85 /* (omit javadoc for this method)
86 * Method declared on ASTNode.
88 final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
89 if (property == TYPE_NAME_PROPERTY) {
93 setTypeName((Name) child);
97 // allow default implementation to flag the error
98 return super.internalGetSetChildProperty(property, get, child);
101 /* (omit javadoc for this method)
102 * Method declared on BodyDeclaration.
104 final ChildPropertyDescriptor internalTypeNameProperty() {
105 return TYPE_NAME_PROPERTY;
108 /* (omit javadoc for this method)
109 * Method declared on ASTNode.
111 final int getNodeType0() {
112 return MARKER_ANNOTATION;
115 /* (omit javadoc for this method)
116 * Method declared on ASTNode.
118 ASTNode clone0(AST target) {
119 MarkerAnnotation result = new MarkerAnnotation(target);
120 result.setSourceRange(this.getStartPosition(), this.getLength());
121 result.setTypeName((Name) ASTNode.copySubtree(target, getTypeName()));
125 /* (omit javadoc for this method)
126 * Method declared on ASTNode.
128 final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
129 // dispatch to correct overloaded match method
130 return matcher.match(this, other);
133 /* (omit javadoc for this method)
134 * Method declared on ASTNode.
136 void accept0(ASTVisitor visitor) {
137 boolean visitChildren = visitor.visit(this);
139 // visit children in normal left to right reading order
140 acceptChild(visitor, getTypeName());
142 visitor.endVisit(this);
145 /* (omit javadoc for this method)
146 * Method declared on ASTNode.
149 return super.memSize();
152 /* (omit javadoc for this method)
153 * Method declared on ASTNode.
158 + (this.typeName == null ? 0 : getTypeName().treeSize());