< prev index next >
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
Print this page
*** 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
--- 1713,1802 ----
* @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
*** 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();
--- 1806,1815 ----
*** 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 = "";
--- 1848,1858 ----
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 = "";
*** 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;
--- 1863,1877 ----
}
}
// 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;
*** 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("(");
--- 1882,1897 ----
*
* @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("(");
*** 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();
--- 1904,1914 ----
} 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();
*** 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;
--- 2017,2027 ----
}
}.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;
< prev index next >