/** * This creates an AnnotationParser for a method/field * * @param element The method/field javadoc item * @param options The doclet options */ public AnnotationParser(ProgramElementDoc element, DocletOptions options) { this.annotations = element.annotations(); this.options = options; }
/** * @return The {@link PackageDoc} containing the given {@code doc}, or {@code null} iff {@code doc} is a * {@link RootDoc} */ @Nullable public static PackageDoc packageScope(Doc doc) { return ( doc instanceof PackageDoc ? (PackageDoc) doc : doc instanceof ProgramElementDoc ? ((ProgramElementDoc) doc).containingPackage() : null ); }
/** * Return true if the given Doc is deprecated. * * @param doc the Doc to check. * @return true if the given Doc is deprecated. */ public static boolean isDeprecated(ProgramElementDoc doc) { if (doc.tags("deprecated").length > 0) { return true; } AnnotationDesc[] annotationDescList = doc.annotations(); for (int i = 0; i < annotationDescList.length; i++) { if (annotationDescList[i].annotationType().qualifiedName().equals( java.lang.Deprecated.class.getName())){ return true; } } return false; } }
public static Visibility get(ProgramElementDoc doc) { if (doc.isPrivate()) return PRIVATE; else if (doc.isPackagePrivate()) return PACKAGE; else if (doc.isProtected()) return PROTECTED; else return PUBLIC; } }
/** * Returns string representation of scope * * @param doc * @return */ protected String parseScope(ProgramElementDoc doc) { if (doc.isPrivate()) { return "private"; } else if (doc.isProtected()) { return "protected"; } else if (doc.isPublic()) { return "public"; } return ""; } }
/** * Print the visibility adornment of element e prefixed by * any stereotypes */ private String visibility(Options opt, ProgramElementDoc e) { if (!opt.showVisibility) return " "; if (e.isPrivate()) return "- "; else if (e.isPublic()) return "+ "; else if (e.isProtected()) return "# "; else if (e.isPackagePrivate()) return "~ "; else return " "; }
ClassDoc classDoc = (referenceDoc.isClass() || referenceDoc.isInterface()) ? (ClassDoc) referenceDoc : referenceDoc.containingClass(); if (referenceDoc.isField()) { if (referenceDoc.isFinal() && !classDoc.isInterface()) { pw.print("P:"); } else { pw.print("F:"); } else if (referenceDoc.isConstructor() || referenceDoc.isMethod()) { pw.print("M:"); } else { if (referenceDoc.isField()) { if (classDoc.isInterface()) { pw.print(".__Fields."); pw.print(referenceDoc.name()); } else if (referenceDoc.isConstructor()) { pw.print(".#ctor"); printParameters(pw, (ConstructorDoc) referenceDoc); } else if (referenceDoc.isMethod()){ pw.print("."); pw.print(referenceDoc.name()); printParameters(pw, (MethodDoc) referenceDoc);
private void printModifier(ProgramElementDoc member) { if (member.isProtected()) { print("protected "); } else if (member.isPrivate()) { print("private "); } else if (!member.isPublic()) { // Package private writer.printText("doclet.Package_private"); print(" "); } if (member.isMethod() && ((MethodDoc)member).isAbstract()) { print("abstract "); } if (member.isStatic()) { print("static"); } }
private boolean isTreatedAsPrivate(ProgramElementDoc pgmelem) { if (!configuration.javafx) { return false; } Tag[] aspTags = pgmelem.tags("@treatAsPrivate"); boolean result = (aspTags != null) && (aspTags.length > 0); return result; }
protected String name(ProgramElementDoc member) { return member.name(); }
/** * Return true if the given <code>ProgramElement</code> is inherited * by the class that is being documented. * * @param ped The <code>ProgramElement</code> being checked. * return true if the <code>ProgramElement</code> is being inherited and * false otherwise. */ protected boolean isInherited(ProgramElementDoc ped){ if(ped.isPrivate() || (ped.isPackagePrivate() && ! ped.containingPackage().equals(classdoc.containingPackage()))){ return false; } return true; }
/** Return true if c has a @hidden tag associated with it */ private boolean hidden(ProgramElementDoc c) { Tag tags[] = c.tags("hidden"); if (tags.length > 0) return true; tags = c.tags("view"); if (tags.length > 0) return true; Options opt; if(c instanceof ClassDoc) opt = optionProvider.getOptionsFor((ClassDoc) c); else opt = optionProvider.getOptionsFor(c.containingClass()); return opt.matchesHideExpression(c.toString()); }
/** Return true if c has a @hidden tag associated with it */ private boolean hidden(ProgramElementDoc c) { if (c.tags("hidden").length > 0 || c.tags("view").length > 0) return true; Options opt = optionProvider.getOptionsFor(c instanceof ClassDoc ? (ClassDoc) c : c.containingClass()); return opt.matchesHideExpression(c.toString()) // || (opt.hidePrivateInner && c instanceof ClassDoc && c.isPrivate() && ((ClassDoc) c).containingClass() != null); }
/** * Reconstitute the class name from the given class JavaDoc object. * * @param doc the Javadoc model for the given class. * @return The (string) class name of the given class. */ protected static String getClassName(ProgramElementDoc doc, boolean binaryName) { PackageDoc containingPackage = doc.containingPackage(); String className = doc.name(); if (binaryName) { className = className.replaceAll("\\.", "\\$"); } return containingPackage.name().length() > 0 ? String.format("%s.%s", containingPackage.name(), className) : String.format("%s", className); }
/** * Is given doc item visible in given classdoc in terms fo inheritance? * The given doc item is visible in the given classdoc if it is public * or protected and if it is package-private if it's containing class * is in the same package as the given classdoc. */ private boolean memberIsVisible(ProgramElementDoc pgmdoc) { if (pgmdoc.containingClass().equals(classdoc)) { //Member is in class that we are finding visible members for. //Of course it is visible. return true; } else if (pgmdoc.isPrivate()) { //Member is in super class or implemented interface. //Private, so not inherited. return false; } else if (pgmdoc.isPackagePrivate()) { //Member is package private. Only return true if its class is in //same package. return pgmdoc.containingClass().containingPackage().equals( classdoc.containingPackage()); } else { //Public members are always inherited. return true; } }
/** * Construct a new ConstructorWriterImpl. * * @param writer The writer for the class that the constructors belong to. * @param classDoc the class being documented. */ public ConstructorWriterImpl(SubWriterHolderWriter writer, ClassDoc classDoc) { super(writer, classDoc); VisibleMemberMap visibleMemberMap = new VisibleMemberMap(classDoc, VisibleMemberMap.CONSTRUCTORS, configuration); List<ProgramElementDoc> constructors = new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc)); for (int i = 0; i < constructors.size(); i++) { if ((constructors.get(i)).isProtected() || (constructors.get(i)).isPrivate()) { setFoundNonPubConstructor(true); } } }
SeeTagImpl(DocImpl holder, String name, String text) { super(holder, name, text); parseSeeString(); if (where != null) { ClassDocImpl container = null; if (holder instanceof MemberDoc) { container = (ClassDocImpl)((ProgramElementDoc)holder).containingClass(); } else if (holder instanceof ClassDoc) { container = (ClassDocImpl)holder; } findReferenced(container); if (showRef) showRef(); } }
/** * This gets the first sentence tags of a method or its overridden ancestor method * * @param methodDoc The method * @return The first sentence tag or null if there is none */ static String getInheritableCommentText(ProgramElementDoc methodDoc, DocletOptions options) { String result = null; while (result == null && methodDoc != null) { final Tag[] tags = methodDoc.tags(); String versionedCommentText = options.getDialect() .flatMap(dialect -> getVersionedOperationCommentText(tags, dialect)) .orElse(""); String commentText = methodDoc.commentText() + " " + versionedCommentText; if (!commentText.isEmpty()) { result = commentText; } methodDoc = getAncestor(methodDoc); } return result; }
if (programElementDoc.tags("@exclude").length > 0) { return; printComment(pw, programElementDoc, programElementDoc.inlineTags());
HtmlTree tr = HtmlTree.TR(tdSummaryType); tr.addContent(tdSummary); if (member instanceof MethodDoc && !member.isAnnotationTypeElement()) { int methodType = (member.isStatic()) ? MethodTypes.STATIC.value() : MethodTypes.INSTANCE.value(); if (member.containingClass().isInterface()) { methodType = (((MethodDoc) member).isAbstract()) ? methodType | MethodTypes.ABSTRACT.value()