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; } }
protected MethodParameter parseMethodParameter(Parameter parameter) { MethodParameter parameterMethodNode = objectFactory.createMethodParameter(); parameterMethodNode.setName(parameter.name()); parameterMethodNode.setType(parseTypeInfo(parameter.type())); for (AnnotationDesc annotationDesc : parameter.annotations()) { parameterMethodNode.getAnnotation().add(parseAnnotationDesc(annotationDesc, parameter.typeName())); } return parameterMethodNode; }
/** Print the method parameter p */ private String parameter(Options opt, Parameter p[]) { StringBuilder par = new StringBuilder(1000); for (int i = 0; i < p.length; i++) { par.append(p[i].name() + typeAnnotation(opt, p[i].type())); if (i + 1 < p.length) par.append(", "); } return par.toString(); }
private static String parameterListForFragmentIdentifier(ExecutableMemberDoc executableMemberDoc) { StringBuilder result = new StringBuilder().append('('); for (int i = 0; i < executableMemberDoc.parameters().length; i++) { Parameter parameter = executableMemberDoc.parameters()[i]; if (i > 0) result.append(", "); result.append(parameter.type().qualifiedTypeName()); } return result.append(')').toString(); }
private static String parameterListForFragmentIdentifier(ExecutableMemberDoc executableMemberDoc) { StringBuilder result = new StringBuilder().append('('); for (int i = 0; i < executableMemberDoc.parameters().length; i++) { Parameter parameter = executableMemberDoc.parameters()[i]; if (i > 0) result.append(", "); result.append(parameter.type().qualifiedTypeName()); } return result.append(')').toString(); }
private static boolean equalParameters(@Nullable List<Object> expected, Parameter[] actual) { if (expected == null) return true; if (expected.size() != actual.length) return false; for (int i = 0; i < expected.size(); i++) { Object parameterType = expected.get(i); Type mdParameterType = actual[i].type(); ClassDoc mdParameterClassDoc = mdParameterType.asClassDoc(); if (mdParameterClassDoc == null) { if (!mdParameterType.toString().equals(parameterType)) return false; } else { if (!mdParameterClassDoc.equals(parameterType)) return false; } } return true; }
private static boolean equalParameters(@Nullable List<Object> expected, Parameter[] actual) { if (expected == null) return true; if (expected.size() != actual.length) return false; for (int i = 0; i < expected.size(); i++) { Object parameterType = expected.get(i); Type mdParameterType = actual[i].type(); ClassDoc mdParameterClassDoc = mdParameterType.asClassDoc(); if (mdParameterClassDoc == null) { if (!mdParameterType.toString().equals(parameterType)) return false; } else { if (!mdParameterClassDoc.equals(parameterType)) return false; } } return true; }
/** Print the method parameter p */ private String parameter(Options opt, Parameter p[]) { String par = ""; for (int i = 0; i < p.length; i++) { par += p[i].name() + typeAnnotation(opt, p[i].type()); if (i + 1 < p.length) par += ", "; } return par; }
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); }
Type parameterType = parameters[i].type();
protected void writeParam(ExecutableMemberDoc member, Parameter param, boolean isVarArg) { if (param.type() != null) { writer.printLink(new LinkInfoImpl( LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM, param.type(), isVarArg)); } if(param.name().length() > 0) { writer.space(); writer.print(param.name()); } }
private String prettyPrintParameterList(ExecutableMemberDoc executableMemberDoc) { StringBuilder result = new StringBuilder().append('('); for (int i = 0; i < executableMemberDoc.parameters().length; i++) { Parameter parameter = executableMemberDoc.parameters()[i]; if (i > 0) { result.append(", "); } Type pt = parameter.type(); if (pt.isPrimitive()) { result.append(pt.toString()); continue; } // Show erasure type, not type variable name. ClassDoc cd = pt.asClassDoc(); assert cd != null : parameter; result.append(cd.name()); } result.append(')'); return result.toString(); } };
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 String prettyPrintParameterList(ExecutableMemberDoc executableMemberDoc) { StringBuilder result = new StringBuilder().append('('); for (int i = 0; i < executableMemberDoc.parameters().length; i++) { Parameter parameter = executableMemberDoc.parameters()[i]; if (i > 0) { result.append(", "); } Type pt = parameter.type(); if (pt.isPrimitive()) { result.append(pt.toString()); continue; } // Show erasure type, not type variable name. ClassDoc cd = pt.asClassDoc(); assert cd != null : parameter; result.append(cd.name()); } result.append(')'); return result.toString(); } };
private static Option<Class<?>[]> loadParameterClasses(MethodDoc methodDoc) { Parameter[] jp = methodDoc.parameters(); List<Class<?>> parameters = new ArrayList<>(); for (Parameter p : jp) { final String classForName = getClassForNameFromType(p.type()); Option<Class<?>> clz = loadClass(classForName); if (clz.isEmpty()) { log.error("Could not load Class.forName({}). Returning no parameters for {}.", classForName, methodDoc.name()); return none(); } parameters.add(clz.get()); } return some(parameters.toArray(new Class[parameters.size()])); }
/** * 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; } }
/** * 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) { StringBuilder buf = new StringBuilder(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 ? writer.getName(buf.toString()) : null; } }
/** * Add the parameter for the executable member. * * @param member the member to write parameter for. * @param param the parameter that needs to be written. * @param isVarArg true if this is a link to var arg. * @param tree the content tree to which the parameter information will be added. */ protected void addParam(ExecutableMemberDoc member, Parameter param, boolean isVarArg, Content tree) { if (param.type() != null) { Content link = writer.getLink(new LinkInfoImpl( configuration, LinkInfoImpl.Kind.EXECUTABLE_MEMBER_PARAM, param.type()).varargs(isVarArg)); tree.addContent(link); } if(param.name().length() > 0) { tree.addContent(writer.getSpace()); tree.addContent(param.name()); } }
/** * The documentation for values() and valueOf() in Enums are set by the * doclet. */ public static void setEnumDocumentation(Configuration configuration, ClassDoc classDoc) { MethodDoc[] methods = classDoc.methods(); for (int j = 0; j < methods.length; j++) { MethodDoc currentMethod = methods[j]; if (currentMethod.name().equals("values") && currentMethod.parameters().length == 0) { currentMethod.setRawCommentText( configuration.getText("doclet.enum_values_doc", classDoc.name())); } else if (currentMethod.name().equals("valueOf") && currentMethod.parameters().length == 1) { Type paramType = currentMethod.parameters()[0].type(); if (paramType != null && paramType.qualifiedTypeName().equals(String.class.getName())) { currentMethod.setRawCommentText( configuration.getText("doclet.enum_valueof_doc")); } } } }