MaybeVisible
}
public static BindingValueKey getBindingKeyIfMatches(IJavaProject javaProject, IType type, IMember member, String nameStartingWith, String prefix, boolean requireExactNameMatch, int accessorsOrMutators, TypeCache cache) throws JavaModelException {
//System.out.println("BindingReflectionUtils.getBindingKeyIfMatches: " + member.getElementName() + " starts with " + nameStartingWith);
BindingValueKey bindingKey = null;
int flags = member.getFlags();
Visibility visible = Visibility.Hidden;
// Private is never an option
if (Flags.isPrivate(flags)) {
visible = Visibility.Hidden;
}
// Don't show static methods and fields
else if (Flags.isStatic(flags)) {
visible = Visibility.Hidden;
}
// Public bindings are always visible
else if (Flags.isPublic(flags) || type.isInterface()) {
visible = Visibility.Visible;
}
// Components that are not in a package can have bindings to protected fields
//else if ((Flags.isProtected(flags) || Flags.isPackageDefault(flags)) && BindingReflectionUtils.isDefaultPackage(member)) {
else if (Flags.isProtected(flags) || Flags.isPackageDefault(flags)) {
if (BindingReflectionUtils.isDefaultPackage(member)) {
visible = Visibility.Visible;
}
else {
visible = Visibility.MaybeVisible;
}
}
if (visible != Visibility.Hidden) {
boolean memberSignatureMatches;
if (member instanceof IMethod) {
IMethod method = (IMethod) member;
if (method.isConstructor()) {
memberSignatureMatches = false;
}
else {
int parameterCount = method.getParameterTypes().length;
String returnType = method.getReturnType();
if (accessorsOrMutators == BindingReflectionUtils.ACCESSORS_ONLY) {
memberSignatureMatches = (parameterCount == 0 && !"V".equals(returnType));
}
else if (accessorsOrMutators == BindingReflectionUtils.ACCESSORS_OR_VOID) {
memberSignatureMatches = (parameterCount == 0);
}
else if (accessorsOrMutators == BindingReflectionUtils.VOID_ONLY) {
memberSignatureMatches = (parameterCount == 0 && "V".equals(returnType));
}
else {
memberSignatureMatches = (parameterCount == 1 && "V".equals(returnType));
}
}
}
else {
memberSignatureMatches = true;
}
if (memberSignatureMatches) {
String memberName = member.getElementName();
String lowercaseMemberName = memberName.toLowerCase();
int prefixLength = prefix.length();
if ((requireExactNameMatch && lowercaseMemberName.equals(nameStartingWith)) || (!requireExactNameMatch && lowercaseMemberName.startsWith(nameStartingWith))) {
String bindingName = BindingReflectionUtils.toLowercaseFirstLetter(memberName.substring(prefixLength));
//System.out.println("BindingReflectionUtils.getBindingKeyIfMatches: bindingName = " + bindingName);
if (nameStartingWith.length() > 0 || !bindingName.startsWith("_")) {
if (visible == Visibility.MaybeVisible) {
String packageName = type.getPackageFragment().getElementName();
String kvcProtectedAccessorClassName = packageName.length() == 0 ? "KeyValueCodingProtectedAccessor" : (packageName + ".KeyValueCodingProtectedAccessor");
IType kvcProtectedAccessor = type.getJavaProject().findType(kvcProtectedAccessorClassName);
if (kvcProtectedAccessor != null) {
visible = Visibility.Visible;
}
}
if (visible == Visibility.Visible) {
bindingKey = new BindingValueKey(bindingName, type, member, javaProject, cache);
}
}
}
}
}