Lines 20-26
Link Here
|
20 |
public class FieldDeclaration extends AbstractVariableDeclaration { |
20 |
public class FieldDeclaration extends AbstractVariableDeclaration { |
21 |
|
21 |
|
22 |
public FieldBinding binding; |
22 |
public FieldBinding binding; |
23 |
boolean hasBeenResolved = false; // TODO (philippe) should use a tagBit instead |
|
|
24 |
public Javadoc javadoc; |
23 |
public Javadoc javadoc; |
25 |
|
24 |
|
26 |
//allows to retrieve both the "type" part of the declaration (part1) |
25 |
//allows to retrieve both the "type" part of the declaration (part1) |
Lines 34-303
Link Here
|
34 |
public int endPart1Position; |
33 |
public int endPart1Position; |
35 |
public int endPart2Position; |
34 |
public int endPart2Position; |
36 |
|
35 |
|
37 |
public FieldDeclaration() { |
36 |
public FieldDeclaration() { |
38 |
// for subtypes or conversion |
37 |
// for subtypes or conversion |
39 |
} |
38 |
} |
40 |
|
39 |
|
41 |
public FieldDeclaration( |
40 |
public FieldDeclaration( char[] name, int sourceStart, int sourceEnd) { |
42 |
char[] name, |
41 |
this.name = name; |
43 |
int sourceStart, |
42 |
//due to some declaration like |
44 |
int sourceEnd) { |
43 |
// int x, y = 3, z , x ; |
45 |
|
44 |
//the sourceStart and the sourceEnd is ONLY on the name |
46 |
this.name = name; |
45 |
this.sourceStart = sourceStart; |
47 |
|
46 |
this.sourceEnd = sourceEnd; |
48 |
//due to some declaration like |
47 |
} |
49 |
// int x, y = 3, z , x ; |
|
|
50 |
//the sourceStart and the sourceEnd is ONLY on the name |
51 |
this.sourceStart = sourceStart; |
52 |
this.sourceEnd = sourceEnd; |
53 |
} |
54 |
|
48 |
|
55 |
public FlowInfo analyseCode( |
49 |
public FlowInfo analyseCode(MethodScope initializationScope, FlowContext flowContext, FlowInfo flowInfo) { |
56 |
MethodScope initializationScope, |
50 |
if (this.binding != null && !this.binding.isUsed()) { |
57 |
FlowContext flowContext, |
51 |
if (this.binding.isPrivate() || (this.binding.declaringClass != null && this.binding.declaringClass.isLocalType())) { |
58 |
FlowInfo flowInfo) { |
52 |
if (!initializationScope.referenceCompilationUnit().compilationResult.hasSyntaxError) { |
59 |
|
53 |
initializationScope.problemReporter().unusedPrivateField(this); |
60 |
if (this.binding != null && !this.binding.isUsed()) { |
|
|
61 |
if (this.binding.isPrivate() || (this.binding.declaringClass != null && this.binding.declaringClass.isLocalType())) { |
62 |
if (!initializationScope.referenceCompilationUnit().compilationResult.hasSyntaxError) { |
63 |
initializationScope.problemReporter().unusedPrivateField(this); |
64 |
} |
65 |
} |
54 |
} |
66 |
} |
55 |
} |
67 |
// cannot define static non-constant field inside nested class |
|
|
68 |
if (this.binding != null |
69 |
&& this.binding.isValidBinding() |
70 |
&& this.binding.isStatic() |
71 |
&& this.binding.constant() == Constant.NotAConstant |
72 |
&& this.binding.declaringClass.isNestedType() |
73 |
&& !this.binding.declaringClass.isStatic()) { |
74 |
initializationScope.problemReporter().unexpectedStaticModifierForField( |
75 |
(SourceTypeBinding) this.binding.declaringClass, |
76 |
this); |
77 |
} |
78 |
|
79 |
if (this.initialization != null) { |
80 |
flowInfo = |
81 |
this.initialization |
82 |
.analyseCode(initializationScope, flowContext, flowInfo) |
83 |
.unconditionalInits(); |
84 |
flowInfo.markAsDefinitelyAssigned(this.binding); |
85 |
} |
86 |
return flowInfo; |
87 |
} |
56 |
} |
88 |
|
57 |
// cannot define static non-constant field inside nested class |
89 |
/** |
58 |
if (this.binding != null |
90 |
* Code generation for a field declaration: |
59 |
&& this.binding.isValidBinding() |
91 |
* standard assignment to a field |
60 |
&& this.binding.isStatic() |
92 |
* |
61 |
&& this.binding.constant() == Constant.NotAConstant |
93 |
* @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope |
62 |
&& this.binding.declaringClass.isNestedType() |
94 |
* @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream |
63 |
&& !this.binding.declaringClass.isStatic()) { |
95 |
*/ |
64 |
initializationScope.problemReporter().unexpectedStaticModifierForField( |
96 |
public void generateCode(BlockScope currentScope, CodeStream codeStream) { |
65 |
(SourceTypeBinding) this.binding.declaringClass, |
97 |
|
66 |
this); |
98 |
if ((this.bits & IsReachable) == 0) { |
|
|
99 |
return; |
100 |
} |
101 |
// do not generate initialization code if final and static (constant is then |
102 |
// recorded inside the field itself). |
103 |
int pc = codeStream.position; |
104 |
boolean isStatic; |
105 |
if (this.initialization != null |
106 |
&& !((isStatic = this.binding.isStatic()) && this.binding.constant() != Constant.NotAConstant)) { |
107 |
// non-static field, need receiver |
108 |
if (!isStatic) |
109 |
codeStream.aload_0(); |
110 |
// generate initialization value |
111 |
this.initialization.generateCode(currentScope, codeStream, true); |
112 |
// store into field |
113 |
if (isStatic) { |
114 |
codeStream.putstatic(this.binding); |
115 |
} else { |
116 |
codeStream.putfield(this.binding); |
117 |
} |
118 |
} |
119 |
codeStream.recordPositionsFrom(pc, this.sourceStart); |
120 |
} |
67 |
} |
121 |
|
68 |
|
122 |
/** |
69 |
if (this.initialization != null) { |
123 |
* @see org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration#getKind() |
70 |
flowInfo = |
124 |
*/ |
71 |
this.initialization |
125 |
public int getKind() { |
72 |
.analyseCode(initializationScope, flowContext, flowInfo) |
126 |
return this.type == null ? ENUM_CONSTANT : FIELD; |
73 |
.unconditionalInits(); |
|
|
74 |
flowInfo.markAsDefinitelyAssigned(this.binding); |
127 |
} |
75 |
} |
128 |
|
76 |
return flowInfo; |
129 |
public boolean isStatic() { |
77 |
} |
130 |
|
78 |
|
131 |
if (this.binding != null) |
79 |
/** |
132 |
return this.binding.isStatic(); |
80 |
* Code generation for a field declaration: |
133 |
return (this.modifiers & ClassFileConstants.AccStatic) != 0; |
81 |
* standard assignment to a field |
|
|
82 |
* |
83 |
* @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope |
84 |
* @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream |
85 |
*/ |
86 |
public void generateCode(BlockScope currentScope, CodeStream codeStream) { |
87 |
if ((this.bits & IsReachable) == 0) { |
88 |
return; |
134 |
} |
89 |
} |
135 |
|
90 |
// do not generate initialization code if final and static (constant is then |
136 |
public StringBuffer printStatement(int indent, StringBuffer output) { |
91 |
// recorded inside the field itself). |
137 |
if (this.javadoc != null) { |
92 |
int pc = codeStream.position; |
138 |
this.javadoc.print(indent, output); |
93 |
boolean isStatic; |
|
|
94 |
if (this.initialization != null |
95 |
&& !((isStatic = this.binding.isStatic()) && this.binding.constant() != Constant.NotAConstant)) { |
96 |
// non-static field, need receiver |
97 |
if (!isStatic) |
98 |
codeStream.aload_0(); |
99 |
// generate initialization value |
100 |
this.initialization.generateCode(currentScope, codeStream, true); |
101 |
// store into field |
102 |
if (isStatic) { |
103 |
codeStream.putstatic(this.binding); |
104 |
} else { |
105 |
codeStream.putfield(this.binding); |
139 |
} |
106 |
} |
140 |
return super.printStatement(indent, output); |
|
|
141 |
} |
107 |
} |
|
|
108 |
codeStream.recordPositionsFrom(pc, this.sourceStart); |
109 |
} |
142 |
|
110 |
|
143 |
public void resolve(MethodScope initializationScope) { |
111 |
/** |
|
|
112 |
* @see org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration#getKind() |
113 |
*/ |
114 |
public int getKind() { |
115 |
return this.type == null ? ENUM_CONSTANT : FIELD; |
116 |
} |
144 |
|
117 |
|
145 |
// the two <constant = Constant.NotAConstant> could be regrouped into |
118 |
public boolean isStatic() { |
146 |
// a single line but it is clearer to have two lines while the reason of their |
119 |
if (this.binding != null) |
147 |
// existence is not at all the same. See comment for the second one. |
120 |
return this.binding.isStatic(); |
|
|
121 |
return (this.modifiers & ClassFileConstants.AccStatic) != 0; |
122 |
} |
148 |
|
123 |
|
149 |
//-------------------------------------------------------- |
124 |
public StringBuffer printStatement(int indent, StringBuffer output) { |
150 |
if (!this.hasBeenResolved && this.binding != null && this.binding.isValidBinding()) { |
125 |
if (this.javadoc != null) { |
|
|
126 |
this.javadoc.print(indent, output); |
127 |
} |
128 |
return super.printStatement(indent, output); |
129 |
} |
151 |
|
130 |
|
152 |
this.hasBeenResolved = true; |
131 |
public void resolve(MethodScope initializationScope) { |
|
|
132 |
// the two <constant = Constant.NotAConstant> could be regrouped into |
133 |
// a single line but it is clearer to have two lines while the reason of their |
134 |
// existence is not at all the same. See comment for the second one. |
135 |
|
136 |
//-------------------------------------------------------- |
137 |
if ((this.bits & ASTNode.HasBeenResolved) != 0) return; |
138 |
if (this.binding == null || !this.binding.isValidBinding()) return; |
139 |
|
140 |
this.bits |= ASTNode.HasBeenResolved; |
153 |
|
141 |
|
154 |
// check if field is hiding some variable - issue is that field binding already got inserted in scope |
142 |
// check if field is hiding some variable - issue is that field binding already got inserted in scope |
155 |
// thus must lookup separately in super type and outer context |
143 |
// thus must lookup separately in super type and outer context |
156 |
ClassScope classScope = initializationScope.enclosingClassScope(); |
144 |
ClassScope classScope = initializationScope.enclosingClassScope(); |
157 |
|
145 |
|
158 |
if (classScope != null) { |
146 |
if (classScope != null) { |
159 |
checkHiding: { |
147 |
checkHiding: { |
160 |
SourceTypeBinding declaringType = classScope.enclosingSourceType(); |
148 |
SourceTypeBinding declaringType = classScope.enclosingSourceType(); |
161 |
checkHidingSuperField: { |
149 |
checkHidingSuperField: { |
162 |
if (declaringType.superclass == null) break checkHidingSuperField; |
150 |
if (declaringType.superclass == null) break checkHidingSuperField; |
163 |
Binding existingVariable = classScope.findField(declaringType.superclass, this.name, this, false /*do not resolve hidden field*/); |
151 |
Binding existingVariable = classScope.findField(declaringType.superclass, this.name, this, false /*do not resolve hidden field*/); |
164 |
if (existingVariable == null) break checkHidingSuperField; // keep checking outer scenario |
152 |
if (existingVariable == null) break checkHidingSuperField; // keep checking outer scenario |
165 |
if (!existingVariable.isValidBinding()) break checkHidingSuperField; // keep checking outer scenario |
153 |
if (!existingVariable.isValidBinding()) break checkHidingSuperField; // keep checking outer scenario |
166 |
if (existingVariable instanceof FieldBinding) { |
154 |
if (existingVariable instanceof FieldBinding) { |
167 |
FieldBinding existingField = (FieldBinding) existingVariable; |
155 |
FieldBinding existingField = (FieldBinding) existingVariable; |
168 |
if (existingField.original() == this.binding) break checkHidingSuperField; // keep checking outer scenario |
156 |
if (existingField.original() == this.binding) break checkHidingSuperField; // keep checking outer scenario |
169 |
} |
|
|
170 |
// collision with supertype field |
171 |
initializationScope.problemReporter().fieldHiding(this, existingVariable); |
172 |
break checkHiding; // already found a matching field |
173 |
} |
174 |
// only corner case is: lookup of outer field through static declaringType, which isn't detected by #getBinding as lookup starts |
175 |
// from outer scope. Subsequent static contexts are detected for free. |
176 |
Scope outerScope = classScope.parent; |
177 |
if (outerScope.kind == Scope.COMPILATION_UNIT_SCOPE) break checkHiding; |
178 |
Binding existingVariable = outerScope.getBinding(this.name, Binding.VARIABLE, this, false /*do not resolve hidden field*/); |
179 |
if (existingVariable == null) break checkHiding; |
180 |
if (!existingVariable.isValidBinding()) break checkHiding; |
181 |
if (existingVariable == this.binding) break checkHiding; |
182 |
if (existingVariable instanceof FieldBinding) { |
183 |
FieldBinding existingField = (FieldBinding) existingVariable; |
184 |
if (existingField.original() == this.binding) break checkHiding; |
185 |
if (!existingField.isStatic() && declaringType.isStatic()) break checkHiding; |
186 |
} |
187 |
// collision with outer field or local variable |
188 |
initializationScope.problemReporter().fieldHiding(this, existingVariable); |
189 |
} |
157 |
} |
|
|
158 |
// collision with supertype field |
159 |
initializationScope.problemReporter().fieldHiding(this, existingVariable); |
160 |
break checkHiding; // already found a matching field |
161 |
} |
162 |
// only corner case is: lookup of outer field through static declaringType, which isn't detected by #getBinding as lookup starts |
163 |
// from outer scope. Subsequent static contexts are detected for free. |
164 |
Scope outerScope = classScope.parent; |
165 |
if (outerScope.kind == Scope.COMPILATION_UNIT_SCOPE) break checkHiding; |
166 |
Binding existingVariable = outerScope.getBinding(this.name, Binding.VARIABLE, this, false /*do not resolve hidden field*/); |
167 |
if (existingVariable == null) break checkHiding; |
168 |
if (!existingVariable.isValidBinding()) break checkHiding; |
169 |
if (existingVariable == this.binding) break checkHiding; |
170 |
if (existingVariable instanceof FieldBinding) { |
171 |
FieldBinding existingField = (FieldBinding) existingVariable; |
172 |
if (existingField.original() == this.binding) break checkHiding; |
173 |
if (!existingField.isStatic() && declaringType.isStatic()) break checkHiding; |
190 |
} |
174 |
} |
|
|
175 |
// collision with outer field or local variable |
176 |
initializationScope.problemReporter().fieldHiding(this, existingVariable); |
177 |
} |
178 |
} |
179 |
|
180 |
if (this.type != null ) { // enum constants have no declared type |
181 |
this.type.resolvedType = this.binding.type; // update binding for type reference |
182 |
} |
183 |
|
184 |
FieldBinding previousField = initializationScope.initializedField; |
185 |
int previousFieldID = initializationScope.lastVisibleFieldID; |
186 |
try { |
187 |
initializationScope.initializedField = this.binding; |
188 |
initializationScope.lastVisibleFieldID = this.binding.id; |
189 |
|
190 |
resolveAnnotations(initializationScope, this.annotations, this.binding); |
191 |
// check @Deprecated annotation presence |
192 |
if ((this.binding.getAnnotationTagBits() & TagBits.AnnotationDeprecated) == 0 |
193 |
&& (this.binding.modifiers & ClassFileConstants.AccDeprecated) != 0 |
194 |
&& initializationScope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { |
195 |
initializationScope.problemReporter().missingDeprecatedAnnotationForField(this); |
196 |
} |
197 |
// the resolution of the initialization hasn't been done |
198 |
if (this.initialization == null) { |
199 |
this.binding.setConstant(Constant.NotAConstant); |
200 |
} else { |
201 |
// break dead-lock cycles by forcing constant to NotAConstant |
202 |
this.binding.setConstant(Constant.NotAConstant); |
191 |
|
203 |
|
192 |
if (this.type != null ) { // enum constants have no declared type |
204 |
TypeBinding fieldType = this.binding.type; |
193 |
this.type.resolvedType = this.binding.type; // update binding for type reference |
205 |
TypeBinding initializationType; |
194 |
} |
206 |
this.initialization.setExpectedType(fieldType); // needed in case of generic method invocation |
|
|
207 |
if (this.initialization instanceof ArrayInitializer) { |
208 |
|
209 |
if ((initializationType = this.initialization.resolveTypeExpecting(initializationScope, fieldType)) != null) { |
210 |
((ArrayInitializer) this.initialization).binding = (ArrayBinding) initializationType; |
211 |
this.initialization.computeConversion(initializationScope, fieldType, initializationType); |
212 |
} |
213 |
} else if ((initializationType = this.initialization.resolveType(initializationScope)) != null) { |
195 |
|
214 |
|
196 |
FieldBinding previousField = initializationScope.initializedField; |
215 |
if (fieldType != initializationType) // must call before computeConversion() and typeMismatchError() |
197 |
int previousFieldID = initializationScope.lastVisibleFieldID; |
216 |
initializationScope.compilationUnitScope().recordTypeConversion(fieldType, initializationType); |
198 |
try { |
217 |
if (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, fieldType) |
199 |
initializationScope.initializedField = this.binding; |
218 |
|| (fieldType.isBaseType() && BaseTypeBinding.isWidening(fieldType.id, initializationType.id)) |
200 |
initializationScope.lastVisibleFieldID = this.binding.id; |
219 |
|| initializationType.isCompatibleWith(fieldType)) { |
201 |
|
220 |
this.initialization.computeConversion(initializationScope, fieldType, initializationType); |
202 |
resolveAnnotations(initializationScope, this.annotations, this.binding); |
221 |
if (initializationType.needsUncheckedConversion(fieldType)) { |
203 |
// check @Deprecated annotation presence |
222 |
initializationScope.problemReporter().unsafeTypeConversion(this.initialization, initializationType, fieldType); |
204 |
if ((this.binding.getAnnotationTagBits() & TagBits.AnnotationDeprecated) == 0 |
|
|
205 |
&& (this.binding.modifiers & ClassFileConstants.AccDeprecated) != 0 |
206 |
&& initializationScope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { |
207 |
initializationScope.problemReporter().missingDeprecatedAnnotationForField(this); |
208 |
} |
209 |
// the resolution of the initialization hasn't been done |
210 |
if (this.initialization == null) { |
211 |
this.binding.setConstant(Constant.NotAConstant); |
212 |
} else { |
213 |
// break dead-lock cycles by forcing constant to NotAConstant |
214 |
this.binding.setConstant(Constant.NotAConstant); |
215 |
|
216 |
TypeBinding fieldType = this.binding.type; |
217 |
TypeBinding initializationType; |
218 |
this.initialization.setExpectedType(fieldType); // needed in case of generic method invocation |
219 |
if (this.initialization instanceof ArrayInitializer) { |
220 |
|
221 |
if ((initializationType = this.initialization.resolveTypeExpecting(initializationScope, fieldType)) != null) { |
222 |
((ArrayInitializer) this.initialization).binding = (ArrayBinding) initializationType; |
223 |
this.initialization.computeConversion(initializationScope, fieldType, initializationType); |
224 |
} |
225 |
} else if ((initializationType = this.initialization.resolveType(initializationScope)) != null) { |
226 |
|
227 |
if (fieldType != initializationType) // must call before computeConversion() and typeMismatchError() |
228 |
initializationScope.compilationUnitScope().recordTypeConversion(fieldType, initializationType); |
229 |
if (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, fieldType) |
230 |
|| (fieldType.isBaseType() && BaseTypeBinding.isWidening(fieldType.id, initializationType.id)) |
231 |
|| initializationType.isCompatibleWith(fieldType)) { |
232 |
this.initialization.computeConversion(initializationScope, fieldType, initializationType); |
233 |
if (initializationType.needsUncheckedConversion(fieldType)) { |
234 |
initializationScope.problemReporter().unsafeTypeConversion(this.initialization, initializationType, fieldType); |
235 |
} |
236 |
if (this.initialization instanceof CastExpression |
237 |
&& (this.initialization.bits & ASTNode.UnnecessaryCast) == 0) { |
238 |
CastExpression.checkNeedForAssignedCast(initializationScope, fieldType, (CastExpression) this.initialization); |
239 |
} |
240 |
} else if (initializationScope.isBoxingCompatibleWith(initializationType, fieldType) |
241 |
|| (initializationType.isBaseType() // narrowing then boxing ? |
242 |
&& initializationScope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5 // autoboxing |
243 |
&& !fieldType.isBaseType() |
244 |
&& initialization.isConstantValueOfTypeAssignableToType(initializationType, initializationScope.environment().computeBoxingType(fieldType)))) { |
245 |
this.initialization.computeConversion(initializationScope, fieldType, initializationType); |
246 |
if (this.initialization instanceof CastExpression |
247 |
&& (this.initialization.bits & ASTNode.UnnecessaryCast) == 0) { |
248 |
CastExpression.checkNeedForAssignedCast(initializationScope, fieldType, (CastExpression) this.initialization); |
249 |
} |
250 |
} else { |
251 |
initializationScope.problemReporter().typeMismatchError(initializationType, fieldType, this); |
252 |
} |
253 |
if (this.binding.isFinal()){ // cast from constant actual type to variable type |
254 |
this.binding.setConstant(this.initialization.constant.castTo((this.binding.type.id << 4) + this.initialization.constant.typeID())); |
255 |
} |
256 |
} else { |
257 |
this.binding.setConstant(Constant.NotAConstant); |
258 |
} |
223 |
} |
259 |
// check for assignment with no effect |
224 |
if (this.initialization instanceof CastExpression |
260 |
if (this.binding == Assignment.getDirectBinding(this.initialization)) { |
225 |
&& (this.initialization.bits & ASTNode.UnnecessaryCast) == 0) { |
261 |
initializationScope.problemReporter().assignmentHasNoEffect(this, this.name); |
226 |
CastExpression.checkNeedForAssignedCast(initializationScope, fieldType, (CastExpression) this.initialization); |
262 |
} |
227 |
} |
|
|
228 |
} else if (initializationScope.isBoxingCompatibleWith(initializationType, fieldType) |
229 |
|| (initializationType.isBaseType() // narrowing then boxing ? |
230 |
&& initializationScope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5 // autoboxing |
231 |
&& !fieldType.isBaseType() |
232 |
&& initialization.isConstantValueOfTypeAssignableToType(initializationType, initializationScope.environment().computeBoxingType(fieldType)))) { |
233 |
this.initialization.computeConversion(initializationScope, fieldType, initializationType); |
234 |
if (this.initialization instanceof CastExpression |
235 |
&& (this.initialization.bits & ASTNode.UnnecessaryCast) == 0) { |
236 |
CastExpression.checkNeedForAssignedCast(initializationScope, fieldType, (CastExpression) this.initialization); |
237 |
} |
238 |
} else { |
239 |
initializationScope.problemReporter().typeMismatchError(initializationType, fieldType, this); |
263 |
} |
240 |
} |
264 |
// Resolve Javadoc comment if one is present |
241 |
if (this.binding.isFinal()){ // cast from constant actual type to variable type |
265 |
if (this.javadoc != null) { |
242 |
this.binding.setConstant(this.initialization.constant.castTo((this.binding.type.id << 4) + this.initialization.constant.typeID())); |
266 |
/* |
|
|
267 |
if (classScope != null) { |
268 |
this.javadoc.resolve(classScope); |
269 |
} |
270 |
*/ |
271 |
this.javadoc.resolve(initializationScope); |
272 |
} else if (this.binding.declaringClass != null && !this.binding.declaringClass.isLocalType()) { |
273 |
initializationScope.problemReporter().javadocMissing(this.sourceStart, this.sourceEnd, this.binding.modifiers); |
274 |
} |
243 |
} |
275 |
} finally { |
244 |
} else { |
276 |
initializationScope.initializedField = previousField; |
245 |
this.binding.setConstant(Constant.NotAConstant); |
277 |
initializationScope.lastVisibleFieldID = previousFieldID; |
|
|
278 |
if (this.binding.constant() == null) |
279 |
this.binding.setConstant(Constant.NotAConstant); |
280 |
} |
246 |
} |
|
|
247 |
// check for assignment with no effect |
248 |
if (this.binding == Assignment.getDirectBinding(this.initialization)) { |
249 |
initializationScope.problemReporter().assignmentHasNoEffect(this, this.name); |
250 |
} |
281 |
} |
251 |
} |
|
|
252 |
// Resolve Javadoc comment if one is present |
253 |
if (this.javadoc != null) { |
254 |
/* |
255 |
if (classScope != null) { |
256 |
this.javadoc.resolve(classScope); |
257 |
} |
258 |
*/ |
259 |
this.javadoc.resolve(initializationScope); |
260 |
} else if (this.binding.declaringClass != null && !this.binding.declaringClass.isLocalType()) { |
261 |
initializationScope.problemReporter().javadocMissing(this.sourceStart, this.sourceEnd, this.binding.modifiers); |
262 |
} |
263 |
} finally { |
264 |
initializationScope.initializedField = previousField; |
265 |
initializationScope.lastVisibleFieldID = previousFieldID; |
266 |
if (this.binding.constant() == null) |
267 |
this.binding.setConstant(Constant.NotAConstant); |
282 |
} |
268 |
} |
|
|
269 |
} |
283 |
|
270 |
|
284 |
public void traverse(ASTVisitor visitor, MethodScope scope) { |
271 |
public void traverse(ASTVisitor visitor, MethodScope scope) { |
285 |
|
272 |
if (visitor.visit(this, scope)) { |
286 |
if (visitor.visit(this, scope)) { |
273 |
if (this.javadoc != null) { |
287 |
if (this.javadoc != null) { |
274 |
this.javadoc.traverse(visitor, scope); |
288 |
this.javadoc.traverse(visitor, scope); |
|
|
289 |
} |
290 |
if (this.annotations != null) { |
291 |
int annotationsLength = this.annotations.length; |
292 |
for (int i = 0; i < annotationsLength; i++) |
293 |
this.annotations[i].traverse(visitor, scope); |
294 |
} |
295 |
if (this.type != null) { |
296 |
this.type.traverse(visitor, scope); |
297 |
} |
298 |
if (this.initialization != null) |
299 |
this.initialization.traverse(visitor, scope); |
300 |
} |
275 |
} |
301 |
visitor.endVisit(this, scope); |
276 |
if (this.annotations != null) { |
|
|
277 |
int annotationsLength = this.annotations.length; |
278 |
for (int i = 0; i < annotationsLength; i++) |
279 |
this.annotations[i].traverse(visitor, scope); |
280 |
} |
281 |
if (this.type != null) { |
282 |
this.type.traverse(visitor, scope); |
283 |
} |
284 |
if (this.initialization != null) |
285 |
this.initialization.traverse(visitor, scope); |
302 |
} |
286 |
} |
|
|
287 |
visitor.endVisit(this, scope); |
288 |
} |
303 |
} |
289 |
} |