private boolean checkParameters( char[] methodDescriptor, char[][] parameterSimpleNames, char[][] parameterQualifications, boolean isCaseSensitive, boolean isCamelCase) { char[][] arguments = Signature.getParameterTypes(methodDescriptor); int parameterCount = parameterSimpleNames.length; if (parameterCount != arguments.length) return false; for (int i = 0; i < parameterCount; i++) if (!checkTypeName( parameterSimpleNames[i], parameterQualifications[i], Signature.toCharArray(arguments[i]), isCaseSensitive, isCamelCase)) return false; return true; }
boolean matchField(FieldPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) { if (!pattern.findDeclarations) return false; // only relevant when finding declarations if (!(binaryInfo instanceof IBinaryField)) return false; IBinaryField field = (IBinaryField) binaryInfo; if (!pattern.matchesName(pattern.name, field.getName())) return false; if (!checkDeclaringType( enclosingBinaryType, pattern.declaringSimpleName, pattern.declaringQualification, pattern.isCaseSensitive(), pattern.isCamelCase())) return false; char[] fieldTypeSignature = Signature.toCharArray(convertClassFileFormat(field.getTypeName())); return checkTypeName( pattern.typeSimpleName, pattern.typeQualification, fieldTypeSignature, pattern.isCaseSensitive(), pattern.isCamelCase()); }
boolean matchMethod(MethodPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) { if (!pattern.findDeclarations) return false; // only relevant when finding declarations if (!(binaryInfo instanceof IBinaryMethod)) return false; IBinaryMethod method = (IBinaryMethod) binaryInfo; if (!pattern.matchesName(pattern.selector, method.getSelector())) return false; if (!checkDeclaringType( enclosingBinaryType, pattern.declaringSimpleName, pattern.declaringQualification, pattern.isCaseSensitive(), pattern.isCamelCase())) return false; // look at return type only if declaring type is not specified boolean checkReturnType = pattern.declaringSimpleName == null && (pattern.returnSimpleName != null || pattern.returnQualification != null); boolean checkParameters = pattern.parameterSimpleNames != null; if (checkReturnType || checkParameters) { char[] methodDescriptor = convertClassFileFormat(method.getMethodDescriptor()); if (checkReturnType) { char[] returnTypeSignature = Signature.toCharArray(Signature.getReturnType(methodDescriptor)); if (!checkTypeName( pattern.returnSimpleName, pattern.returnQualification, returnTypeSignature, pattern.isCaseSensitive(), pattern.isCamelCase())) return false; } if (checkParameters && !checkParameters( methodDescriptor, pattern.parameterSimpleNames, pattern.parameterQualifications, pattern.isCaseSensitive(), pattern.isCamelCase())) return false; } return true; }
private boolean checkAnnotation(IBinaryAnnotation annotation, TypeReferencePattern pattern) { if (checkTypeName( pattern.simpleName, pattern.qualification, convertClassFileFormat(Signature.toCharArray(annotation.getTypeName())), pattern.isCaseSensitive, pattern.isCamelCase)) { return true; } IBinaryElementValuePair[] valuePairs = annotation.getElementValuePairs(); if (valuePairs != null) { for (int j = 0, vpLength = valuePairs.length; j < vpLength; j++) { IBinaryElementValuePair valuePair = valuePairs[j]; Object pairValue = valuePair.getValue(); if (pairValue instanceof IBinaryAnnotation) { if (checkAnnotation((IBinaryAnnotation) pairValue, pattern)) { return true; } } } } return false; }
public final String getQualifiedTypeName() { if (fQualifiedName == null) fQualifiedName = String.valueOf(Signature.toCharArray(Signature.getTypeErasure(fProposal.getSignature()))); return fQualifiedName; }