removed unused private methods.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / core / dom / ArrayInitializer.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 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
12 package net.sourceforge.phpdt.core.dom;
13
14 import java.util.ArrayList;
15 import java.util.List;
16
17 /**
18  * Array initializer AST node type.
19  *
20  * <pre>
21  * ArrayInitializer:
22  *              <b>{</b> [ Expression { <b>,</b> Expression} [ <b>,</b> ]] <b>}</b>
23  * </pre>
24  * 
25  * @since 2.0
26  * @noinstantiate This class is not intended to be instantiated by clients.
27  */
28 public class ArrayInitializer extends Expression {
29         
30         /**
31          * The "expressions" structural property of this node type.
32          * @since 3.0
33          */
34         public static final ChildListPropertyDescriptor EXPRESSIONS_PROPERTY = 
35                 new ChildListPropertyDescriptor(ArrayInitializer.class, "expressions", Expression.class, CYCLE_RISK); //$NON-NLS-1$
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 properyList = new ArrayList(2);
46                 createPropertyList(ArrayInitializer.class, properyList);
47                 addProperty(EXPRESSIONS_PROPERTY, properyList);
48                 PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
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
56          * <code>AST.JLS*</code> constants
57
58          * @return a list of property descriptors (element type: 
59          * {@link StructuralPropertyDescriptor})
60          * @since 3.0
61          */
62         public static List propertyDescriptors(int apiLevel) {
63                 return PROPERTY_DESCRIPTORS;
64         }
65                         
66         /**
67          * The list of expressions (element type:
68          * <code>Expression</code>). Defaults to an empty list.
69          */
70         private ASTNode.NodeList expressions =
71                 new ASTNode.NodeList(EXPRESSIONS_PROPERTY);
72
73         /**
74          * Creates a new AST node for an array initializer owned by the 
75          * given AST. By default, the list of expressions is empty.
76          * 
77          * @param ast the AST that is to own this node
78          */
79         ArrayInitializer(AST ast) {
80                 super(ast);     
81         }
82
83         /* (omit javadoc for this method)
84          * Method declared on ASTNode.
85          */
86         final List internalStructuralPropertiesForType(int apiLevel) {
87                 return propertyDescriptors(apiLevel);
88         }
89         
90         /* (omit javadoc for this method)
91          * Method declared on ASTNode.
92          */
93         final List internalGetChildListProperty(ChildListPropertyDescriptor property) {
94                 if (property == EXPRESSIONS_PROPERTY) {
95                         return expressions();
96                 }
97                 // allow default implementation to flag the error
98                 return super.internalGetChildListProperty(property);
99         }
100
101         /* (omit javadoc for this method)
102          * Method declared on ASTNode.
103          */
104         final int getNodeType0() {
105                 return ARRAY_INITIALIZER;
106         }
107
108         /* (omit javadoc for this method)
109          * Method declared on ASTNode.
110          */
111         ASTNode clone0(AST target) {
112                 ArrayInitializer result = new ArrayInitializer(target);
113                 result.setSourceRange(this.getStartPosition(), this.getLength());
114                 result.expressions().addAll(ASTNode.copySubtrees(target, expressions()));
115                 return result;
116         }
117
118         /* (omit javadoc for this method)
119          * Method declared on ASTNode.
120          */
121         final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
122                 // dispatch to correct overloaded match method
123                 return matcher.match(this, other);
124         }
125
126         /* (omit javadoc for this method)
127          * Method declared on ASTNode.
128          */
129         void accept0(ASTVisitor visitor) {
130                 boolean visitChildren = visitor.visit(this);
131                 if (visitChildren) {
132                         acceptChildren(visitor, this.expressions);
133                 }
134                 visitor.endVisit(this);
135         }
136         
137         /**
138          * Returns the live ordered list of expressions in this array initializer.
139          * 
140          * @return the live list of expressions 
141          *    (element type: <code>Expression</code>)
142          */ 
143         public List expressions() {
144                 return this.expressions;
145         }
146         
147         /* (omit javadoc for this method)
148          * Method declared on ASTNode.
149          */
150         int memSize() {
151                 return BASE_NODE_SIZE + 1 * 4;
152         }
153         
154         /* (omit javadoc for this method)
155          * Method declared on ASTNode.
156          */
157         int treeSize() {
158                 return memSize() + this.expressions.listSize();
159         }
160 }
161