*/
private boolean checkForConflictingInstanceGetterAndSuperclassMember() {
if (enclosingClass == null) {
return false;
}
InterfaceType enclosingType = enclosingClass.getType();
// check every accessor
boolean hasProblem = false;
for (PropertyAccessorElement accessor : enclosingClass.getAccessors()) {
// we analyze instance accessors here
if (accessor.isStatic()) {
continue;
}
// prepare accessor properties
String name = accessor.getDisplayName();
boolean getter = accessor.isGetter();
// if non-final variable, ignore setter - we alreay reported problem for getter
if (accessor.isSetter() && accessor.isSynthetic()) {
continue;
}
// try to find super element
ExecutableElement superElement;
superElement = enclosingType.lookUpGetterInSuperclass(name, currentLibrary);
if (superElement == null) {
superElement = enclosingType.lookUpSetterInSuperclass(name, currentLibrary);
}
if (superElement == null) {
superElement = enclosingType.lookUpMethodInSuperclass(name, currentLibrary);
}
if (superElement == null) {
continue;
}
// OK, not static
if (!superElement.isStatic()) {
continue;
}
// prepare "super" type to report its name
ClassElement superElementClass = (ClassElement) superElement.getEnclosingElement();
InterfaceType superElementType = superElementClass.getType();
// report problem
hasProblem = true;
if (getter) {
errorReporter.reportErrorForElement(
StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER,
accessor,
superElementType.getDisplayName());
} else {
errorReporter.reportErrorForElement(
StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER,
accessor,
superElementType.getDisplayName());
}
}
// done
return hasProblem;
}