View | Details | Raw Unified | Return to bug 76159
Collapse All | Expand All

(-).classpath (-1 / +1 lines)
Lines 9-15 Link Here
9
	<classpathentry kind="src" path="formatter"/>
9
	<classpathentry kind="src" path="formatter"/>
10
	<classpathentry kind="src" path="model"/>
10
	<classpathentry kind="src" path="model"/>
11
	<classpathentry kind="src" path="search"/>
11
	<classpathentry kind="src" path="search"/>
12
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
12
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins" excluding="**/internal/"/>
13
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
13
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
14
	<classpathentry kind="output" path="bin"/>
14
	<classpathentry kind="output" path="bin"/>
15
</classpath>
15
</classpath>
(-)compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java (+12 lines)
Lines 35-40 Link Here
35
		return flowInfo;
35
		return flowInfo;
36
	}
36
	}
37
	
37
	
38
	public static final int FIELD = 1;
39
	public static final int INITIALIZER = 2;
40
	public static final int ENUM_CONSTANT = 3;
41
	public static final int LOCAL_VARIABLE = 4;
42
	public static final int PARAMETER = 5;
43
	public static final int TYPE_PARAMETER = 6;
44
	
45
	
38
	/**
46
	/**
39
	 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments()
47
	 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments()
40
	 */
48
	 */
Lines 56-61 Link Here
56
		return false;
64
		return false;
57
	}
65
	}
58
66
67
	/**
68
	 * Returns the constant kind of this variable declaration
69
	 */
70
	public abstract int kind();
59
	
71
	
60
	public StringBuffer printStatement(int indent, StringBuffer output) {
72
	public StringBuffer printStatement(int indent, StringBuffer output) {
61
73
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java (+7 lines)
Lines 65-70 Link Here
65
		this.binding.useFlag = used ? LocalVariableBinding.USED : LocalVariableBinding.UNUSED;
65
		this.binding.useFlag = used ? LocalVariableBinding.USED : LocalVariableBinding.UNUSED;
66
	}
66
	}
67
67
68
	/**
69
	 * @see org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration#kind()
70
	 */
71
	public int kind() {
72
		return PARAMETER;
73
	}
74
	
68
	public StringBuffer print(int indent, StringBuffer output) {
75
	public StringBuffer print(int indent, StringBuffer output) {
69
76
70
		printIndent(indent, output);
77
		printIndent(indent, output);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/EnumConstant.java (-153 / +19 lines)
Lines 11-34 Link Here
11
package org.eclipse.jdt.internal.compiler.ast;
11
package org.eclipse.jdt.internal.compiler.ast;
12
12
13
import org.eclipse.jdt.internal.compiler.ASTVisitor;
13
import org.eclipse.jdt.internal.compiler.ASTVisitor;
14
import org.eclipse.jdt.internal.compiler.CompilationResult;
14
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
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;
15
import org.eclipse.jdt.internal.compiler.problem.AbortType;
19
16
20
/**
17
/**
21
 * Enum constant node
18
 * Enum constant node
22
 */
19
 */
23
public class EnumConstant extends TypeDeclaration {
20
public class EnumConstant extends FieldDeclaration {
24
21
25
	public Expression[] arguments;
22
	public Expression[] arguments;
26
23
	public TypeDeclaration anonymousType;
27
	public EnumConstant(CompilationResult compilationResult) {
24
	
28
		super(compilationResult);
25
	public EnumConstant(
29
		this.compilationResult = compilationResult;
26
			char[] name,
27
			int sourceStart,
28
			int sourceEnd) {
29
		
30
		super(name, sourceStart, sourceEnd);
30
	}
31
	}
31
32
	
32
	public StringBuffer print(int indent, StringBuffer output) {
33
	public StringBuffer print(int indent, StringBuffer output) {
33
		output.append(name);
34
		output.append(name);
34
		if (arguments != null) {
35
		if (arguments != null) {
Lines 40-115 Link Here
40
			}
41
			}
41
			arguments[length - 1].print(0, output);
42
			arguments[length - 1].print(0, output);
42
			output.append(')');
43
			output.append(')');
44
		}		
45
		if (anonymousType != null) {
46
			anonymousType.print(indent, output);
43
		}
47
		}
44
		printBody(indent, output);
45
		return output;
48
		return output;
46
	}
49
	}
47
50
48
	/**
51
	public void traverse(ASTVisitor visitor, MethodScope scope) {
49
	 *	Iteration for a package member type
50
	 *
51
	 */
52
	public void traverse(
53
		ASTVisitor visitor,
54
		CompilationUnitScope unitScope) {
55
	
56
		if (ignoreFurtherInvestigation)
57
			return;
58
		try {
59
			if (visitor.visit(this, unitScope)) {
60
				if (this.annotations != null) {
61
					int annotationsLength = this.annotations.length;
62
					for (int i = 0; i < annotationsLength; i++)
63
						this.annotations[i].traverse(visitor, scope);
64
				}
65
				if (this.arguments != null) {
66
					int length = this.arguments.length;
67
					for (int i = 0; i < length; i++)
68
						this.arguments[i].traverse(visitor, scope);
69
				}
70
				if (this.memberTypes != null) {
71
					int length = this.memberTypes.length;
72
					for (int i = 0; i < length; i++)
73
						this.memberTypes[i].traverse(visitor, scope);
74
				}
75
				if (this.enums != null) {
76
					int length = this.enums.length;
77
					for (int i = 0; i < length; i++)
78
						this.enums[i].traverse(visitor, scope);
79
				}
80
				if (this.fields != null) {
81
					int length = this.fields.length;
82
					for (int i = 0; i < length; i++) {
83
						FieldDeclaration field;
84
						if ((field = this.fields[i]).isStatic()) {
85
							field.traverse(visitor, staticInitializerScope);
86
						} else {
87
							field.traverse(visitor, initializerScope);
88
						}
89
					}
90
				}
91
				if (this.methods != null) {
92
					int length = this.methods.length;
93
					for (int i = 0; i < length; i++)
94
						this.methods[i].traverse(visitor, scope);
95
				}
96
			}
97
			visitor.endVisit(this, unitScope);
98
		} catch (AbortType e) {
99
			// silent abort
100
		}
101
	}
102
103
	/**
104
	 *	Iteration for a local innertype
105
	 *
106
	 */
107
	public void traverse(ASTVisitor visitor, BlockScope blockScope) {
108
		
52
		
109
		if (ignoreFurtherInvestigation)
110
			return;
111
		try {
53
		try {
112
			if (visitor.visit(this, blockScope)) {
54
			if (visitor.visit(this, scope)) {
113
				if (this.annotations != null) {
55
				if (this.annotations != null) {
114
					int annotationsLength = this.annotations.length;
56
					int annotationsLength = this.annotations.length;
115
					for (int i = 0; i < annotationsLength; i++)
57
					for (int i = 0; i < annotationsLength; i++)
Lines 120-206 Link Here
120
					for (int i = 0; i < length; i++)
62
					for (int i = 0; i < length; i++)
121
						this.arguments[i].traverse(visitor, scope);
63
						this.arguments[i].traverse(visitor, scope);
122
				}
64
				}
123
				if (this.memberTypes != null) {
65
				if (this.anonymousType != null) {
124
					int length = this.memberTypes.length;
66
					this.anonymousType.traverse(visitor, scope);
125
					for (int i = 0; i < length; i++)
126
						this.memberTypes[i].traverse(visitor, scope);
127
				}
128
				if (this.enums != null) {
129
					int length = this.enums.length;
130
					for (int i = 0; i < length; i++)
131
						this.enums[i].traverse(visitor, scope);
132
				}
133
				if (this.fields != null) {
134
					int length = this.fields.length;
135
					for (int i = 0; i < length; i++) {
136
						FieldDeclaration field;
137
						if ((field = this.fields[i]).isStatic()) {
138
							field.traverse(visitor, staticInitializerScope);
139
						} else {
140
							field.traverse(visitor, initializerScope);
141
						}
142
					}
143
				}
144
				if (this.methods != null) {
145
					int length = this.methods.length;
146
					for (int i = 0; i < length; i++)
147
						this.methods[i].traverse(visitor, scope);
148
				}
149
			}
150
			visitor.endVisit(this, blockScope);
151
		} catch (AbortType e) {
152
			// silent abort
153
		}
154
	}
155
156
	/**
157
	 *	Iteration for a member innertype
158
	 *
159
	 */
160
	public void traverse(ASTVisitor visitor, ClassScope classScope) {
161
		
162
		if (ignoreFurtherInvestigation)
163
			return;
164
		try {
165
			if (visitor.visit(this, classScope)) {
166
				if (this.annotations != null) {
167
					int annotationsLength = this.annotations.length;
168
					for (int i = 0; i < annotationsLength; i++)
169
						this.annotations[i].traverse(visitor, scope);
170
				}
171
				if (this.arguments != null) {
172
					int length = this.arguments.length;
173
					for (int i = 0; i < length; i++)
174
						this.arguments[i].traverse(visitor, scope);
175
				}
176
				if (this.memberTypes != null) {
177
					int length = this.memberTypes.length;
178
					for (int i = 0; i < length; i++)
179
						this.memberTypes[i].traverse(visitor, scope);
180
				}
181
				if (this.enums != null) {
182
					int length = this.enums.length;
183
					for (int i = 0; i < length; i++)
184
						this.enums[i].traverse(visitor, scope);
185
				}
186
				if (this.fields != null) {
187
					int length = this.fields.length;
188
					for (int i = 0; i < length; i++) {
189
						FieldDeclaration field;
190
						if ((field = this.fields[i]).isStatic()) {
191
							field.traverse(visitor, staticInitializerScope);
192
						} else {
193
							field.traverse(visitor, initializerScope);
194
						}
195
					}
196
				}
197
				if (this.methods != null) {
198
					int length = this.methods.length;
199
					for (int i = 0; i < length; i++)
200
						this.methods[i].traverse(visitor, scope);
201
				}
67
				}
202
			}
68
			}
203
			visitor.endVisit(this, classScope);
69
			visitor.endVisit(this, scope);
204
		} catch (AbortType e) {
70
		} catch (AbortType e) {
205
			// silent abort
71
			// silent abort
206
		}
72
		}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/EnumDeclaration.java (-242 lines)
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
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java (+8 lines)
Lines 17-22 Link Here
17
import org.eclipse.jdt.internal.compiler.lookup.*;
17
import org.eclipse.jdt.internal.compiler.lookup.*;
18
18
19
public class FieldDeclaration extends AbstractVariableDeclaration {
19
public class FieldDeclaration extends AbstractVariableDeclaration {
20
	
20
	public FieldBinding binding;
21
	public FieldBinding binding;
21
	boolean hasBeenResolved = false;
22
	boolean hasBeenResolved = false;
22
	public Javadoc javadoc;
23
	public Javadoc javadoc;
Lines 126-131 Link Here
126
		if (this.binding != null)
127
		if (this.binding != null)
127
			return this.binding.isStatic();
128
			return this.binding.isStatic();
128
		return (this.modifiers & AccStatic) != 0;
129
		return (this.modifiers & AccStatic) != 0;
130
	}
131
	
132
	/**
133
	 * @see org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration#kind()
134
	 */
135
	public int kind() {
136
		return FIELD;
129
	}
137
	}
130
	
138
	
131
	public void resolve(MethodScope initializationScope) {
139
	public void resolve(MethodScope initializationScope) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Initializer.java (+7 lines)
Lines 67-72 Link Here
67
		return (modifiers & AccStatic) != 0;
67
		return (modifiers & AccStatic) != 0;
68
	}
68
	}
69
69
70
	/**
71
	 * @see org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration#kind()
72
	 */
73
	public int kind() {
74
		return INITIALIZER;
75
	}
76
	
70
	public void parseStatements(
77
	public void parseStatements(
71
		Parser parser,
78
		Parser parser,
72
		TypeDeclaration typeDeclaration,
79
		TypeDeclaration typeDeclaration,
(-)compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java (+7 lines)
Lines 131-136 Link Here
131
		codeStream.recordPositionsFrom(pc, this.sourceStart);
131
		codeStream.recordPositionsFrom(pc, this.sourceStart);
132
	}
132
	}
133
133
134
	/**
135
	 * @see org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration#kind()
136
	 */
137
	public int kind() {
138
		return LOCAL_VARIABLE;
139
	}
140
	
134
	public void resolve(BlockScope scope) {
141
	public void resolve(BlockScope scope) {
135
142
136
		// create a binding and add it to the scope
143
		// create a binding and add it to the scope
(-)compiler/org/eclipse/jdt/internal/compiler/ast/TypeParameter.java (+7 lines)
Lines 21-26 Link Here
21
    public TypeVariableBinding binding;
21
    public TypeVariableBinding binding;
22
	public TypeReference[] bounds;
22
	public TypeReference[] bounds;
23
23
24
	/**
25
	 * @see org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration#kind()
26
	 */
27
	public int kind() {
28
		return TYPE_PARAMETER;
29
	}
30
	
24
	public void resolve(ClassScope scope) {
31
	public void resolve(ClassScope scope) {
25
	    // TODO (philippe) add warning for detecting variable name collisions
32
	    // TODO (philippe) add warning for detecting variable name collisions
26
	}
33
	}
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-1 / +1 lines)
Lines 2467-2473 Link Here
2467
		annotationTypeDeclaration.sourceStart,
2467
		annotationTypeDeclaration.sourceStart,
2468
		annotationTypeDeclaration.sourceEnd);
2468
		annotationTypeDeclaration.sourceEnd);
2469
}
2469
}
2470
public void invalidUsageOfEnumDeclarations(EnumDeclaration enumDeclaration) {
2470
public void invalidUsageOfEnumDeclarations(TypeDeclaration enumDeclaration) {
2471
	this.handle(
2471
	this.handle(
2472
		IProblem.InvalidUsageOfEnumDeclarations,
2472
		IProblem.InvalidUsageOfEnumDeclarations,
2473
		NoArgument, 
2473
		NoArgument, 

Return to bug 76159