diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java index 472f54955bac8..33cd75c4aefe3 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java @@ -32,11 +32,9 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; -import javax.lang.model.type.ArrayType; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.ExecutableType; import javax.lang.model.type.TypeMirror; -import javax.lang.model.type.TypeVariable; import javax.lang.model.util.SimpleTypeVisitor14; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; @@ -97,7 +95,8 @@ protected Content getSummaryLink(Element member) { } content.add(signature); - return writer.getDocLink(MEMBER_DEPRECATED_PREVIEW, utils.getEnclosingTypeElement(member), member, content); + return writer.getDocLink(MEMBER_DEPRECATED_PREVIEW, utils.getEnclosingTypeElement(member), + member, content, false); } /** @@ -113,7 +112,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement te, Element Content tdSummary) { ExecutableElement ee = (ExecutableElement)member; Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink, - writer.getDocLink(context, te, ee, name(ee), false)); + writer.getDocLink(context, te, ee, name(ee))); Content code = HtmlTree.CODE(memberLink); addParameters(ee, code); tdSummary.add(code); @@ -128,7 +127,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement te, Element */ @Override protected void addInheritedSummaryLink(TypeElement te, Element member, Content linksTree) { - linksTree.add(writer.getDocLink(MEMBER, te, member, name(member), false)); + linksTree.add(writer.getDocLink(MEMBER, te, member, name(member))); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java index 7f19b0a50bd53..4e867a1325ca4 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java @@ -187,7 +187,7 @@ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedT protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element member, Content tdSummary) { Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink, - writer.getDocLink(context, member, name(member), false)); + writer.getDocLink(context, member, name(member))); Content code = HtmlTree.CODE(memberLink); tdSummary.add(code); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java index 43128f419d963..1e708788767f7 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -237,7 +237,7 @@ private Content getTypeColumn(VariableElement member) { */ private Content getNameColumn(VariableElement member) { Content nameContent = getDocLink(LinkInfoImpl.Kind.CONSTANT_SUMMARY, - member, member.getSimpleName(), false); + member, member.getSimpleName()); return HtmlTree.CODE(nameContent); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java index 1cdd4ea29bce5..b4fdc3f7c7c1d 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java @@ -160,7 +160,7 @@ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedT protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element member, Content tdSummary) { Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink, - writer.getDocLink(context, member, name(member), false)); + writer.getDocLink(context, member, name(member))); Content code = HtmlTree.CODE(memberLink); tdSummary.add(code); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java index 8fe174d5340cb..f97a12ae6557f 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java @@ -161,7 +161,7 @@ protected Table createSummaryTable() { @Override public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) { Content classLink = writer.getPreQualifiedClassLink( - LinkInfoImpl.Kind.MEMBER, typeElement, false); + LinkInfoImpl.Kind.MEMBER, typeElement); Content label; if (options.summarizeOverriddenMethods()) { label = new StringContent(utils.isClass(typeElement) @@ -184,7 +184,7 @@ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedT protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element member, Content tdSummary) { Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink, - writer.getDocLink(context, typeElement , member, name(member), false)); + writer.getDocLink(context, typeElement , member, name(member))); Content code = HtmlTree.CODE(memberLink); tdSummary.add(code); } @@ -192,8 +192,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement @Override protected void addInheritedSummaryLink(TypeElement typeElement, Element member, Content linksTree) { linksTree.add( - writer.getDocLink(LinkInfoImpl.Kind.MEMBER, typeElement, member, - name(member), false)); + writer.getDocLink(LinkInfoImpl.Kind.MEMBER, typeElement, member, name(member))); } @Override diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java index 85d4739b87ab5..f548d1cce1398 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java @@ -763,7 +763,7 @@ public Content getLink(LinkInfoImpl linkInfo) { */ public Content getTypeParameterLinks(LinkInfoImpl linkInfo) { LinkFactoryImpl factory = new LinkFactoryImpl(this); - return factory.getTypeParameterLinks(linkInfo, false); + return factory.getTypeParameterLinks(linkInfo); } /************************************************************* @@ -853,18 +853,16 @@ public void addPreQualifiedClassLink(LinkInfoImpl.Kind context, TypeElement type * link label. * * @param typeElement the class to link to. - * @param isStrong true if the link should be strong. * @return the link with the package portion of the label in plain text. */ - public Content getPreQualifiedClassLink(LinkInfoImpl.Kind context, - TypeElement typeElement, boolean isStrong) { + public Content getPreQualifiedClassLink(LinkInfoImpl.Kind context, TypeElement typeElement) { ContentBuilder classlink = new ContentBuilder(); PackageElement pkg = utils.containingPackage(typeElement); if (pkg != null && ! configuration.shouldExcludeQualifier(pkg.getSimpleName().toString())) { classlink.add(getEnclosingPackageName(typeElement)); } classlink.add(getLink(new LinkInfoImpl(configuration, - context, typeElement).label(utils.getSimpleName(typeElement)).strong(isStrong))); + context, typeElement).label(utils.getSimpleName(typeElement)))); return classlink; } @@ -934,65 +932,55 @@ public void addPreQualifiedStrongClassLink(LinkInfoImpl.Kind context, TypeElemen */ public Content getDocLink(LinkInfoImpl.Kind context, Element element, CharSequence label) { return getDocLink(context, utils.getEnclosingTypeElement(element), element, - new StringContent(label)); + new StringContent(label), false); } /** * Return the link for the given member. * * @param context the id of the context where the link will be printed. + * @param typeElement the typeElement that we should link to. This is not + * not necessarily the type containing element since we may be + * inheriting comments. * @param element the member being linked to. * @param label the label for the link. - * @param strong true if the link should be strong. * @return the link for the given member. */ - public Content getDocLink(LinkInfoImpl.Kind context, Element element, CharSequence label, - boolean strong) { - return getDocLink(context, utils.getEnclosingTypeElement(element), element, label, strong); + public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element, + CharSequence label) { + return getDocLink(context, typeElement, element, label, false); } /** * Return the link for the given member. * * @param context the id of the context where the link will be printed. - * @param typeElement the typeElement that we should link to. This is not - necessarily equal to element.containingClass(). We may be - inheriting comments. + * @param typeElement the typeElement that we should link to. This is not + * not necessarily the type containing element since we may be + * inheriting comments. * @param element the member being linked to. * @param label the label for the link. - * @param strong true if the link should be strong. * @return the link for the given member. */ public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element, - CharSequence label, boolean strong) { - return getDocLink(context, typeElement, element, label, strong, false); - } - - public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element, - Content label, boolean strong) { - return getDocLink(context, typeElement, element, label, strong, false); + CharSequence label, boolean isProperty) { + return getDocLink(context, typeElement, element, new StringContent(label), isProperty); } /** * Return the link for the given member. * * @param context the id of the context where the link will be printed. - * @param typeElement the typeElement that we should link to. This is not - necessarily equal to element.containingClass(). We may be - inheriting comments. + * @param typeElement the typeElement that we should link to. This is not + * not necessarily the type containing element since we may be + * inheriting comments. * @param element the member being linked to. * @param label the label for the link. - * @param strong true if the link should be strong. * @param isProperty true if the element parameter is a JavaFX property. * @return the link for the given member. */ public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element, - CharSequence label, boolean strong, boolean isProperty) { - return getDocLink(context, typeElement, element, new StringContent(label), strong, isProperty); - } - - public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element, - Content label, boolean strong, boolean isProperty) { + Content label, boolean isProperty) { if (!utils.isLinkable(typeElement, element)) { return label; } @@ -1003,52 +991,19 @@ public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, El return getLink(new LinkInfoImpl(configuration, context, typeElement) .label(label) .where(id.name()) - .targetMember(element) - .strong(strong)); + .targetMember(element)); } if (utils.isVariableElement(element) || utils.isTypeElement(element)) { return getLink(new LinkInfoImpl(configuration, context, typeElement) .label(label) .where(element.getSimpleName().toString()) - .targetMember(element) - .strong(strong)); + .targetMember(element)); } return label; } - /** - * Return the link for the given member. - * - * @param context the id of the context where the link will be added - * @param typeElement the typeElement that we should link to. This is not - necessarily equal to element.containingClass(). We may be - inheriting comments - * @param element the member being linked to - * @param label the label for the link - * @return the link for the given member - */ - public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element, - Content label) { - if (!(utils.isIncluded(element) || utils.isLinkable(typeElement))) { - return label; - } else if (utils.isExecutableElement(element)) { - ExecutableElement emd = (ExecutableElement) element; - return getLink(new LinkInfoImpl(configuration, context, typeElement) - .label(label) - .where(htmlIds.forMember(emd).name()) - .targetMember(element)); - } else if (utils.isVariableElement(element) || utils.isTypeElement(element)) { - return getLink(new LinkInfoImpl(configuration, context, typeElement) - .label(label) - .where(element.getSimpleName().toString()) - .targetMember(element)); - } else { - return label; - } - } - public Content seeTagToContent(Element element, DocTree see) { Kind kind = see.getKind(); if (!(kind == LINK || kind == SEE || kind == LINK_PLAIN)) { @@ -1900,8 +1855,7 @@ private void addAnnotations(TypeElement annotationDoc, LinkInfoImpl linkInfo, } String simpleName = element.getSimpleName().toString(); if (multipleValues || !"value".equals(simpleName)) { // Omit "value=" where unnecessary - annotation.add(getDocLink(LinkInfoImpl.Kind.ANNOTATION, - element, simpleName, false)); + annotation.add(getDocLink(LinkInfoImpl.Kind.ANNOTATION, element, simpleName)); annotation.add("="); } AnnotationValue annotationValue = map.get(element); @@ -2015,8 +1969,7 @@ public Content visitAnnotation(AnnotationMirror a, Void p) { } @Override public Content visitEnumConstant(VariableElement c, Void p) { - return getDocLink(LinkInfoImpl.Kind.ANNOTATION, - c, c.getSimpleName(), false); + return getDocLink(LinkInfoImpl.Kind.ANNOTATION, c, c.getSimpleName()); } @Override public Content visitArray(List vals, Void p) { diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexWriter.java index a6f1cb8c09ac2..35103b381155c 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -226,7 +226,8 @@ protected void addElementDescription(IndexItem item, Content dlTree) { case ENUM_CONSTANT: TypeElement containingType = item.getContainingTypeElement(); dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.memberNameLink, - getDocLink(LinkInfoImpl.Kind.INDEX, containingType, element, new StringContent(label)))); + getDocLink(LinkInfoImpl.Kind.INDEX, containingType, element, + new StringContent(label), false))); dt.add(" - "); addMemberDesc(element, containingType, dt); break; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java index e78e340d9b7cf..59cc14ed05bc2 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java @@ -39,7 +39,6 @@ import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.Entity; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; -import jdk.javadoc.internal.doclets.formats.html.markup.TagName; import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.Resources; @@ -78,7 +77,6 @@ protected Content newContent() { protected Content getClassLink(LinkInfo linkInfo) { BaseConfiguration configuration = m_writer.configuration; LinkInfoImpl classLinkInfo = (LinkInfoImpl) linkInfo; - boolean noLabel = linkInfo.label == null || linkInfo.label.isEmpty(); TypeElement typeElement = classLinkInfo.typeElement; // Create a tool tip if we are linking to a class or interface. Don't // create one if we are linking to a member. @@ -121,9 +119,6 @@ protected Content getClassLink(LinkInfo linkInfo) { filename.fragment(m_writer.htmlIds.forPreviewSection(target).name()), m_writer.contents.previewMark))); } - if (noLabel && !classLinkInfo.excludeTypeParameterLinks) { - link.add(getTypeParameterLinks(linkInfo)); - } return link; } } @@ -140,9 +135,6 @@ protected Content getClassLink(LinkInfo linkInfo) { m_writer.contents.previewMark, false, false))); } - if (noLabel && !classLinkInfo.excludeTypeParameterLinks) { - link.add(getTypeParameterLinks(linkInfo)); - } return link; } } @@ -151,14 +143,11 @@ protected Content getClassLink(LinkInfo linkInfo) { if (flags.contains(ElementFlag.PREVIEW)) { link.add(HtmlTree.SUP(m_writer.contents.previewMark)); } - if (noLabel && !classLinkInfo.excludeTypeParameterLinks) { - link.add(getTypeParameterLinks(linkInfo)); - } return link; } @Override - protected Content getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel) { + protected Content getTypeParameterLinks(LinkInfo linkInfo) { Content links = newContent(); List vars = new ArrayList<>(); TypeMirror ctype = linkInfo.type != null @@ -176,8 +165,7 @@ protected Content getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel) // Nothing to document. return links; } - if (((linkInfo.includeTypeInClassLinkLabel && isClassLabel) - || (linkInfo.includeTypeAsSepLink && !isClassLabel)) && !vars.isEmpty()) { + if (!vars.isEmpty()) { links.add("<"); boolean many = false; for (TypeMirror t : vars) { @@ -284,11 +272,6 @@ private String getClassToolTip(TypeElement typeElement, boolean isTypeLink) { * @param linkInfo the information about the link. */ private DocPath getPath(LinkInfoImpl linkInfo) { - if (linkInfo.context == LinkInfoImpl.Kind.PACKAGE_FRAME) { - //Not really necessary to do this but we want to be consistent - //with 1.4.2 output. - return docPaths.forName(linkInfo.typeElement); - } return m_writer.pathToRoot.resolve(docPaths.forClass(linkInfo.typeElement)); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkInfoImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkInfoImpl.java index f00087cff65f9..fe512d80c887a 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkInfoImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkInfoImpl.java @@ -108,11 +108,6 @@ public enum Kind { */ TREE, - /** - * Indicate that the link appears in a class list. - */ - PACKAGE_FRAME, - /** * The header in the class documentation. */ @@ -246,7 +241,8 @@ public enum Kind { */ public Element targetMember; - public final Utils utils; + public final Utils utils; + /** * Construct a LinkInfo object. * @@ -362,22 +358,8 @@ public Kind getContext() { * @param c the context id to set. */ public final void setContext(Kind c) { - //NOTE: Put context specific link code here. switch (c) { - case PACKAGE_FRAME: - case IMPLEMENTED_CLASSES: - case SUBCLASSES: - case EXECUTABLE_ELEMENT_COPY: - case PROPERTY_COPY: - case CLASS_USE_HEADER: - includeTypeInClassLinkLabel = false; - break; - case ANNOTATION: - excludeTypeParameterLinks = true; - excludeTypeBounds = true; - break; - case IMPLEMENTED_INTERFACES: case SUPER_INTERFACES: case SUBINTERFACES: @@ -387,8 +369,6 @@ public final void setContext(Kind c) { case PERMITTED_SUBCLASSES: excludeTypeParameterLinks = true; excludeTypeBounds = true; - includeTypeInClassLinkLabel = false; - includeTypeAsSepLink = true; break; case PACKAGE: @@ -397,13 +377,6 @@ public final void setContext(Kind c) { case CLASS_SIGNATURE: case RECEIVER_TYPE: excludeTypeParameterLinks = true; - includeTypeAsSepLink = true; - includeTypeInClassLinkLabel = false; - break; - - case MEMBER_TYPE_PARAMS: - includeTypeAsSepLink = true; - includeTypeInClassLinkLabel = false; break; case RETURN_TYPE: @@ -414,11 +387,6 @@ public final void setContext(Kind c) { break; } context = c; - if (type != null && - utils.isTypeVariable(type) && - utils.isExecutableElement(utils.asTypeElement(type).getEnclosingElement())) { - excludeTypeParameterLinks = true; - } } /** @@ -433,6 +401,33 @@ public boolean isLinkable() { return configuration.utils.isLinkable(typeElement); } + @Override + public boolean includeTypeParameterLinks() { + return switch (context) { + case IMPLEMENTED_INTERFACES, + SUPER_INTERFACES, + SUBINTERFACES, + CLASS_TREE_PARENT, + TREE, + CLASS_SIGNATURE_PARENT_NAME, + PERMITTED_SUBCLASSES, + PACKAGE, + CLASS_USE, + CLASS_HEADER, + CLASS_SIGNATURE, + RECEIVER_TYPE, + MEMBER_TYPE_PARAMS -> true; + + case IMPLEMENTED_CLASSES, + SUBCLASSES, + EXECUTABLE_ELEMENT_COPY, + PROPERTY_COPY, + CLASS_USE_HEADER -> false; + + default -> label == null || label.isEmpty(); + }; + } + @Override public String toString() { return "LinkInfoImpl{" + diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java index 80b0783f4a39c..0baee37c51d0c 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java @@ -154,8 +154,7 @@ public void addComments(TypeMirror holderType, ExecutableElement method, Content holder, method, utils.isIncluded(holder) ? utils.getSimpleName(holder) - : utils.getFullyQualifiedName(holder), - false); + : utils.getFullyQualifiedName(holder)); Content codeLink = HtmlTree.CODE(link); Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel, utils.isClass(holder) @@ -214,7 +213,7 @@ protected Table createSummaryTable() { @Override public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) { Content classLink = writer.getPreQualifiedClassLink( - LinkInfoImpl.Kind.MEMBER, typeElement, false); + LinkInfoImpl.Kind.MEMBER, typeElement); Content label; if (options.summarizeOverriddenMethods()) { label = new StringContent(utils.isClass(typeElement) @@ -328,7 +327,7 @@ protected static void addImplementsInfo(HtmlDocletWriter writer, dl.add(HtmlTree.DT(contents.specifiedByLabel)); Content methlink = writer.getDocLink( LinkInfoImpl.Kind.MEMBER, implementedMeth, - implementedMeth.getSimpleName(), false); + implementedMeth.getSimpleName()); Content codeMethLink = HtmlTree.CODE(methlink); Content dd = HtmlTree.DD(codeMethLink); dd.add(Entity.NO_BREAK_SPACE); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java index 54d1add708d9f..7a8545e7e7fc9 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java @@ -101,8 +101,7 @@ protected Table createSummaryTable() { @Override public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) { - Content classLink = writer.getPreQualifiedClassLink( - LinkInfoImpl.Kind.MEMBER, typeElement, false); + Content classLink = writer.getPreQualifiedClassLink(LinkInfoImpl.Kind.MEMBER, typeElement); Content label; if (options.summarizeOverriddenMethods()) { label = new StringContent(utils.isInterface(typeElement) diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java index 97368b4616a10..81711ce4a6d02 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java @@ -115,8 +115,7 @@ public void addComments(ExecutableElement property, Content propertyDocTree) { writer.getDocLink(LinkInfoImpl.Kind.PROPERTY_COPY, holder, property, utils.isIncluded(holder) - ? holder.getSimpleName() : holder.getQualifiedName(), - false); + ? holder.getSimpleName() : holder.getQualifiedName()); Content codeLink = HtmlTree.CODE(link); Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel, utils.isClass(holder) @@ -168,7 +167,7 @@ protected Table createSummaryTable() { @Override public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) { Content classLink = writer.getPreQualifiedClassLink( - LinkInfoImpl.Kind.MEMBER, typeElement, false); + LinkInfoImpl.Kind.MEMBER, typeElement); Content label; if (options.summarizeOverriddenMethods()) { label = new StringContent(utils.isClass(typeElement) @@ -194,7 +193,6 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement writer.getDocLink(context, typeElement, member, utils.getPropertyLabel(name(member)), - false, true)); Content code = HtmlTree.CODE(memberLink); @@ -205,8 +203,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement protected void addInheritedSummaryLink(TypeElement typeElement, Element member, Content linksTree) { String mname = name(member); Content content = writer.getDocLink(LinkInfoImpl.Kind.MEMBER, typeElement, member, - utils.isProperty(mname) ? utils.getPropertyName(mname) : mname, - false, true); + utils.isProperty(mname) ? utils.getPropertyName(mname) : mname, true); linksTree.add(content); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java index ead520440d108..1d40e0ecbc408 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java @@ -352,7 +352,7 @@ public Content throwsTagOutput(TypeMirror throwsType) { @Override public Content valueTagOutput(VariableElement field, String constantVal, boolean includeLink) { return includeLink - ? htmlWriter.getDocLink(LinkInfoImpl.Kind.VALUE_TAG, field, constantVal, false) + ? htmlWriter.getDocLink(LinkInfoImpl.Kind.VALUE_TAG, field, constantVal) : new StringContent(constantVal); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java index d2de0fd28b3b4..cb1b16a4f8837 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java @@ -35,8 +35,7 @@ import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeVariable; import javax.lang.model.type.WildcardType; -import javax.lang.model.util.SimpleTypeVisitor9; -import jdk.javadoc.internal.doclets.formats.html.LinkInfoImpl; +import javax.lang.model.util.SimpleTypeVisitor14; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.util.Utils; @@ -57,7 +56,7 @@ protected LinkFactory(Utils utils) { } /** - * Return an empty instance of a content object. + * Returns an empty instance of a content object. * * @return an empty instance of a content object. */ @@ -71,11 +70,9 @@ protected LinkFactory(Utils utils) { */ public Content getLink(LinkInfo linkInfo) { if (linkInfo.type != null) { - SimpleTypeVisitor9 linkVisitor = - new SimpleTypeVisitor9() { + SimpleTypeVisitor14 linkVisitor = new SimpleTypeVisitor14<>() { - TypeMirror componentType = utils.getComponentType(linkInfo.type); - Content link = newContent(); + final Content link = newContent(); // handles primitives, no types and error types @Override @@ -109,7 +106,6 @@ public Content visitArray(ArrayType type, LinkInfo linkInfo) { @Override public Content visitWildcard(WildcardType type, LinkInfo linkInfo) { - linkInfo.isTypeBound = true; link.add(getTypeAnnotationLinks(linkInfo)); link.add("?"); TypeMirror extendsBound = type.getExtendsBound(); @@ -130,12 +126,11 @@ public Content visitWildcard(WildcardType type, LinkInfo linkInfo) { @Override public Content visitTypeVariable(TypeVariable type, LinkInfo linkInfo) { link.add(getTypeAnnotationLinks(linkInfo)); - linkInfo.isTypeBound = true; TypeVariable typevariable = (utils.isArrayType(type)) - ? (TypeVariable) componentType + ? (TypeVariable) utils.getComponentType(type) : type; Element owner = typevariable.asElement().getEnclosingElement(); - if ((!linkInfo.excludeTypeParameterLinks) && utils.isTypeElement(owner)) { + if (!linkInfo.excludeTypeParameterLinks && utils.isTypeElement(owner)) { linkInfo.typeElement = (TypeElement) owner; Content label = newContent(); label.add(utils.getTypeName(type, false)); @@ -171,20 +166,11 @@ public Content visitTypeVariable(TypeVariable type, LinkInfo linkInfo) { @Override public Content visitDeclared(DeclaredType type, LinkInfo linkInfo) { - if (linkInfo.isTypeBound && linkInfo.excludeTypeBoundsLinks) { - // Since we are excluding type parameter links, we should not - // be linking to the type bound. - link.add(utils.getTypeName(type, false)); + link.add(getTypeAnnotationLinks(linkInfo)); + linkInfo.typeElement = utils.asTypeElement(type); + link.add(getClassLink(linkInfo)); + if (linkInfo.includeTypeParameterLinks()) { link.add(getTypeParameterLinks(linkInfo)); - return link; - } else { - link = newContent(); - link.add(getTypeAnnotationLinks(linkInfo)); - linkInfo.typeElement = utils.asTypeElement(type); - link.add(getClassLink(linkInfo)); - if (linkInfo.includeTypeAsSepLink) { - link.add(getTypeParameterLinks(linkInfo, false)); - } } return link; } @@ -193,8 +179,8 @@ public Content visitDeclared(DeclaredType type, LinkInfo linkInfo) { } else if (linkInfo.typeElement != null) { Content link = newContent(); link.add(getClassLink(linkInfo)); - if (linkInfo.includeTypeAsSepLink) { - link.add(getTypeParameterLinks(linkInfo, false)); + if (linkInfo.includeTypeParameterLinks()) { + link.add(getTypeParameterLinks(linkInfo)); } return link; } else { @@ -213,7 +199,6 @@ private void setBoundsLinkInfo(LinkInfo linkInfo, TypeMirror bound) { * Returns a link to the given class. * * @param linkInfo the information about the link to construct - * * @return the link for the given class. */ protected abstract Content getClassLink(LinkInfo linkInfo); @@ -221,22 +206,16 @@ private void setBoundsLinkInfo(LinkInfo linkInfo, TypeMirror bound) { /** * Returns links to the type parameters. * - * @param linkInfo the information about the link to construct - * @param isClassLabel true if this is a class label, or false if it is - * the type parameters portion of the link + * @param linkInfo the information about the link to construct * @return the links to the type parameters */ - protected abstract Content getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel); + protected abstract Content getTypeParameterLinks(LinkInfo linkInfo); /** - * Returns links to the type parameters. + * Returns links to the type annotations. * - * @param linkInfo the information about the link to construct - * @return the links to the type parameters. + * @param linkInfo the information about the link to construct + * @return the links to the type annotations */ - public Content getTypeParameterLinks(LinkInfo linkInfo) { - return getTypeParameterLinks(linkInfo, true); - } - public abstract Content getTypeAnnotationLinks(LinkInfo linkInfo); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkInfo.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkInfo.java index 37dee02f3b61b..5810f0d6c06f2 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkInfo.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,11 +64,6 @@ public abstract class LinkInfo { */ public boolean isVarArg = false; - /** - * Set this to true to indicate that you are linking to a type parameter. - */ - public boolean isTypeBound = false; - /** * The label for the link. */ @@ -79,16 +74,6 @@ public abstract class LinkInfo { */ public boolean isStrong = false; - /** - * True if we should include the type in the link label. False otherwise. - */ - public boolean includeTypeInClassLinkLabel = true; - - /** - * True if we should include the type as separate link. False otherwise. - */ - public boolean includeTypeAsSepLink = false; - /** * True if we should exclude the type bounds for the type parameter. */ @@ -99,11 +84,6 @@ public abstract class LinkInfo { */ public boolean excludeTypeParameterLinks = false; - /** - * True if we should print the type bounds, but not link them. - */ - public boolean excludeTypeBoundsLinks = false; - /** * By default, the link can be to the page it's already on. However, * there are cases where we don't want this (e.g. heading of class page). @@ -116,14 +96,14 @@ public abstract class LinkInfo { public boolean skipPreview; /** - * Return an empty instance of a content object. + * Returns an empty instance of a content object. * * @return an empty instance of a content object. */ protected abstract Content newContent(); /** - * Return true if this link is linkable and false if we can't link to the + * Returns true if this link is linkable and false if we can't link to the * desired place. * * @return true if this link is linkable and false if we can't link to the @@ -131,6 +111,14 @@ public abstract class LinkInfo { */ public abstract boolean isLinkable(); + /** + * Returns true if links to declared types should include links to the + * type parameters. + * + * @return true if type parameter links should be included + */ + public abstract boolean includeTypeParameterLinks(); + /** * Return the label for this class link. * @@ -157,14 +145,10 @@ public String toString() { ", executableElement=" + executableElement + ", type=" + type + ", isVarArg=" + isVarArg + - ", isTypeBound=" + isTypeBound + ", label=" + label + ", isStrong=" + isStrong + - ", includeTypeInClassLinkLabel=" + includeTypeInClassLinkLabel + - ", includeTypeAsSepLink=" + includeTypeAsSepLink + ", excludeTypeBounds=" + excludeTypeBounds + ", excludeTypeParameterLinks=" + excludeTypeParameterLinks + - ", excludeTypeBoundsLinks=" + excludeTypeBoundsLinks + ", linkToSelf=" + linkToSelf + '}'; } }