boolean missingElementsHaveProblems,
char[] castedReceiver,
int receiverStart,
int receiverEnd) {
ObjectVector newFieldsFound = new ObjectVector();
// if the proposal is being asked inside a field's initialization, we'll record its id
int fieldBeingCompletedId = -1;
boolean isFieldBeingCompletedStatic = false;
for (int f = fields.length; --f >=0;) {
FieldBinding field = fields[f];
FieldDeclaration fieldDeclaration = field.sourceField();
// We maybe asking for a proposal inside this field's initialization. So record its id
ASTNode astNode = this.parser.assistNode;
if (fieldDeclaration != null && fieldDeclaration.initialization != null && astNode != null) {
if (CharOperation.equals(this.fileName, field.declaringClass.getFileName()) && fieldDeclaration.initialization.sourceEnd > 0) {
if (fieldDeclaration.initialization.sourceStart <= astNode.sourceStart &&
astNode.sourceEnd <= fieldDeclaration.initialization.sourceEnd) {
// completion is inside a field initializer
fieldBeingCompletedId = field.id;
isFieldBeingCompletedStatic = field.isStatic();
break;
}
} else { // The sourceEnd may not yet be set
CompletionNodeDetector detector = new CompletionNodeDetector(astNode, fieldDeclaration.initialization);
if (detector.containsCompletionNode()) { // completion is inside a field initializer
fieldBeingCompletedId = field.id;
isFieldBeingCompletedStatic = field.isStatic();
break;
}
}
}
}
// Inherited fields which are hidden by subclasses are filtered out
// No visibility checks can be performed without the scope & invocationSite
int fieldLength = fieldName.length;
next : for (int f = fields.length; --f >= 0;) {
FieldBinding field = fields[f];
// Content assist invoked inside some field's initialization.
// bug 310427 and 325481
if (fieldBeingCompletedId >= 0 && field.id >= fieldBeingCompletedId) {
// Don't propose field which is being declared currently
// Don't propose fields declared after the current field declaration statement
// Though, if field is static, then it can be still be proposed
if (!field.isStatic()) {
continue next;
} else if (isFieldBeingCompletedStatic) {
// static fields can't be proposed before they are actually declared if the
// field currently being declared is also static
continue next;
}
}
if (field.isSynthetic()) continue next;
if (onlyStaticFields && !field.isStatic()) continue next;
if (fieldLength > field.name.length) continue next;
if (!CharOperation.prefixEquals(fieldName, field.name, false /* ignore case */)
&& !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(fieldName, field.name))) continue next;
if (this.options.checkDeprecation &&
field.isViewedAsDeprecated() &&
!scope.isDefinedInSameUnit(field.declaringClass))
continue next;
if (this.options.checkVisibility
&& !field.canBeSeenBy(receiverType, invocationSite, scope)) continue next;
// don't propose non constant fields or strings (1.6 or below) in case expression
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=195346
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=343342
if (this.assistNodeIsInsideCase) {
if (field.isFinal() && field.isStatic()) {
if (this.assistNodeIsString){
if (field.type == null || field.type.id != TypeIds.T_JavaLangString)
continue next;
} else if (!(field.type instanceof BaseTypeBinding))
continue next;
} else {
continue next; // non-constants not allowed in case.
}
}
boolean prefixRequired = false;
for (int i = fieldsFound.size; --i >= 0;) {
Object[] other = (Object[])fieldsFound.elementAt(i);
FieldBinding otherField = (FieldBinding) other[0];
ReferenceBinding otherReceiverType = (ReferenceBinding) other[1];
if (field == otherField && TypeBinding.equalsEquals(receiverType, otherReceiverType))
continue next;
if (CharOperation.equals(field.name, otherField.name, true)) {
if (field.declaringClass.isSuperclassOf(otherField.declaringClass))
continue next;
if (otherField.declaringClass.isInterface()) {
if (TypeBinding.equalsEquals(field.declaringClass, scope.getJavaLangObject()))
continue next;
if (field.declaringClass.implementsInterface(otherField.declaringClass, true))
continue next;
}
if (field.declaringClass.isInterface())
if (otherField.declaringClass.implementsInterface(field.declaringClass, true))
continue next;
if(canBePrefixed) {
prefixRequired = true;
} else {
continue next;
}
}
}
for (int l = localsFound.size; --l >= 0;) {
LocalVariableBinding local = (LocalVariableBinding) localsFound.elementAt(l);
if (CharOperation.equals(field.name, local.name, true)) {
SourceTypeBinding declarationType = scope.enclosingSourceType();
if (declarationType.isAnonymousType() && TypeBinding.notEquals(declarationType, invocationScope.enclosingSourceType())) {
continue next;
}
if(canBePrefixed) {
prefixRequired = true;
} else {
continue next;
}
break;
}
}
newFieldsFound.add(new Object[]{field, receiverType});
char[] completion = field.name;
if(prefixRequired || this.options.forceImplicitQualification){
char[] prefix = computePrefix(scope.enclosingSourceType(), invocationScope.enclosingSourceType(), field.isStatic());