< prev index next >

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java

Print this page

        

*** 25,35 **** package jdk.javadoc.internal.doclets.formats.html; import java.util.ArrayList; import java.util.Collections; - import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import java.util.Locale; import java.util.Map; --- 25,34 ----
*** 196,213 **** protected String winTitle; protected Script mainBodyScript; /** - * A table of the anchors used for at-index and related tags, - * so that they can be made unique by appending a suitable suffix. - * (Ideally, javadoc should be tracking all id's generated in a file - * to avoid generating duplicates.) - */ - Map<String, Integer> indexAnchorTable = new HashMap<>(); - - /** * Constructor to construct the HtmlStandardWriter object. * * @param configuration the configuration for this doclet * @param path the file to be generated. */ --- 195,204 ----
*** 1722,1811 **** * @param packageElement the package to write annotations for. * @param htmltree the documentation tree to which the annotation info will be * added */ public void addAnnotationInfo(PackageElement packageElement, Content htmltree) { ! addAnnotationInfo(packageElement.getAnnotationMirrors(), htmltree); } /* * this is a hack to delay dealing with Annotations in the writers, the assumption * is that all necessary checks have been made to get here. */ public void addReceiverAnnotationInfo(ExecutableElement method, TypeMirror rcvrTypeMirror, List<? extends AnnotationMirror> annotationMirrors, Content htmltree) { TypeMirror rcvrType = method.getReceiverType(); List<? extends AnnotationMirror> annotationMirrors1 = rcvrType.getAnnotationMirrors(); ! htmltree.add(getAnnotationInfo(annotationMirrors1, false)); } /** * Adds the annotation types for the given element. * * @param element the package to write annotations for * @param htmltree the content tree to which the annotation types will be added */ public void addAnnotationInfo(Element element, Content htmltree) { ! addAnnotationInfo(element.getAnnotationMirrors(), htmltree); } /** * Add the annotatation types for the given element and parameter. * * @param param the parameter to write annotations for. * @param tree the content tree to which the annotation types will be added */ ! public boolean addAnnotationInfo(VariableElement param, Content tree) { ! Content annotaionInfo = getAnnotationInfo(param.getAnnotationMirrors(), false); ! if (annotaionInfo.isEmpty()) { ! return false; ! } ! tree.add(annotaionInfo); ! return true; } /** * Adds the annotatation types for the given Element. * * @param descList a list of annotation mirrors. * @param htmltree the documentation tree to which the annotation info will be * added */ ! private void addAnnotationInfo(List<? extends AnnotationMirror> descList, Content htmltree) { ! htmltree.add(getAnnotationInfo(descList, true)); } /** ! * Return a content tree containing the annotation types for the given element. * * @param descList a list of annotation mirrors. ! * @return the documentation tree containing the annotation info. */ ! Content getAnnotationInfo(List<? extends AnnotationMirror> descList, boolean lineBreak) { ! List<Content> annotations = getAnnotations(descList, lineBreak); String sep = ""; ! ContentBuilder builder = new ContentBuilder(); for (Content annotation: annotations) { ! builder.add(sep); ! builder.add(annotation); if (!lineBreak) { sep = " "; } } ! return builder; } /** * Return the string representations of the annotation types for * the given doc. * * @param descList a list of annotation mirrors. * @param linkBreak if true, add new line between each member value. * @return a list of strings representing the annotations being * documented. */ ! public List<Content> getAnnotations(List<? extends AnnotationMirror> descList, boolean linkBreak) { List<Content> results = new ArrayList<>(); ContentBuilder annotation; for (AnnotationMirror aDesc : descList) { TypeElement annotationElement = (TypeElement)aDesc.getAnnotationType().asElement(); // If an annotation is not documented, do not add it to the list. If --- 1713,1847 ---- * @param packageElement the package to write annotations for. * @param htmltree the documentation tree to which the annotation info will be * added */ public void addAnnotationInfo(PackageElement packageElement, Content htmltree) { ! addAnnotationInfo(packageElement, packageElement.getAnnotationMirrors(), htmltree); ! } ! ! /** ! * Add the annotation types of the executable receiver. ! * ! * @param method the executable to write the receiver annotations for. ! * @param descList a list of annotation mirrors. ! * @param htmltree the documentation tree to which the annotation info will be ! * added ! */ ! public void addReceiverAnnotationInfo(ExecutableElement method, List<AnnotationMirror> descList, ! Content htmltree) { ! addAnnotationInfo(0, method, descList, false, htmltree); } /* * this is a hack to delay dealing with Annotations in the writers, the assumption * is that all necessary checks have been made to get here. */ public void addReceiverAnnotationInfo(ExecutableElement method, TypeMirror rcvrTypeMirror, List<? extends AnnotationMirror> annotationMirrors, Content htmltree) { TypeMirror rcvrType = method.getReceiverType(); List<? extends AnnotationMirror> annotationMirrors1 = rcvrType.getAnnotationMirrors(); ! addAnnotationInfo(0, method, annotationMirrors1, false, htmltree); } /** * Adds the annotation types for the given element. * * @param element the package to write annotations for * @param htmltree the content tree to which the annotation types will be added */ public void addAnnotationInfo(Element element, Content htmltree) { ! addAnnotationInfo(element, element.getAnnotationMirrors(), htmltree); } /** * Add the annotatation types for the given element and parameter. * + * @param indent the number of spaces to indent the parameters. + * @param element the element to write annotations for. * @param param the parameter to write annotations for. * @param tree the content tree to which the annotation types will be added */ ! public boolean addAnnotationInfo(int indent, Element element, VariableElement param, ! Content tree) { ! return addAnnotationInfo(indent, element, param.getAnnotationMirrors(), false, tree); } /** * Adds the annotatation types for the given Element. * + * @param element the element to write annotations for. * @param descList a list of annotation mirrors. * @param htmltree the documentation tree to which the annotation info will be * added */ ! private void addAnnotationInfo(Element element, List<? extends AnnotationMirror> descList, ! Content htmltree) { ! addAnnotationInfo(0, element, descList, true, htmltree); } /** ! * Adds the annotation types for the given element. * + * @param indent the number of extra spaces to indent the annotations. + * @param element the element to write annotations for. * @param descList a list of annotation mirrors. ! * @param htmltree the documentation tree to which the annotation info will be ! * added */ ! private boolean addAnnotationInfo(int indent, Element element, ! List<? extends AnnotationMirror> descList, boolean lineBreak, Content htmltree) { ! List<Content> annotations = getAnnotations(indent, descList, lineBreak); String sep = ""; ! if (annotations.isEmpty()) { ! return false; ! } for (Content annotation: annotations) { ! htmltree.add(sep); ! htmltree.add(annotation); if (!lineBreak) { sep = " "; } } ! return true; ! } ! ! /** ! * Return the string representations of the annotation types for ! * the given doc. ! * ! * @param indent the number of extra spaces to indent the annotations. ! * @param descList a list of annotation mirrors. ! * @param linkBreak if true, add new line between each member value. ! * @return a list of strings representing the annotations being ! * documented. ! */ ! private List<Content> getAnnotations(int indent, List<? extends AnnotationMirror> descList, boolean linkBreak) { ! return getAnnotations(indent, descList, linkBreak, true); ! } ! ! private List<Content> getAnnotations(int indent, AnnotationMirror amirror, boolean linkBreak) { ! List<AnnotationMirror> descList = new ArrayList<>(); ! descList.add(amirror); ! return getAnnotations(indent, descList, linkBreak, true); } /** * Return the string representations of the annotation types for * the given doc. * + * A {@code null} {@code elementType} indicates that all the + * annotations should be returned without any filtering. + * + * @param indent the number of extra spaces to indent the annotations. * @param descList a list of annotation mirrors. * @param linkBreak if true, add new line between each member value. + * @param isJava5DeclarationLocation * @return a list of strings representing the annotations being * documented. */ ! public List<Content> getAnnotations(int indent, List<? extends AnnotationMirror> descList, ! boolean linkBreak, boolean isJava5DeclarationLocation) { List<Content> results = new ArrayList<>(); ContentBuilder annotation; for (AnnotationMirror aDesc : descList) { TypeElement annotationElement = (TypeElement)aDesc.getAnnotationType().asElement(); // If an annotation is not documented, do not add it to the list. If
*** 1815,1824 **** --- 1851,1865 ---- // but its container is documented, it will be added to the list. if (!utils.isDocumentedAnnotation(annotationElement) && (!isAnnotationDocumented && !isContainerDocumented)) { continue; } + /* TODO: check logic here to correctly handle declaration + * and type annotations. + if (utils.isDeclarationAnnotation(annotationElement, isJava5DeclarationLocation)) { + continue; + }*/ annotation = new ContentBuilder(); isAnnotationDocumented = false; LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.Kind.ANNOTATION, annotationElement); Map<? extends ExecutableElement, ? extends AnnotationValue> pairs = aDesc.getElementValues();
*** 1857,1867 **** List<AnnotationValue> annotationTypeValues = new ArrayList<>(); for (AnnotationValue a : pairs.values()) { new SimpleAnnotationValueVisitor9<Void, List<AnnotationValue>>() { @Override public Void visitArray(List<? extends AnnotationValue> vals, List<AnnotationValue> annotationTypeValues) { ! annotationTypeValues.addAll(vals); return null; } }.visit(a, annotationTypeValues); } String sep = ""; --- 1898,1910 ---- List<AnnotationValue> annotationTypeValues = new ArrayList<>(); for (AnnotationValue a : pairs.values()) { new SimpleAnnotationValueVisitor9<Void, List<AnnotationValue>>() { @Override public Void visitArray(List<? extends AnnotationValue> vals, List<AnnotationValue> annotationTypeValues) { ! for (AnnotationValue av : vals) { ! annotationTypeValues.add(av); ! } return null; } }.visit(a, annotationTypeValues); } String sep = "";
*** 1872,1886 **** } } // If the container has 1 or more value defined and if the // repeatable type annotation is not documented, print the container. else { ! addAnnotations(annotationElement, linkInfo, annotation, pairs, false); } } else { ! addAnnotations(annotationElement, linkInfo, annotation, pairs, linkBreak); } annotation.add(linkBreak ? DocletConstants.NL : ""); results.add(annotation); } return results; --- 1915,1931 ---- } } // If the container has 1 or more value defined and if the // repeatable type annotation is not documented, print the container. else { ! addAnnotations(annotationElement, linkInfo, annotation, pairs, ! indent, false); } } else { ! addAnnotations(annotationElement, linkInfo, annotation, pairs, ! indent, linkBreak); } annotation.add(linkBreak ? DocletConstants.NL : ""); results.add(annotation); } return results;
*** 1891,1906 **** * * @param annotationDoc the annotation being documented * @param linkInfo the information about the link * @param annotation the annotation string to which the annotation will be added * @param map annotation type element to annotation value pairs * @param linkBreak if true, add new line between each member value */ private void addAnnotations(TypeElement annotationDoc, LinkInfoImpl linkInfo, ContentBuilder annotation, Map<? extends ExecutableElement, ? extends AnnotationValue> map, ! boolean linkBreak) { linkInfo.label = new StringContent("@"); linkInfo.label.add(annotationDoc.getSimpleName()); annotation.add(getLink(linkInfo)); if (!map.isEmpty()) { annotation.add("("); --- 1936,1952 ---- * * @param annotationDoc the annotation being documented * @param linkInfo the information about the link * @param annotation the annotation string to which the annotation will be added * @param map annotation type element to annotation value pairs + * @param indent the number of extra spaces to indent the annotations. * @param linkBreak if true, add new line between each member value */ private void addAnnotations(TypeElement annotationDoc, LinkInfoImpl linkInfo, ContentBuilder annotation, Map<? extends ExecutableElement, ? extends AnnotationValue> map, ! int indent, boolean linkBreak) { linkInfo.label = new StringContent("@"); linkInfo.label.add(annotationDoc.getSimpleName()); annotation.add(getLink(linkInfo)); if (!map.isEmpty()) { annotation.add("(");
*** 1913,1923 **** } else { annotation.add(","); if (linkBreak) { annotation.add(DocletConstants.NL); int spaces = annotationDoc.getSimpleName().length() + 2; ! for (int k = 0; k < (spaces); k++) { annotation.add(" "); } } } String simpleName = element.getSimpleName().toString(); --- 1959,1969 ---- } else { annotation.add(","); if (linkBreak) { annotation.add(DocletConstants.NL); int spaces = annotationDoc.getSimpleName().length() + 2; ! for (int k = 0; k < (spaces + indent); k++) { annotation.add(" "); } } } String simpleName = element.getSimpleName().toString();
*** 2026,2036 **** } }.visit(t); } @Override public Content visitAnnotation(AnnotationMirror a, Void p) { ! List<Content> list = getAnnotations(List.of(a), false); ContentBuilder buf = new ContentBuilder(); for (Content c : list) { buf.add(c); } return buf; --- 2072,2082 ---- } }.visit(t); } @Override public Content visitAnnotation(AnnotationMirror a, Void p) { ! List<Content> list = getAnnotations(0, a, false); ContentBuilder buf = new ContentBuilder(); for (Content c : list) { buf.add(c); } return buf;
< prev index next >