/* * Copyright (c) 2003, 2019, 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 * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * 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.toolkit.taglets; import java.util.EnumSet; import java.util.List; import javax.lang.model.element.Element; import javax.lang.model.element.Name; import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeMirror; import com.sun.source.doctree.DocTree; import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.taglets.Taglet.UnsupportedTagletOperationException; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.Utils; /** * The interface for the taglet writer. * *
This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.
*
* @author Jamie Ho
*/
public abstract class TagletWriter {
/**
* True if we only want to write the first sentence.
*/
protected final boolean isFirstSentence;
protected TagletWriter(boolean isFirstSentence) {
this.isFirstSentence = isFirstSentence;
}
/**
* @return an instance of an output object.
*/
public abstract Content getOutputInstance();
/**
* Return the output for a {@code {@code ...}} tag.
*
* @param element
* @param tag the tag.
* @return the output of the taglet.
*/
protected abstract Content codeTagOutput(Element element, DocTree tag);
/**
* Return the output for a {@index...} tag.
*
* @param tag the tag.
* @return the output of the taglet.
*/
protected abstract Content indexTagOutput(Element element, DocTree tag);
/**
* Returns the output for the DocRoot inline tag.
* @return the output for the DocRoot inline tag.
*/
protected abstract Content getDocRootOutput();
/**
* Return the deprecated tag output.
*
* @param element the element to write deprecated documentation for.
* @return the output of the deprecated tag.
*/
protected abstract Content deprecatedTagOutput(Element element);
/**
* Return the output for a {@code {@literal ...}} tag.
*
* @param element
* @param tag the tag.
* @return the output of the taglet.
*/
protected abstract Content literalTagOutput(Element element, DocTree tag);
/**
* Return the header for the param tags.
*
* @param header the header to display.
* @return the header for the param tags.
*/
protected abstract Content getParamHeader(String header);
/**
* Return the output for param tags.
*
* @param element
* @param paramTag the parameter to document.
* @param paramName the name of the parameter.
* @return the output of the param tag.
*/
protected abstract Content paramTagOutput(Element element, DocTree paramTag, String paramName);
/**
* Return the output for property tags.
*
* @param element
* @param propertyTag the parameter to document.
* @param prefix the text with which to prefix the property name.
* @return the output of the param tag.
*/
protected abstract Content propertyTagOutput(Element element, DocTree propertyTag, String prefix);
/**
* Return the return tag output.
*
* @param element
* @param returnTag the return tag to output.
* @return the output of the return tag.
*/
protected abstract Content returnTagOutput(Element element, DocTree returnTag);
/**
* Return the see tag output.
*
* @param holder
* @param seeTags the array of See tags.
* @return the output of the see tags.
*/
protected abstract Content seeTagOutput(Element holder, List extends DocTree> seeTags);
/**
* Return the output for a simple tag.
*
* @param element
* @param simpleTags the array of simple tags.
* @param header
* @return the output of the simple tags.
*/
protected abstract Content simpleTagOutput(Element element, List extends DocTree> simpleTags, String header);
/**
* Return the output for a simple tag.
*
* @param element
* @param simpleTag the simple tag.
* @param header
* @return the output of the simple tag.
*/
protected abstract Content simpleTagOutput(Element element, DocTree simpleTag, String header);
/**
* Return the system property tag output.
*
* @param element
* @param systemPropertyTag the system property tag
* @return the output of system property tag
*/
protected abstract Content systemPropertyTagOutput(Element element, DocTree systemPropertyTag);
/**
* Return the header for the throws tag.
*
* @return the header for the throws tag.
*/
protected abstract Content getThrowsHeader();
/**
* Return the header for the throws tag.
*
* @param element
* @param throwsTag the throws tag.
* @return the output of the throws tag.
*/
protected abstract Content throwsTagOutput(Element element, DocTree throwsTag);
/**
* Return the output for the throws tag.
*
* @param throwsType the throws type.
* @return the output of the throws type.
*/
protected abstract Content throwsTagOutput(TypeMirror throwsType);
/**
* Return the output for the value tag.
*
* @param field the constant field that holds the value tag.
* @param constantVal the constant value to document.
* @param includeLink true if we should link the constant text to the
* constant field itself.
* @return the output of the value tag.
*/
protected abstract Content valueTagOutput(VariableElement field,
String constantVal, boolean includeLink);
/**
* Given an output object, append to it the tag documentation for
* the given member.
*
* @param tagletManager the manager that manages the taglets.
* @param element the Doc that we are print tags for.
* @param taglets the taglets to print.
* @param writer the writer that will generate the output strings.
* @param output the output buffer to store the output in.
*/
public static void genTagOutput(TagletManager tagletManager, Element element,
List