/** * 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; }
/** * @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; }
/** * 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; }
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; } } }
/** * 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; } }
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");