@Override public boolean equalsIgnoringTypeParams(final TypeSignature other) { if (!(other instanceof ArrayTypeSignature)) { return false; } final ArrayTypeSignature o = (ArrayTypeSignature) other; return o.elementTypeSignature.equalsIgnoringTypeParams(this.elementTypeSignature) && o.numDims == this.numDims; }
@Override void getReferencedClassNames(final Set<String> classNameListOut) { elementTypeSignature.getReferencedClassNames(classNameListOut); }
/** * Returns the parsed type signature for the field, if available. * * @return The parsed type signature for the field, if available, else returns null. */ public TypeSignature getTypeSignature() { if (typeSignatureStr == null) { return null; } if (typeSignature == null) { try { typeSignature = TypeSignature.parse(typeSignatureStr, declaringClassName); typeSignature.setScanResult(scanResult); } catch (final ParseException e) { throw new IllegalArgumentException(e); } } return typeSignature; }
protected void setScanResult(final ScanResult scanResult) { this.scanResult = scanResult; if (this.annotationInfo != null) { for (final AnnotationInfo ai : annotationInfo) { ai.setScanResult(scanResult); } } if (this.typeDescriptor != null) { this.typeDescriptor.setScanResult(scanResult); } if (this.typeSignature != null) { this.typeSignature.setScanResult(scanResult); } }
final TypeSignature typeSig = TypeSignature.parse(className.replace('.', '/'), typeSig.getReferencedClassNames(refdClassNames); } catch (final ParseException e) { if (log != null) { } else { final TypeSignature typeSig = TypeSignature.parse(typeSigStr, typeSig.getReferencedClassNames(refdClassNames);
static ArrayTypeSignature parse(final Parser parser, final String definingClassName) throws ParseException { int numArrayDims = 0; while (parser.peek() == '[') { numArrayDims++; parser.next(); } if (numArrayDims > 0) { final TypeSignature elementTypeSignature = TypeSignature.parse(parser, definingClassName); if (elementTypeSignature == null) { throw new ParseException(parser, "elementTypeSignature == null"); } return new ArrayTypeSignature(elementTypeSignature, numArrayDims); } else { return null; } } }
/** * Load the class this method is associated with, and get the {@link Method} reference for this method. * * @return The {@link Method} reference for this field. * @throws IllegalArgumentException * if the method does not exist. */ public Method loadClassAndGetMethod() throws IllegalArgumentException { final MethodParameterInfo[] allParameterInfo = getParameterInfo(); final List<Class<?>> parameterClasses = new ArrayList<>(allParameterInfo.length); for (final MethodParameterInfo parameterInfo : allParameterInfo) { final TypeSignature parameterType = parameterInfo.getTypeSignatureOrTypeDescriptor(); parameterClasses.add(parameterType.loadClass()); } final Class<?>[] parameterClassesArr = parameterClasses.toArray(new Class<?>[0]); try { return loadClass().getMethod(getName(), parameterClassesArr); } catch (final NoSuchMethodException e1) { try { return loadClass().getDeclaredMethod(getName(), parameterClassesArr); } catch (final NoSuchMethodException es2) { throw new IllegalArgumentException("No such method: " + getClassName() + "." + getName()); } } }
@Override void setScanResult(final ScanResult scanResult) { super.setScanResult(scanResult); if (elementTypeSignature != null) { elementTypeSignature.setScanResult(scanResult); } }
/** * Parse a type signature. * * @param typeDescriptor * The type descriptor or type signature to parse. * @param definingClass * The class containing the type descriptor. * @return The parsed type descriptor or type signature. * @throws ParseException * If the type signature could not be parsed. */ static TypeSignature parse(final String typeDescriptor, final String definingClass) throws ParseException { final Parser parser = new Parser(typeDescriptor); TypeSignature typeSignature; typeSignature = parse(parser, definingClass); if (typeSignature == null) { throw new ParseException(parser, "Could not parse type signature"); } if (parser.hasMore()) { throw new ParseException(parser, "Extra characters at end of type descriptor"); } return typeSignature; } }
/** * Returns the parsed type descriptor for the field, if available. * * @return The parsed type descriptor for the field, if available, else returns null. */ public TypeSignature getTypeDescriptor() { if (typeDescriptorStr == null) { return null; } if (typeDescriptor == null) { try { typeDescriptor = TypeSignature.parse(typeDescriptorStr, declaringClassName); typeDescriptor.setScanResult(scanResult); } catch (final ParseException e) { throw new IllegalArgumentException(e); } } return typeDescriptor; }
@Override void setScanResult(final ScanResult scanResult) { super.setScanResult(scanResult); if (typeSignature != null) { typeSignature.setScanResult(scanResult); } }
@Override void getReferencedClassNames(final Set<String> classNameListOut) { for (final TypeParameter typeParameter : typeParameters) { if (typeParameter != null) { typeParameter.getReferencedClassNames(classNameListOut); } } for (final TypeSignature typeSignature : parameterTypeSignatures) { if (typeSignature != null) { typeSignature.getReferencedClassNames(classNameListOut); } } resultType.getReferencedClassNames(classNameListOut); for (final ClassRefOrTypeVariableSignature typeSignature : throwsSignatures) { if (typeSignature != null) { typeSignature.getReferencedClassNames(classNameListOut); } } }
throw new ParseException(parser, "Ran out of input while parsing method signature"); final TypeSignature paramType = TypeSignature.parse(parser, definingClassName); if (paramType == null) { throw new ParseException(parser, "Missing method parameter type signature"); final TypeSignature resultType = TypeSignature.parse(parser, definingClassName); if (resultType == null) { throw new ParseException(parser, "Missing method result type signature");
@Override public boolean equalsIgnoringTypeParams(final TypeSignature other) { if (other instanceof TypeVariableSignature) { // Compare class type signature to type variable -- the logic for this // is implemented in TypeVariableSignature, and is not duplicated here return other.equalsIgnoringTypeParams(this); } if (!(other instanceof ClassRefTypeSignature)) { return false; } final ClassRefTypeSignature o = (ClassRefTypeSignature) other; if (o.suffixes.equals(this.suffixes)) { return o.className.equals(this.className); } else { return o.getFullyQualifiedClassName().equals(this.getFullyQualifiedClassName()); } }
/** * @return The type signature of the {@code Class<?>} reference. This will be a {@link ClassRefTypeSignature} or * a {@link BaseTypeSignature}. */ private TypeSignature getTypeSignature() { if (typeSignature == null) { try { // There can't be any type variables to resolve in either ClassRefTypeSignature or // BaseTypeSignature, so just set definingClassName to null typeSignature = TypeSignature.parse(typeDescriptorStr, /* definingClassName = */ null); typeSignature.setScanResult(scanResult); } catch (final ParseException e) { throw new IllegalArgumentException(e); } } return typeSignature; }
@Override void setScanResult(final ScanResult scanResult) { super.setScanResult(scanResult); if (this.typeSignature != null) { this.typeSignature.setScanResult(scanResult); } if (this.typeDescriptor != null) { this.typeDescriptor.setScanResult(scanResult); } if (this.annotationInfo != null) { for (final AnnotationInfo ai : this.annotationInfo) { ai.setScanResult(scanResult); } } }
/** Get the names of any classes in the type descriptor or type signature. */ @Override protected void getReferencedClassNames(final Set<String> classNames) { final TypeSignature methodSig = getTypeSignature(); if (methodSig != null) { methodSig.getReferencedClassNames(classNames); } final TypeSignature methodDesc = getTypeDescriptor(); if (methodDesc != null) { methodDesc.getReferencedClassNames(classNames); } if (annotationInfo != null) { for (final AnnotationInfo annotationInfo : annotationInfo) { annotationInfo.getReferencedClassNames(classNames); } } }
@Override void setScanResult(final ScanResult scanResult) { super.setScanResult(scanResult); if (typeParameters != null) { for (final TypeParameter typeParameter : typeParameters) { typeParameter.setScanResult(scanResult); } } if (this.parameterTypeSignatures != null) { for (final TypeSignature typeParameter : parameterTypeSignatures) { typeParameter.setScanResult(scanResult); } } if (this.resultType != null) { this.resultType.setScanResult(scanResult); } if (throwsSignatures != null) { for (final ClassRefOrTypeVariableSignature throwsSignature : throwsSignatures) { throwsSignature.setScanResult(scanResult); } } }
final TypeSignature fieldSig = fi.getTypeSignatureOrTypeDescriptor(); if (fieldSig != null) { fieldSig.getReferencedClassNames(referencedFieldTypeNames);