methodDocType.setMethodName(methodDoc.name()); methodDocType.setMethodSignature(methodDoc.signature()); methodDocType.setCommentText(methodDoc.commentText());
/** * Returns an array containing all of the "test" methods (including those that are inherited) for * the given class. */ private static MethodDoc[] getTestMethods(ClassDoc c) { Set set = new TreeSet(); while (c != null) { MethodDoc[] methods = c.methods(); for (int i = 0; i < methods.length; i++) { MethodDoc method = methods[i]; if (method.isPublic() && method.parameters().length == 0 && method.name().startsWith("test")) { set.add(method); } } c = c.superclass(); } return (MethodDoc[]) set.toArray(new MethodDoc[0]); }
/** * Summarizes the test methods of the given class */ public static void document(ClassDoc c, PrintWriter pw) throws IOException { pw.println(c.qualifiedName()); { String comment = c.commentText(); if (comment != null && !comment.equals("")) { pw.println(""); indent(comment, 4, pw); pw.println(""); } } MethodDoc[] methods = getTestMethods(c); for (int i = 0; i < methods.length; i++) { MethodDoc method = methods[i]; pw.print(" "); pw.println(method.name()); String comment = method.commentText(); if (comment != null && !comment.equals("")) { pw.println(""); indent(comment, 6, pw); pw.println(""); } } pw.println(""); }
private static String summaryFromMethodName(MethodDoc methodDoc) { return StringUtils.capitalize( Arrays.stream(StringUtils.splitByCharacterTypeCamelCase(methodDoc.name())) .map(StringUtils::lowerCase) .collect(Collectors.joining(" "))); }
private boolean isPropertyGetterOrSetter(MethodDoc[] members, MethodDoc methodDoc) { boolean found = false; String propertyName = Util.propertyNameFromMethodName(configuration, methodDoc.name()); if (!propertyName.isEmpty()) { String propertyMethodName = propertyName + "Property"; for (MethodDoc member: members) { if (member.name().equals(propertyMethodName)) { found = true; break; } } } return found; } }
private FieldDoc fieldForProperty(FieldDoc[] fields, MethodDoc property) { for (FieldDoc field : fields) { final String fieldName = field.name(); final String propertyName = fieldName + "Property"; if (propertyName.equals(property.name())) { return field; } } return null; }
private void addMethod(MethodDoc methodDoc) { this.methods.put(methodDoc.name(), MethodDocumentation.fromMethodDoc(methodDoc)); } }
public class ListClassAndMethods { public static boolean start(RootDoc root) { ClassDoc[] classes = root.classes(); for(ClassDoc clazz : classes){ System.out.println("Class Name: "+clazz); System.out.println("--------------------------"); for(MethodDoc methodz :clazz.methods()){ System.out.println(methodz.name()); } } return true; } }
protected ClassDoc implementsMethodInIntfac(MethodDoc method, ClassDoc[] intfacs) { for (int i = 0; i < intfacs.length; i++) { MethodDoc[] methods = intfacs[i].methods(); if (methods.length > 0) { for (int j = 0; j < methods.length; j++) { if (methods[j].name().equals(method.name()) && methods[j].signature().equals(method.signature())) { return intfacs[i]; } } } } return null; }
private boolean isPropertyMethod(MethodDoc method) { if (!method.name().endsWith("Property")) { return false; } if (! memberIsVisible(method)) { return false; } if (pattern.matcher(method.name()).matches()) { return false; } return 0 == method.parameters().length && !"void".equals(method.returnType().simpleTypeName()); }
protected ClassDoc implementsMethodInIntfac(MethodDoc method, ClassDoc[] intfacs) { for (int i = 0; i < intfacs.length; i++) { MethodDoc[] methods = intfacs[i].methods(); if (methods.length > 0) { for (int j = 0; j < methods.length; j++) { if (methods[j].name().equals(method.name()) && methods[j].signature().equals(method.signature())) { return intfacs[i]; } } } } return null; }
/** * {@inheritDoc} */ public Content getPropertyDocTreeHeader(MethodDoc property, Content propertyDetailsTree) { propertyDetailsTree.addContent( writer.getMarkerAnchor(property.name())); Content propertyDocTree = writer.getMemberTreeHeader(); Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); heading.addContent(property.name().substring(0, property.name().lastIndexOf("Property"))); propertyDocTree.addContent(heading); return propertyDocTree; }
/** * Tries to find a method with the correct signature and name on an interface. * * @param object The class or interface on which you want to search for a method * @param method The name and signature of the method you are searching for * @return Null if no method matches. */ private static MethodDoc findInterfaceMethod(ClassDoc object, MethodDoc method) { for (MethodDoc intfMethod : object.methods()) { if (intfMethod.name().equals(method.name())) { if (intfMethod.flatSignature().equals(method.flatSignature())) { // xxx: do we need to consider more compllicated cases like contravariance? return intfMethod; } } } return null; }
/** * Returns an array containing all of the "test" methods (including * those that are inherited) for the given class. */ private static MethodDoc[] getTestMethods(ClassDoc c) { Set set = new TreeSet(); while (c != null) { MethodDoc[] methods = c.methods(); for (int i = 0; i < methods.length; i++) { MethodDoc method = methods[i]; if (method.isPublic() && method.parameters().length == 0 && method.name().startsWith("test")) { set.add(method); } } c = c.superclass(); } return (MethodDoc[]) set.toArray(new MethodDoc[0]); }
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()])); }
/** * Build the method tags. */ public void buildMethodTags() { methodWriter.writeMemberTags((MethodDoc) currentMember); MethodDoc method = (MethodDoc)currentMember; if (method.name().compareTo("writeExternal") == 0 && method.tags("serialData").length == 0) { if (configuration.serialwarn) { configuration.getDocletSpecificMsg().warning( currentMember.position(), "doclet.MissingSerialDataTag", method.containingClass().qualifiedName(), method.name()); } } }
/** * Build the method tags. * * @param node the XML element that specifies which components to document * @param methodsContentTree content tree to which the documentation will be added */ public void buildMethodTags(XMLNode node, Content methodsContentTree) { methodWriter.addMemberTags((MethodDoc) currentMember, methodsContentTree); MethodDoc method = (MethodDoc)currentMember; if (method.name().compareTo("writeExternal") == 0 && method.tags("serialData").length == 0) { if (configuration.serialwarn) { configuration.getDocletSpecificMsg().warning( currentMember.position(), "doclet.MissingSerialDataTag", method.containingClass().qualifiedName(), method.name()); } } }
/** Print the class's operations m */ private boolean operations(Options opt, MethodDoc m[]) { boolean printed = false; for (MethodDoc md : m) { if (hidden(md)) continue; // Filter-out static initializer method if (md.name().equals("<clinit>") && md.isStatic() && md.isPackagePrivate()) continue; stereotype(opt, md, Align.LEFT); String op = visibility(opt, md) + md.name() + // (opt.showType ? "(" + parameter(opt, md.parameters()) + ")" + typeAnnotation(opt, md.returnType()) : "()"); tableLine(Align.LEFT, (md.isAbstract() ? Font.ABSTRACT : Font.NORMAL).wrap(opt, op)); printed = true; tagvalue(opt, md); } return printed; }
/** * {@inheritDoc} */ public Content getMethodDocTreeHeader(MethodDoc method, Content methodDetailsTree) { String erasureAnchor; if ((erasureAnchor = getErasureAnchor(method)) != null) { methodDetailsTree.addContent(writer.getMarkerAnchor((erasureAnchor))); } methodDetailsTree.addContent( writer.getMarkerAnchor(writer.getAnchor(method))); Content methodDocTree = writer.getMemberTreeHeader(); Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); heading.addContent(method.name()); methodDocTree.addContent(heading); return methodDocTree; }