public ImplementedMethods(MethodDoc method, Configuration configuration) { this.method = method; this.configuration = configuration; classdoc = method.containingClass(); }
public ImplementedMethods(MethodDoc method, Configuration configuration) { this.method = method; this.configuration = configuration; classdoc = method.containingClass(); }
/** * Search in the already found methods' list and check if it contains * a method which is overriding the method parameter or is the method * parameter itself. * * @param method MethodDoc Method to be searched in the Method List for * an overriding method. */ private boolean overridingMethodFound(MethodDoc method) { ClassDoc containingClass = method.containingClass(); for (int i = 0; i < methlist.size(); i++) { MethodDoc listmethod = methlist.get(i); if (containingClass == listmethod.containingClass()) { // it's the same method. return true; } ClassDoc cd = listmethod.overriddenClass(); if (cd == null) { continue; } if (cd == containingClass || cd.subclassOf(containingClass)) { return true; } } return false; } }
/** * Search in the already found methods' list and check if it contains * a method which is overriding the method parameter or is the method * parameter itself. * * @param method MethodDoc Method to be searched in the Method List for * an overriding method. */ private boolean overridingMethodFound(MethodDoc method) { ClassDoc containingClass = method.containingClass(); for (int i = 0; i < methlist.size(); i++) { MethodDoc listmethod = methlist.get(i); if (containingClass == listmethod.containingClass()) { // it's the same method. return true; } ClassDoc cd = listmethod.overriddenClass(); if (cd == null) { continue; } if (cd == containingClass || cd.subclassOf(containingClass)) { return true; } } return false; } }
/** * Search in the method list and check if it contains a method which * is overridden by the method as parameter. If found, remove the * overridden method from the method list. * * @param method Is this method overriding a method in the method list. */ private void removeOverriddenMethod(MethodDoc method) { ClassDoc overriddenClass = method.overriddenClass(); if (overriddenClass != null) { for (int i = 0; i < methlist.size(); i++) { ClassDoc cd = methlist.get(i).containingClass(); if (cd == overriddenClass || overriddenClass.subclassOf(cd)) { methlist.remove(i); // remove overridden method return; } } } }
/** * Search in the method list and check if it contains a method which * is overridden by the method as parameter. If found, remove the * overridden method from the method list. * * @param method Is this method overriding a method in the method list. */ private void removeOverriddenMethod(MethodDoc method) { ClassDoc overriddenClass = method.overriddenClass(); if (overriddenClass != null) { for (int i = 0; i < methlist.size(); i++) { ClassDoc cd = methlist.get(i).containingClass(); if (cd == overriddenClass || overriddenClass.subclassOf(cd)) { methlist.remove(i); // remove overridden method return; } } } }
/** * Gets all tags from a method and its containing class and package * * @param methodDoc the method doc * @return a combined list of tags */ static TagLists getTagsUpwards(MethodDoc methodDoc) { List<Tag> methodTags = getInheritableTags(methodDoc); List<Tag> classTags = getInheritableTags(methodDoc.containingClass()); Tag[] packageTags = methodDoc.containingClass().containingPackage().tags(); return new TagLists(methodTags, classTags, asList(packageTags)); }
/** * This gets the list of consumes mime types from the given method * * @param methodDoc The method javadoc * @param options The doclet options * @return The list or null if none were found */ static List<String> getConsumes(MethodDoc methodDoc, DocletOptions options) { List<String> methodLevel = listInheritableValues(methodDoc, JAX_RS_CONSUMES, "value", options); if (methodLevel == null) { // look for class level return listInheritableValues(methodDoc.containingClass(), JAX_RS_CONSUMES, "value", options); } return methodLevel; }
/** * This gets the list of produces mime types from the given method * * @param methodDoc The method javadoc * @param options The doclet options * @return The list or null if none were found */ static List<String> getProduces(MethodDoc methodDoc, DocletOptions options) { List<String> methodLevel = listInheritableValues(methodDoc, JAX_RS_PRODUCES, "value", options); if (methodLevel == null) { // look for class level return listInheritableValues(methodDoc.containingClass(), JAX_RS_PRODUCES, "value", options); } return methodLevel; }
/** * Build the comments for the method. Do nothing if * {@link Configuration#nocomment} is set to true. If this method */ public void buildMethodComments() { if (!configuration.nocomment) { MethodDoc method = (MethodDoc) methods.get(currentMethodIndex); if (method.inlineTags().length == 0) { DocFinder.Output docs = DocFinder.search( new DocFinder.Input(method)); method = docs.inlineTags != null && docs.inlineTags.length > 0 ? (MethodDoc) docs.holder : method; } //NOTE: When we fix the bug where ClassDoc.interfaceTypes() does // not pass all implemented interfaces, holder will be the // interface type. For now, it is really the erasure. writer.writeComments(method.containingClass(), method); } }
/** * Build the comments for the method. Do nothing if * {@link Configuration#nocomment} is set to true. * * @param node the XML element that specifies which components to document * @param methodDocTree the content tree to which the documentation will be added */ public void buildMethodComments(XMLNode node, Content methodDocTree) { if (!configuration.nocomment) { MethodDoc method = (MethodDoc) methods.get(currentMethodIndex); if (method.inlineTags().length == 0) { DocFinder.Output docs = DocFinder.search( new DocFinder.Input(method)); method = docs.inlineTags != null && docs.inlineTags.length > 0 ? (MethodDoc) docs.holder : method; } //NOTE: When we fix the bug where ClassDoc.interfaceTypes() does // not pass all implemented interfaces, holder will be the // interface type. For now, it is really the erasure. writer.addComments(method.containingClass(), method, methodDocTree); } }
/** * Finds a methods definition on any ancestor, be it interface or class. * * @param methodDoc The element to get the inherited member of * @return null if there is no ancestor. */ private static MethodDoc getAncestor(MethodDoc methodDoc) { // only provides parent class overrides, but does not include interfaces if (methodDoc.overriddenMethod() != null) { return methodDoc.overriddenMethod(); } // search for method on interfaces by looping through. I arbitrarily decided that // the first match wins in case there are multiple. One could consider joining the // various documentations... for (ClassDoc intf : methodDoc.containingClass().interfaces()) { final MethodDoc intfMethod = findInterfaceMethod(intf, methodDoc); if (intfMethod != null) { return intfMethod; } } return null; }
/** * 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()); } } }
/** * Loads a Method object from the JavaDoc description of that method * * @param methodDoc the method in javadoc * @return the method if it can be loaded */ public static Option<Method> loadMethod(MethodDoc methodDoc) { ClassDoc classDoc = methodDoc.containingClass(); Option<Method> method = none(); Option<Class<?>[]> parameters = loadParameterClasses(methodDoc); Option<Class<?>> clz = loadClass(classDoc.qualifiedName()); if (clz.isDefined() && parameters.isDefined()) { method = matchMethod(methodDoc.name(), clz.get(), parameters.get()); } if (method.isEmpty()) { log.error(String.format("Unable to load methodDoc %s", methodDoc.qualifiedName())); } return method; }
/** * Add method information. * * @param method the method to be documented * @param dl the content tree to which the method information will be added */ private void addMethodInfo(MethodDoc method, Content dl) { ClassDoc[] intfacs = method.containingClass().interfaces(); MethodDoc overriddenMethod = method.overriddenMethod(); // Check whether there is any implementation or overridden info to be // printed. If no overridden or implementation info needs to be // printed, do not print this section. if ((intfacs.length > 0 && new ImplementedMethods(method, this.configuration).build().length > 0) || overriddenMethod != null) { MethodWriterImpl.addImplementsInfo(this, method, dl); if (overriddenMethod != null) { MethodWriterImpl.addOverridden(this, method.overriddenType(), overriddenMethod, dl); } } }
public void writeMemberTags(MethodDoc member) { TagletOutputImpl output = new TagletOutputImpl(""); TagletManager tagletManager = ConfigurationImpl.getInstance().tagletManager; TagletWriter.genTagOuput(tagletManager, member, tagletManager.getSerializedFormTags(), writer.getTagletWriterInstance(false), output); String outputString = output.toString().trim(); if (!outputString.isEmpty()) { writer.printMemberDetailsListStartTag(); writer.dd(); writer.dl(); print(outputString); writer.dlEnd(); writer.ddEnd(); } MethodDoc method = member; if (method.name().compareTo("writeExternal") == 0 && method.tags("serialData").length == 0) { serialWarning(member.position(), "doclet.MissingSerialDataTag", method.containingClass().qualifiedName(), method.name()); } }
/** * Add the tag information for this member. * * @param member the method to document. * @param methodsContentTree the tree to which the member tags info will be added */ public void addMemberTags(MethodDoc member, Content methodsContentTree) { Content tagContent = new ContentBuilder(); TagletManager tagletManager = configuration.tagletManager; TagletWriter.genTagOuput(tagletManager, member, tagletManager.getSerializedFormTaglets(), writer.getTagletWriterInstance(false), tagContent); Content dlTags = new HtmlTree(HtmlTag.DL); dlTags.addContent(tagContent); methodsContentTree.addContent(dlTags); // TODO: what if empty? MethodDoc method = member; if (method.name().compareTo("writeExternal") == 0 && method.tags("serialData").length == 0) { serialWarning(member.position(), "doclet.MissingSerialDataTag", method.containingClass().qualifiedName(), method.name()); } } }
private void printMethodInfo( MethodDoc method ) { ClassDoc[] intfacs = method.containingClass().interfaces(); MethodDoc overriddenMethod = method.overriddenMethod(); // Check whether there is any implementation or overridden info to be // printed. If no overridden or implementation info needs to be // printed, do not print this section. if( (intfacs.length > 0 && new ImplementedMethods( method, this.configuration ).build().length > 0) || overriddenMethod != null ) { printMemberDetailsListStartTag(); dd(); printTagsInfoHeader(); MethodWriterImpl.printImplementsInfo( this, method ); if( overriddenMethod != null ) { MethodWriterImpl.printOverridden( this, method.overriddenType(), overriddenMethod ); } printTagsInfoFooter(); ddEnd(); } }
/** * {@inheritDoc} */ public void addComments(MethodDoc property, Content propertyDocTree) { ClassDoc holder = property.containingClass(); if (property.inlineTags().length > 0) { if (holder.equals(classdoc) || (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) { writer.addInlineComment(property, propertyDocTree); } else { Content link = writer.getDocLink(LinkInfoImpl.Kind.PROPERTY_DOC_COPY, holder, property, holder.isIncluded() ? holder.typeName() : holder.qualifiedTypeName(), false); Content codeLink = HtmlTree.CODE(link); Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel, holder.isClass()? writer.descfrmClassLabel : writer.descfrmInterfaceLabel); descfrmLabel.addContent(writer.getSpace()); descfrmLabel.addContent(codeLink); propertyDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel)); writer.addInlineComment(property, propertyDocTree); } } }