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

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1997, 2015, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1997, 2016, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 21,40 **** * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package com.sun.tools.doclets.formats.html; import java.io.*; import java.util.*; ! import com.sun.javadoc.*; ! import com.sun.tools.doclets.formats.html.markup.*; ! import com.sun.tools.doclets.internal.toolkit.*; ! import com.sun.tools.doclets.internal.toolkit.util.*; /** * Writes constructor documentation. * * <p><b>This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. --- 21,50 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package jdk.javadoc.internal.doclets.formats.html; import java.io.*; import java.util.*; ! import javax.lang.model.element.Element; ! import javax.lang.model.element.ExecutableElement; ! import javax.lang.model.element.TypeElement; + import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; + import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; + import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; + import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; + import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; + import jdk.javadoc.internal.doclets.toolkit.ConstructorWriter; + import jdk.javadoc.internal.doclets.toolkit.Content; + import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter; + import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap; + + /** * Writes constructor documentation. * * <p><b>This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk.
*** 52,71 **** /** * 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<>(visibleMemberMap.getMembersFor(classDoc)); ! for (ProgramElementDoc constructor : constructors) { ! if (constructor.isProtected() || constructor.isPrivate()) { setFoundNonPubConstructor(true); } } } --- 62,82 ---- /** * Construct a new ConstructorWriterImpl. * * @param writer The writer for the class that the constructors belong to. ! * @param typeElement the class being documented. */ ! public ConstructorWriterImpl(SubWriterHolderWriter writer, TypeElement typeElement) { ! super(writer, typeElement); ! ! VisibleMemberMap visibleMemberMap = new VisibleMemberMap( ! typeElement, ! VisibleMemberMap.Kind.CONSTRUCTORS, configuration); ! SortedSet<Element> constructors = visibleMemberMap.getMembersFor(typeElement); ! for (Element constructor : constructors) { ! if (utils.isProtected(constructor) || utils.isPrivate(constructor)) { setFoundNonPubConstructor(true); } } }
*** 79,93 **** } /** * {@inheritDoc} */ ! public Content getMemberSummaryHeader(ClassDoc classDoc, Content memberSummaryTree) { memberSummaryTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); ! writer.addSummaryHeader(this, classDoc, memberTree); return memberTree; } /** * {@inheritDoc} --- 90,105 ---- } /** * {@inheritDoc} */ ! @Override ! public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { memberSummaryTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); ! writer.addSummaryHeader(this, typeElement, memberTree); return memberTree; } /** * {@inheritDoc}
*** 97,107 **** } /** * {@inheritDoc} */ ! public Content getConstructorDetailsTreeHeader(ClassDoc classDoc, Content memberDetailsTree) { memberDetailsTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_DETAILS); Content constructorDetailsTree = writer.getMemberTreeHeader(); constructorDetailsTree.addContent(writer.getMarkerAnchor( SectionName.CONSTRUCTOR_DETAIL)); --- 109,120 ---- } /** * {@inheritDoc} */ ! @Override ! public Content getConstructorDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) { memberDetailsTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_DETAILS); Content constructorDetailsTree = writer.getMemberTreeHeader(); constructorDetailsTree.addContent(writer.getMarkerAnchor( SectionName.CONSTRUCTOR_DETAIL));
*** 112,149 **** } /** * {@inheritDoc} */ ! public Content getConstructorDocTreeHeader(ConstructorDoc constructor, Content constructorDetailsTree) { String erasureAnchor; if ((erasureAnchor = getErasureAnchor(constructor)) != null) { constructorDetailsTree.addContent(writer.getMarkerAnchor((erasureAnchor))); } constructorDetailsTree.addContent( writer.getMarkerAnchor(writer.getAnchor(constructor))); Content constructorDocTree = writer.getMemberTreeHeader(); Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); ! heading.addContent(constructor.name()); constructorDocTree.addContent(heading); return constructorDocTree; } /** * {@inheritDoc} */ ! public Content getSignature(ConstructorDoc constructor) { Content pre = new HtmlTree(HtmlTag.PRE); writer.addAnnotationInfo(constructor, pre); int annotationLength = pre.charCount(); addModifiers(constructor, pre); if (configuration.linksource) { ! Content constructorName = new StringContent(constructor.name()); writer.addSrcLink(constructor, constructorName, pre); } else { ! addName(constructor.name(), pre); } int indent = pre.charCount() - annotationLength; addParameters(constructor, pre, indent); addExceptions(constructor, pre, indent); return pre; --- 125,164 ---- } /** * {@inheritDoc} */ ! @Override ! public Content getConstructorDocTreeHeader(ExecutableElement constructor, Content constructorDetailsTree) { String erasureAnchor; if ((erasureAnchor = getErasureAnchor(constructor)) != null) { constructorDetailsTree.addContent(writer.getMarkerAnchor((erasureAnchor))); } constructorDetailsTree.addContent( writer.getMarkerAnchor(writer.getAnchor(constructor))); Content constructorDocTree = writer.getMemberTreeHeader(); Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); ! heading.addContent(name(constructor)); constructorDocTree.addContent(heading); return constructorDocTree; } /** * {@inheritDoc} */ ! @Override ! public Content getSignature(ExecutableElement constructor) { Content pre = new HtmlTree(HtmlTag.PRE); writer.addAnnotationInfo(constructor, pre); int annotationLength = pre.charCount(); addModifiers(constructor, pre); if (configuration.linksource) { ! Content constructorName = new StringContent(name(constructor)); writer.addSrcLink(constructor, constructorName, pre); } else { ! addName(name(constructor), pre); } int indent = pre.charCount() - annotationLength; addParameters(constructor, pre, indent); addExceptions(constructor, pre, indent); return pre;
*** 161,191 **** } /** * {@inheritDoc} */ ! public void addDeprecated(ConstructorDoc constructor, Content constructorDocTree) { addDeprecatedInfo(constructor, constructorDocTree); } /** * {@inheritDoc} */ ! public void addComments(ConstructorDoc constructor, Content constructorDocTree) { addComment(constructor, constructorDocTree); } /** * {@inheritDoc} */ ! public void addTags(ConstructorDoc constructor, Content constructorDocTree) { writer.addTagsInfo(constructor, constructorDocTree); } /** * {@inheritDoc} */ public Content getConstructorDetails(Content constructorDetailsTree) { if (configuration.allowTag(HtmlTag.SECTION)) { HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(constructorDetailsTree)); return htmlTree; } --- 176,210 ---- } /** * {@inheritDoc} */ ! @Override ! public void addDeprecated(ExecutableElement constructor, Content constructorDocTree) { addDeprecatedInfo(constructor, constructorDocTree); } /** * {@inheritDoc} */ ! @Override ! public void addComments(ExecutableElement constructor, Content constructorDocTree) { addComment(constructor, constructorDocTree); } /** * {@inheritDoc} */ ! @Override ! public void addTags(ExecutableElement constructor, Content constructorDocTree) { writer.addTagsInfo(constructor, constructorDocTree); } /** * {@inheritDoc} */ + @Override public Content getConstructorDetails(Content constructorDetailsTree) { if (configuration.allowTag(HtmlTag.SECTION)) { HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(constructorDetailsTree)); return htmlTree; }
*** 193,299 **** } /** * {@inheritDoc} */ public Content getConstructorDoc(Content constructorDocTree, boolean isLastContent) { return getMemberTree(constructorDocTree, isLastContent); } /** * Close the writer. */ public void close() throws IOException { writer.close(); } /** * Let the writer know whether a non public constructor was found. * * @param foundNonPubConstructor true if we found a non public constructor. */ public void setFoundNonPubConstructor(boolean foundNonPubConstructor) { this.foundNonPubConstructor = foundNonPubConstructor; } /** * {@inheritDoc} */ public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, writer.getResource("doclet.Constructor_Summary")); memberTree.addContent(label); } /** * {@inheritDoc} */ public String getTableSummary() { return configuration.getText("doclet.Member_Table_Summary", configuration.getText("doclet.Constructor_Summary"), configuration.getText("doclet.constructors")); } /** * {@inheritDoc} */ public Content getCaption() { return configuration.getResource("doclet.Constructors"); } /** * {@inheritDoc} */ ! public String[] getSummaryTableHeader(ProgramElementDoc member) { ! String[] header; if (foundNonPubConstructor) { ! header = new String[] { ! configuration.getText("doclet.Modifier"), ! configuration.getText("doclet.0_and_1", ! configuration.getText("doclet.Constructor"), ! configuration.getText("doclet.Description")) ! }; } ! else { ! header = new String[] { ! configuration.getText("doclet.0_and_1", configuration.getText("doclet.Constructor"), ! configuration.getText("doclet.Description")) ! }; ! } return header; } /** * {@inheritDoc} */ ! public void addSummaryAnchor(ClassDoc cd, Content memberTree) { memberTree.addContent(writer.getMarkerAnchor( SectionName.CONSTRUCTOR_SUMMARY)); } /** * {@inheritDoc} */ ! public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) { } /** * {@inheritDoc} */ ! public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) { } - public int getMemberKind() { - return VisibleMemberMap.CONSTRUCTORS; - } - /** * {@inheritDoc} */ ! protected Content getNavSummaryLink(ClassDoc cd, boolean link) { if (link) { return writer.getHyperLink(SectionName.CONSTRUCTOR_SUMMARY, writer.getResource("doclet.navConstructor")); } else { return writer.getResource("doclet.navConstructor"); --- 212,316 ---- } /** * {@inheritDoc} */ + @Override public Content getConstructorDoc(Content constructorDocTree, boolean isLastContent) { return getMemberTree(constructorDocTree, isLastContent); } /** * Close the writer. */ + @Override public void close() throws IOException { writer.close(); } /** * Let the writer know whether a non public constructor was found. * * @param foundNonPubConstructor true if we found a non public constructor. */ + @Override public void setFoundNonPubConstructor(boolean foundNonPubConstructor) { this.foundNonPubConstructor = foundNonPubConstructor; } /** * {@inheritDoc} */ + @Override public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, writer.getResource("doclet.Constructor_Summary")); memberTree.addContent(label); } /** * {@inheritDoc} */ + @Override public String getTableSummary() { return configuration.getText("doclet.Member_Table_Summary", configuration.getText("doclet.Constructor_Summary"), configuration.getText("doclet.constructors")); } /** * {@inheritDoc} */ + @Override public Content getCaption() { return configuration.getResource("doclet.Constructors"); } /** * {@inheritDoc} */ ! @Override ! public List<String> getSummaryTableHeader(Element member) { ! List<String> header = new ArrayList<>(); if (foundNonPubConstructor) { ! header.add(configuration.getText("doclet.Modifier")); } ! header.add(configuration.getText("doclet.0_and_1", configuration.getText("doclet.Constructor"), ! configuration.getText("doclet.Description"))); return header; } /** * {@inheritDoc} */ ! @Override ! public void addSummaryAnchor(TypeElement typeElement, Content memberTree) { memberTree.addContent(writer.getMarkerAnchor( SectionName.CONSTRUCTOR_SUMMARY)); } /** * {@inheritDoc} */ ! @Override ! public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) { } /** * {@inheritDoc} */ ! @Override ! public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) { } /** * {@inheritDoc} */ ! @Override ! protected Content getNavSummaryLink(TypeElement typeElement, boolean link) { if (link) { return writer.getHyperLink(SectionName.CONSTRUCTOR_SUMMARY, writer.getResource("doclet.navConstructor")); } else { return writer.getResource("doclet.navConstructor");
*** 301,310 **** --- 318,328 ---- } /** * {@inheritDoc} */ + @Override protected void addNavDetailLink(boolean link, Content liNav) { if (link) { liNav.addContent(writer.getHyperLink( SectionName.CONSTRUCTOR_DETAIL, writer.getResource("doclet.navConstructor")));
*** 314,331 **** } /** * {@inheritDoc} */ ! protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) { if (foundNonPubConstructor) { Content code = new HtmlTree(HtmlTag.CODE); ! if (member.isProtected()) { code.addContent("protected "); ! } else if (member.isPrivate()) { code.addContent("private "); ! } else if (member.isPublic()) { code.addContent(writer.getSpace()); } else { code.addContent( configuration.getText("doclet.Package_private")); } --- 332,350 ---- } /** * {@inheritDoc} */ ! @Override ! protected void addSummaryType(Element member, Content tdSummaryType) { if (foundNonPubConstructor) { Content code = new HtmlTree(HtmlTag.CODE); ! if (utils.isProtected(member)) { code.addContent("protected "); ! } else if (utils.isPrivate(member)) { code.addContent("private "); ! } else if (utils.isPublic(member)) { code.addContent(writer.getSpace()); } else { code.addContent( configuration.getText("doclet.Package_private")); }