/** * Returns whether or not a class is a unit test. That is, whether or not it is a subclass of * {@link junit.framework.TestCase}. */ private static boolean isUnitTest(ClassDoc c) { if (c == null) { return false; } else if (c.qualifiedName().equals(TestCase.class.getName())) { return true; } else { return isUnitTest(c.superclass()); } }
/** * 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 ClassDoc getAncestorClass(ClassDoc classDoc) { final ClassDoc superclass = classDoc.superclass(); if (superclass != null) { return superclass; } // TODO search in interfaces - to do this we'd probably need to pass a Predicate (what are we looking for), or return an array of ClassDoc return null; }
/** * @return The <var>clasS</var>, and all superclasses (including {@link Object}) it extends */ public static ClassDoc[] withSuperclasses(ClassDoc clasS) { List<ClassDoc> result = new ArrayList<ClassDoc>(); for (ClassDoc c = clasS; c != null; c = c.superclass()) { result.add(c); } return result.toArray(new ClassDoc[result.size()]); }
/** * @return The <var>clasS</var>, and all superclasses (including {@link Object}) it extends */ public static ClassDoc[] withSuperclasses(ClassDoc clasS) { List<ClassDoc> result = new ArrayList<ClassDoc>(); for (ClassDoc c = clasS; c != null; c = c.superclass()) { result.add(c); } return result.toArray(new ClassDoc[result.size()]); }
public boolean matches(ClassDoc cd) { // if it's the class we're looking for return if(pattern.matcher(cd.toString()).matches()) return true; // recurse on supeclass, if available return cd.superclass() == null ? false : matches(cd.superclass()); }
public boolean matches(ClassDoc cd) { // if it's the class we're looking for return if(pattern.matcher(cd.toString()).matches()) return true; // recurse on supeclass, if available if(cd.superclass() != null) return matches(cd.superclass()); return false; }
/** * Returns all the tags of a class including its super classes * * @param classDoc the class to check * @return a list of tags */ private static List<Tag> getInheritableTags(ClassDoc classDoc) { List<Tag> tags = new ArrayList<>(); while (classDoc != null) { tags.addAll(asList(classDoc.tags())); classDoc = classDoc.superclass(); } Collections.reverse(tags); return tags; }
/** Return a list of fields for this class and all it's superclasses */ protected static List<FieldDoc> getFields(ClassDoc classDoc) { List<FieldDoc> ret = new ArrayList<>(); ClassDoc parent = classDoc.superclass(); if (parent != null) { ret.addAll(getFields(parent)); } ret.addAll(Arrays.asList(classDoc.fields())); return ret; } }
/** * Returns whether or not a class is a unit test. That is, whether * or not it is a subclass of {@link junit.framework.TestCase}. */ private static boolean isUnitTest(ClassDoc c) { if (c == null) { return false; } else if (c.qualifiedName().equals(TestCase.class.getName())) { return true; } else { return isUnitTest(c.superclass()); } }
public boolean matches(ClassDoc cd) { // if it's the interface we're looking for, match if(cd.isInterface() && pattern.matcher(cd.toString()).matches()) return true; // for each interface, recurse, since classes and interfaces // are treated the same in the doclet API for (ClassDoc iface : cd.interfaces()) if(matches(iface)) return true; // recurse on supeclass, if available return cd.superclass() == null ? false : matches(cd.superclass()); }
private static void addClassSuperclassesAndInterfaces(ClassDoc clasS, List<ClassDoc> result) { result.add(clasS); ClassDoc superclass = clasS.superclass(); if (superclass != null) { Docs.addClassSuperclassesAndInterfaces(superclass, result); } for (ClassDoc interfacE : clasS.interfaces()) { Docs.addInterfaceAndExtendedInterfaces(interfacE, result); } }
private static void addClassSuperclassesAndInterfaces(ClassDoc clasS, List<ClassDoc> result) { result.add(clasS); ClassDoc superclass = clasS.superclass(); if (superclass != null) { Docs.addClassSuperclassesAndInterfaces(superclass, result); } for (ClassDoc interfacE : clasS.interfaces()) { Docs.addInterfaceAndExtendedInterfaces(interfacE, result); } }
private ParameterDescription getPublishedParameterDescription(ClassDescriptionSource source, FieldDoc fd, String name) { String currentClassName = fd.type().qualifiedTypeName(); while (true) { ClassDescription componentCD = source.getDescription(currentClassName); if (componentCD.classDoc == null) throw new IllegalArgumentException(String.format("Published parameter '%s' from %s not found.", name, fd.qualifiedName())); if (componentCD.parameters.containsKey(name)) { return componentCD.parameters.get(name); } currentClassName = componentCD.classDoc.superclass().typeName(); } }
/** * @return Whether <var>b</var> is <var>a</var>, or an interface or superclass of <var>a</var> */ public static boolean isSubclassOf(ClassDoc a, ClassDoc b) { if (a == b) return true; for (ClassDoc i : a.interfaces()) { if (Docs.isSubclassOf(i, b)) return true; } ClassDoc s = a.superclass(); return s != null && Docs.isSubclassOf(s, b); }
/** * @return Whether {@code b} is {@code a}, or an interface or superclass of {@code a} */ public static boolean isSubclassOf(ClassDoc a, ClassDoc b) { if (a == b) return true; for (ClassDoc i : a.interfaces()) { if (Docs.isSubclassOf(i, b)) return true; } ClassDoc s = a.superclass(); return s != null && Docs.isSubclassOf(s, b); }
public ClassDescription(ClassDoc classDoc, ClassDescriptionSource source) { this.classDoc = classDoc; loadEvents(); loadParameters(source); ClassDoc parentDoc = classDoc.superclass(); if (parentDoc != null) { ClassDescription parentDescription = source.getDescription(classDoc.superclass().qualifiedName()); mergeInto(events, parentDescription.events); mergeInto(parameters, parentDescription.parameters); } }
public ClassDescription(ClassDoc classDoc, ClassDescriptionSource source) { this.classDoc = classDoc; loadEvents(); loadParameters(source); ClassDoc parentDoc = classDoc.superclass(); if (parentDoc != null) { ClassDescription parentDescription = source.getDescription(classDoc.superclass().qualifiedName()); mergeInto(events, parentDescription.events); mergeInto(parameters, parentDescription.parameters); } }
/** * Builds a view along with its parent views, recursively */ private static View buildView(RootDoc root, ClassDoc viewClass, OptionProvider provider) { ClassDoc superClass = viewClass.superclass(); if(superClass == null || superClass.tags("view").length == 0) return new View(root, viewClass, provider); return new View(root, viewClass, buildView(root, superClass, provider)); }
/** * Builds a view along with its parent views, recursively */ private static View buildView(RootDoc root, ClassDoc viewClass, OptionProvider provider) { ClassDoc superClass = viewClass.superclass(); if(superClass == null || superClass.tags("view").length == 0) return new View(root, viewClass, provider); return new View(root, viewClass, buildView(root, superClass, provider)); }