Initial upgrade to Platform/JDT 3.4.1
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / core / dom / MarkerAnnotation.java
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
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.core.dom;
12
13 import java.util.ArrayList;
14 import java.util.List;
15
16 /**
17  * Marker annotation node (added in JLS3 API). The marker annotation 
18  * "@foo" is equivalent to the normal annotation "@foo()".
19  * <p>
20  * <pre>
21  * MarkerAnnotation:
22  *   <b>@</b> TypeName
23  * </pre>
24  * </p>
25  * 
26  * @since 3.1
27  * @noinstantiate This class is not intended to be instantiated by clients.
28  */
29 public final class MarkerAnnotation extends Annotation {
30
31         /**
32          * The "typeName" structural property of this node type.
33          */
34         public static final ChildPropertyDescriptor TYPE_NAME_PROPERTY = 
35                 internalTypeNamePropertyFactory(MarkerAnnotation.class);
36
37         /**
38          * A list of property descriptors (element type: 
39          * {@link StructuralPropertyDescriptor}),
40          * or null if uninitialized.
41          */
42         private static final List PROPERTY_DESCRIPTORS;
43         
44         static {
45                 List propertyList = new ArrayList(2);
46                 createPropertyList(MarkerAnnotation.class, propertyList);
47                 addProperty(TYPE_NAME_PROPERTY, propertyList);
48                 PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
49         }
50         
51         /**
52          * Returns a list of structural property descriptors for this node type.
53          * Clients must not modify the result.
54          * 
55          * @param apiLevel the API level; one of the AST.JLS* constants
56          * @return a list of property descriptors (element type: 
57          * {@link StructuralPropertyDescriptor})
58          */
59         public static List propertyDescriptors(int apiLevel) {
60                 return PROPERTY_DESCRIPTORS;
61         }
62         
63         /**
64          * Creates a new unparented marker annotation node owned 
65          * by the given AST. By default, the annotation has an
66          * unspecified type name .
67          * <p>
68          * N.B. This constructor is package-private.
69          * </p>
70          * 
71          * @param ast the AST that is to own this node
72          */
73         MarkerAnnotation(AST ast) {
74                 super(ast);
75             unsupportedIn2();
76         }
77
78         /* (omit javadoc for this method)
79          * Method declared on ASTNode.
80          */
81         final List internalStructuralPropertiesForType(int apiLevel) {
82                 return propertyDescriptors(apiLevel);
83         }
84         
85         /* (omit javadoc for this method)
86          * Method declared on ASTNode.
87          */
88         final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) {
89                 if (property == TYPE_NAME_PROPERTY) {
90                         if (get) {
91                                 return getTypeName();
92                         } else {
93                                 setTypeName((Name) child);
94                                 return null;
95                         }
96                 }
97                 // allow default implementation to flag the error
98                 return super.internalGetSetChildProperty(property, get, child);
99         }
100         
101         /* (omit javadoc for this method)
102          * Method declared on BodyDeclaration.
103          */
104         final ChildPropertyDescriptor internalTypeNameProperty() {
105                 return TYPE_NAME_PROPERTY;
106         }
107
108         /* (omit javadoc for this method)
109          * Method declared on ASTNode.
110          */
111         final int getNodeType0() {
112                 return MARKER_ANNOTATION;
113         }
114
115         /* (omit javadoc for this method)
116          * Method declared on ASTNode.
117          */
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()));
122                 return result;
123         }
124         
125         /* (omit javadoc for this method)
126          * Method declared on ASTNode.
127          */
128         final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
129                 // dispatch to correct overloaded match method
130                 return matcher.match(this, other);
131         }
132         
133         /* (omit javadoc for this method)
134          * Method declared on ASTNode.
135          */
136         void accept0(ASTVisitor visitor) {
137                 boolean visitChildren = visitor.visit(this);
138                 if (visitChildren) {
139                         // visit children in normal left to right reading order
140                         acceptChild(visitor, getTypeName());
141                 }
142                 visitor.endVisit(this);
143         }
144         
145         /* (omit javadoc for this method)
146          * Method declared on ASTNode.
147          */
148         int memSize() {
149                 return super.memSize();
150         }
151         
152         /* (omit javadoc for this method)
153          * Method declared on ASTNode.
154          */
155         int treeSize() {
156                 return
157                         memSize()
158                         + (this.typeName == null ? 0 : getTypeName().treeSize());
159         }
160 }