Lines 11-16
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.env.AccessRestriction; |
14 |
import org.eclipse.jdt.internal.compiler.impl.Constant; |
15 |
import org.eclipse.jdt.internal.compiler.impl.Constant; |
15 |
import org.eclipse.jdt.internal.compiler.lookup.*; |
16 |
import org.eclipse.jdt.internal.compiler.lookup.*; |
16 |
|
17 |
|
Lines 95-101
Link Here
|
95 |
} |
96 |
} |
96 |
this.binding = (FieldBinding) fieldBinding; |
97 |
this.binding = (FieldBinding) fieldBinding; |
97 |
|
98 |
|
98 |
if (isFieldUseDeprecated(this.binding, scope, (this.bits & IsStrictlyAssigned) != 0)) { |
99 |
if (fieldCanBeUsedAsReference(this.binding, scope, (this.bits & IsStrictlyAssigned) != 0)) { |
99 |
scope.problemReporter().javadocDeprecatedField(this.binding, this, scope.getDeclarationModifiers()); |
100 |
scope.problemReporter().javadocDeprecatedField(this.binding, this, scope.getDeclarationModifiers()); |
100 |
} |
101 |
} |
101 |
return this.resolvedType = this.binding.type; |
102 |
return this.resolvedType = this.binding.type; |
Lines 144-147
Link Here
|
144 |
} |
145 |
} |
145 |
visitor.endVisit(this, scope); |
146 |
visitor.endVisit(this, scope); |
146 |
} |
147 |
} |
|
|
148 |
/* |
149 |
* This method overrides the code in ASTNode#isFieldUseDeprecated(FieldBinding, Scope, boolean) |
150 |
* @see ASTNode#isFieldUseDeprecated(FieldBinding, Scope, boolean) |
151 |
* Do not modify field modifiers when searching for reference in Javadoc |
152 |
*/ |
153 |
private final boolean fieldCanBeUsedAsReference(FieldBinding field, Scope scope, boolean isStrictlyAssigned) { |
154 |
|
155 |
if ((field.modifiers & ExtraCompilerModifiers.AccRestrictedAccess) != 0) { |
156 |
AccessRestriction restriction = |
157 |
scope.environment().getAccessRestriction(field.declaringClass.erasure()); |
158 |
if (restriction != null) { |
159 |
scope.problemReporter().forbiddenReference(field, this, |
160 |
restriction.getFieldAccessMessageTemplate(), restriction.getProblemId()); |
161 |
} |
162 |
} |
163 |
|
164 |
if (!field.isViewedAsDeprecated()) return false; |
165 |
|
166 |
// inside same unit - no report |
167 |
if (scope.isDefinedInSameUnit(field.declaringClass)) return false; |
168 |
|
169 |
// if context is deprecated, may avoid reporting |
170 |
if (!scope.compilerOptions().reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false; |
171 |
return true; |
172 |
} |
147 |
} |
173 |
} |