private static List<MethodInspect> getInspects(ExecutableMemberDoc[] memberDocs) { List<MethodInspect> methodInspects = new ArrayList<>(memberDocs.length); for (ExecutableMemberDoc memberDoc : memberDocs) { List<String> signature = new ArrayList<>(); for (Parameter parameter : memberDoc.parameters()) { signature.add(parameter.type().qualifiedTypeName() + " " + parameter.name()); } MethodInspect methodInspect = new MethodInspect(memberDoc.name(), memberDoc.getRawCommentText(), String.join(", ", signature)); methodInspects.add(methodInspect); } return methodInspects; } }
/** Print a a basic type t */ private String type(Options opt, Type t, boolean generics) { return ((generics ? opt.showQualifiedGenerics : opt.showQualified) ? // t.qualifiedTypeName() : t.typeName()) // + (opt.hideGenerics ? "" : typeParameters(opt, t.asParameterizedType())); }
private static String getTypeName(Type type) { String typeName = type.qualifiedTypeName(); // look for Class<X> way of referencing sub resources ParameterizedType pt = type.asParameterizedType(); if (pt != null && typeName.equals("java.lang.Class")) { Type[] typeArgs = pt.typeArguments(); if (typeArgs != null && typeArgs.length == 1) { typeName = typeArgs[0].qualifiedTypeName(); } } return typeName; }
public static MethodIdentity create(MethodDoc method) { final List<String> parameterTypeNames = new ArrayList<String>(); for (Parameter param: method.parameters()) { Type type = param.type(); parameterTypeNames.add(type.qualifiedTypeName() + type.dimension()); } return new MethodIdentity(method.qualifiedName(), parameterTypeNames); }
private FieldRelationInfo getFieldRelationInfo(FieldDoc field) { Type type = field.type(); if(type.isPrimitive() || type instanceof WildcardType || type instanceof TypeVariable) return null; if (type.dimension().endsWith("[]")) { return new FieldRelationInfo(type.asClassDoc(), true); } Options opt = optionProvider.getOptionsFor(type.asClassDoc()); if (opt.matchesCollPackageExpression(type.qualifiedTypeName())) { Type[] argTypes = getInterfaceTypeArguments(collectionClassDoc, type); if (argTypes != null && argTypes.length == 1 && !argTypes[0].isPrimitive()) return new FieldRelationInfo(argTypes[0].asClassDoc(), true); argTypes = getInterfaceTypeArguments(mapClassDoc, type); if (argTypes != null && argTypes.length == 2 && !argTypes[1].isPrimitive()) return new FieldRelationInfo(argTypes[1].asClassDoc(), true); } return new FieldRelationInfo(type.asClassDoc(), false); }
/** * For backward compatibility, include an anchor using the erasures of the * parameters. NOTE: We won't need this method anymore after we fix * see tags so that they use the type instead of the erasure. * * @param emd the ExecutableMemberDoc to anchor to. * @return the 1.4.x style anchor for the ExecutableMemberDoc. */ protected String getErasureAnchor(ExecutableMemberDoc emd) { StringBuffer buf = new StringBuffer(emd.name() + "("); Parameter[] params = emd.parameters(); boolean foundTypeVariable = false; for (int i = 0; i < params.length; i++) { if (i > 0) { buf.append(","); } Type t = params[i].type(); foundTypeVariable = foundTypeVariable || t.asTypeVariable() != null; buf.append(t.isPrimitive() ? t.typeName() : t.asClassDoc().qualifiedName()); buf.append(t.dimension()); } buf.append(")"); return foundTypeVariable ? buf.toString() : null; } }
if( type.asClassDoc() != null ) linkInfo.label = (type.asClassDoc().isIncluded() ? type.typeName() : type.qualifiedTypeName()) + type.dimension() + ".class"; return getLink( linkInfo ); return type.typeName() + type.dimension() + ".class";
public static Method getMethodByDoc(Class<?> classz, MethodDoc methodDoc) throws Exception { Class<?>[] parameterTypes = new Class<?>[methodDoc.parameters().length]; for (int i = 0; i < methodDoc.parameters().length; i++) { Parameter parameter = methodDoc.parameters()[i]; if (parameter.type().isPrimitive()) { if (parameter.type().simpleTypeName().equals("byte")) parameterTypes[i] = byte.class; else if (parameter.type().simpleTypeName().equals("boolean")) parameterTypes[i] = boolean.class; else if (parameter.type().simpleTypeName().equals("short")) parameterTypes[i] = short.class; else if (parameter.type().simpleTypeName().equals("char")) parameterTypes[i] = char.class; else if (parameter.type().simpleTypeName().equals("int")) parameterTypes[i] = int.class; else if (parameter.type().simpleTypeName().equals("long")) parameterTypes[i] = long.class; else if (parameter.type().simpleTypeName().equals("float")) parameterTypes[i] = float.class; else if (parameter.type().simpleTypeName().equals("double")) parameterTypes[i] = double.class; } else { parameterTypes[i] = Class.forName(parameter.type().qualifiedTypeName()); } if (!StringUtils.isEmpty(parameter.type().dimension())) { int dimension = StringUtil.getStrCount(parameter.type().dimension(), "[]"); parameterTypes[i] = Array.newInstance(parameterTypes[i], (int[])Array.newInstance(int.class, dimension)).getClass(); } } return classz.getDeclaredMethod(methodDoc.name(), parameterTypes); }
/** * {@inheritDoc} */ public void addComments(Type holder, MethodDoc method, Content methodDocTree) { ClassDoc holderClassDoc = holder.asClassDoc(); if (method.inlineTags().length > 0) { if (holder.asClassDoc().equals(classdoc) || (! (holderClassDoc.isPublic() || Util.isLinkable(holderClassDoc, configuration)))) { writer.addInlineComment(method, methodDocTree); } else { Content link = writer.getDocLink(LinkInfoImpl.Kind.METHOD_DOC_COPY, holder.asClassDoc(), method, holder.asClassDoc().isIncluded() ? holder.typeName() : holder.qualifiedTypeName(), false); Content codelLink = HtmlTree.CODE(link); Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel, holder.asClassDoc().isClass()? writer.descfrmClassLabel : writer.descfrmInterfaceLabel); descfrmLabel.addContent(writer.getSpace()); descfrmLabel.addContent(codelLink); methodDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel)); writer.addInlineComment(method, methodDocTree); } } }
protected TypeInfo parseTypeInfo(Type type) { TypeInfo typeInfoNode = objectFactory.createTypeInfo(); typeInfoNode.setQualified(type.qualifiedTypeName()); String dimension = type.dimension(); if (dimension.length() > 0) { typeInfoNode.setDimension(dimension); } WildcardType wildcard = type.asWildcardType(); if (wildcard != null) { typeInfoNode.setWildcard(parseWildcard(wildcard)); } ParameterizedType parameterized = type.asParameterizedType(); if (parameterized != null) { for (Type typeArgument : parameterized.typeArguments()) { typeInfoNode.getGeneric().add(parseTypeInfo(typeArgument)); } } return typeInfoNode; }
/** * Returns the fully qualified class name from a {@link Type} that will work with {@link Class#forName(String)}. * <p> * This method correctly handles nested classes such that they can be fed into {@link Class#forName(String)}. * * @param type The type that you wish to derive the fully qualified path name for. * @return The fully qualified class name for the type. */ private static String getClassForNameFromType(Type type) { final String fullClassName = type.typeName(); final String fullClassForName = fullClassName.replace(".", "$"); return type.qualifiedTypeName().replace(fullClassName, fullClassForName); }
Type[] arguments; if ( typeDoc.isPrimitive() ) { // an attribute of primitive type try { type = (Classifier) factory.locateModelElement( typeDoc.simpleTypeName() ); // TODO CHECK AGAIN if qualified of simple name should be used type = factory.constructDataType( typeDoc.simpleTypeName()); declaredAttributeClass = Class.forName( typeDoc.qualifiedTypeName() ); genericType = typeDoc.asParameterizedType(); if ( genericType != null ) { // a generic collection, assumed with a single type parameter arguments = genericType.typeArguments(); if ( arguments.length > 0 ) { associatedClassName = arguments[0].qualifiedTypeName(); associatedClassName = typeDoc.qualifiedTypeName();
Type type = linkInfo.type; Content link = newContent(); if (type.isPrimitive()) { link.addContent(type.typeName()); } else if (type.asAnnotatedType() != null && type.dimension().length() == 0) { link.addContent(getTypeAnnotationLinks(linkInfo)); linkInfo.type = type.asAnnotatedType().underlyingType(); link.addContent(getLink(linkInfo)); return link; } else if (type.asWildcardType() != null) { WildcardType wildcardType = type.asWildcardType(); Type[] extendsBounds = wildcardType.extendsBounds(); for (int i = 0; i < extendsBounds.length; i++) { } else if (type.asTypeVariable()!= null) { link.addContent(getTypeAnnotationLinks(linkInfo)); linkInfo.isTypeBound = true; Doc owner = type.asTypeVariable().owner(); if ((! linkInfo.excludeTypeParameterLinks) && owner instanceof ClassDoc) { linkInfo.classDoc = (ClassDoc) owner; Content label = newContent(); label.addContent(type.typeName()); linkInfo.label = label; link.addContent(getClassLink(linkInfo)); } else {
Type pcd = params[k].type(); if ((! params[k].type().isPrimitive()) && ! classArgs.contains(pcd) && ! (pcd instanceof TypeVariable)) { add(isConstructor? classToConstructorArgs :classToMethodArgs, pcd.asClassDoc(), em); classArgs.add(pcd); mapTypeParameters(isConstructor?
if (!parameter.type().isPrimitive()) { paramClz = Class.forName(parameter.type().qualifiedTypeName()); if (parameter.type().isPrimitive() || BeanUtils.isSimpleProperty(paramClz) || paramClz.isAssignableFrom(List.class) paramDoc.setType(fieldDoc==null ? "" : fieldDoc.type().typeName()); String[] paramTexts = fieldDoc.commentText().split("(e.g|eg|e.g.|example|exam|例如|如)(:|:)", 2); paramDoc.setDesc(paramTexts[0]);
/** * Build the field sub header. */ public void buildFieldSubHeader() { if (! currentClass.definesSerializableFields() ){ FieldDoc field = (FieldDoc) currentMember; fieldWriter.writeMemberHeader(field.type().asClassDoc(), field.type().typeName(), field.type().dimension(), field.name()); } }
/** * Return this type as a class. Array dimensions are ignored. * * @return a ClassDocImpl if the type is a Class. * Return null if it is a primitive type.. */ public ClassDoc asClassDoc() { return skipArrays().asClassDoc(); }
protected void printTypeLinkNoDimension(Type type) { ClassDoc cd = type.asClassDoc(); if (type.isPrimitive() || cd.isPackagePrivate()) { print(type.typeName()); } else { writer.printLink(new LinkInfoImpl( LinkInfoImpl.CONTEXT_SERIAL_MEMBER,type)); } } }