Removed
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2004 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Common Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
6 |
* http://www.eclipse.org/legal/cpl-v10.html |
7 |
* |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.internal.compiler.ast; |
12 |
|
13 |
import org.eclipse.jdt.internal.compiler.CompilationResult; |
14 |
import org.eclipse.jdt.internal.compiler.ASTVisitor; |
15 |
import org.eclipse.jdt.internal.compiler.lookup.BlockScope; |
16 |
import org.eclipse.jdt.internal.compiler.lookup.ClassScope; |
17 |
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; |
18 |
import org.eclipse.jdt.internal.compiler.problem.AbortType; |
19 |
|
20 |
/** |
21 |
* Enum declaration |
22 |
*/ |
23 |
public class EnumDeclaration extends TypeDeclaration { |
24 |
|
25 |
public EnumConstant[] enumConstants; |
26 |
|
27 |
/** |
28 |
* @param compilationResult |
29 |
*/ |
30 |
public EnumDeclaration(CompilationResult compilationResult) { |
31 |
super(compilationResult); |
32 |
} |
33 |
|
34 |
public StringBuffer printBody(int indent, StringBuffer output) { |
35 |
|
36 |
output.append(" {"); //$NON-NLS-1$ |
37 |
if (enumConstants != null) { |
38 |
int length = enumConstants.length; |
39 |
output.append('\n'); |
40 |
for (int i = 0; i < length - 1; i++) { |
41 |
if (enumConstants[i] != null) { |
42 |
enumConstants[i].print(indent + 1, output); |
43 |
output.append(",\n");//$NON-NLS-1$ |
44 |
} |
45 |
} |
46 |
enumConstants[length - 1].print(indent + 1, output); |
47 |
output.append("\n;\n");//$NON-NLS-1$ |
48 |
} |
49 |
if (this.enums != null) { |
50 |
for (int i = 0; i < this.enums.length; i++) { |
51 |
if (this.enums[i] != null) { |
52 |
output.append('\n'); |
53 |
this.enums[i].print(indent + 1, output); |
54 |
} |
55 |
} |
56 |
} |
57 |
if (memberTypes != null) { |
58 |
for (int i = 0; i < memberTypes.length; i++) { |
59 |
if (memberTypes[i] != null) { |
60 |
output.append('\n'); |
61 |
memberTypes[i].print(indent + 1, output); |
62 |
} |
63 |
} |
64 |
} |
65 |
if (fields != null) { |
66 |
for (int fieldI = 0; fieldI < fields.length; fieldI++) { |
67 |
if (fields[fieldI] != null) { |
68 |
output.append('\n'); |
69 |
fields[fieldI].print(indent + 1, output); |
70 |
} |
71 |
} |
72 |
} |
73 |
if (methods != null) { |
74 |
for (int i = 0; i < methods.length; i++) { |
75 |
if (methods[i] != null) { |
76 |
output.append('\n'); |
77 |
methods[i].print(indent + 1, output); |
78 |
} |
79 |
} |
80 |
} |
81 |
output.append('\n'); |
82 |
return printIndent(indent, output).append('}'); |
83 |
} |
84 |
|
85 |
public void traverse(ASTVisitor visitor, BlockScope blockScope) { |
86 |
|
87 |
if (ignoreFurtherInvestigation) |
88 |
return; |
89 |
try { |
90 |
if (visitor.visit(this, blockScope)) { |
91 |
if (this.typeParameters != null) { |
92 |
int length = this.typeParameters.length; |
93 |
for (int i = 0; i < length; i++) { |
94 |
this.typeParameters[i].traverse(visitor, scope); |
95 |
} |
96 |
} |
97 |
if (this.superclass != null) |
98 |
this.superclass.traverse(visitor, scope); |
99 |
if (this.superInterfaces != null) { |
100 |
int length = this.superInterfaces.length; |
101 |
for (int i = 0; i < length; i++) |
102 |
this.superInterfaces[i].traverse(visitor, scope); |
103 |
} |
104 |
if (this.memberTypes != null) { |
105 |
int length = this.memberTypes.length; |
106 |
for (int i = 0; i < length; i++) |
107 |
this.memberTypes[i].traverse(visitor, scope); |
108 |
} |
109 |
if (this.enums != null) { |
110 |
int length = this.enums.length; |
111 |
for (int i = 0; i < length; i++) { |
112 |
this.enums[i].traverse(visitor, scope); |
113 |
} |
114 |
} |
115 |
if (this.fields != null) { |
116 |
int length = this.fields.length; |
117 |
for (int i = 0; i < length; i++) { |
118 |
FieldDeclaration field; |
119 |
if ((field = this.fields[i]).isStatic()) { |
120 |
field.traverse(visitor, staticInitializerScope); |
121 |
} else { |
122 |
field.traverse(visitor, initializerScope); |
123 |
} |
124 |
} |
125 |
} |
126 |
if (this.methods != null) { |
127 |
int length = methods.length; |
128 |
for (int i = 0; i < length; i++) |
129 |
this.methods[i].traverse(visitor, scope); |
130 |
} |
131 |
} |
132 |
visitor.endVisit(this, blockScope); |
133 |
} catch (AbortType e) { |
134 |
// silent abort |
135 |
} |
136 |
} |
137 |
public void traverse(ASTVisitor visitor, ClassScope classScope) { |
138 |
|
139 |
if (ignoreFurtherInvestigation) |
140 |
return; |
141 |
try { |
142 |
if (visitor.visit(this, classScope)) { |
143 |
if (this.typeParameters != null) { |
144 |
int typeParametersLength = this.typeParameters.length; |
145 |
for (int i = 0; i < typeParametersLength; i++) { |
146 |
this.typeParameters[i].traverse(visitor, scope); |
147 |
} |
148 |
} |
149 |
if (this.superclass != null) |
150 |
this.superclass.traverse(visitor, scope); |
151 |
if (this.superInterfaces != null) { |
152 |
int length = this.superInterfaces.length; |
153 |
for (int i = 0; i < length; i++) |
154 |
this.superInterfaces[i].traverse(visitor, scope); |
155 |
} |
156 |
if (this.memberTypes != null) { |
157 |
int length = this.memberTypes.length; |
158 |
for (int i = 0; i < length; i++) |
159 |
this.memberTypes[i].traverse(visitor, scope); |
160 |
} |
161 |
if (this.enums != null) { |
162 |
int length = this.enums.length; |
163 |
for (int i = 0; i < length; i++) { |
164 |
this.enums[i].traverse(visitor, scope); |
165 |
} |
166 |
} |
167 |
if (this.fields != null) { |
168 |
int length = this.fields.length; |
169 |
for (int i = 0; i < length; i++) { |
170 |
FieldDeclaration field; |
171 |
if ((field = this.fields[i]).isStatic()) { |
172 |
field.traverse(visitor, staticInitializerScope); |
173 |
} else { |
174 |
field.traverse(visitor, initializerScope); |
175 |
} |
176 |
} |
177 |
} |
178 |
if (this.methods != null) { |
179 |
int length = this.methods.length; |
180 |
for (int i = 0; i < length; i++) |
181 |
this.methods[i].traverse(visitor, scope); |
182 |
} |
183 |
} |
184 |
visitor.endVisit(this, classScope); |
185 |
} catch (AbortType e) { |
186 |
// silent abort |
187 |
} |
188 |
} |
189 |
|
190 |
public void traverse(ASTVisitor visitor, CompilationUnitScope unitScope) { |
191 |
|
192 |
if (ignoreFurtherInvestigation) |
193 |
return; |
194 |
try { |
195 |
if (visitor.visit(this, unitScope)) { |
196 |
if (this.typeParameters != null) { |
197 |
int length = this.typeParameters.length; |
198 |
for (int i = 0; i < length; i++) { |
199 |
this.typeParameters[i].traverse(visitor, scope); |
200 |
} |
201 |
} |
202 |
if (this.superclass != null) |
203 |
this.superclass.traverse(visitor, scope); |
204 |
if (this.superInterfaces != null) { |
205 |
int length = this.superInterfaces.length; |
206 |
for (int i = 0; i < length; i++) |
207 |
this.superInterfaces[i].traverse(visitor, scope); |
208 |
} |
209 |
if (this.memberTypes != null) { |
210 |
int length = this.memberTypes.length; |
211 |
for (int i = 0; i < length; i++) |
212 |
this.memberTypes[i].traverse(visitor, scope); |
213 |
} |
214 |
if (this.enums != null) { |
215 |
int length = this.enums.length; |
216 |
for (int i = 0; i < length; i++) { |
217 |
this.enums[i].traverse(visitor, scope); |
218 |
} |
219 |
} |
220 |
if (this.fields != null) { |
221 |
int length = this.fields.length; |
222 |
for (int i = 0; i < length; i++) { |
223 |
FieldDeclaration field; |
224 |
if ((field = this.fields[i]).isStatic()) { |
225 |
field.traverse(visitor, staticInitializerScope); |
226 |
} else { |
227 |
field.traverse(visitor, initializerScope); |
228 |
} |
229 |
} |
230 |
} |
231 |
if (this.methods != null) { |
232 |
int length = this.methods.length; |
233 |
for (int i = 0; i < length; i++) |
234 |
this.methods[i].traverse(visitor, scope); |
235 |
} |
236 |
} |
237 |
visitor.endVisit(this, unitScope); |
238 |
} catch (AbortType e) { |
239 |
// silent abort |
240 |
} |
241 |
} |
242 |
} |