mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-14 00:49:42 +00:00
Merge
This commit is contained in:
commit
e46ec34e4b
@ -46,7 +46,7 @@ $(eval $(call SetupJavaCompilation,BUILD_INTERIM_LANGTOOLS, \
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/jdk.compiler \
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/jdk.javadoc \
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdeps, \
|
||||
EXCLUDES := sun jdk, \
|
||||
EXCLUDES := sun, \
|
||||
COPY := .gif .png .xml .css .js javax.tools.JavaCompilerTool, \
|
||||
BIN := $(BUILDTOOLS_OUTPUTDIR)/langtools_interim_classes, \
|
||||
JAR := $(INTERIM_LANGTOOLS_JAR)))
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2014, 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
|
||||
@ -25,9 +25,12 @@
|
||||
|
||||
include GensrcCommon.gmk
|
||||
|
||||
$(eval $(call SetupVersionProperties,JAVADOC_VERSION,\
|
||||
$(eval $(call SetupVersionProperties,OLD_JAVADOC_VERSION,\
|
||||
com/sun/tools/javadoc/resources/version.properties))
|
||||
|
||||
$(eval $(call SetupVersionProperties,JAVADOC_VERSION,\
|
||||
jdk/javadoc/internal/tool/resources/version.properties))
|
||||
|
||||
$(eval $(call SetupCompileProperties,COMPILE_PROPERTIES, $(JAVADOC_VERSION)))
|
||||
|
||||
all: $(COMPILE_PROPERTIES)
|
||||
|
||||
@ -93,7 +93,11 @@
|
||||
<macrodef name="resolve-main-class">
|
||||
<attribute name="tool.name"/>
|
||||
<sequential>
|
||||
<property name="langtools.main.class" value="${tool.@{tool.name}.main.class}"/>
|
||||
<condition property="langtools.main.class"
|
||||
value="jdk.javadoc.internal.tool.Main"
|
||||
else="${tool.@{tool.name}.main.class}">
|
||||
<equals arg1="${langtools.tool.name}" arg2="javadoc"/>
|
||||
</condition>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
|
||||
@ -104,7 +104,7 @@ public class ToolProvider {
|
||||
}
|
||||
|
||||
private static final String systemDocumentationToolName
|
||||
= "com.sun.tools.javadoc.api.JavadocTool";
|
||||
= "jdk.javadoc.internal.api.JavadocTool";
|
||||
|
||||
/**
|
||||
* Returns the Java™ programming language documentation tool provided
|
||||
|
||||
@ -26,9 +26,7 @@
|
||||
package com.sun.tools.javac.code;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.lang.model.element.ElementVisitor;
|
||||
import javax.tools.JavaFileObject;
|
||||
@ -39,7 +37,6 @@ import com.sun.tools.javac.code.Symbol.ClassSymbol;
|
||||
import com.sun.tools.javac.code.Symbol.Completer;
|
||||
import com.sun.tools.javac.code.Symbol.CompletionFailure;
|
||||
import com.sun.tools.javac.code.Symbol.MethodSymbol;
|
||||
import com.sun.tools.javac.code.Symbol.OperatorSymbol;
|
||||
import com.sun.tools.javac.code.Symbol.PackageSymbol;
|
||||
import com.sun.tools.javac.code.Symbol.TypeSymbol;
|
||||
import com.sun.tools.javac.code.Symbol.VarSymbol;
|
||||
@ -50,7 +47,6 @@ import com.sun.tools.javac.code.Type.JCPrimitiveType;
|
||||
import com.sun.tools.javac.code.Type.JCVoidType;
|
||||
import com.sun.tools.javac.code.Type.MethodType;
|
||||
import com.sun.tools.javac.code.Type.UnknownType;
|
||||
import com.sun.tools.javac.jvm.ByteCodes;
|
||||
import com.sun.tools.javac.jvm.Target;
|
||||
import com.sun.tools.javac.util.Assert;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
@ -65,7 +61,6 @@ import com.sun.tools.javac.util.Names;
|
||||
|
||||
import static com.sun.tools.javac.code.Flags.*;
|
||||
import static com.sun.tools.javac.code.Kinds.Kind.*;
|
||||
import static com.sun.tools.javac.jvm.ByteCodes.*;
|
||||
import static com.sun.tools.javac.code.TypeTag.*;
|
||||
|
||||
/** A class that defines all predefined constants and operators
|
||||
@ -193,6 +188,7 @@ public class Symtab {
|
||||
public final Type autoCloseableType;
|
||||
public final Type trustMeType;
|
||||
public final Type lambdaMetafactory;
|
||||
public final Type stringConcatFactory;
|
||||
public final Type repeatableType;
|
||||
public final Type documentedType;
|
||||
public final Type elementTypeType;
|
||||
@ -472,6 +468,7 @@ public class Symtab {
|
||||
trustMeType = enterClass("java.lang.SafeVarargs");
|
||||
nativeHeaderType = enterClass("java.lang.annotation.Native");
|
||||
lambdaMetafactory = enterClass("java.lang.invoke.LambdaMetafactory");
|
||||
stringConcatFactory = enterClass("java.lang.invoke.StringConcatFactory");
|
||||
functionalInterfaceType = enterClass("java.lang.FunctionalInterface");
|
||||
|
||||
synthesizeEmptyInterfaceIfMissing(autoCloseableType);
|
||||
@ -479,6 +476,7 @@ public class Symtab {
|
||||
synthesizeEmptyInterfaceIfMissing(serializableType);
|
||||
synthesizeEmptyInterfaceIfMissing(lambdaMetafactory);
|
||||
synthesizeEmptyInterfaceIfMissing(serializedLambdaType);
|
||||
synthesizeEmptyInterfaceIfMissing(stringConcatFactory);
|
||||
synthesizeBoxTypeIfMissing(doubleType);
|
||||
synthesizeBoxTypeIfMissing(floatType);
|
||||
synthesizeBoxTypeIfMissing(voidType);
|
||||
|
||||
@ -68,6 +68,7 @@ import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static com.sun.tools.javac.code.TypeTag.ARRAY;
|
||||
import static com.sun.tools.javac.code.TypeTag.DEFERRED;
|
||||
import static com.sun.tools.javac.code.TypeTag.FORALL;
|
||||
import static com.sun.tools.javac.code.TypeTag.METHOD;
|
||||
@ -275,7 +276,7 @@ public class ArgumentAttr extends JCTree.Visitor {
|
||||
res.type != null && res.type.hasTag(FORALL) ||
|
||||
(res.flags() & Flags.VARARGS) != 0 ||
|
||||
(TreeInfo.isStaticSelector(exprTree, tree.name.table.names) &&
|
||||
exprTree.type.isRaw())) {
|
||||
exprTree.type.isRaw() && !exprTree.type.hasTag(ARRAY))) {
|
||||
tree.overloadKind = JCMemberReference.OverloadKind.OVERLOADED;
|
||||
} else {
|
||||
tree.overloadKind = JCMemberReference.OverloadKind.UNOVERLOADED;
|
||||
|
||||
@ -239,7 +239,7 @@ public class Attr extends JCTree.Visitor {
|
||||
//this means we are dealing with a partially inferred poly expression
|
||||
owntype = shouldCheck ? resultInfo.pt : found;
|
||||
if (resultInfo.checkMode.installPostInferenceHook()) {
|
||||
inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt),
|
||||
inferenceContext.addFreeTypeListener(List.of(found),
|
||||
instantiatedContext -> {
|
||||
ResultInfo pendingResult =
|
||||
resultInfo.dup(inferenceContext.asInstType(resultInfo.pt));
|
||||
|
||||
@ -1812,7 +1812,7 @@ public class LambdaToMethod extends TreeTranslator {
|
||||
|
||||
TranslationContext(T tree) {
|
||||
this.tree = tree;
|
||||
this.owner = owner();
|
||||
this.owner = owner(true);
|
||||
this.depth = frameStack.size() - 1;
|
||||
this.prev = context();
|
||||
ClassSymbol csym =
|
||||
|
||||
@ -25,8 +25,6 @@
|
||||
|
||||
package com.sun.tools.javac.jvm;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.tools.javac.util.*;
|
||||
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
|
||||
import com.sun.tools.javac.util.List;
|
||||
@ -45,7 +43,6 @@ import com.sun.tools.javac.tree.JCTree.*;
|
||||
|
||||
import static com.sun.tools.javac.code.Flags.*;
|
||||
import static com.sun.tools.javac.code.Kinds.Kind.*;
|
||||
import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
|
||||
import static com.sun.tools.javac.code.TypeTag.*;
|
||||
import static com.sun.tools.javac.jvm.ByteCodes.*;
|
||||
import static com.sun.tools.javac.jvm.CRTFlags.*;
|
||||
@ -69,12 +66,12 @@ public class Gen extends JCTree.Visitor {
|
||||
private final TreeMaker make;
|
||||
private final Names names;
|
||||
private final Target target;
|
||||
private final Map<Type,Symbol> stringBufferAppend;
|
||||
private Name accessDollar;
|
||||
private final Types types;
|
||||
private final Lower lower;
|
||||
private final Flow flow;
|
||||
private final Annotate annotate;
|
||||
private final StringConcat concat;
|
||||
|
||||
/** Format of stackmap tables to be generated. */
|
||||
private final Code.StackMapFormat stackMap;
|
||||
@ -105,8 +102,9 @@ public class Gen extends JCTree.Visitor {
|
||||
make = TreeMaker.instance(context);
|
||||
target = Target.instance(context);
|
||||
types = Types.instance(context);
|
||||
concat = StringConcat.instance(context);
|
||||
|
||||
methodType = new MethodType(null, null, null, syms.methodClass);
|
||||
stringBufferAppend = new HashMap<>();
|
||||
accessDollar = names.
|
||||
fromString("access" + target.syntheticNameChar());
|
||||
flow = Flow.instance(context);
|
||||
@ -753,6 +751,18 @@ public class Gen extends JCTree.Visitor {
|
||||
}
|
||||
}
|
||||
|
||||
public Code getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public Items getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public Env<AttrContext> getAttrEnv() {
|
||||
return attrEnv;
|
||||
}
|
||||
|
||||
/** Visitor class for expressions which might be constant expressions.
|
||||
* This class is a subset of TreeScanner. Intended to visit trees pruned by
|
||||
* Lower as long as constant expressions looking for references to any
|
||||
@ -1895,25 +1905,7 @@ public class Gen extends JCTree.Visitor {
|
||||
OperatorSymbol operator = (OperatorSymbol) tree.operator;
|
||||
Item l;
|
||||
if (operator.opcode == string_add) {
|
||||
// Generate code to make a string buffer
|
||||
makeStringBuffer(tree.pos());
|
||||
|
||||
// Generate code for first string, possibly save one
|
||||
// copy under buffer
|
||||
l = genExpr(tree.lhs, tree.lhs.type);
|
||||
if (l.width() > 0) {
|
||||
code.emitop0(dup_x1 + 3 * (l.width() - 1));
|
||||
}
|
||||
|
||||
// Load first string and append to buffer.
|
||||
l.load();
|
||||
appendString(tree.lhs);
|
||||
|
||||
// Append all other strings to buffer.
|
||||
appendStrings(tree.rhs);
|
||||
|
||||
// Convert buffer to string.
|
||||
bufferToString(tree.pos());
|
||||
l = concat.makeConcat(tree);
|
||||
} else {
|
||||
// Generate code for first expression
|
||||
l = genExpr(tree.lhs, tree.lhs.type);
|
||||
@ -2026,13 +2018,7 @@ public class Gen extends JCTree.Visitor {
|
||||
public void visitBinary(JCBinary tree) {
|
||||
OperatorSymbol operator = (OperatorSymbol)tree.operator;
|
||||
if (operator.opcode == string_add) {
|
||||
// Create a string buffer.
|
||||
makeStringBuffer(tree.pos());
|
||||
// Append all strings to buffer.
|
||||
appendStrings(tree);
|
||||
// Convert buffer to string.
|
||||
bufferToString(tree.pos());
|
||||
result = items.makeStackItem(syms.stringType);
|
||||
result = concat.makeConcat(tree);
|
||||
} else if (tree.hasTag(AND)) {
|
||||
CondItem lcond = genCond(tree.lhs, CRT_FLOW_CONTROLLER);
|
||||
if (!lcond.isFalse()) {
|
||||
@ -2066,67 +2052,7 @@ public class Gen extends JCTree.Visitor {
|
||||
result = completeBinop(tree.lhs, tree.rhs, operator);
|
||||
}
|
||||
}
|
||||
//where
|
||||
/** Make a new string buffer.
|
||||
*/
|
||||
void makeStringBuffer(DiagnosticPosition pos) {
|
||||
code.emitop2(new_, makeRef(pos, syms.stringBuilderType));
|
||||
code.emitop0(dup);
|
||||
callMethod(
|
||||
pos, syms.stringBuilderType, names.init, List.<Type>nil(), false);
|
||||
}
|
||||
|
||||
/** Append value (on tos) to string buffer (on tos - 1).
|
||||
*/
|
||||
void appendString(JCTree tree) {
|
||||
Type t = tree.type.baseType();
|
||||
if (!t.isPrimitive() && t.tsym != syms.stringType.tsym) {
|
||||
t = syms.objectType;
|
||||
}
|
||||
items.makeMemberItem(getStringBufferAppend(tree, t), false).invoke();
|
||||
}
|
||||
Symbol getStringBufferAppend(JCTree tree, Type t) {
|
||||
Assert.checkNull(t.constValue());
|
||||
Symbol method = stringBufferAppend.get(t);
|
||||
if (method == null) {
|
||||
method = rs.resolveInternalMethod(tree.pos(),
|
||||
attrEnv,
|
||||
syms.stringBuilderType,
|
||||
names.append,
|
||||
List.of(t),
|
||||
null);
|
||||
stringBufferAppend.put(t, method);
|
||||
}
|
||||
return method;
|
||||
}
|
||||
|
||||
/** Add all strings in tree to string buffer.
|
||||
*/
|
||||
void appendStrings(JCTree tree) {
|
||||
tree = TreeInfo.skipParens(tree);
|
||||
if (tree.hasTag(PLUS) && tree.type.constValue() == null) {
|
||||
JCBinary op = (JCBinary) tree;
|
||||
if (op.operator.kind == MTH &&
|
||||
((OperatorSymbol) op.operator).opcode == string_add) {
|
||||
appendStrings(op.lhs);
|
||||
appendStrings(op.rhs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
genExpr(tree, tree.type).load();
|
||||
appendString(tree);
|
||||
}
|
||||
|
||||
/** Convert string buffer on tos to string.
|
||||
*/
|
||||
void bufferToString(DiagnosticPosition pos) {
|
||||
callMethod(
|
||||
pos,
|
||||
syms.stringBuilderType,
|
||||
names.toString,
|
||||
List.<Type>nil(),
|
||||
false);
|
||||
}
|
||||
|
||||
/** Complete generating code for operation, with left operand
|
||||
* already on stack.
|
||||
@ -2173,8 +2099,8 @@ public class Gen extends JCTree.Visitor {
|
||||
}
|
||||
|
||||
public void visitTypeCast(JCTypeCast tree) {
|
||||
setTypeAnnotationPositions(tree.pos);
|
||||
result = genExpr(tree.expr, tree.clazz.type).load();
|
||||
setTypeAnnotationPositions(tree.pos);
|
||||
// Additional code is only needed if we cast to a reference type
|
||||
// which is not statically a supertype of the expression's type.
|
||||
// For basic types, the coerce(...) in genExpr(...) will do
|
||||
@ -2191,8 +2117,8 @@ public class Gen extends JCTree.Visitor {
|
||||
}
|
||||
|
||||
public void visitTypeTest(JCInstanceOf tree) {
|
||||
setTypeAnnotationPositions(tree.pos);
|
||||
genExpr(tree.expr, tree.expr.type).load();
|
||||
setTypeAnnotationPositions(tree.pos);
|
||||
code.emitop2(instanceof_, makeRef(tree.pos(), tree.clazz.type));
|
||||
result = items.makeStackItem(syms.booleanType);
|
||||
}
|
||||
|
||||
@ -0,0 +1,485 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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
|
||||
* 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 com.sun.tools.javac.jvm;
|
||||
|
||||
import com.sun.tools.javac.code.*;
|
||||
import com.sun.tools.javac.comp.Resolve;
|
||||
import com.sun.tools.javac.tree.JCTree;
|
||||
import com.sun.tools.javac.tree.TreeInfo;
|
||||
import com.sun.tools.javac.tree.TreeMaker;
|
||||
import com.sun.tools.javac.util.*;
|
||||
|
||||
import static com.sun.tools.javac.code.Kinds.Kind.MTH;
|
||||
import static com.sun.tools.javac.code.TypeTag.DOUBLE;
|
||||
import static com.sun.tools.javac.code.TypeTag.LONG;
|
||||
import static com.sun.tools.javac.jvm.ByteCodes.*;
|
||||
import static com.sun.tools.javac.tree.JCTree.Tag.PLUS;
|
||||
import com.sun.tools.javac.jvm.Items.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/** This lowers the String concatenation to something that JVM can understand.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public abstract class StringConcat {
|
||||
|
||||
/**
|
||||
* Maximum number of slots for String Concat call.
|
||||
* JDK's StringConcatFactory does not support more than that.
|
||||
*/
|
||||
private static final int MAX_INDY_CONCAT_ARG_SLOTS = 200;
|
||||
private static final char TAG_ARG = '\u0001';
|
||||
private static final char TAG_CONST = '\u0002';
|
||||
|
||||
protected final Gen gen;
|
||||
protected final Symtab syms;
|
||||
protected final Names names;
|
||||
protected final TreeMaker make;
|
||||
protected final Types types;
|
||||
protected final Map<Type, Symbol> sbAppends;
|
||||
protected final Resolve rs;
|
||||
|
||||
protected static final Context.Key<StringConcat> concatKey = new Context.Key<>();
|
||||
|
||||
public static StringConcat instance(Context context) {
|
||||
StringConcat instance = context.get(concatKey);
|
||||
if (instance == null) {
|
||||
instance = makeConcat(context);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static StringConcat makeConcat(Context context) {
|
||||
Target target = Target.instance(context);
|
||||
String opt = Options.instance(context).get("stringConcat");
|
||||
if (target.hasStringConcatFactory()) {
|
||||
if (opt == null) {
|
||||
opt = "indyWithConstants";
|
||||
}
|
||||
} else {
|
||||
if (opt != null && !"inline".equals(opt)) {
|
||||
Assert.error("StringConcatFactory-based string concat is requested on a platform that does not support it.");
|
||||
}
|
||||
opt = "inline";
|
||||
}
|
||||
|
||||
switch (opt) {
|
||||
case "inline":
|
||||
return new Inline(context);
|
||||
case "indy":
|
||||
return new IndyPlain(context);
|
||||
case "indyWithConstants":
|
||||
return new IndyConstants(context);
|
||||
default:
|
||||
Assert.error("Unknown stringConcat: " + opt);
|
||||
throw new IllegalStateException("Unknown stringConcat: " + opt);
|
||||
}
|
||||
}
|
||||
|
||||
protected StringConcat(Context context) {
|
||||
context.put(concatKey, this);
|
||||
gen = Gen.instance(context);
|
||||
syms = Symtab.instance(context);
|
||||
types = Types.instance(context);
|
||||
names = Names.instance(context);
|
||||
make = TreeMaker.instance(context);
|
||||
rs = Resolve.instance(context);
|
||||
sbAppends = new HashMap<>();
|
||||
}
|
||||
|
||||
public abstract Item makeConcat(JCTree.JCAssignOp tree);
|
||||
public abstract Item makeConcat(JCTree.JCBinary tree);
|
||||
|
||||
protected List<JCTree> collectAll(JCTree tree) {
|
||||
return collect(tree, List.nil());
|
||||
}
|
||||
|
||||
protected List<JCTree> collectAll(JCTree.JCExpression lhs, JCTree.JCExpression rhs) {
|
||||
return List.<JCTree>nil()
|
||||
.appendList(collectAll(lhs))
|
||||
.appendList(collectAll(rhs));
|
||||
}
|
||||
|
||||
private List<JCTree> collect(JCTree tree, List<JCTree> res) {
|
||||
tree = TreeInfo.skipParens(tree);
|
||||
if (tree.hasTag(PLUS) && tree.type.constValue() == null) {
|
||||
JCTree.JCBinary op = (JCTree.JCBinary) tree;
|
||||
if (op.operator.kind == MTH &&
|
||||
((Symbol.OperatorSymbol) op.operator).opcode == string_add) {
|
||||
return res
|
||||
.appendList(collect(op.lhs, res))
|
||||
.appendList(collect(op.rhs, res));
|
||||
}
|
||||
}
|
||||
return res.append(tree);
|
||||
}
|
||||
|
||||
/**
|
||||
* "Legacy" bytecode flavor: emit the StringBuilder.append chains for string
|
||||
* concatenation.
|
||||
*/
|
||||
private static class Inline extends StringConcat {
|
||||
public Inline(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item makeConcat(JCTree.JCAssignOp tree) {
|
||||
// Generate code to make a string builder
|
||||
JCDiagnostic.DiagnosticPosition pos = tree.pos();
|
||||
|
||||
// Create a string builder.
|
||||
newStringBuilder(tree);
|
||||
|
||||
// Generate code for first string, possibly save one
|
||||
// copy under builder
|
||||
Item l = gen.genExpr(tree.lhs, tree.lhs.type);
|
||||
if (l.width() > 0) {
|
||||
gen.getCode().emitop0(dup_x1 + 3 * (l.width() - 1));
|
||||
}
|
||||
|
||||
// Load first string and append to builder.
|
||||
l.load();
|
||||
appendString(tree.lhs);
|
||||
|
||||
// Append all other strings to builder.
|
||||
List<JCTree> args = collectAll(tree.rhs);
|
||||
for (JCTree t : args) {
|
||||
gen.genExpr(t, t.type).load();
|
||||
appendString(t);
|
||||
}
|
||||
|
||||
// Convert builder to string.
|
||||
builderToString(pos);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item makeConcat(JCTree.JCBinary tree) {
|
||||
JCDiagnostic.DiagnosticPosition pos = tree.pos();
|
||||
|
||||
// Create a string builder.
|
||||
newStringBuilder(tree);
|
||||
|
||||
// Append all strings to builder.
|
||||
List<JCTree> args = collectAll(tree);
|
||||
for (JCTree t : args) {
|
||||
gen.genExpr(t, t.type).load();
|
||||
appendString(t);
|
||||
}
|
||||
|
||||
// Convert builder to string.
|
||||
builderToString(pos);
|
||||
|
||||
return gen.getItems().makeStackItem(syms.stringType);
|
||||
}
|
||||
|
||||
private JCDiagnostic.DiagnosticPosition newStringBuilder(JCTree tree) {
|
||||
JCDiagnostic.DiagnosticPosition pos = tree.pos();
|
||||
gen.getCode().emitop2(new_, gen.makeRef(pos, syms.stringBuilderType));
|
||||
gen.getCode().emitop0(dup);
|
||||
gen.callMethod(pos, syms.stringBuilderType, names.init, List.<Type>nil(), false);
|
||||
return pos;
|
||||
}
|
||||
|
||||
private void appendString(JCTree tree) {
|
||||
Type t = tree.type.baseType();
|
||||
if (!t.isPrimitive() && t.tsym != syms.stringType.tsym) {
|
||||
t = syms.objectType;
|
||||
}
|
||||
|
||||
Assert.checkNull(t.constValue());
|
||||
Symbol method = sbAppends.get(t);
|
||||
if (method == null) {
|
||||
method = rs.resolveInternalMethod(tree.pos(), gen.getAttrEnv(), syms.stringBuilderType, names.append, List.of(t), null);
|
||||
sbAppends.put(t, method);
|
||||
}
|
||||
|
||||
gen.getItems().makeMemberItem(method, false).invoke();
|
||||
}
|
||||
|
||||
private void builderToString(JCDiagnostic.DiagnosticPosition pos) {
|
||||
gen.callMethod(pos, syms.stringBuilderType, names.toString, List.<Type>nil(), false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for indified concatenation bytecode flavors.
|
||||
*/
|
||||
private static abstract class Indy extends StringConcat {
|
||||
public Indy(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item makeConcat(JCTree.JCAssignOp tree) {
|
||||
List<JCTree> args = collectAll(tree.lhs, tree.rhs);
|
||||
Item l = gen.genExpr(tree.lhs, tree.lhs.type);
|
||||
emit(args, tree.type, tree.pos());
|
||||
return l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item makeConcat(JCTree.JCBinary tree) {
|
||||
List<JCTree> args = collectAll(tree.lhs, tree.rhs);
|
||||
emit(args, tree.type, tree.pos());
|
||||
return gen.getItems().makeStackItem(syms.stringType);
|
||||
}
|
||||
|
||||
protected abstract void emit(List<JCTree> args, Type type, JCDiagnostic.DiagnosticPosition pos);
|
||||
|
||||
/** Peel the argument list into smaller chunks. */
|
||||
protected List<List<JCTree>> split(List<JCTree> args) {
|
||||
ListBuffer<List<JCTree>> splits = new ListBuffer<>();
|
||||
|
||||
int slots = 0;
|
||||
|
||||
// Need to peel, so that neither call has more than acceptable number
|
||||
// of slots for the arguments.
|
||||
ListBuffer<JCTree> cArgs = new ListBuffer<>();
|
||||
for (JCTree t : args) {
|
||||
int needSlots = (t.type.getTag() == LONG || t.type.getTag() == DOUBLE) ? 2 : 1;
|
||||
if (slots + needSlots >= MAX_INDY_CONCAT_ARG_SLOTS) {
|
||||
splits.add(cArgs.toList());
|
||||
cArgs.clear();
|
||||
slots = 0;
|
||||
}
|
||||
cArgs.add(t);
|
||||
slots += needSlots;
|
||||
}
|
||||
|
||||
// Flush the tail slice
|
||||
if (!cArgs.isEmpty()) {
|
||||
splits.add(cArgs.toList());
|
||||
}
|
||||
|
||||
return splits.toList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits the invokedynamic call to JDK java.lang.invoke.StringConcatFactory,
|
||||
* without handling constants specially.
|
||||
*
|
||||
* We bypass empty strings, because they have no meaning at this level. This
|
||||
* captures the Java language trick to force String concat with e.g. ("" + int)-like
|
||||
* expression. Down here, we already know we are in String concat business, and do
|
||||
* not require these markers.
|
||||
*/
|
||||
private static class IndyPlain extends Indy {
|
||||
public IndyPlain(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/** Emit the indy concat for all these arguments, possibly peeling along the way */
|
||||
protected void emit(List<JCTree> args, Type type, JCDiagnostic.DiagnosticPosition pos) {
|
||||
List<List<JCTree>> split = split(args);
|
||||
|
||||
for (List<JCTree> t : split) {
|
||||
Assert.check(!t.isEmpty(), "Arguments list is empty");
|
||||
|
||||
ListBuffer<Type> dynamicArgs = new ListBuffer<>();
|
||||
for (JCTree arg : t) {
|
||||
Object constVal = arg.type.constValue();
|
||||
if ("".equals(constVal)) continue;
|
||||
if (arg.type == syms.botType) {
|
||||
dynamicArgs.add(types.boxedClass(syms.voidType).type);
|
||||
} else {
|
||||
dynamicArgs.add(arg.type);
|
||||
}
|
||||
gen.genExpr(arg, arg.type).load();
|
||||
}
|
||||
|
||||
doCall(type, pos, dynamicArgs.toList());
|
||||
}
|
||||
|
||||
// More that one peel slice produced: concatenate the results
|
||||
if (split.size() > 1) {
|
||||
ListBuffer<Type> argTypes = new ListBuffer<>();
|
||||
for (int c = 0; c < split.size(); c++) {
|
||||
argTypes.append(syms.stringType);
|
||||
}
|
||||
doCall(type, pos, argTypes.toList());
|
||||
}
|
||||
}
|
||||
|
||||
/** Produce the actual invokedynamic call to StringConcatFactory */
|
||||
private void doCall(Type type, JCDiagnostic.DiagnosticPosition pos, List<Type> dynamicArgTypes) {
|
||||
Type.MethodType indyType = new Type.MethodType(dynamicArgTypes,
|
||||
type,
|
||||
List.<Type>nil(),
|
||||
syms.methodClass);
|
||||
|
||||
int prevPos = make.pos;
|
||||
try {
|
||||
make.at(pos);
|
||||
|
||||
List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType,
|
||||
syms.stringType,
|
||||
syms.methodTypeType);
|
||||
|
||||
Symbol bsm = rs.resolveInternalMethod(pos,
|
||||
gen.getAttrEnv(),
|
||||
syms.stringConcatFactory,
|
||||
names.makeConcat,
|
||||
bsm_staticArgs,
|
||||
null);
|
||||
|
||||
Symbol.DynamicMethodSymbol dynSym = new Symbol.DynamicMethodSymbol(names.makeConcat,
|
||||
syms.noSymbol,
|
||||
ClassFile.REF_invokeStatic,
|
||||
(Symbol.MethodSymbol)bsm,
|
||||
indyType,
|
||||
List.nil().toArray());
|
||||
|
||||
Items.Item item = gen.getItems().makeDynamicItem(dynSym);
|
||||
item.invoke();
|
||||
} finally {
|
||||
make.at(prevPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits the invokedynamic call to JDK java.lang.invoke.StringConcatFactory.
|
||||
* This code concatenates all known constants into the recipe, possibly escaping
|
||||
* some constants separately.
|
||||
*
|
||||
* We also bypass empty strings, because they have no meaning at this level. This
|
||||
* captures the Java language trick to force String concat with e.g. ("" + int)-like
|
||||
* expression. Down here, we already know we are in String concat business, and do
|
||||
* not require these markers.
|
||||
*/
|
||||
private static final class IndyConstants extends Indy {
|
||||
public IndyConstants(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void emit(List<JCTree> args, Type type, JCDiagnostic.DiagnosticPosition pos) {
|
||||
List<List<JCTree>> split = split(args);
|
||||
|
||||
for (List<JCTree> t : split) {
|
||||
Assert.check(!t.isEmpty(), "Arguments list is empty");
|
||||
|
||||
StringBuilder recipe = new StringBuilder(t.size());
|
||||
ListBuffer<Type> dynamicArgs = new ListBuffer<>();
|
||||
ListBuffer<Object> staticArgs = new ListBuffer<>();
|
||||
|
||||
for (JCTree arg : t) {
|
||||
Object constVal = arg.type.constValue();
|
||||
if ("".equals(constVal)) continue;
|
||||
if (arg.type == syms.botType) {
|
||||
// Concat the null into the recipe right away
|
||||
recipe.append((String) null);
|
||||
} else if (constVal != null) {
|
||||
// Concat the String representation of the constant, except
|
||||
// for the case it contains special tags, which requires us
|
||||
// to expose it as detached constant.
|
||||
String a = arg.type.stringValue();
|
||||
if (a.indexOf(TAG_CONST) != -1 || a.indexOf(TAG_ARG) != -1) {
|
||||
recipe.append(TAG_CONST);
|
||||
staticArgs.add(a);
|
||||
} else {
|
||||
recipe.append(a);
|
||||
}
|
||||
} else {
|
||||
// Ordinary arguments come through the dynamic arguments.
|
||||
recipe.append(TAG_ARG);
|
||||
dynamicArgs.add(arg.type);
|
||||
gen.genExpr(arg, arg.type).load();
|
||||
}
|
||||
}
|
||||
|
||||
doCall(type, pos, recipe.toString(), staticArgs.toList(), dynamicArgs.toList());
|
||||
}
|
||||
|
||||
// More that one peel slice produced: concatenate the results
|
||||
// All arguments are assumed to be non-constant Strings.
|
||||
if (split.size() > 1) {
|
||||
ListBuffer<Type> argTypes = new ListBuffer<>();
|
||||
StringBuilder recipe = new StringBuilder();
|
||||
for (int c = 0; c < split.size(); c++) {
|
||||
argTypes.append(syms.stringType);
|
||||
recipe.append(TAG_ARG);
|
||||
}
|
||||
doCall(type, pos, recipe.toString(), List.nil(), argTypes.toList());
|
||||
}
|
||||
}
|
||||
|
||||
/** Produce the actual invokedynamic call to StringConcatFactory */
|
||||
private void doCall(Type type, JCDiagnostic.DiagnosticPosition pos, String recipe, List<Object> staticArgs, List<Type> dynamicArgTypes) {
|
||||
Type.MethodType indyType = new Type.MethodType(dynamicArgTypes,
|
||||
type,
|
||||
List.<Type>nil(),
|
||||
syms.methodClass);
|
||||
|
||||
int prevPos = make.pos;
|
||||
try {
|
||||
make.at(pos);
|
||||
|
||||
ListBuffer<Type> constTypes = new ListBuffer<>();
|
||||
ListBuffer<Object> constants = new ListBuffer<>();
|
||||
for (Object t : staticArgs) {
|
||||
constants.add(t);
|
||||
constTypes.add(syms.stringType);
|
||||
}
|
||||
|
||||
List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType,
|
||||
syms.stringType,
|
||||
syms.methodTypeType)
|
||||
.append(syms.stringType)
|
||||
.appendList(constTypes);
|
||||
|
||||
Symbol bsm = rs.resolveInternalMethod(pos,
|
||||
gen.getAttrEnv(),
|
||||
syms.stringConcatFactory,
|
||||
names.makeConcatWithConstants,
|
||||
bsm_staticArgs,
|
||||
null);
|
||||
|
||||
Symbol.DynamicMethodSymbol dynSym = new Symbol.DynamicMethodSymbol(names.makeConcatWithConstants,
|
||||
syms.noSymbol,
|
||||
ClassFile.REF_invokeStatic,
|
||||
(Symbol.MethodSymbol)bsm,
|
||||
indyType,
|
||||
List.<Object>of(recipe).appendList(constants).toArray());
|
||||
|
||||
Items.Item item = gen.getItems().makeDynamicItem(dynSym);
|
||||
item.invoke();
|
||||
} finally {
|
||||
make.at(prevPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -135,4 +135,10 @@ public enum Target {
|
||||
return hasInvokedynamic();
|
||||
}
|
||||
|
||||
/** Does the target JDK contain StringConcatFactory class?
|
||||
*/
|
||||
public boolean hasStringConcatFactory() {
|
||||
return compareTo(JDK1_9) >= 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -179,6 +179,10 @@ public class Names {
|
||||
public final Name altMetafactory;
|
||||
public final Name dollarThis;
|
||||
|
||||
// string concat
|
||||
public final Name makeConcat;
|
||||
public final Name makeConcatWithConstants;
|
||||
|
||||
public final Name.Table table;
|
||||
|
||||
public Names(Context context) {
|
||||
@ -316,6 +320,10 @@ public class Names {
|
||||
lambda = fromString("lambda$");
|
||||
metafactory = fromString("metafactory");
|
||||
altMetafactory = fromString("altMetafactory");
|
||||
|
||||
// string concat
|
||||
makeConcat = fromString("makeConcat");
|
||||
makeConcatWithConstants = fromString("makeConcatWithConstants");
|
||||
}
|
||||
|
||||
protected Name.Table createTable(Options options) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 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
|
||||
@ -24,6 +24,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
<p style="font-style: italic; font-size:larger">
|
||||
<b>Note:</b> The declarations in this package have been superseded by those
|
||||
in the package {@code jdk.javadoc.doclet}.
|
||||
</p>
|
||||
|
||||
The Doclet API (also called the Javadoc API) provides a mechanism
|
||||
for clients to inspect the source-level structure of programs and
|
||||
libraries, including javadoc comments embedded in the source.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 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
|
||||
@ -29,7 +29,14 @@ import com.sun.javadoc.*;
|
||||
|
||||
/**
|
||||
* The interface for a custom tag used by Doclets. A custom
|
||||
* tag must implement this interface. To be loaded and used by
|
||||
* tag must implement this interface.
|
||||
*
|
||||
* <p style="font-style: italic; font-size:larger">
|
||||
* <b>Note:</b> This interface has been superseded by one
|
||||
* in the new package {@code jdk.javadoc.doclet.taglet}.
|
||||
* </p>
|
||||
*
|
||||
* To be loaded and used by
|
||||
* doclets at run-time, the taglet must have a static method called
|
||||
* <code>register</code> that accepts a {@link java.util.Map} as an
|
||||
* argument with the following signature:
|
||||
|
||||
@ -31,4 +31,5 @@
|
||||
This code and its internal interfaces are subject to change or
|
||||
deletion without notice.</b>
|
||||
*/
|
||||
|
||||
package com.sun.tools.doclets.formats.html.markup;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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
|
||||
@ -24,8 +24,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
This is the default doclet provided with JDK that produces Javadoc's
|
||||
default HTML-formatted API output. For more documentation
|
||||
This produces Javadoc's HTML-formatted API output. For more documentation
|
||||
on this doclet, please refer to the link below.
|
||||
|
||||
@see <a href="http://www.java.sun.com/javadoc/standard-doclet.html">
|
||||
@ -36,4 +35,5 @@
|
||||
This code and its internal interfaces are subject to change or
|
||||
deletion without notice.</b>
|
||||
*/
|
||||
|
||||
package com.sun.tools.doclets.formats.html;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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
|
||||
@ -29,6 +29,7 @@ import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.tools.JavaFileManager;
|
||||
|
||||
import com.sun.javadoc.*;
|
||||
@ -37,6 +38,7 @@ import com.sun.tools.javac.jvm.Profile;
|
||||
import com.sun.tools.doclets.internal.toolkit.builders.BuilderFactory;
|
||||
import com.sun.tools.doclets.internal.toolkit.taglets.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.*;
|
||||
import com.sun.tools.doclets.internal.toolkit.util.VisibleMemberMap.GetterSetter;
|
||||
import com.sun.tools.javac.util.StringUtils;
|
||||
|
||||
/**
|
||||
@ -304,6 +306,13 @@ public abstract class Configuration {
|
||||
*/
|
||||
public SortedSet<PackageDoc> packages;
|
||||
|
||||
// The following three fields provide caches for use by all instances of VisibleMemberMap.
|
||||
public final Map<ClassDoc, ProgramElementDoc[]> propertiesCache = new HashMap<>();
|
||||
public final Map<ProgramElementDoc, ProgramElementDoc> classPropertiesMap = new HashMap<>();
|
||||
public final Map<ProgramElementDoc, GetterSetter> getterSetterMap = new HashMap<>();
|
||||
|
||||
public DocFileFactory docFileFactory;
|
||||
|
||||
/**
|
||||
* Constructor. Constructs the message retriever with resource file.
|
||||
*/
|
||||
|
||||
@ -37,4 +37,5 @@
|
||||
This code and its internal interfaces are subject to change or
|
||||
deletion without notice.</b>
|
||||
*/
|
||||
|
||||
package com.sun.tools.doclets.internal.toolkit.builders;
|
||||
|
||||
@ -53,4 +53,5 @@
|
||||
This code and its internal interfaces are subject to change or
|
||||
deletion without notice.</b>
|
||||
*/
|
||||
|
||||
package com.sun.tools.doclets.internal.toolkit;
|
||||
|
||||
@ -48,4 +48,5 @@
|
||||
This code and its internal interfaces are subject to change or
|
||||
deletion without notice.</b>
|
||||
*/
|
||||
|
||||
package com.sun.tools.doclets.internal.toolkit.taglets;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 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
|
||||
@ -25,9 +25,6 @@
|
||||
|
||||
package com.sun.tools.doclets.internal.toolkit.util;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import javax.tools.JavaFileManager;
|
||||
import javax.tools.JavaFileManager.Location;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
@ -45,15 +42,13 @@ import com.sun.tools.doclets.internal.toolkit.Configuration;
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
abstract class DocFileFactory {
|
||||
private static final Map<Configuration, DocFileFactory> factories = new WeakHashMap<>();
|
||||
|
||||
public abstract class DocFileFactory {
|
||||
/**
|
||||
* Get the appropriate factory, based on the file manager given in the
|
||||
* configuration.
|
||||
*/
|
||||
static synchronized DocFileFactory getFactory(Configuration configuration) {
|
||||
DocFileFactory f = factories.get(configuration);
|
||||
DocFileFactory f = configuration.docFileFactory;
|
||||
if (f == null) {
|
||||
JavaFileManager fm = configuration.getFileManager();
|
||||
if (fm instanceof StandardJavaFileManager) {
|
||||
@ -61,7 +56,7 @@ abstract class DocFileFactory {
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
factories.put(configuration, f);
|
||||
configuration.docFileFactory = f;
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
@ -101,9 +101,9 @@ public class VisibleMemberMap {
|
||||
private final Configuration configuration;
|
||||
private final Utils utils;
|
||||
|
||||
private static final Map<ClassDoc, ProgramElementDoc[]> propertiesCache = new HashMap<>();
|
||||
private static final Map<ProgramElementDoc, ProgramElementDoc> classPropertiesMap = new HashMap<>();
|
||||
private static final Map<ProgramElementDoc, GetterSetter> getterSetterMap = new HashMap<>();
|
||||
private final Map<ClassDoc, ProgramElementDoc[]> propertiesCache;
|
||||
private final Map<ProgramElementDoc, ProgramElementDoc> classPropertiesMap;
|
||||
private final Map<ProgramElementDoc, GetterSetter> getterSetterMap;
|
||||
|
||||
/**
|
||||
* Construct a VisibleMemberMap of the given type for the given
|
||||
@ -123,6 +123,9 @@ public class VisibleMemberMap {
|
||||
this.kind = kind;
|
||||
this.configuration = configuration;
|
||||
this.utils = configuration.utils;
|
||||
propertiesCache = configuration.propertiesCache;
|
||||
classPropertiesMap = configuration.classPropertiesMap;
|
||||
getterSetterMap = configuration.getterSetterMap;
|
||||
new ClassMembers(classdoc, STARTLEVEL).build();
|
||||
}
|
||||
|
||||
@ -713,7 +716,7 @@ public class VisibleMemberMap {
|
||||
}
|
||||
}
|
||||
|
||||
private class GetterSetter {
|
||||
public class GetterSetter {
|
||||
private final ProgramElementDoc getter;
|
||||
private final ProgramElementDoc setter;
|
||||
|
||||
|
||||
@ -31,4 +31,5 @@
|
||||
This code and its internal interfaces are subject to change or
|
||||
deletion without notice.</b>
|
||||
*/
|
||||
|
||||
package com.sun.tools.doclets.internal.toolkit.util.links;
|
||||
|
||||
@ -32,4 +32,5 @@
|
||||
This code and its internal interfaces are subject to change or
|
||||
deletion without notice.</b>
|
||||
*/
|
||||
|
||||
package com.sun.tools.doclets.internal.toolkit.util;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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
|
||||
@ -24,6 +24,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
<p style="font-style: italic; font-size:larger">
|
||||
<b>Note:</b> The declarations in this package have been superseded by those
|
||||
in the new package {@code jdk.javadoc.doclet}.
|
||||
</p>
|
||||
|
||||
As of JDK version 1.5, replaced by
|
||||
{@code com.sun.tools.doclets.internal.toolkit.util}.
|
||||
|
||||
@ -32,4 +37,5 @@
|
||||
This code and its internal interfaces are subject to change or
|
||||
deletion without notice.</b>
|
||||
*/
|
||||
|
||||
package com.sun.tools.doclets;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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
|
||||
@ -103,7 +103,11 @@ public class Start extends ToolOption.Helper {
|
||||
this(programName, errWriter, warnWriter, noticeWriter, defaultDocletClassName, null);
|
||||
}
|
||||
|
||||
Start(String programName,
|
||||
public Start(PrintWriter pw) {
|
||||
this(javadocName, pw, pw, pw, standardDocletClassName);
|
||||
}
|
||||
|
||||
public Start(String programName,
|
||||
PrintWriter errWriter,
|
||||
PrintWriter warnWriter,
|
||||
PrintWriter noticeWriter,
|
||||
@ -139,7 +143,7 @@ public class Start extends ToolOption.Helper {
|
||||
this(javadocName, docletParentClassLoader);
|
||||
}
|
||||
|
||||
Start() {
|
||||
public Start() {
|
||||
this(javadocName);
|
||||
}
|
||||
|
||||
@ -212,7 +216,7 @@ public class Start extends ToolOption.Helper {
|
||||
/**
|
||||
* Main program - external wrapper
|
||||
*/
|
||||
int begin(String... argv) {
|
||||
public int begin(String... argv) {
|
||||
boolean ok = begin(null, argv, Collections.<JavaFileObject> emptySet());
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
|
||||
@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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
|
||||
* 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.doclet;
|
||||
|
||||
import java.util.ListIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
|
||||
/**
|
||||
* The user doclet must implement this interface, as described in the
|
||||
* <a href="package-summary.html#package_description">package description</a>.
|
||||
* Each implementation of a Doclet must provide a public no-argument constructor
|
||||
* to be used by tools to instantiate the doclet. The tool infrastructure will
|
||||
* interact with classes implementing this interface as follows:
|
||||
* <ol>
|
||||
* <li> The tool will create an instance of a doclet using the no-arg constructor
|
||||
* of the doclet class.
|
||||
* <li> Next, the tool calls the {@link #init init} method with an appropriate locale
|
||||
* and reporter.
|
||||
* <li> Afterwards, the tool calls {@link #getSupportedOptions getSupportedOptions},
|
||||
* and {@link #getSupportedSourceVersion getSupportedSourceVersion}.
|
||||
* These methods are only called once.
|
||||
* <li> As appropriate, the tool calls the {@link #run run} method on the doclet
|
||||
* object, giving it a DocletEnvironment object, from which the doclet can determine
|
||||
* the elements to be included in the documentation.
|
||||
* </ol>
|
||||
* <p>
|
||||
* If a doclet object is created and used without the above protocol being followed,
|
||||
* then the doclet's behavior is not defined by this interface specification.
|
||||
* <p> To start the doclet, pass {@code -doclet} followed by the fully-qualified
|
||||
* name of the entry point class (i.e. the implementation of this interface) on
|
||||
* the javadoc tool command line.
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public interface Doclet {
|
||||
|
||||
/**
|
||||
* Initializes this doclet with the given locale and error reporter.
|
||||
* This locale will be used by the reporter and the doclet components.
|
||||
* It is recommended to call this as early as possible, for a
|
||||
* uniform localized user experience,
|
||||
* @param locale the locale to be used
|
||||
* @param reporter the reporter to be used
|
||||
*/
|
||||
public void init(Locale locale, Reporter reporter);
|
||||
|
||||
/**
|
||||
* Returns a name identifying the doclet. A name is a simple identifier
|
||||
* without white spaces, as defined in <cite>The Java™ Language Specification</cite>,
|
||||
* section 6.2 "Names and Identifiers".
|
||||
* @return name of the Doclet
|
||||
*/
|
||||
public abstract String getName();
|
||||
|
||||
/**
|
||||
* Returns all the supported options.
|
||||
*
|
||||
* @return a Set containing all the supported options, an empty set if none.
|
||||
*/
|
||||
public Set<Option> getSupportedOptions();
|
||||
|
||||
/**
|
||||
* Returns the version of the Java Programming Language supported
|
||||
* by this doclet.
|
||||
*
|
||||
* @return the language version supported by this doclet, usually
|
||||
* the latest version.
|
||||
*/
|
||||
public SourceVersion getSupportedSourceVersion();
|
||||
|
||||
/**
|
||||
* The entry point of the doclet. Further processing will commence as
|
||||
* instructed by this method.
|
||||
*
|
||||
* @param environment from which essential information can be extracted
|
||||
* @return true on success
|
||||
*/
|
||||
public boolean run(DocletEnvironment environment);
|
||||
|
||||
/**
|
||||
* An encapsulation of option name, aliases, parameters and descriptions
|
||||
* as used by the Doclet.
|
||||
*/
|
||||
interface Option {
|
||||
/**
|
||||
* Returns the number of arguments, this option will consume.
|
||||
* @return number of consumed arguments
|
||||
*/
|
||||
int getArgumentCount();
|
||||
|
||||
/**
|
||||
* Returns the description of the option. For instance, the option "group", would
|
||||
* return the synopsis of the option such as, "groups the documents".
|
||||
* @return description if set, otherwise an empty String
|
||||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* Returns the option kind.
|
||||
* @return the kind of this option
|
||||
*/
|
||||
Option.Kind getKind();
|
||||
|
||||
/**
|
||||
* Returns the option name. For instance for option "-group", will return "group"
|
||||
* @return name of the option, if set, otherwise an empty String
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Returns the parameters of the option. For instance "name <p1>:<p2>.."
|
||||
* @return parameters if set, otherwise an empty String
|
||||
*/
|
||||
String getParameters();
|
||||
|
||||
/**
|
||||
* Checks if the given option name is handled by this option.
|
||||
* @param option the option name with or without the leading "-"
|
||||
* @return true if same
|
||||
*/
|
||||
boolean matches(String option);
|
||||
|
||||
/**
|
||||
* Processes the option and arguments as needed. This method will
|
||||
* be invoked if the given option name matches the option.
|
||||
* @param option the option
|
||||
* @param arguments a ListIterator encapsulating the arguments
|
||||
* @return true if operation succeeded, false otherwise
|
||||
*/
|
||||
boolean process(String option, ListIterator<String> arguments);
|
||||
|
||||
/**
|
||||
* The kind of an option.
|
||||
*/
|
||||
public static enum Kind {
|
||||
/** an extended option, such as those prefixed with -X */
|
||||
EXTENDED,
|
||||
/** a standard option */
|
||||
STANDARD,
|
||||
/** an implementation reserved option */
|
||||
OTHER;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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
|
||||
* 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.doclet;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.util.Elements;
|
||||
import javax.lang.model.util.Types;
|
||||
import javax.tools.JavaFileManager;
|
||||
|
||||
import com.sun.source.util.DocTrees;
|
||||
|
||||
/**
|
||||
* Represents the operating environment of a single invocation
|
||||
* of the doclet. This object can be used to access the program
|
||||
* structures, various utilities and the user specified elements
|
||||
* on the command line.
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public interface DocletEnvironment {
|
||||
/**
|
||||
* Returns the <a href="package-summary.html#included">included</a>
|
||||
* classes, interfaces and enums in all packages.
|
||||
*
|
||||
* @return a Set containing {@link javax.lang.model.element.TypeElement TypeElements}.
|
||||
*/
|
||||
Set<TypeElement> getIncludedClasses();
|
||||
|
||||
/**
|
||||
* Returns an instance of the {@code DocTrees} utility class.
|
||||
* This class provides methods to access {@code TreePath}s, {@code DocCommentTree}s
|
||||
* and so on.
|
||||
* @return a utility class to operate on doc trees.
|
||||
*/
|
||||
DocTrees getDocTrees();
|
||||
|
||||
/**
|
||||
* Returns an instance of the {@code Elements} utility class.
|
||||
* This class provides methods for operating on
|
||||
* {@link javax.lang.model.element.Element elements}.
|
||||
* @return a utility class to operate on elements
|
||||
*/
|
||||
Elements getElementUtils();
|
||||
|
||||
/**
|
||||
* Returns the selected elements that can be documented.
|
||||
*
|
||||
* @param elements those that need to be checked
|
||||
* @return elements selected, an empty list if none.
|
||||
*/
|
||||
List<Element> getSelectedElements(List<? extends Element> elements);
|
||||
|
||||
/**
|
||||
* Returns the elements <a href="package-summary.html#included">specified</a>
|
||||
* on the command line, usually PackageElements and TypeElements.
|
||||
* If {@code -subpackages} and {@code -exclude} options
|
||||
* are used, return all the non-excluded packages.
|
||||
*
|
||||
* @return elements specified on the command line.
|
||||
*/
|
||||
Set<Element> getSpecifiedElements();
|
||||
|
||||
/**
|
||||
* Returns an instance of the {@code Types} utility class.
|
||||
* This class provides methods for operating on
|
||||
* {@link javax.lang.model.type.TypeMirror type mirrors}.
|
||||
* @return a utility class to operate on type mirrors
|
||||
*/
|
||||
Types getTypeUtils();
|
||||
|
||||
/**
|
||||
* Indicates if an element is <a href="package-summary.html#included">included</a>.
|
||||
*
|
||||
* @param e the Element in question
|
||||
* @return true if included, false otherwise
|
||||
*/
|
||||
boolean isIncluded(Element e);
|
||||
|
||||
/**
|
||||
* Returns the file manager used to read and write files.
|
||||
*
|
||||
* @return the file manager used to read and write files
|
||||
*/
|
||||
JavaFileManager getJavaFileManager();
|
||||
|
||||
/**
|
||||
* Returns the source version of the source files that were read.
|
||||
*
|
||||
* @return the source version
|
||||
*/
|
||||
SourceVersion getSourceVersion();
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.doclet;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
import com.sun.source.util.DocTreePath;
|
||||
|
||||
/**
|
||||
* This interface provides error, warning and notice reporting.
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public interface Reporter {
|
||||
|
||||
/**
|
||||
* Print error message and increment error count.
|
||||
*
|
||||
* @param kind specify the diagnostic kind
|
||||
* @param msg message to print
|
||||
*/
|
||||
void print(Diagnostic.Kind kind, String msg);
|
||||
|
||||
/**
|
||||
* Print an error message and increment error count.
|
||||
*
|
||||
* @param kind specify the diagnostic kind
|
||||
* @param path the DocTreePath of item where the error occurs
|
||||
* @param msg message to print
|
||||
*/
|
||||
void print(Diagnostic.Kind kind, DocTreePath path, String msg);
|
||||
|
||||
/**
|
||||
* Print an error message and increment error count.
|
||||
*
|
||||
* @param kind specify the diagnostic kind
|
||||
* @param e the Element for which the error occurs
|
||||
* @param msg message to print
|
||||
*/
|
||||
void print(Diagnostic.Kind kind, Element e, String msg);
|
||||
}
|
||||
@ -0,0 +1,251 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Doclet API provides an environment which, in conjunction with
|
||||
* the Language Model API and Compiler Tree API, allows clients
|
||||
* to inspect the source-level structures of programs and
|
||||
* libraries, including javadoc comments embedded in the source.
|
||||
*
|
||||
* <p style="font-style: italic">
|
||||
* <b>Note:</b> The declarations in this package supersede those
|
||||
* in the older package {@code com.sun.javadoc}. For details on the
|
||||
* mapping of old types to new types, see the
|
||||
* <a href="#migration">Migration Guide</a>.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Doclets are invoked by javadoc and this API can be used to write out
|
||||
* program information to files. For example, the standard doclet is
|
||||
* invoked by default, to generate HTML documentation.
|
||||
* <p>
|
||||
|
||||
* The invocation is defined by the interface {@link jdk.javadoc.doclet.Doclet}
|
||||
* -- the {@link jdk.javadoc.doclet.Doclet#run(DocletEnvironment) run} interface
|
||||
* method, defines the entry point.
|
||||
* <pre>
|
||||
* public boolean <b>run</b>(DocletEnvironment environment)
|
||||
* </pre>
|
||||
* The {@link jdk.javadoc.doclet.DocletEnvironment} instance holds the environment that the
|
||||
* doclet will be initialized with. From this environment all other information can be
|
||||
* extracted, in the form of {@link javax.lang.model} elements. One can further use the
|
||||
* APIs and utilities described by {@link javax.lang.model} to query Elements and Types.
|
||||
* <p>
|
||||
*
|
||||
* <a name="terminology"></a>
|
||||
* <h3>Terminology</h3>
|
||||
*
|
||||
* <a name="included"></a>
|
||||
* When calling javadoc, one can pass in package names and source file names --
|
||||
* these are called the <em>specified</em> PackageElements and TypeElements.
|
||||
* Javadoc options are also passed in; the <em>access control</em> Javadoc options
|
||||
* ({@code -public}, {@code -protected}, {@code -package},
|
||||
* and {@code -private}) are used to filter program elements, producing a
|
||||
* result set, called the <em>included</em> set, or "selected" set.
|
||||
* <p>
|
||||
|
||||
* <a name="qualified"></a>
|
||||
* A <em>qualified</em> element name is one that has its package
|
||||
* name prepended to it, such as {@code java.lang.String}. A non-qualified
|
||||
* name has no package name, such as {@code String}.
|
||||
* <p>
|
||||
*
|
||||
* <a name="example"></a>
|
||||
* <h3>Example</h3>
|
||||
*
|
||||
* The following is an example doclet that displays information of a class
|
||||
* and its members, supporting an option "someoption".
|
||||
* <pre>
|
||||
* import com.sun.source.doctree.DocCommentTree;
|
||||
* import com.sun.source.util.DocTrees;
|
||||
* import java.io.IOException;
|
||||
* import java.util.Collections;
|
||||
* import java.util.Set;
|
||||
* import javax.lang.model.SourceVersion;
|
||||
* import javax.lang.model.element.Element;
|
||||
* import javax.lang.model.element.TypeElement;
|
||||
* import jdk.javadoc.doclet.*;
|
||||
*
|
||||
* public class Example implements Doclet {
|
||||
*
|
||||
* @Override
|
||||
* public void init(Locale locale, Reporter reporter) {
|
||||
* return;
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public boolean run(RootDoc root) {
|
||||
* // cache the DocTrees utility class to access DocComments
|
||||
* DocTrees docTrees = root.getDocTrees();
|
||||
*
|
||||
* // location of an element in the same directory as overview.html
|
||||
* try {
|
||||
* Element barElement = null;
|
||||
* for (Element e : root.getIncludedClasses()) {
|
||||
* if (e.getSimpleName().toString().equals("FooBar")) {
|
||||
* barElement = e;
|
||||
* }
|
||||
* }
|
||||
* DocCommentTree docCommentTree =
|
||||
* docTrees.getDocCommentTree(barElement, "overview.html");
|
||||
* if (docCommentTree != null) {
|
||||
* System.out.println("Overview html: " +
|
||||
* docCommentTree.getFullBody());
|
||||
* }
|
||||
* } catch (IOException missing) {
|
||||
* System.err.println("No overview.html found.");
|
||||
* }
|
||||
*
|
||||
* for (TypeElement t : root.getIncludedClasses()) {
|
||||
* System.out.println(t.getKind() + ":" + t);
|
||||
* for (Element e : t.getEnclosedElements()) {
|
||||
* DocCommentTree docCommentTree = docTrees.getDocCommentTree(e);
|
||||
* if (docCommentTree != null) {
|
||||
* System.out.println("Element (" + e.getKind() + ": " +
|
||||
* e + ") has the following comments:");
|
||||
* System.out.println("Entire body: " + docCommentTree.getFullBody());
|
||||
* System.out.println("Block tags: " + docCommentTree.getBlockTags());
|
||||
* } else {
|
||||
* System.out.println("no comment.");
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* return true;
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public String getName() {
|
||||
* return "Example";
|
||||
* }
|
||||
*
|
||||
* private String someOption;
|
||||
*
|
||||
* @Override
|
||||
* public Set<Option> getSupportedOptions() {
|
||||
* Option[] options = {
|
||||
* new Option() {
|
||||
* public int getArgumentCount() {
|
||||
* return 1;
|
||||
* }
|
||||
* public String getDescription() {
|
||||
* return "someoption";
|
||||
* }
|
||||
* public Option.Kind getKind() {
|
||||
* return Option.Kind.STANDARD;
|
||||
* }
|
||||
* public String getName() {
|
||||
* return "someoption";
|
||||
* }
|
||||
* public String getParameters() {
|
||||
* return "url";
|
||||
* }
|
||||
* public boolean matches(String option) {
|
||||
* String opt = option.startsWith("-") ? option.substring(1) : option;
|
||||
* return getName().equals(opt);
|
||||
* }
|
||||
* public boolean process(String option, ListIterator<String> arguments) {
|
||||
* overviewpath = arguments.next();
|
||||
* return true;
|
||||
* }
|
||||
* }
|
||||
* };
|
||||
* return new HashSet<Option>(Arrays.asList(options));
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public SourceVersion getSupportedSourceVersion() {
|
||||
* // support the latest release
|
||||
* return SourceVersion.latest();
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* <p>
|
||||
* This doclet when invoked with a command line, such as:
|
||||
* <pre>
|
||||
* javadoc -doclet Example -sourcepath <source-location>
|
||||
* </pre>
|
||||
* will produce an output, such as:
|
||||
* <pre>
|
||||
* Overview.html: overview comments
|
||||
* ...
|
||||
* ...
|
||||
* CLASS: SomeKlass
|
||||
* .....
|
||||
* Element (METHOD: main(java.lang.String...)) has the following comments:
|
||||
* Entire body: The main entry point.
|
||||
* Block tags: @param an array of Strings
|
||||
* ...
|
||||
* </pre>
|
||||
*
|
||||
* <h3><a name="migration">Migration Guide</a></h3>
|
||||
*
|
||||
* <p>Many of the types in the old {@code com.sun.javadoc} API do not have equivalents in this
|
||||
* package. Instead, types in the {@code javax.lang.model} and {@code com.sun.source} APIs
|
||||
* are used instead.
|
||||
*
|
||||
* <p>The following table gives a guide to the mapping from old types to their replacements.
|
||||
* In some cases, there is no direct equivalent.
|
||||
*
|
||||
* <table style="font-family: monospace" border=1>
|
||||
<caption>Guide for mapping old types to new types</caption>
|
||||
<tr><th>Old Type<th>New Type
|
||||
<tr><td>AnnotatedType<td>javax.lang.model.type.Type
|
||||
<tr><td>AnnotationDesc<td>javax.lang.model.element.AnnotationMirror
|
||||
<tr><td>AnnotationDesc.ElementValuePair<td>javax.lang.model.element.AnnotationValue
|
||||
<tr><td>AnnotationTypeDoc<td>javax.lang.model.element.TypeElement
|
||||
<tr><td>AnnotationTypeElementDoc<td>javax.lang.model.element.ExecutableElement
|
||||
<tr><td>AnnotationValue<td>javax.lang.model.element.AnnotationValue
|
||||
<tr><td>ClassDoc<td>javax.lang.model.element.TypeElement
|
||||
<tr><td>ConstructorDoc<td>javax.lang.model.element.ExecutableElement
|
||||
<tr><td>Doc<td>javax.lang.model.element.Element
|
||||
<tr><td>DocErrorReporter<td>jdk.javadoc.doclet.Reporter
|
||||
<tr><td>Doclet<td>jdk.javadoc.doclet.Doclet
|
||||
<tr><td>ExecutableMemberDoc<td>javax.lang.model.element.ExecutableElement
|
||||
<tr><td>FieldDoc<td>javax.lang.model.element.VariableElement
|
||||
<tr><td>LanguageVersion<td>javax.lang.model.SourceVersion
|
||||
<tr><td>MemberDoc<td>javax.lang.model.element.Element
|
||||
<tr><td>MethodDoc<td>javax.lang.model.element.ExecutableElement
|
||||
<tr><td>PackageDoc<td>javax.lang.model.element.PackageElement
|
||||
<tr><td>Parameter<td>javax.lang.model.element.VariableElement
|
||||
<tr><td>ParameterizedType<td>javax.lang.model.type.DeclaredType
|
||||
<tr><td>ParamTag<td>com.sun.source.doctree.ParamTree
|
||||
<tr><td>ProgramElementDoc<td>javax.lang.model.element.Element
|
||||
<tr><td>RootDoc<td>jdk.javadoc.doclet.DocletEnvironment
|
||||
<tr><td>SeeTag<td>com.sun.source.doctree.LinkTree<br>com.sun.source.doctree.SeeTree
|
||||
<tr><td>SerialFieldTag<td>com.sun.source.doctree.SerialFieldTree
|
||||
<tr><td>SourcePosition<td>com.sun.source.util.SourcePositions
|
||||
<tr><td>Tag<td>com.sun.source.doctree.DocTree
|
||||
<tr><td>ThrowsTag<td>com.sun.source.doctree.ThrowsTree
|
||||
<tr><td>Type<td>javax.lang.model.type.Type
|
||||
<tr><td>TypeVariable<td>javax.lang.model.type.TypeVariable
|
||||
<tr><td>WildcardType<td>javax.lang.model.type.WildcardType
|
||||
* </table>
|
||||
*
|
||||
* @see jdk.javadoc.doclet.Doclet
|
||||
* @see jdk.javadoc.doclet.DocletEnvironment
|
||||
* @since 9
|
||||
*/
|
||||
|
||||
package jdk.javadoc.doclet;
|
||||
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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
|
||||
* 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.doclet.taglet;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sun.source.doctree.DocTree;
|
||||
|
||||
/**
|
||||
* The interface for a custom tag used by Doclets. A custom
|
||||
* tag must implement this interface, and must have a public
|
||||
* default constructor (i.e. a public constructor with no
|
||||
* parameters), by which, the doclet will instantiate and
|
||||
* register the custom tag.
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
|
||||
public interface Taglet {
|
||||
|
||||
/**
|
||||
* Returns the set of locations in which a taglet may be used.
|
||||
* @return the set of locations in which a taglet may be used
|
||||
* allowed in or an empty set.
|
||||
*/
|
||||
Set<Location> getAllowedLocations();
|
||||
|
||||
/**
|
||||
* Indicates the tag is an inline or a body tag.
|
||||
* @return true if this <code>Taglet</code>
|
||||
* is an inline tag, false otherwise.
|
||||
*/
|
||||
public abstract boolean isInlineTag();
|
||||
|
||||
/**
|
||||
* Returns the name of the tag.
|
||||
* @return the name of this custom tag.
|
||||
*/
|
||||
public abstract String getName();
|
||||
|
||||
/**
|
||||
* Given the {@link DocTree DocTree} representation of this custom
|
||||
* tag, return its string representation, which is output
|
||||
* to the generated page.
|
||||
* @param tag the <code>Tag</code> representation of this custom tag.
|
||||
* @return the string representation of this <code>Tag</code>.
|
||||
*/
|
||||
public abstract String toString(DocTree tag);
|
||||
|
||||
/**
|
||||
* Given a List of {@link DocTree DocTrees} representing this custom
|
||||
* tag, return its string representation, which is output
|
||||
* to the generated page. This method should
|
||||
* return null if this taglet represents an inline or body tag.
|
||||
* @param tags the list of <code>DocTree</code>s representing this custom tag.
|
||||
* @return the string representation of this <code>Tag</code>.
|
||||
*/
|
||||
public abstract String toString(List<? extends DocTree> tags);
|
||||
|
||||
/**
|
||||
* The kind of location.
|
||||
*/
|
||||
public static enum Location {
|
||||
/** In an Overview document. */
|
||||
OVERVIEW,
|
||||
/** In the documentation for a package. */
|
||||
PACKAGE,
|
||||
/** In the documentation for a class, interface or enum. */
|
||||
TYPE,
|
||||
/** In the documentation for a constructor. */
|
||||
CONSTRUCTOR,
|
||||
/** In the documentation for a method. */
|
||||
METHOD,
|
||||
/** In the documentation for a field. */
|
||||
FIELD
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Taglet API provides a way to declare custom tags that can be
|
||||
* used by the standard doclet.
|
||||
*
|
||||
* <p style="font-style: italic">
|
||||
* <b>Note:</b> The declarations in this package supersede those
|
||||
* in the older package {@code com.sun.tools.doclets}.
|
||||
* </p>
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
package jdk.javadoc.doclet.taglet;
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 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
|
||||
@ -23,21 +23,20 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.javadoc.api;
|
||||
package jdk.javadoc.internal.api;
|
||||
|
||||
import com.sun.tools.javac.util.ClientCodeException;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.tools.DocumentationTool.DocumentationTask;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
import com.sun.tools.javac.util.ClientCodeException;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javadoc.Start;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.sun.tools.javac.util.DefinedBy;
|
||||
import com.sun.tools.javac.util.DefinedBy.Api;
|
||||
import jdk.javadoc.internal.tool.Start;
|
||||
|
||||
/**
|
||||
* Provides access to functionality specific to the JDK documentation tool,
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 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
|
||||
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.javadoc.api;
|
||||
package jdk.javadoc.internal.api;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@ -52,7 +52,7 @@ import com.sun.tools.javac.util.Context;
|
||||
import com.sun.tools.javac.util.DefinedBy;
|
||||
import com.sun.tools.javac.util.DefinedBy.Api;
|
||||
import com.sun.tools.javac.util.Log;
|
||||
import com.sun.tools.javadoc.ToolOption;
|
||||
import jdk.javadoc.internal.tool.ToolOption;
|
||||
|
||||
/**
|
||||
* Provides access to functionality specific to the JDK documentation tool,
|
||||
@ -150,10 +150,7 @@ public class JavadocTool implements DocumentationTool {
|
||||
PrintWriter err_pw = new PrintWriter(err == null ? System.err : err, true);
|
||||
PrintWriter out_pw = new PrintWriter(out == null ? System.out : out);
|
||||
try {
|
||||
String standardDocletName = "com.sun.tools.doclets.standard.Standard";
|
||||
ClassLoader cl = getClass().getClassLoader();
|
||||
return com.sun.tools.javadoc.Main.execute(
|
||||
"javadoc", err_pw, err_pw, out_pw, standardDocletName, cl, arguments);
|
||||
return jdk.javadoc.internal.tool.Main.execute(arguments, err_pw);
|
||||
} finally {
|
||||
err_pw.flush();
|
||||
out_pw.flush();
|
||||
@ -0,0 +1,352 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.lang.model.element.AnnotationMirror;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ElementKind;
|
||||
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.TypeMirror;
|
||||
import javax.lang.model.type.TypeVariable;
|
||||
import javax.lang.model.util.SimpleTypeVisitor9;
|
||||
|
||||
import com.sun.tools.javac.util.DefinedBy;
|
||||
import com.sun.tools.javac.util.DefinedBy.Api;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
|
||||
|
||||
import static jdk.javadoc.internal.doclets.formats.html.LinkInfoImpl.Kind.*;
|
||||
|
||||
/**
|
||||
* Print method and constructor info.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Robert Field
|
||||
* @author Atul M Dambalkar
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public abstract class AbstractExecutableMemberWriter extends AbstractMemberWriter {
|
||||
|
||||
public AbstractExecutableMemberWriter(SubWriterHolderWriter writer, TypeElement typeElement) {
|
||||
super(writer, typeElement);
|
||||
}
|
||||
|
||||
public AbstractExecutableMemberWriter(SubWriterHolderWriter writer) {
|
||||
super(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the type parameters for the executable member.
|
||||
*
|
||||
* @param member the member to write type parameters for.
|
||||
* @param htmltree the content tree to which the parameters will be added.
|
||||
*/
|
||||
protected void addTypeParameters(ExecutableElement member, Content htmltree) {
|
||||
Content typeParameters = getTypeParameters(member);
|
||||
if (!typeParameters.isEmpty()) {
|
||||
htmltree.addContent(typeParameters);
|
||||
htmltree.addContent(writer.getSpace());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type parameters for the executable member.
|
||||
*
|
||||
* @param member the member for which to get the type parameters.
|
||||
* @return the type parameters.
|
||||
*/
|
||||
protected Content getTypeParameters(ExecutableElement member) {
|
||||
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, MEMBER_TYPE_PARAMS, member);
|
||||
return writer.getTypeParameterLinks(linkInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content getDeprecatedLink(Element member) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(utils.getFullyQualifiedName(member));
|
||||
if (!utils.isConstructor(member)) {
|
||||
sb.append(".");
|
||||
sb.append(member.getSimpleName().toString());
|
||||
}
|
||||
sb.append(utils.flatSignature((ExecutableElement) member));
|
||||
|
||||
return writer.getDocLink(MEMBER, member, sb.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the summary link for the member.
|
||||
*
|
||||
* @param context the id of the context where the link will be printed
|
||||
* @param te the classDoc that we should link to
|
||||
* @param member the member being linked to
|
||||
* @param tdSummary the content tree to which the link will be added
|
||||
*/
|
||||
@Override
|
||||
protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement te, Element member,
|
||||
Content tdSummary) {
|
||||
ExecutableElement ee = (ExecutableElement)member;
|
||||
Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink,
|
||||
writer.getDocLink(context, te, ee,
|
||||
name(ee), false));
|
||||
Content code = HtmlTree.CODE(memberLink);
|
||||
addParameters(ee, false, code, name(ee).length() - 1);
|
||||
tdSummary.addContent(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the inherited summary link for the member.
|
||||
*
|
||||
* @param te the type element that we should link to
|
||||
* @param member the member being linked to
|
||||
* @param linksTree the content tree to which the link will be added
|
||||
*/
|
||||
@Override
|
||||
protected void addInheritedSummaryLink(TypeElement te, Element member, Content linksTree) {
|
||||
linksTree.addContent(writer.getDocLink(MEMBER, te, member, name(member), false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the parameter for the executable member.
|
||||
*
|
||||
* @param member the member to write parameter for.
|
||||
* @param param the parameter that needs to be written.
|
||||
* @param isVarArg true if this is a link to var arg.
|
||||
* @param tree the content tree to which the parameter information will be added.
|
||||
*/
|
||||
protected void addParam(ExecutableElement member, VariableElement param,
|
||||
boolean isVarArg, Content tree) {
|
||||
Content link = writer.getLink(new LinkInfoImpl(configuration, EXECUTABLE_MEMBER_PARAM,
|
||||
param.asType()).varargs(isVarArg));
|
||||
tree.addContent(link);
|
||||
if(name(param).length() > 0) {
|
||||
tree.addContent(writer.getSpace());
|
||||
tree.addContent(name(param));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the receiver annotations information.
|
||||
*
|
||||
* @param member the member to write receiver annotations for.
|
||||
* @param rcvrType the receiver type.
|
||||
* @param descList list of annotation description.
|
||||
* @param tree the content tree to which the information will be added.
|
||||
*/
|
||||
protected void addReceiverAnnotations(ExecutableElement member, TypeMirror rcvrType,
|
||||
List<? extends AnnotationMirror> annotationMirrors, Content tree) {
|
||||
writer.addReceiverAnnotationInfo(member, rcvrType, annotationMirrors, tree);
|
||||
tree.addContent(writer.getSpace());
|
||||
tree.addContent(utils.getTypeName(rcvrType, false));
|
||||
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, RECEIVER_TYPE, rcvrType);
|
||||
tree.addContent(writer.getTypeParameterLinks(linkInfo));
|
||||
tree.addContent(writer.getSpace());
|
||||
tree.addContent("this");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add all the parameters for the executable member.
|
||||
*
|
||||
* @param member the member to write parameters for.
|
||||
* @param htmltree the content tree to which the parameters information will be added.
|
||||
*/
|
||||
protected void addParameters(ExecutableElement member, Content htmltree, int indentSize) {
|
||||
addParameters(member, true, htmltree, indentSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all the parameters for the executable member.
|
||||
*
|
||||
* @param member the member to write parameters for.
|
||||
* @param includeAnnotations true if annotation information needs to be added.
|
||||
* @param htmltree the content tree to which the parameters information will be added.
|
||||
*/
|
||||
protected void addParameters(ExecutableElement member,
|
||||
boolean includeAnnotations, Content htmltree, int indentSize) {
|
||||
htmltree.addContent("(");
|
||||
String sep = "";
|
||||
List<? extends VariableElement> parameters = member.getParameters();
|
||||
String indent = makeSpace(indentSize + 1);
|
||||
TypeMirror rcvrType = member.getReceiverType();
|
||||
if (includeAnnotations && rcvrType != null && utils.isAnnotated(rcvrType)) {
|
||||
List<? extends AnnotationMirror> annotationMirrors = rcvrType.getAnnotationMirrors();
|
||||
addReceiverAnnotations(member, rcvrType, annotationMirrors, htmltree);
|
||||
sep = "," + DocletConstants.NL + indent;
|
||||
}
|
||||
int paramstart;
|
||||
for (paramstart = 0; paramstart < parameters.size(); paramstart++) {
|
||||
htmltree.addContent(sep);
|
||||
VariableElement param = parameters.get(paramstart);
|
||||
|
||||
if (param.getKind() != ElementKind.INSTANCE_INIT) {
|
||||
if (includeAnnotations) {
|
||||
boolean foundAnnotations =
|
||||
writer.addAnnotationInfo(indent.length(),
|
||||
member, param, htmltree);
|
||||
if (foundAnnotations) {
|
||||
htmltree.addContent(DocletConstants.NL);
|
||||
htmltree.addContent(indent);
|
||||
}
|
||||
}
|
||||
addParam(member, param,
|
||||
(paramstart == parameters.size() - 1) && member.isVarArgs(), htmltree);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = paramstart + 1; i < parameters.size(); i++) {
|
||||
htmltree.addContent(",");
|
||||
htmltree.addContent(DocletConstants.NL);
|
||||
htmltree.addContent(indent);
|
||||
if (includeAnnotations) {
|
||||
boolean foundAnnotations =
|
||||
writer.addAnnotationInfo(indent.length(), member, parameters.get(i),
|
||||
htmltree);
|
||||
if (foundAnnotations) {
|
||||
htmltree.addContent(DocletConstants.NL);
|
||||
htmltree.addContent(indent);
|
||||
}
|
||||
}
|
||||
addParam(member, parameters.get(i), (i == parameters.size() - 1) && member.isVarArgs(),
|
||||
htmltree);
|
||||
}
|
||||
htmltree.addContent(")");
|
||||
}
|
||||
|
||||
/**
|
||||
* Add exceptions for the executable member.
|
||||
*
|
||||
* @param member the member to write exceptions for.
|
||||
* @param htmltree the content tree to which the exceptions information will be added.
|
||||
*/
|
||||
protected void addExceptions(ExecutableElement member, Content htmltree, int indentSize) {
|
||||
List<? extends TypeMirror> exceptions = member.getThrownTypes();
|
||||
if (!exceptions.isEmpty()) {
|
||||
String indent = makeSpace(indentSize + 1 - 7);
|
||||
htmltree.addContent(DocletConstants.NL);
|
||||
htmltree.addContent(indent);
|
||||
htmltree.addContent("throws ");
|
||||
indent = makeSpace(indentSize + 1);
|
||||
Content link = writer.getLink(new LinkInfoImpl(configuration, MEMBER, exceptions.get(0)));
|
||||
htmltree.addContent(link);
|
||||
for(int i = 1; i < exceptions.size(); i++) {
|
||||
htmltree.addContent(",");
|
||||
htmltree.addContent(DocletConstants.NL);
|
||||
htmltree.addContent(indent);
|
||||
Content exceptionLink = writer.getLink(new LinkInfoImpl(configuration, MEMBER,
|
||||
exceptions.get(i)));
|
||||
htmltree.addContent(exceptionLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected TypeElement implementsMethodInIntfac(ExecutableElement method,
|
||||
List<TypeElement> intfacs) {
|
||||
for (TypeElement intf : intfacs) {
|
||||
List<ExecutableElement> methods = utils.getMethods(intf);
|
||||
if (!methods.isEmpty()) {
|
||||
for (ExecutableElement md : methods) {
|
||||
if (name(md).equals(name(method)) &&
|
||||
md.toString().equals(method.toString())) {
|
||||
return intf;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* For backward compatibility, include an anchor using the erasures of the
|
||||
* parameters. NOTE: We won't need this method anymore after we fix
|
||||
* see tags so that they use the type instead of the erasure.
|
||||
*
|
||||
* @param executableElement the ExecutableElement to anchor to.
|
||||
* @return the 1.4.x style anchor for the executable element.
|
||||
*/
|
||||
protected String getErasureAnchor(ExecutableElement executableElement) {
|
||||
final StringBuilder buf = new StringBuilder(name(executableElement) + "(");
|
||||
List<? extends VariableElement> parameters = executableElement.getParameters();
|
||||
boolean foundTypeVariable = false;
|
||||
for (int i = 0; i < parameters.size(); i++) {
|
||||
if (i > 0) {
|
||||
buf.append(",");
|
||||
}
|
||||
TypeMirror t = parameters.get(i).asType();
|
||||
SimpleTypeVisitor9<Boolean, Void> stv = new SimpleTypeVisitor9<Boolean, Void>() {
|
||||
boolean foundTypeVariable = false;
|
||||
|
||||
@Override @DefinedBy(Api.LANGUAGE_MODEL)
|
||||
public Boolean visitArray(ArrayType t, Void p) {
|
||||
visit(t.getComponentType());
|
||||
buf.append(utils.getDimension(t));
|
||||
return foundTypeVariable;
|
||||
}
|
||||
|
||||
@Override @DefinedBy(Api.LANGUAGE_MODEL)
|
||||
public Boolean visitTypeVariable(TypeVariable t, Void p) {
|
||||
buf.append(utils.asTypeElement(t).getQualifiedName());
|
||||
foundTypeVariable = true;
|
||||
return foundTypeVariable;
|
||||
}
|
||||
|
||||
@Override @DefinedBy(Api.LANGUAGE_MODEL)
|
||||
public Boolean visitDeclared(DeclaredType t, Void p) {
|
||||
buf.append(utils.getQualifiedTypeName(t));
|
||||
return foundTypeVariable;
|
||||
}
|
||||
|
||||
@Override @DefinedBy(Api.LANGUAGE_MODEL)
|
||||
protected Boolean defaultAction(TypeMirror e, Void p) {
|
||||
buf.append(e.toString());
|
||||
return foundTypeVariable;
|
||||
}
|
||||
};
|
||||
|
||||
boolean isTypeVariable = stv.visit(t);
|
||||
if (!foundTypeVariable) {
|
||||
foundTypeVariable = isTypeVariable;
|
||||
}
|
||||
}
|
||||
buf.append(")");
|
||||
return foundTypeVariable ? writer.getName(buf.toString()) : null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,461 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.element.PackageElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.util.SimpleElementVisitor9;
|
||||
|
||||
import com.sun.source.doctree.DocTree;
|
||||
import com.sun.tools.javac.util.DefinedBy;
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
|
||||
|
||||
/**
|
||||
* Generate Index for all the Member Names with Indexing in
|
||||
* Unicode Order. This class is a base class for {@link SingleIndexWriter} and
|
||||
* {@link SplitIndexWriter}. It uses the functionality from
|
||||
* {@link HtmlDocletWriter} to generate the Index Contents.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @see IndexBuilder
|
||||
* @author Atul M Dambalkar
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class AbstractIndexWriter extends HtmlDocletWriter {
|
||||
|
||||
/**
|
||||
* The index of all the members with unicode character.
|
||||
*/
|
||||
protected IndexBuilder indexbuilder;
|
||||
|
||||
/**
|
||||
* This constructor will be used by {@link SplitIndexWriter}. Initializes
|
||||
* path to this file and relative path from this file.
|
||||
*
|
||||
* @param configuration The current configuration
|
||||
* @param path Path to the file which is getting generated.
|
||||
* @param indexbuilder Unicode based Index from {@link IndexBuilder}
|
||||
*/
|
||||
protected AbstractIndexWriter(ConfigurationImpl configuration,
|
||||
DocPath path,
|
||||
IndexBuilder indexbuilder)
|
||||
throws IOException {
|
||||
super(configuration, path);
|
||||
this.indexbuilder = indexbuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index label for navigation bar.
|
||||
*
|
||||
* @return a content tree for the tree label
|
||||
*/
|
||||
protected Content getNavLinkIndex() {
|
||||
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, indexLabel);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the member information for the unicode character along with the
|
||||
* list of the members.
|
||||
*
|
||||
* @param uc Unicode for which member list information to be generated
|
||||
* @param memberlist List of members for the unicode character
|
||||
* @param contentTree the content tree to which the information will be added
|
||||
*/
|
||||
protected void addContents(Character uc, Collection<? extends Element> memberlist,
|
||||
Content contentTree) {
|
||||
addHeading(uc, contentTree);
|
||||
// Display the list only if there are elements to be displayed.
|
||||
if (!memberlist.isEmpty()) {
|
||||
Content dl = new HtmlTree(HtmlTag.DL);
|
||||
for (Element element : memberlist) {
|
||||
addDescription(dl, element);
|
||||
}
|
||||
contentTree.addContent(dl);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addSearchContents(Character uc, List<SearchIndexItem> searchList,
|
||||
Content contentTree) {
|
||||
addHeading(uc, contentTree);
|
||||
// Display the list only if there are elements to be displayed.
|
||||
if (!searchList.isEmpty()) {
|
||||
Content dl = new HtmlTree(HtmlTag.DL);
|
||||
for (SearchIndexItem sii : searchList) {
|
||||
addDescription(sii, dl);
|
||||
}
|
||||
contentTree.addContent(dl);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addContents(Character uc, List<? extends Element> memberlist,
|
||||
List<SearchIndexItem> searchList, Content contentTree) {
|
||||
addHeading(uc, contentTree);
|
||||
int memberListSize = memberlist.size();
|
||||
int searchListSize = searchList.size();
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
Content dl = new HtmlTree(HtmlTag.DL);
|
||||
while (i < memberListSize && j < searchListSize) {
|
||||
String name = utils.getSimpleName(memberlist.get(i));
|
||||
if (name.compareTo(searchList.get(j).getLabel()) < 0) {
|
||||
addDescription(dl, memberlist.get(i));
|
||||
i++;
|
||||
} else if (name.compareTo(searchList.get(j).getLabel()) > 0) {
|
||||
addDescription(searchList.get(j), dl);
|
||||
j++;
|
||||
} else {
|
||||
addDescription(dl, memberlist.get(i));
|
||||
addDescription(searchList.get(j), dl);
|
||||
j++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (i >= memberListSize) {
|
||||
while (j < searchListSize) {
|
||||
addDescription(searchList.get(j), dl);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
if (j >= searchListSize) {
|
||||
while (i < memberListSize) {
|
||||
addDescription(dl, memberlist.get(i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
contentTree.addContent(dl);
|
||||
}
|
||||
|
||||
protected void addHeading(Character uc, Content contentTree) {
|
||||
String unicode = uc.toString();
|
||||
contentTree.addContent(getMarkerAnchorForIndex(unicode));
|
||||
Content headContent = new StringContent(unicode);
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, false,
|
||||
HtmlStyle.title, headContent);
|
||||
contentTree.addContent(heading);
|
||||
}
|
||||
|
||||
protected void addDescription(Content dl, Element element) {
|
||||
SearchIndexItem si = new SearchIndexItem();
|
||||
new SimpleElementVisitor9<Void, Void>() {
|
||||
|
||||
@Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
|
||||
public Void visitPackage(PackageElement e, Void p) {
|
||||
addDescription(e, dl, si);
|
||||
configuration.packageSearchIndex.add(si);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
|
||||
public Void visitType(TypeElement e, Void p) {
|
||||
addDescription(e, dl, si);
|
||||
configuration.typeSearchIndex.add(si);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
|
||||
protected Void defaultAction(Element e, Void p) {
|
||||
addDescription(e, dl, si);
|
||||
configuration.memberSearchIndex.add(si);
|
||||
return null;
|
||||
}
|
||||
|
||||
}.visit(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add one line summary comment for the package.
|
||||
*
|
||||
* @param pkg the package to be documented
|
||||
* @param dlTree the content tree to which the description will be added
|
||||
*/
|
||||
protected void addDescription(PackageElement pkg, Content dlTree, SearchIndexItem si) {
|
||||
Content link = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg)));
|
||||
si.setLabel(utils.getPackageName(pkg));
|
||||
si.setCategory(getResource("doclet.Packages").toString());
|
||||
Content dt = HtmlTree.DT(link);
|
||||
dt.addContent(" - ");
|
||||
dt.addContent(getResource("doclet.package"));
|
||||
dt.addContent(" " + utils.getPackageName(pkg));
|
||||
dlTree.addContent(dt);
|
||||
Content dd = new HtmlTree(HtmlTag.DD);
|
||||
addSummaryComment(pkg, dd);
|
||||
dlTree.addContent(dd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add one line summary comment for the class.
|
||||
*
|
||||
* @param typeElement the class being documented
|
||||
* @param dlTree the content tree to which the description will be added
|
||||
*/
|
||||
protected void addDescription(TypeElement typeElement, Content dlTree, SearchIndexItem si) {
|
||||
Content link = getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.INDEX, typeElement).strong(true));
|
||||
si.setContainingPackage(utils.getPackageName(utils.containingPackage(typeElement)));
|
||||
si.setLabel(utils.getSimpleName(typeElement));
|
||||
si.setCategory(getResource("doclet.Types").toString());
|
||||
Content dt = HtmlTree.DT(link);
|
||||
dt.addContent(" - ");
|
||||
addClassInfo(typeElement, dt);
|
||||
dlTree.addContent(dt);
|
||||
Content dd = new HtmlTree(HtmlTag.DD);
|
||||
addComment(typeElement, dd);
|
||||
dlTree.addContent(dd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the classkind (class, interface, exception), error of the class
|
||||
* passed.
|
||||
*
|
||||
* @param te the class being documented
|
||||
* @param contentTree the content tree to which the class info will be added
|
||||
*/
|
||||
protected void addClassInfo(TypeElement te, Content contentTree) {
|
||||
contentTree.addContent(getResource("doclet.in",
|
||||
utils.getTypeElementName(te, false),
|
||||
getPackageLink(utils.containingPackage(te),
|
||||
utils.getPackageName(utils.containingPackage(te)))
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add description for Class, Field, Method or Constructor.
|
||||
*
|
||||
* @param member the member of the Class Kind
|
||||
* @param dlTree the content tree to which the description will be added
|
||||
* @param si search index item
|
||||
*/
|
||||
protected void addDescription(Element member, Content dlTree, SearchIndexItem si) {
|
||||
|
||||
si.setContainingPackage(utils.getPackageName(utils.containingPackage(member)));
|
||||
si.setContainingClass(utils.getSimpleName(utils.getEnclosingTypeElement(member)));
|
||||
String name = utils.getSimpleName(member);
|
||||
if (utils.isExecutableElement(member)) {
|
||||
ExecutableElement ee = (ExecutableElement)member;
|
||||
name = name + utils.flatSignature(ee);
|
||||
si.setLabel(name);
|
||||
if (!((utils.signature(ee)).equals(utils.flatSignature(ee)))) {
|
||||
si.setUrl(getName(getAnchor(ee)));
|
||||
}
|
||||
|
||||
} else {
|
||||
si.setLabel(name);
|
||||
}
|
||||
si.setCategory(getResource("doclet.Members").toString());
|
||||
Content span = HtmlTree.SPAN(HtmlStyle.memberNameLink,
|
||||
getDocLink(LinkInfoImpl.Kind.INDEX, member, name));
|
||||
Content dt = HtmlTree.DT(span);
|
||||
dt.addContent(" - ");
|
||||
addMemberDesc(member, dt);
|
||||
dlTree.addContent(dt);
|
||||
Content dd = new HtmlTree(HtmlTag.DD);
|
||||
addComment(member, dd);
|
||||
dlTree.addContent(dd);
|
||||
}
|
||||
|
||||
protected void addDescription(SearchIndexItem sii, Content dlTree) {
|
||||
String path = pathToRoot.isEmpty() ? "" : pathToRoot.getPath() + "/";
|
||||
path += sii.getUrl();
|
||||
HtmlTree labelLink = HtmlTree.A(path, new StringContent(sii.getLabel()));
|
||||
Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.searchTagLink, labelLink));
|
||||
dt.addContent(" - ");
|
||||
dt.addContent(getResource("doclet.Search_tag_in", sii.getHolder()));
|
||||
dlTree.addContent(dt);
|
||||
Content dd = new HtmlTree(HtmlTag.DD);
|
||||
if (sii.getDescription().isEmpty()) {
|
||||
dd.addContent(getSpace());
|
||||
} else {
|
||||
dd.addContent(sii.getDescription());
|
||||
}
|
||||
dlTree.addContent(dd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add comment for each element in the index. If the element is deprecated
|
||||
* and it has a @deprecated tag, use that comment. Else if the containing
|
||||
* class for this element is deprecated, then add the word "Deprecated." at
|
||||
* the start and then print the normal comment.
|
||||
*
|
||||
* @param element Index element
|
||||
* @param contentTree the content tree to which the comment will be added
|
||||
*/
|
||||
protected void addComment(Element element, Content contentTree) {
|
||||
List<? extends DocTree> tags;
|
||||
Content span = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
|
||||
HtmlTree div = new HtmlTree(HtmlTag.DIV);
|
||||
div.addStyle(HtmlStyle.block);
|
||||
if (utils.isDeprecated(element)) {
|
||||
div.addContent(span);
|
||||
tags = utils.getBlockTags(element, DocTree.Kind.DEPRECATED);
|
||||
if (!tags.isEmpty())
|
||||
addInlineDeprecatedComment(element, tags.get(0), div);
|
||||
contentTree.addContent(div);
|
||||
} else {
|
||||
TypeElement encl = utils.getEnclosingTypeElement(element);
|
||||
while (encl != null) {
|
||||
if (utils.isDeprecated(encl)) {
|
||||
div.addContent(span);
|
||||
contentTree.addContent(div);
|
||||
break;
|
||||
}
|
||||
encl = utils.getEnclosingTypeElement(encl);
|
||||
}
|
||||
addSummaryComment(element, contentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add description about the Static Variable/Method/Constructor for a
|
||||
* member.
|
||||
*
|
||||
* @param member MemberDoc for the member within the Class Kind
|
||||
* @param contentTree the content tree to which the member description will be added
|
||||
*/
|
||||
protected void addMemberDesc(Element member, Content contentTree) {
|
||||
TypeElement containing = utils.getEnclosingTypeElement(member);
|
||||
String classdesc = utils.getTypeElementName(containing, true) + " ";
|
||||
if (utils.isField(member)) {
|
||||
Content resource = getResource(utils.isStatic(member)
|
||||
? "doclet.Static_variable_in"
|
||||
: "doclet.Variable_in", classdesc);
|
||||
contentTree.addContent(resource);
|
||||
} else if (utils.isConstructor(member)) {
|
||||
contentTree.addContent(
|
||||
getResource("doclet.Constructor_for", classdesc));
|
||||
} else if (utils.isMethod(member)) {
|
||||
Content resource = getResource(utils.isStatic(member)
|
||||
? "doclet.Static_method_in"
|
||||
: "doclet.Method_in", classdesc);
|
||||
contentTree.addContent(resource);
|
||||
}
|
||||
addPreQualifiedClassLink(LinkInfoImpl.Kind.INDEX, containing,
|
||||
false, contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the marker anchor which will be added to the index documentation tree.
|
||||
*
|
||||
* @param anchorNameForIndex the anchor name attribute for index page
|
||||
* @return a content tree for the marker anchor
|
||||
*/
|
||||
public Content getMarkerAnchorForIndex(String anchorNameForIndex) {
|
||||
return getMarkerAnchor(getNameForIndex(anchorNameForIndex), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a valid HTML name for member index page.
|
||||
*
|
||||
* @param unicode the string that needs to be converted to valid HTML name.
|
||||
* @return a valid HTML name string.
|
||||
*/
|
||||
public String getNameForIndex(String unicode) {
|
||||
return "I:" + getName(unicode);
|
||||
}
|
||||
|
||||
protected void createSearchIndexFiles() {
|
||||
createSearchIndexFile(DocPaths.PACKAGE_SEARCH_INDEX_JSON, DocPaths.PACKAGE_SEARCH_INDEX_ZIP,
|
||||
configuration.packageSearchIndex);
|
||||
createSearchIndexFile(DocPaths.TYPE_SEARCH_INDEX_JSON, DocPaths.TYPE_SEARCH_INDEX_ZIP,
|
||||
configuration.typeSearchIndex);
|
||||
createSearchIndexFile(DocPaths.MEMBER_SEARCH_INDEX_JSON, DocPaths.MEMBER_SEARCH_INDEX_ZIP,
|
||||
configuration.memberSearchIndex);
|
||||
createSearchIndexFile(DocPaths.TAG_SEARCH_INDEX_JSON, DocPaths.TAG_SEARCH_INDEX_ZIP,
|
||||
configuration.tagSearchIndex);
|
||||
}
|
||||
|
||||
protected void createSearchIndexFile(DocPath searchIndexFile, DocPath searchIndexZip,
|
||||
List<SearchIndexItem> searchIndex) {
|
||||
if (!searchIndex.isEmpty()) {
|
||||
try {
|
||||
StringBuilder searchVar = new StringBuilder("[");
|
||||
boolean first = true;
|
||||
DocFile searchFile = DocFile.createFileForOutput(configuration, searchIndexFile);
|
||||
Path p = Paths.get(searchFile.getPath());
|
||||
for (SearchIndexItem item : searchIndex) {
|
||||
if (first) {
|
||||
searchVar.append(item.toString());
|
||||
first = false;
|
||||
} else {
|
||||
searchVar.append(",").append(item.toString());
|
||||
}
|
||||
}
|
||||
searchVar.append("]");
|
||||
Files.write(p, searchVar.toString().getBytes());
|
||||
DocFile zipFile = DocFile.createFileForOutput(configuration, searchIndexZip);
|
||||
try (FileOutputStream fos = new FileOutputStream(zipFile.getPath());
|
||||
ZipOutputStream zos = new ZipOutputStream(fos)) {
|
||||
zipFile(searchFile.getPath(), searchIndexFile, zos);
|
||||
}
|
||||
Files.delete(p);
|
||||
} catch (IOException ie) {
|
||||
throw new DocletAbortException(ie);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void zipFile(String inputFile, DocPath file, ZipOutputStream zos) {
|
||||
try {
|
||||
try {
|
||||
ZipEntry ze = new ZipEntry(file.getPath());
|
||||
zos.putNextEntry(ze);
|
||||
try (FileInputStream fis = new FileInputStream(new File(inputFile))) {
|
||||
byte[] buf = new byte[2048];
|
||||
int len = fis.read(buf);
|
||||
while (len > 0) {
|
||||
zos.write(buf, 0, len);
|
||||
len = fis.read(buf);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
zos.closeEntry();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,708 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.element.TypeParameterElement;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.lang.model.util.SimpleElementVisitor9;
|
||||
|
||||
import com.sun.source.doctree.DocTree;
|
||||
import com.sun.tools.javac.util.DefinedBy;
|
||||
import com.sun.tools.javac.util.DefinedBy.Api;
|
||||
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.taglets.DeprecatedTaglet;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.MethodTypes;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
|
||||
|
||||
import static javax.lang.model.element.Modifier.*;
|
||||
|
||||
/**
|
||||
* The base class for member writers.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Robert Field
|
||||
* @author Atul M Dambalkar
|
||||
* @author Jamie Ho (Re-write)
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public abstract class AbstractMemberWriter {
|
||||
|
||||
protected final ConfigurationImpl configuration;
|
||||
protected final Utils utils;
|
||||
protected final SubWriterHolderWriter writer;
|
||||
protected final TypeElement typeElement;
|
||||
protected Map<String, Integer> typeMap = new LinkedHashMap<>();
|
||||
protected Set<MethodTypes> methodTypes = EnumSet.noneOf(MethodTypes.class);
|
||||
private int methodTypesOr = 0;
|
||||
public final boolean nodepr;
|
||||
|
||||
protected boolean printedSummaryHeader = false;
|
||||
|
||||
public AbstractMemberWriter(SubWriterHolderWriter writer, TypeElement typeElement) {
|
||||
this.configuration = writer.configuration;
|
||||
this.writer = writer;
|
||||
this.nodepr = configuration.nodeprecated;
|
||||
this.typeElement = typeElement;
|
||||
this.utils = writer.configuration.utils;
|
||||
}
|
||||
|
||||
public AbstractMemberWriter(SubWriterHolderWriter writer) {
|
||||
this(writer, null);
|
||||
}
|
||||
|
||||
/*** abstracts ***/
|
||||
|
||||
/**
|
||||
* Add the summary label for the member.
|
||||
*
|
||||
* @param memberTree the content tree to which the label will be added
|
||||
*/
|
||||
public abstract void addSummaryLabel(Content memberTree);
|
||||
|
||||
/**
|
||||
* Get the summary for the member summary table.
|
||||
*
|
||||
* @return a string for the table summary
|
||||
*/
|
||||
public abstract String getTableSummary();
|
||||
|
||||
/**
|
||||
* Get the caption for the member summary table.
|
||||
*
|
||||
* @return a string for the table caption
|
||||
*/
|
||||
public abstract Content getCaption();
|
||||
|
||||
/**
|
||||
* Get the summary table header for the member.
|
||||
*
|
||||
* @param member the member to be documented
|
||||
* @return the summary table header
|
||||
*/
|
||||
public abstract List<String> getSummaryTableHeader(Element member);
|
||||
|
||||
/**
|
||||
* Add inherited summary label for the member.
|
||||
*
|
||||
* @param typeElement the TypeElement to which to link to
|
||||
* @param inheritedTree the content tree to which the inherited summary label will be added
|
||||
*/
|
||||
public abstract void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree);
|
||||
|
||||
/**
|
||||
* Add the anchor for the summary section of the member.
|
||||
*
|
||||
* @param typeElement the TypeElement to be documented
|
||||
* @param memberTree the content tree to which the summary anchor will be added
|
||||
*/
|
||||
public abstract void addSummaryAnchor(TypeElement typeElement, Content memberTree);
|
||||
|
||||
/**
|
||||
* Add the anchor for the inherited summary section of the member.
|
||||
*
|
||||
* @param typeElement the TypeElement to be documented
|
||||
* @param inheritedTree the content tree to which the inherited summary anchor will be added
|
||||
*/
|
||||
public abstract void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree);
|
||||
|
||||
/**
|
||||
* Add the summary type for the member.
|
||||
*
|
||||
* @param member the member to be documented
|
||||
* @param tdSummaryType the content tree to which the type will be added
|
||||
*/
|
||||
protected abstract void addSummaryType(Element member, Content tdSummaryType);
|
||||
|
||||
/**
|
||||
* Add the summary link for the member.
|
||||
*
|
||||
* @param typeElement the TypeElement to be documented
|
||||
* @param member the member to be documented
|
||||
* @param tdSummary the content tree to which the link will be added
|
||||
*/
|
||||
protected void addSummaryLink(TypeElement typeElement, Element member, Content tdSummary) {
|
||||
addSummaryLink(LinkInfoImpl.Kind.MEMBER, typeElement, member, tdSummary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the summary link for the member.
|
||||
*
|
||||
* @param context the id of the context where the link will be printed
|
||||
* @param typeElement the TypeElement to be documented
|
||||
* @param member the member to be documented
|
||||
* @param tdSummary the content tree to which the summary link will be added
|
||||
*/
|
||||
protected abstract void addSummaryLink(LinkInfoImpl.Kind context,
|
||||
TypeElement typeElement, Element member, Content tdSummary);
|
||||
|
||||
/**
|
||||
* Add the inherited summary link for the member.
|
||||
*
|
||||
* @param typeElement the TypeElement to be documented
|
||||
* @param member the member to be documented
|
||||
* @param linksTree the content tree to which the inherited summary link will be added
|
||||
*/
|
||||
protected abstract void addInheritedSummaryLink(TypeElement typeElement,
|
||||
Element member, Content linksTree);
|
||||
|
||||
/**
|
||||
* Get the deprecated link.
|
||||
*
|
||||
* @param member the member being linked to
|
||||
* @return a content tree representing the link
|
||||
*/
|
||||
protected abstract Content getDeprecatedLink(Element member);
|
||||
|
||||
/**
|
||||
* Get the navigation summary link.
|
||||
*
|
||||
* @param typeElement the TypeElement to be documented
|
||||
* @param link true if its a link else the label to be printed
|
||||
* @return a content tree for the navigation summary link.
|
||||
*/
|
||||
protected abstract Content getNavSummaryLink(TypeElement typeElement, boolean link);
|
||||
|
||||
/**
|
||||
* Add the navigation detail link.
|
||||
*
|
||||
* @param link true if its a link else the label to be printed
|
||||
* @param liNav the content tree to which the navigation detail link will be added
|
||||
*/
|
||||
protected abstract void addNavDetailLink(boolean link, Content liNav);
|
||||
|
||||
/**
|
||||
* Add the member name to the content tree.
|
||||
*
|
||||
* @param name the member name to be added to the content tree.
|
||||
* @param htmltree the content tree to which the name will be added.
|
||||
*/
|
||||
protected void addName(String name, Content htmltree) {
|
||||
htmltree.addContent(name);
|
||||
}
|
||||
|
||||
protected String typeString(Element member) {
|
||||
return new SimpleElementVisitor9<String, Void>() {
|
||||
|
||||
@Override @DefinedBy(Api.LANGUAGE_MODEL)
|
||||
public String visitExecutable(ExecutableElement e, Void p) {
|
||||
return utils.isMethod(e) ? e.getReturnType().toString() : "";
|
||||
}
|
||||
|
||||
@Override @DefinedBy(Api.LANGUAGE_MODEL)
|
||||
public String visitVariable(VariableElement e, Void p) {
|
||||
return e.toString();
|
||||
}
|
||||
|
||||
@Override @DefinedBy(Api.LANGUAGE_MODEL)
|
||||
protected String defaultAction(Element e, Void p) {
|
||||
return "";
|
||||
}
|
||||
}.visit(member);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the modifier for the member. The modifiers are ordered as specified
|
||||
* by <em>The Java Language Specification</em>.
|
||||
*
|
||||
* @param member the member for which teh modifier will be added.
|
||||
* @param htmltree the content tree to which the modifier information will be added.
|
||||
*/
|
||||
protected void addModifiers(Element member, Content htmltree) {
|
||||
Set<Modifier> set = new TreeSet<>(member.getModifiers());
|
||||
|
||||
// remove the ones we really don't need
|
||||
set.remove(NATIVE);
|
||||
set.remove(SYNCHRONIZED);
|
||||
set.remove(STRICTFP);
|
||||
|
||||
// According to JLS, we should not be showing public modifier for
|
||||
// interface methods.
|
||||
if ((utils.isField(member) || utils.isMethod(member))
|
||||
&& writer instanceof ClassWriterImpl
|
||||
&& utils.isInterface(((ClassWriterImpl) writer).getTypeElement())) {
|
||||
// Remove the implicit abstract and public modifiers
|
||||
if (utils.isMethod(member) && utils.isInterface(member.getEnclosingElement())) {
|
||||
set.remove(ABSTRACT);
|
||||
set.remove(PUBLIC);
|
||||
}
|
||||
if (!utils.isMethod(member)) {
|
||||
set.remove(PUBLIC);
|
||||
}
|
||||
}
|
||||
if (!set.isEmpty()) {
|
||||
String mods = set.stream().map(m -> m.toString()).collect(Collectors.joining(" "));
|
||||
htmltree.addContent(mods);
|
||||
htmltree.addContent(writer.getSpace());
|
||||
}
|
||||
}
|
||||
|
||||
protected String makeSpace(int len) {
|
||||
if (len <= 0) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
sb.append(' ');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the modifier and type for the member in the member summary.
|
||||
*
|
||||
* @param member the member to add the type for
|
||||
* @param type the type to add
|
||||
* @param tdSummaryType the content tree to which the modified and type will be added
|
||||
*/
|
||||
protected void addModifierAndType(Element member, TypeMirror type,
|
||||
Content tdSummaryType) {
|
||||
HtmlTree code = new HtmlTree(HtmlTag.CODE);
|
||||
addModifier(member, code);
|
||||
if (type == null) {
|
||||
code.addContent(utils.isClass(member) ? "class" : "interface");
|
||||
code.addContent(writer.getSpace());
|
||||
} else {
|
||||
List<? extends TypeParameterElement> list = utils.isExecutableElement(member)
|
||||
? ((ExecutableElement)member).getTypeParameters()
|
||||
: null;
|
||||
if (list != null && !list.isEmpty()) {
|
||||
Content typeParameters = ((AbstractExecutableMemberWriter) this)
|
||||
.getTypeParameters((ExecutableElement)member);
|
||||
code.addContent(typeParameters);
|
||||
//Code to avoid ugly wrapping in member summary table.
|
||||
if (typeParameters.charCount() > 10) {
|
||||
code.addContent(new HtmlTree(HtmlTag.BR));
|
||||
} else {
|
||||
code.addContent(writer.getSpace());
|
||||
}
|
||||
code.addContent(
|
||||
writer.getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
|
||||
} else {
|
||||
code.addContent(
|
||||
writer.getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
|
||||
}
|
||||
|
||||
}
|
||||
tdSummaryType.addContent(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the modifier for the member.
|
||||
*
|
||||
* @param member the member to add the type for
|
||||
* @param code the content tree to which the modified will be added
|
||||
*/
|
||||
private void addModifier(Element member, Content code) {
|
||||
if (utils.isProtected(member)) {
|
||||
code.addContent("protected ");
|
||||
} else if (utils.isPrivate(member)) {
|
||||
code.addContent("private ");
|
||||
} else if (!utils.isPublic(member)) { // Package private
|
||||
code.addContent(configuration.getText("doclet.Package_private"));
|
||||
code.addContent(" ");
|
||||
}
|
||||
boolean isAnnotatedTypeElement = utils.isAnnotationType(member.getEnclosingElement());
|
||||
if (!isAnnotatedTypeElement && utils.isMethod(member)) {
|
||||
if (!utils.isInterface(member.getEnclosingElement()) && utils.isAbstract(member)) {
|
||||
code.addContent("abstract ");
|
||||
}
|
||||
if (utils.isDefault(member)) {
|
||||
code.addContent("default ");
|
||||
}
|
||||
}
|
||||
if (utils.isStatic(member)) {
|
||||
code.addContent("static ");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the deprecated information for the given member.
|
||||
*
|
||||
* @param member the member being documented.
|
||||
* @param contentTree the content tree to which the deprecated information will be added.
|
||||
*/
|
||||
protected void addDeprecatedInfo(Element member, Content contentTree) {
|
||||
Content output = (new DeprecatedTaglet()).getTagletOutput(member,
|
||||
writer.getTagletWriterInstance(false));
|
||||
if (!output.isEmpty()) {
|
||||
Content deprecatedContent = output;
|
||||
Content div = HtmlTree.DIV(HtmlStyle.block, deprecatedContent);
|
||||
contentTree.addContent(div);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the comment for the given member.
|
||||
*
|
||||
* @param member the member being documented.
|
||||
* @param htmltree the content tree to which the comment will be added.
|
||||
*/
|
||||
protected void addComment(Element member, Content htmltree) {
|
||||
if (!utils.getBody(member).isEmpty()) {
|
||||
writer.addInlineComment(member, htmltree);
|
||||
}
|
||||
}
|
||||
|
||||
protected String name(Element member) {
|
||||
return utils.getSimpleName(member);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the header for the section.
|
||||
*
|
||||
* @param member the member being documented.
|
||||
* @return a header content for the section.
|
||||
*/
|
||||
protected Content getHead(Element member) {
|
||||
Content memberContent = new StringContent(name(member));
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, memberContent);
|
||||
return heading;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the given <code>ProgramElement</code> is inherited
|
||||
* by the class that is being documented.
|
||||
*
|
||||
* @param ped The <code>ProgramElement</code> being checked.
|
||||
* return true if the <code>ProgramElement</code> is being inherited and
|
||||
* false otherwise.
|
||||
*/
|
||||
protected boolean isInherited(Element ped){
|
||||
return (!utils.isPrivate(ped) &&
|
||||
(!utils.isPackagePrivate(ped) ||
|
||||
ped.getEnclosingElement().equals(ped.getEnclosingElement())));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add deprecated information to the documentation tree
|
||||
*
|
||||
* @param deprmembers list of deprecated members
|
||||
* @param headingKey the caption for the deprecated members table
|
||||
* @param tableSummary the summary for the deprecated members table
|
||||
* @param tableHeader table headers for the deprecated members table
|
||||
* @param contentTree the content tree to which the deprecated members table will be added
|
||||
*/
|
||||
protected void addDeprecatedAPI(Collection<Element> deprmembers, String headingKey,
|
||||
String tableSummary, List<String> tableHeader, Content contentTree) {
|
||||
if (deprmembers.size() > 0) {
|
||||
Content caption = writer.getTableCaption(configuration.getResource(headingKey));
|
||||
Content table = (configuration.isOutputHtml5())
|
||||
? HtmlTree.TABLE(HtmlStyle.deprecatedSummary, caption)
|
||||
: HtmlTree.TABLE(HtmlStyle.deprecatedSummary, tableSummary, caption);
|
||||
table.addContent(writer.getSummaryTableHeader(tableHeader, "col"));
|
||||
Content tbody = new HtmlTree(HtmlTag.TBODY);
|
||||
boolean altColor = true;
|
||||
for (Element member : deprmembers) {
|
||||
HtmlTree td = HtmlTree.TD(HtmlStyle.colOne, getDeprecatedLink(member));
|
||||
List<? extends DocTree> deprTrees = utils.getBlockTags(member, DocTree.Kind.DEPRECATED);
|
||||
if (!deprTrees.isEmpty()) {
|
||||
writer.addInlineDeprecatedComment(member, deprTrees.get(0), td);
|
||||
}
|
||||
HtmlTree tr = HtmlTree.TR(td);
|
||||
tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
|
||||
altColor = !altColor;
|
||||
tbody.addContent(tr);
|
||||
}
|
||||
table.addContent(tbody);
|
||||
Content li = HtmlTree.LI(HtmlStyle.blockList, table);
|
||||
Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
|
||||
contentTree.addContent(ul);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add use information to the documentation tree.
|
||||
*
|
||||
* @param mems list of program elements for which the use information will be added
|
||||
* @param heading the section heading
|
||||
* @param tableSummary the summary for the use table
|
||||
* @param contentTree the content tree to which the use information will be added
|
||||
*/
|
||||
protected void addUseInfo(List<? extends Element> mems,
|
||||
Content heading, String tableSummary, Content contentTree) {
|
||||
if (mems == null || mems.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<? extends Element> members = mems;
|
||||
boolean printedUseTableHeader = false;
|
||||
if (members.size() > 0) {
|
||||
Content caption = writer.getTableCaption(heading);
|
||||
Content table = (configuration.isOutputHtml5())
|
||||
? HtmlTree.TABLE(HtmlStyle.useSummary, caption)
|
||||
: HtmlTree.TABLE(HtmlStyle.useSummary, tableSummary, caption);
|
||||
Content tbody = new HtmlTree(HtmlTag.TBODY);
|
||||
boolean altColor = true;
|
||||
for (Element element : members) {
|
||||
TypeElement te = utils.getEnclosingTypeElement(element);
|
||||
if (!printedUseTableHeader) {
|
||||
table.addContent(writer.getSummaryTableHeader(
|
||||
this.getSummaryTableHeader(element), "col"));
|
||||
printedUseTableHeader = true;
|
||||
}
|
||||
HtmlTree tr = new HtmlTree(HtmlTag.TR);
|
||||
tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
|
||||
altColor = !altColor;
|
||||
HtmlTree tdFirst = new HtmlTree(HtmlTag.TD);
|
||||
tdFirst.addStyle(HtmlStyle.colFirst);
|
||||
writer.addSummaryType(this, element, tdFirst);
|
||||
tr.addContent(tdFirst);
|
||||
HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
|
||||
tdLast.addStyle(HtmlStyle.colLast);
|
||||
if (te != null
|
||||
&& !utils.isConstructor(element)
|
||||
&& !utils.isClass(element)
|
||||
&& !utils.isInterface(element)
|
||||
&& !utils.isAnnotationType(element)) {
|
||||
HtmlTree name = new HtmlTree(HtmlTag.SPAN);
|
||||
name.addStyle(HtmlStyle.typeNameLabel);
|
||||
name.addContent(name(te) + ".");
|
||||
tdLast.addContent(name);
|
||||
}
|
||||
addSummaryLink(utils.isClass(element) || utils.isInterface(element)
|
||||
? LinkInfoImpl.Kind.CLASS_USE
|
||||
: LinkInfoImpl.Kind.MEMBER,
|
||||
te, element, tdLast);
|
||||
writer.addSummaryLinkComment(this, element, tdLast);
|
||||
tr.addContent(tdLast);
|
||||
tbody.addContent(tr);
|
||||
}
|
||||
table.addContent(tbody);
|
||||
contentTree.addContent(table);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the navigation detail link.
|
||||
*
|
||||
* @param members the members to be linked
|
||||
* @param liNav the content tree to which the navigation detail link will be added
|
||||
*/
|
||||
protected void addNavDetailLink(SortedSet<Element> members, Content liNav) {
|
||||
addNavDetailLink(!members.isEmpty(), liNav);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the navigation summary link.
|
||||
*
|
||||
* @param members members to be linked
|
||||
* @param visibleMemberMap the visible inherited members map
|
||||
* @param liNav the content tree to which the navigation summary link will be added
|
||||
*/
|
||||
protected void addNavSummaryLink(SortedSet<? extends Element> members,
|
||||
VisibleMemberMap visibleMemberMap, Content liNav) {
|
||||
if (!members.isEmpty()) {
|
||||
liNav.addContent(getNavSummaryLink(null, true));
|
||||
return;
|
||||
}
|
||||
|
||||
TypeElement superClass = utils.getSuperClass(typeElement);
|
||||
while (superClass != null) {
|
||||
if (visibleMemberMap.hasMembersFor(superClass)) {
|
||||
liNav.addContent(getNavSummaryLink(superClass, true));
|
||||
return;
|
||||
}
|
||||
superClass = utils.getSuperClass(superClass);
|
||||
}
|
||||
liNav.addContent(getNavSummaryLink(null, false));
|
||||
}
|
||||
|
||||
protected void serialWarning(Element e, String key, String a1, String a2) {
|
||||
if (configuration.serialwarn) {
|
||||
configuration.getDocletSpecificMsg().warning(e, key, a1, a2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the member summary for the given class.
|
||||
*
|
||||
* @param tElement the class that is being documented
|
||||
* @param member the member being documented
|
||||
* @param firstSentenceTags the first sentence tags to be added to the summary
|
||||
* @param tableContents the list of contents to which the documentation will be added
|
||||
* @param counter the counter for determining id and style for the table row
|
||||
*/
|
||||
public void addMemberSummary(TypeElement tElement, Element member,
|
||||
List<? extends DocTree> firstSentenceTags, List<Content> tableContents, int counter) {
|
||||
HtmlTree tdSummaryType = new HtmlTree(HtmlTag.TD);
|
||||
tdSummaryType.addStyle(HtmlStyle.colFirst);
|
||||
writer.addSummaryType(this, member, tdSummaryType);
|
||||
HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
|
||||
setSummaryColumnStyle(tdSummary);
|
||||
addSummaryLink(tElement, member, tdSummary);
|
||||
writer.addSummaryLinkComment(this, member, firstSentenceTags, tdSummary);
|
||||
HtmlTree tr = HtmlTree.TR(tdSummaryType);
|
||||
tr.addContent(tdSummary);
|
||||
if (utils.isMethod(member) && !utils.isAnnotationType(member)) {
|
||||
int methodType = utils.isStatic(member) ? MethodTypes.STATIC.value() :
|
||||
MethodTypes.INSTANCE.value();
|
||||
if (utils.isInterface(member.getEnclosingElement())) {
|
||||
methodType = utils.isAbstract(member)
|
||||
? methodType | MethodTypes.ABSTRACT.value()
|
||||
: methodType | MethodTypes.DEFAULT.value();
|
||||
} else {
|
||||
methodType = utils.isAbstract(member)
|
||||
? methodType | MethodTypes.ABSTRACT.value()
|
||||
: methodType | MethodTypes.CONCRETE.value();
|
||||
}
|
||||
if (utils.isDeprecated(member) || utils.isDeprecated(typeElement)) {
|
||||
methodType = methodType | MethodTypes.DEPRECATED.value();
|
||||
}
|
||||
methodTypesOr = methodTypesOr | methodType;
|
||||
String tableId = "i" + counter;
|
||||
typeMap.put(tableId, methodType);
|
||||
tr.addAttr(HtmlAttr.ID, tableId);
|
||||
}
|
||||
if (counter%2 == 0)
|
||||
tr.addStyle(HtmlStyle.altColor);
|
||||
else
|
||||
tr.addStyle(HtmlStyle.rowColor);
|
||||
tableContents.add(tr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the method types set and return true if the method summary table
|
||||
* needs to show tabs.
|
||||
*
|
||||
* @return true if the table should show tabs
|
||||
*/
|
||||
public boolean showTabs() {
|
||||
int value;
|
||||
for (MethodTypes type : EnumSet.allOf(MethodTypes.class)) {
|
||||
value = type.value();
|
||||
if ((value & methodTypesOr) == value) {
|
||||
methodTypes.add(type);
|
||||
}
|
||||
}
|
||||
boolean showTabs = methodTypes.size() > 1;
|
||||
if (showTabs) {
|
||||
methodTypes.add(MethodTypes.ALL);
|
||||
}
|
||||
return showTabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the style for the summary column.
|
||||
*
|
||||
* @param tdTree the column for which the style will be set
|
||||
*/
|
||||
public void setSummaryColumnStyle(HtmlTree tdTree) {
|
||||
tdTree.addStyle(HtmlStyle.colLast);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add inherited member summary for the given class and member.
|
||||
*
|
||||
* @param tElement the class the inherited member belongs to
|
||||
* @param nestedClass the inherited member that is summarized
|
||||
* @param isFirst true if this is the first member in the list
|
||||
* @param isLast true if this is the last member in the list
|
||||
* @param linksTree the content tree to which the summary will be added
|
||||
*/
|
||||
public void addInheritedMemberSummary(TypeElement tElement,
|
||||
Element nestedClass, boolean isFirst, boolean isLast,
|
||||
Content linksTree) {
|
||||
writer.addInheritedMemberSummary(this, tElement, nestedClass, isFirst,
|
||||
linksTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the inherited summary header for the given class.
|
||||
*
|
||||
* @param tElement the class the inherited member belongs to
|
||||
* @return a content tree for the inherited summary header
|
||||
*/
|
||||
public Content getInheritedSummaryHeader(TypeElement tElement) {
|
||||
Content inheritedTree = writer.getMemberTreeHeader();
|
||||
writer.addInheritedSummaryHeader(this, tElement, inheritedTree);
|
||||
return inheritedTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the inherited summary links tree.
|
||||
*
|
||||
* @return a content tree for the inherited summary links
|
||||
*/
|
||||
public Content getInheritedSummaryLinksTree() {
|
||||
return new HtmlTree(HtmlTag.CODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the summary table tree for the given class.
|
||||
*
|
||||
* @param tElement the class for which the summary table is generated
|
||||
* @param tableContents list of contents to be displayed in the summary table
|
||||
* @return a content tree for the summary table
|
||||
*/
|
||||
public Content getSummaryTableTree(TypeElement tElement, List<Content> tableContents) {
|
||||
return writer.getSummaryTableTree(this, tElement, tableContents, showTabs());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the member tree to be documented.
|
||||
*
|
||||
* @param memberTree the content tree of member to be documented
|
||||
* @return a content tree that will be added to the class documentation
|
||||
*/
|
||||
public Content getMemberTree(Content memberTree) {
|
||||
return writer.getMemberTree(memberTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the member tree to be documented.
|
||||
*
|
||||
* @param memberTree the content tree of member to be documented
|
||||
* @param isLastContent true if the content to be added is the last content
|
||||
* @return a content tree that will be added to the class documentation
|
||||
*/
|
||||
public Content getMemberTree(Content memberTree, boolean isLastContent) {
|
||||
if (isLastContent)
|
||||
return HtmlTree.UL(HtmlStyle.blockListLast, memberTree);
|
||||
else
|
||||
return HtmlTree.UL(HtmlStyle.blockList, memberTree);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.lang.model.element.PackageElement;
|
||||
|
||||
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.RawHtml;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
|
||||
/**
|
||||
* Abstract class to generate the overview files in
|
||||
* Frame and Non-Frame format. This will be sub-classed by to
|
||||
* generate overview-frame.html as well as overview-summary.html.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter {
|
||||
|
||||
/**
|
||||
* A Set of Packages to be documented.
|
||||
*/
|
||||
protected SortedSet<PackageElement> packages;
|
||||
|
||||
/**
|
||||
* Constructor. Also initializes the packages variable.
|
||||
*
|
||||
* @param configuration The current configuration
|
||||
* @param filename Name of the package index file to be generated.
|
||||
*/
|
||||
public AbstractPackageIndexWriter(ConfigurationImpl configuration,
|
||||
DocPath filename) throws IOException {
|
||||
super(configuration, filename);
|
||||
packages = configuration.packages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the navigation bar header to the documentation tree.
|
||||
*
|
||||
* @param body the document tree to which the navigation bar header will be added
|
||||
*/
|
||||
protected abstract void addNavigationBarHeader(Content body);
|
||||
|
||||
/**
|
||||
* Adds the navigation bar footer to the documentation tree.
|
||||
*
|
||||
* @param body the document tree to which the navigation bar footer will be added
|
||||
*/
|
||||
protected abstract void addNavigationBarFooter(Content body);
|
||||
|
||||
/**
|
||||
* Adds the overview header to the documentation tree.
|
||||
*
|
||||
* @param body the document tree to which the overview header will be added
|
||||
*/
|
||||
protected abstract void addOverviewHeader(Content body);
|
||||
|
||||
/**
|
||||
* Adds the packages list to the documentation tree.
|
||||
*
|
||||
* @param packages a collection of packagedoc objects
|
||||
* @param text caption for the table
|
||||
* @param tableSummary summary for the table
|
||||
* @param body the document tree to which the packages list will be added
|
||||
*/
|
||||
protected abstract void addPackagesList(Collection<PackageElement> packages, String text,
|
||||
String tableSummary, Content body);
|
||||
|
||||
/**
|
||||
* Generate and prints the contents in the package index file. Call appropriate
|
||||
* methods from the sub-class in order to generate Frame or Non
|
||||
* Frame format.
|
||||
*
|
||||
* @param title the title of the window.
|
||||
* @param includeScript boolean set true if windowtitle script is to be included
|
||||
*/
|
||||
protected void buildPackageIndexFile(String title, boolean includeScript) throws IOException {
|
||||
String windowOverview = configuration.getText(title);
|
||||
Content body = getBody(includeScript, getWindowTitle(windowOverview));
|
||||
addNavigationBarHeader(body);
|
||||
addOverviewHeader(body);
|
||||
addIndex(body);
|
||||
addOverview(body);
|
||||
addNavigationBarFooter(body);
|
||||
printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
|
||||
configuration.doctitle), includeScript, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default to no overview, override to add overview.
|
||||
*
|
||||
* @param body the document tree to which the overview will be added
|
||||
*/
|
||||
protected void addOverview(Content body) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the frame or non-frame package index to the documentation tree.
|
||||
*
|
||||
* @param body the document tree to which the index will be added
|
||||
*/
|
||||
protected void addIndex(Content body) {
|
||||
addIndexContents(packages, "doclet.Package_Summary",
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Package_Summary"),
|
||||
configuration.getText("doclet.packages")), body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds package index contents. Call appropriate methods from
|
||||
* the sub-classes. Adds it to the body HtmlTree
|
||||
*
|
||||
* @param packages a collection of packages to be documented
|
||||
* @param text string which will be used as the heading
|
||||
* @param tableSummary summary for the table
|
||||
* @param body the document tree to which the index contents will be added
|
||||
*/
|
||||
protected void addIndexContents(Collection<PackageElement> packages, String text,
|
||||
String tableSummary, Content body) {
|
||||
if (!packages.isEmpty()) {
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.NAV))
|
||||
? HtmlTree.NAV()
|
||||
: new HtmlTree(HtmlTag.DIV);
|
||||
htmlTree.addStyle(HtmlStyle.indexNav);
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
addAllClassesLink(ul);
|
||||
htmlTree.addContent(ul);
|
||||
body.addContent(htmlTree);
|
||||
addPackagesList(packages, text, tableSummary, body);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the doctitle to the documentation tree, if it is specified on the command line.
|
||||
*
|
||||
* @param body the document tree to which the title will be added
|
||||
*/
|
||||
protected void addConfigurationTitle(Content body) {
|
||||
if (configuration.doctitle.length() > 0) {
|
||||
Content title = new RawHtml(configuration.doctitle);
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
|
||||
HtmlStyle.title, title);
|
||||
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
|
||||
body.addContent(div);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns highlighted "Overview", in the navigation bar as this is the
|
||||
* overview page.
|
||||
*
|
||||
* @return a Content object to be added to the documentation tree
|
||||
*/
|
||||
protected Content getNavLinkContents() {
|
||||
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do nothing. This will be overridden.
|
||||
*
|
||||
* @param div the document tree to which the all classes link will be added
|
||||
*/
|
||||
protected void addAllClassesLink(Content div) {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
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.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract class to print the class hierarchy page for all the Classes. This
|
||||
* is sub-classed by {@link PackageTreeWriter} and {@link TreeWriter} to
|
||||
* generate the Package Tree and global Tree(for all the classes and packages)
|
||||
* pages.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
*/
|
||||
public abstract class AbstractTreeWriter extends HtmlDocletWriter {
|
||||
|
||||
/**
|
||||
* The class and interface tree built by using {@link ClassTree}
|
||||
*/
|
||||
protected final ClassTree classtree;
|
||||
|
||||
/**
|
||||
* Constructor initializes classtree variable. This constructor will be used
|
||||
* while generating global tree file "overview-tree.html".
|
||||
*
|
||||
* @param configuration The current configuration
|
||||
* @param filename File to be generated.
|
||||
* @param classtree Tree built by {@link ClassTree}.
|
||||
* @throws IOException
|
||||
* @throws DocletAbortException
|
||||
*/
|
||||
protected AbstractTreeWriter(ConfigurationImpl configuration,
|
||||
DocPath filename, ClassTree classtree)
|
||||
throws IOException {
|
||||
super(configuration, filename);
|
||||
this.classtree = classtree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add each level of the class tree. For each sub-class or
|
||||
* sub-interface indents the next level information.
|
||||
* Recurses itself to add sub-classes info.
|
||||
*
|
||||
* @param parent the superclass or superinterface of the sset
|
||||
* @param collection a collection of the sub-classes at this level
|
||||
* @param isEnum true if we are generating a tree for enums
|
||||
* @param contentTree the content tree to which the level information will be added
|
||||
*/
|
||||
protected void addLevelInfo(TypeElement parent, Collection<TypeElement> collection,
|
||||
boolean isEnum, Content contentTree) {
|
||||
if (!collection.isEmpty()) {
|
||||
Content ul = new HtmlTree(HtmlTag.UL);
|
||||
for (TypeElement local : collection) {
|
||||
HtmlTree li = new HtmlTree(HtmlTag.LI);
|
||||
li.addStyle(HtmlStyle.circle);
|
||||
addPartialInfo(local, li);
|
||||
addExtendsImplements(parent, local, li);
|
||||
addLevelInfo(local, classtree.directSubClasses(local, isEnum),
|
||||
isEnum, li); // Recurse
|
||||
ul.addContent(li);
|
||||
}
|
||||
contentTree.addContent(ul);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the heading for the tree depending upon tree type if it's a
|
||||
* Class Tree or Interface tree.
|
||||
*
|
||||
* @param sset classes which are at the most base level, all the
|
||||
* other classes in this run will derive from these classes
|
||||
* @param heading heading for the tree
|
||||
* @param div the content tree to which the tree will be added
|
||||
*/
|
||||
protected void addTree(SortedSet<TypeElement> sset, String heading, HtmlTree div) {
|
||||
addTree(sset, heading, div, false);
|
||||
}
|
||||
|
||||
protected void addTree(SortedSet<TypeElement> sset, String heading,
|
||||
HtmlTree div, boolean isEnums) {
|
||||
if (!sset.isEmpty()) {
|
||||
TypeElement firstTypeElement = sset.first();
|
||||
Content headingContent = getResource(heading);
|
||||
Content sectionHeading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
|
||||
headingContent);
|
||||
HtmlTree htmlTree;
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
htmlTree = HtmlTree.SECTION(sectionHeading);
|
||||
} else {
|
||||
div.addContent(sectionHeading);
|
||||
htmlTree = div;
|
||||
}
|
||||
addLevelInfo(!utils.isInterface(firstTypeElement) ? firstTypeElement : null,
|
||||
sset, isEnums, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
div.addContent(htmlTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add information regarding the classes which this class extends or
|
||||
* implements.
|
||||
*
|
||||
* @param parent the parent class of the class being documented
|
||||
* @param typeElement the TypeElement under consideration
|
||||
* @param contentTree the content tree to which the information will be added
|
||||
*/
|
||||
protected void addExtendsImplements(TypeElement parent, TypeElement typeElement,
|
||||
Content contentTree) {
|
||||
SortedSet<TypeElement> interfaces = new TreeSet<>(utils.makeGeneralPurposeComparator());
|
||||
typeElement.getInterfaces().stream().forEach((t) -> {
|
||||
interfaces.add(utils.asTypeElement(t));
|
||||
});
|
||||
if (interfaces.size() > (utils.isInterface(typeElement) ? 1 : 0)) {
|
||||
boolean isFirst = true;
|
||||
for (TypeElement intf : interfaces) {
|
||||
if (parent != intf) {
|
||||
if (utils.isPublic(intf) || utils.isLinkable(intf)) {
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
if (utils.isInterface(typeElement)) {
|
||||
contentTree.addContent(" (");
|
||||
contentTree.addContent(getResource("doclet.also"));
|
||||
contentTree.addContent(" extends ");
|
||||
} else {
|
||||
contentTree.addContent(" (implements ");
|
||||
}
|
||||
} else {
|
||||
contentTree.addContent(", ");
|
||||
}
|
||||
addPreQualifiedClassLink(LinkInfoImpl.Kind.TREE, intf, contentTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isFirst) {
|
||||
contentTree.addContent(")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add information about the class kind, if it's a "class" or "interface".
|
||||
*
|
||||
* @param typeElement the class being documented
|
||||
* @param contentTree the content tree to which the information will be added
|
||||
*/
|
||||
protected void addPartialInfo(TypeElement typeElement, Content contentTree) {
|
||||
addPreQualifiedStrongClassLink(LinkInfoImpl.Kind.TREE, typeElement, contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tree label for the navigation bar.
|
||||
*
|
||||
* @return a content tree for the tree label
|
||||
*/
|
||||
protected Content getNavLinkTree() {
|
||||
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, treeLabel);
|
||||
return li;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,180 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
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.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Generate the file with list of all the classes in this run. This page will be
|
||||
* used in the left-hand bottom frame, when "All Classes" link is clicked in
|
||||
* the left-hand top frame. The name of the generated file is
|
||||
* "allclasses-frame.html".
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
* @author Doug Kramer
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class AllClassesFrameWriter extends HtmlDocletWriter {
|
||||
|
||||
/**
|
||||
* Index of all the classes.
|
||||
*/
|
||||
protected IndexBuilder indexbuilder;
|
||||
|
||||
/**
|
||||
* BR tag to be used within a document tree.
|
||||
*/
|
||||
final HtmlTree BR = new HtmlTree(HtmlTag.BR);
|
||||
|
||||
/**
|
||||
* Construct AllClassesFrameWriter object. Also initializes the indexbuilder
|
||||
* variable in this class.
|
||||
* @param configuration The current configuration
|
||||
* @param filename Path to the file which is getting generated.
|
||||
* @param indexbuilder Unicode based Index from {@link IndexBuilder}
|
||||
* @throws IOException
|
||||
* @throws DocletAbortException
|
||||
*/
|
||||
public AllClassesFrameWriter(ConfigurationImpl configuration,
|
||||
DocPath filename, IndexBuilder indexbuilder)
|
||||
throws IOException {
|
||||
super(configuration, filename);
|
||||
this.indexbuilder = indexbuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create AllClassesFrameWriter object. Then use it to generate the
|
||||
* "allclasses-frame.html" file. Generate the file in the current or the
|
||||
* destination directory.
|
||||
*
|
||||
* @param indexbuilder IndexBuilder object for all classes index.
|
||||
* @throws DocletAbortException
|
||||
*/
|
||||
public static void generate(ConfigurationImpl configuration,
|
||||
IndexBuilder indexbuilder) {
|
||||
AllClassesFrameWriter allclassgen;
|
||||
DocPath filename = DocPaths.ALLCLASSES_FRAME;
|
||||
try {
|
||||
allclassgen = new AllClassesFrameWriter(configuration,
|
||||
filename, indexbuilder);
|
||||
allclassgen.buildAllClassesFile(true);
|
||||
allclassgen.close();
|
||||
filename = DocPaths.ALLCLASSES_NOFRAME;
|
||||
allclassgen = new AllClassesFrameWriter(configuration,
|
||||
filename, indexbuilder);
|
||||
allclassgen.buildAllClassesFile(false);
|
||||
allclassgen.close();
|
||||
} catch (IOException exc) {
|
||||
configuration.standardmessage.
|
||||
error("doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print all the classes in the file.
|
||||
* @param wantFrames True if we want frames.
|
||||
*/
|
||||
protected void buildAllClassesFile(boolean wantFrames) throws IOException {
|
||||
String label = configuration.getText("doclet.All_Classes");
|
||||
Content body = getBody(false, getWindowTitle(label));
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
|
||||
HtmlStyle.bar, allclassesLabel);
|
||||
body.addContent(heading);
|
||||
Content ul = new HtmlTree(HtmlTag.UL);
|
||||
// Generate the class links and add it to the tdFont tree.
|
||||
addAllClasses(ul, wantFrames);
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
|
||||
? HtmlTree.MAIN(HtmlStyle.indexContainer, ul)
|
||||
: HtmlTree.DIV(HtmlStyle.indexContainer, ul);
|
||||
body.addContent(htmlTree);
|
||||
printHtmlDocument(null, false, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the sorted index of all the classes and add all the classes to the
|
||||
* content list.
|
||||
*
|
||||
* @param content HtmlTree content to which all classes information will be added
|
||||
* @param wantFrames True if we want frames.
|
||||
*/
|
||||
protected void addAllClasses(Content content, boolean wantFrames) {
|
||||
for (Character unicode : indexbuilder.index()) {
|
||||
addContents(indexbuilder.getMemberList(unicode), wantFrames, content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a list of classes, generate links for each class or interface.
|
||||
* If the class kind is interface, print it in the italics font. Also all
|
||||
* links should target the right-hand frame. If clicked on any class name
|
||||
* in this page, appropriate class page should get opened in the right-hand
|
||||
* frame.
|
||||
*
|
||||
* @param classlist Sorted list of classes.
|
||||
* @param wantFrames True if we want frames.
|
||||
* @param content HtmlTree content to which the links will be added
|
||||
*/
|
||||
protected void addContents(Iterable<? extends Element> classlist, boolean wantFrames,
|
||||
Content content) {
|
||||
for (Element element : classlist) {
|
||||
TypeElement typeElement = (TypeElement)element;
|
||||
if (!utils.isCoreClass(typeElement)) {
|
||||
continue;
|
||||
}
|
||||
Content label = interfaceName(typeElement, false);
|
||||
Content linkContent;
|
||||
if (wantFrames) {
|
||||
linkContent = getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.ALL_CLASSES_FRAME, typeElement).label(label).target("classFrame"));
|
||||
} else {
|
||||
linkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, typeElement).label(label));
|
||||
}
|
||||
Content li = HtmlTree.LI(linkContent);
|
||||
content.addContent(li);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,324 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
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.AnnotationTypeFieldWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
|
||||
|
||||
|
||||
/**
|
||||
* Writes annotation type field documentation in HTML format.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
*/
|
||||
public class AnnotationTypeFieldWriterImpl extends AbstractMemberWriter
|
||||
implements AnnotationTypeFieldWriter, MemberSummaryWriter {
|
||||
|
||||
/**
|
||||
* Construct a new AnnotationTypeFieldWriterImpl.
|
||||
*
|
||||
* @param writer the writer that will write the output.
|
||||
* @param annotationType the AnnotationType that holds this member.
|
||||
*/
|
||||
public AnnotationTypeFieldWriterImpl(SubWriterHolderWriter writer,
|
||||
TypeElement annotationType) {
|
||||
super(writer, annotationType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getMemberSummaryHeader(TypeElement typeElement,
|
||||
Content memberSummaryTree) {
|
||||
memberSummaryTree.addContent(
|
||||
HtmlConstants.START_OF_ANNOTATION_TYPE_FIELD_SUMMARY);
|
||||
Content memberTree = writer.getMemberTreeHeader();
|
||||
writer.addSummaryHeader(this, typeElement, memberTree);
|
||||
return memberTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getMemberTreeHeader() {
|
||||
return writer.getMemberTreeHeader();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addMemberTree(Content memberSummaryTree, Content memberTree) {
|
||||
writer.addMemberTree(memberSummaryTree, memberTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addAnnotationFieldDetailsMarker(Content memberDetails) {
|
||||
memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_FIELD_DETAILS);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addAnnotationDetailsTreeHeader(TypeElement typeElement,
|
||||
Content memberDetailsTree) {
|
||||
if (!writer.printedAnnotationFieldHeading) {
|
||||
memberDetailsTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.ANNOTATION_TYPE_FIELD_DETAIL));
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
|
||||
writer.fieldDetailsLabel);
|
||||
memberDetailsTree.addContent(heading);
|
||||
writer.printedAnnotationFieldHeading = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getAnnotationDocTreeHeader(Element member,
|
||||
Content annotationDetailsTree) {
|
||||
annotationDetailsTree.addContent(
|
||||
writer.getMarkerAnchor(name(member)));
|
||||
Content annotationDocTree = writer.getMemberTreeHeader();
|
||||
Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
|
||||
heading.addContent(name(member));
|
||||
annotationDocTree.addContent(heading);
|
||||
return annotationDocTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getSignature(Element member) {
|
||||
Content pre = new HtmlTree(HtmlTag.PRE);
|
||||
writer.addAnnotationInfo(member, pre);
|
||||
addModifiers(member, pre);
|
||||
Content link =
|
||||
writer.getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.MEMBER, getType(member)));
|
||||
pre.addContent(link);
|
||||
pre.addContent(writer.getSpace());
|
||||
if (configuration.linksource) {
|
||||
Content memberName = new StringContent(name(member));
|
||||
writer.addSrcLink(member, memberName, pre);
|
||||
} else {
|
||||
addName(name(member), pre);
|
||||
}
|
||||
return pre;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addDeprecated(Element member, Content annotationDocTree) {
|
||||
addDeprecatedInfo(member, annotationDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addComments(Element member, Content annotationDocTree) {
|
||||
addComment(member, annotationDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addTags(Element member, Content annotationDocTree) {
|
||||
writer.addTagsInfo(member, annotationDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getAnnotationDetails(Content annotationDetailsTree) {
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(annotationDetailsTree));
|
||||
return htmlTree;
|
||||
}
|
||||
return getMemberTree(annotationDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getAnnotationDoc(Content annotationDocTree,
|
||||
boolean isLastContent) {
|
||||
return getMemberTree(annotationDocTree, isLastContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the writer.
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addSummaryLabel(Content memberTree) {
|
||||
Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
|
||||
writer.getResource("doclet.Field_Summary"));
|
||||
memberTree.addContent(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getTableSummary() {
|
||||
return configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Field_Summary"),
|
||||
configuration.getText("doclet.fields"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getCaption() {
|
||||
return configuration.getResource("doclet.Fields");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<String> getSummaryTableHeader(Element member) {
|
||||
List<String> header = Arrays.asList(writer.getModifierTypeHeader(),
|
||||
configuration.getText("doclet.0_and_1",
|
||||
configuration.getText("doclet.Fields"),
|
||||
configuration.getText("doclet.Description")));
|
||||
return header;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
|
||||
memberTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.ANNOTATION_TYPE_FIELD_SUMMARY));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
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));
|
||||
Content code = HtmlTree.CODE(memberLink);
|
||||
tdSummary.addContent(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected void addInheritedSummaryLink(TypeElement typeElement,
|
||||
Element member, Content linksTree) {
|
||||
//Not applicable.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected void addSummaryType(Element member, Content tdSummaryType) {
|
||||
addModifierAndType(member, getType(member), tdSummaryType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected Content getDeprecatedLink(Element member) {
|
||||
return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
|
||||
member, utils.getFullyQualifiedName(member));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
|
||||
if (link) {
|
||||
return writer.getHyperLink(
|
||||
SectionName.ANNOTATION_TYPE_FIELD_SUMMARY,
|
||||
writer.getResource("doclet.navField"));
|
||||
} else {
|
||||
return writer.getResource("doclet.navField");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected void addNavDetailLink(boolean link, Content liNav) {
|
||||
if (link) {
|
||||
liNav.addContent(writer.getHyperLink(
|
||||
SectionName.ANNOTATION_TYPE_FIELD_DETAIL,
|
||||
writer.getResource("doclet.navField")));
|
||||
} else {
|
||||
liNav.addContent(writer.getResource("doclet.navField"));
|
||||
}
|
||||
}
|
||||
private TypeMirror getType(Element member) {
|
||||
if (utils.isConstructor(member))
|
||||
return null;
|
||||
if (utils.isExecutableElement(member))
|
||||
return utils.getReturnType((ExecutableElement)member);
|
||||
return member.asType();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.lang.model.element.AnnotationValue;
|
||||
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.HtmlTree;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
|
||||
import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeOptionalMemberWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
|
||||
|
||||
|
||||
/**
|
||||
* Writes annotation type optional member documentation in HTML format.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class AnnotationTypeOptionalMemberWriterImpl extends
|
||||
AnnotationTypeRequiredMemberWriterImpl
|
||||
implements AnnotationTypeOptionalMemberWriter, MemberSummaryWriter {
|
||||
|
||||
/**
|
||||
* Construct a new AnnotationTypeOptionalMemberWriterImpl.
|
||||
*
|
||||
* @param writer the writer that will write the output.
|
||||
* @param annotationType the AnnotationType that holds this member.
|
||||
*/
|
||||
public AnnotationTypeOptionalMemberWriterImpl(SubWriterHolderWriter writer,
|
||||
TypeElement annotationType) {
|
||||
super(writer, annotationType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getMemberSummaryHeader(TypeElement typeElement,
|
||||
Content memberSummaryTree) {
|
||||
memberSummaryTree.addContent(
|
||||
HtmlConstants.START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY);
|
||||
Content memberTree = writer.getMemberTreeHeader();
|
||||
writer.addSummaryHeader(this, typeElement, memberTree);
|
||||
return memberTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addMemberTree(Content memberSummaryTree, Content memberTree) {
|
||||
writer.addMemberTree(memberSummaryTree, memberTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addDefaultValueInfo(Element member, Content annotationDocTree) {
|
||||
if (utils.isAnnotationType(member)) {
|
||||
ExecutableElement ee = (ExecutableElement)member;
|
||||
AnnotationValue value = ee.getDefaultValue();
|
||||
if (value != null) {
|
||||
Content dt = HtmlTree.DT(writer.getResource("doclet.Default"));
|
||||
Content dl = HtmlTree.DL(dt);
|
||||
Content dd = HtmlTree.DD(new StringContent(value.toString()));
|
||||
dl.addContent(dd);
|
||||
annotationDocTree.addContent(dl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addSummaryLabel(Content memberTree) {
|
||||
Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
|
||||
writer.getResource("doclet.Annotation_Type_Optional_Member_Summary"));
|
||||
memberTree.addContent(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getTableSummary() {
|
||||
return configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Annotation_Type_Optional_Member_Summary"),
|
||||
configuration.getText("doclet.annotation_type_optional_members"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getCaption() {
|
||||
return configuration.getResource("doclet.Annotation_Type_Optional_Members");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<String> getSummaryTableHeader(Element member) {
|
||||
List<String> header = Arrays.asList(writer.getModifierTypeHeader(),
|
||||
configuration.getText("doclet.0_and_1",
|
||||
configuration.getText("doclet.Annotation_Type_Optional_Member"),
|
||||
configuration.getText("doclet.Description")));
|
||||
return header;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
|
||||
memberTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.ANNOTATION_TYPE_OPTIONAL_ELEMENT_SUMMARY));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
|
||||
if (link) {
|
||||
return writer.getHyperLink(
|
||||
SectionName.ANNOTATION_TYPE_OPTIONAL_ELEMENT_SUMMARY,
|
||||
writer.getResource("doclet.navAnnotationTypeOptionalMember"));
|
||||
} else {
|
||||
return writer.getResource("doclet.navAnnotationTypeOptionalMember");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,324 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
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.AnnotationTypeRequiredMemberWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
|
||||
|
||||
|
||||
/**
|
||||
* Writes annotation type required member documentation in HTML format.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
|
||||
implements AnnotationTypeRequiredMemberWriter, MemberSummaryWriter {
|
||||
|
||||
/**
|
||||
* Construct a new AnnotationTypeRequiredMemberWriterImpl.
|
||||
*
|
||||
* @param writer the writer that will write the output.
|
||||
* @param annotationType the AnnotationType that holds this member.
|
||||
*/
|
||||
public AnnotationTypeRequiredMemberWriterImpl(SubWriterHolderWriter writer,
|
||||
TypeElement annotationType) {
|
||||
super(writer, annotationType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getMemberSummaryHeader(TypeElement typeElement,
|
||||
Content memberSummaryTree) {
|
||||
memberSummaryTree.addContent(
|
||||
HtmlConstants.START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY);
|
||||
Content memberTree = writer.getMemberTreeHeader();
|
||||
writer.addSummaryHeader(this, typeElement, memberTree);
|
||||
return memberTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getMemberTreeHeader() {
|
||||
return writer.getMemberTreeHeader();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addMemberTree(Content memberSummaryTree, Content memberTree) {
|
||||
writer.addMemberTree(memberSummaryTree, memberTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addAnnotationDetailsMarker(Content memberDetails) {
|
||||
memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_DETAILS);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addAnnotationDetailsTreeHeader(TypeElement classDoc,
|
||||
Content memberDetailsTree) {
|
||||
if (!writer.printedAnnotationHeading) {
|
||||
memberDetailsTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL));
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
|
||||
writer.annotationTypeDetailsLabel);
|
||||
memberDetailsTree.addContent(heading);
|
||||
writer.printedAnnotationHeading = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getAnnotationDocTreeHeader(Element member,
|
||||
Content annotationDetailsTree) {
|
||||
String simpleName = name(member);
|
||||
annotationDetailsTree.addContent(writer.getMarkerAnchor(simpleName +
|
||||
utils.signature((ExecutableElement) member)));
|
||||
Content annotationDocTree = writer.getMemberTreeHeader();
|
||||
Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
|
||||
heading.addContent(simpleName);
|
||||
annotationDocTree.addContent(heading);
|
||||
return annotationDocTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getSignature(Element member) {
|
||||
Content pre = new HtmlTree(HtmlTag.PRE);
|
||||
writer.addAnnotationInfo(member, pre);
|
||||
addModifiers(member, pre);
|
||||
Content link =
|
||||
writer.getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.MEMBER, getType(member)));
|
||||
pre.addContent(link);
|
||||
pre.addContent(writer.getSpace());
|
||||
if (configuration.linksource) {
|
||||
Content memberName = new StringContent(name(member));
|
||||
writer.addSrcLink(member, memberName, pre);
|
||||
} else {
|
||||
addName(name(member), pre);
|
||||
}
|
||||
return pre;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addDeprecated(Element member, Content annotationDocTree) {
|
||||
addDeprecatedInfo(member, annotationDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addComments(Element member, Content annotationDocTree) {
|
||||
addComment(member, annotationDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addTags(Element member, Content annotationDocTree) {
|
||||
writer.addTagsInfo(member, annotationDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getAnnotationDetails(Content annotationDetailsTree) {
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(annotationDetailsTree));
|
||||
return htmlTree;
|
||||
}
|
||||
return getMemberTree(annotationDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getAnnotationDoc(Content annotationDocTree,
|
||||
boolean isLastContent) {
|
||||
return getMemberTree(annotationDocTree, isLastContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the writer.
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addSummaryLabel(Content memberTree) {
|
||||
Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
|
||||
writer.getResource("doclet.Annotation_Type_Required_Member_Summary"));
|
||||
memberTree.addContent(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String getTableSummary() {
|
||||
return configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Annotation_Type_Required_Member_Summary"),
|
||||
configuration.getText("doclet.annotation_type_required_members"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getCaption() {
|
||||
return configuration.getResource("doclet.Annotation_Type_Required_Members");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<String> getSummaryTableHeader(Element member) {
|
||||
List<String> header = Arrays.asList(writer.getModifierTypeHeader(),
|
||||
configuration.getText("doclet.0_and_1",
|
||||
configuration.getText("doclet.Annotation_Type_Required_Member"),
|
||||
configuration.getText("doclet.Description")));
|
||||
return header;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
|
||||
memberTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
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));
|
||||
Content code = HtmlTree.CODE(memberLink);
|
||||
tdSummary.addContent(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected void addInheritedSummaryLink(TypeElement typeElement,
|
||||
Element member, Content linksTree) {
|
||||
//Not applicable.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected void addSummaryType(Element member, Content tdSummaryType) {
|
||||
addModifierAndType(member, getType(member), tdSummaryType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected Content getDeprecatedLink(Element member) {
|
||||
String name = utils.getFullyQualifiedName(member) + "." + member.getSimpleName();
|
||||
return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, member, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
|
||||
if (link) {
|
||||
return writer.getHyperLink(
|
||||
SectionName.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY,
|
||||
writer.getResource("doclet.navAnnotationTypeRequiredMember"));
|
||||
} else {
|
||||
return writer.getResource("doclet.navAnnotationTypeRequiredMember");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected void addNavDetailLink(boolean link, Content liNav) {
|
||||
if (link) {
|
||||
liNav.addContent(writer.getHyperLink(
|
||||
SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL,
|
||||
writer.getResource("doclet.navAnnotationTypeMember")));
|
||||
} else {
|
||||
liNav.addContent(writer.getResource("doclet.navAnnotationTypeMember"));
|
||||
}
|
||||
}
|
||||
|
||||
private TypeMirror getType(Element member) {
|
||||
return utils.isExecutableElement(member)
|
||||
? utils.getReturnType((ExecutableElement) member)
|
||||
: member.asType();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,465 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.lang.model.element.PackageElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
import com.sun.source.doctree.DocTree;
|
||||
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.AnnotationTypeWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.builders.MemberSummaryBuilder;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
|
||||
|
||||
/**
|
||||
* Generate the Class Information Page.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @see java.util.Collections
|
||||
* @see java.util.List
|
||||
* @see java.util.ArrayList
|
||||
* @see java.util.HashMap
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
* @author Robert Field
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
|
||||
implements AnnotationTypeWriter {
|
||||
|
||||
protected TypeElement annotationType;
|
||||
|
||||
protected TypeMirror prev;
|
||||
|
||||
protected TypeMirror next;
|
||||
|
||||
/**
|
||||
* @param configuration the configuration
|
||||
* @param annotationType the annotation type being documented.
|
||||
* @param prevType the previous class that was documented.
|
||||
* @param nextType the next class being documented.
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
public AnnotationTypeWriterImpl(ConfigurationImpl configuration,
|
||||
TypeElement annotationType, TypeMirror prevType, TypeMirror nextType)
|
||||
throws Exception {
|
||||
super(configuration, DocPath.forClass(configuration.utils, annotationType));
|
||||
this.annotationType = annotationType;
|
||||
configuration.currentTypeElement = annotationType;
|
||||
this.prev = prevType;
|
||||
this.next = nextType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this package link.
|
||||
*
|
||||
* @return a content tree for the package link
|
||||
*/
|
||||
@Override
|
||||
protected Content getNavLinkPackage() {
|
||||
Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
|
||||
packageLabel);
|
||||
Content li = HtmlTree.LI(linkContent);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class link.
|
||||
*
|
||||
* @return a content tree for the class link
|
||||
*/
|
||||
@Override
|
||||
protected Content getNavLinkClass() {
|
||||
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class use link.
|
||||
*
|
||||
* @return a content tree for the class use link
|
||||
*/
|
||||
@Override
|
||||
protected Content getNavLinkClassUse() {
|
||||
Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel);
|
||||
Content li = HtmlTree.LI(linkContent);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link to previous class.
|
||||
*
|
||||
* @return a content tree for the previous class link
|
||||
*/
|
||||
@Override
|
||||
public Content getNavLinkPrevious() {
|
||||
Content li;
|
||||
if (prev != null) {
|
||||
Content prevLink = getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS, utils.asTypeElement(prev))
|
||||
.label(prevclassLabel).strong(true));
|
||||
li = HtmlTree.LI(prevLink);
|
||||
}
|
||||
else
|
||||
li = HtmlTree.LI(prevclassLabel);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link to next class.
|
||||
*
|
||||
* @return a content tree for the next class link
|
||||
*/
|
||||
@Override
|
||||
public Content getNavLinkNext() {
|
||||
Content li;
|
||||
if (next != null) {
|
||||
Content nextLink = getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS, utils.asTypeElement(next))
|
||||
.label(nextclassLabel).strong(true));
|
||||
li = HtmlTree.LI(nextLink);
|
||||
}
|
||||
else
|
||||
li = HtmlTree.LI(nextclassLabel);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getHeader(String header) {
|
||||
HtmlTree bodyTree = getBody(true, getWindowTitle(utils.getSimpleName(annotationType)));
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
|
||||
? HtmlTree.HEADER()
|
||||
: bodyTree;
|
||||
addTop(htmlTree);
|
||||
addNavLinks(true, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.HEADER)) {
|
||||
bodyTree.addContent(htmlTree);
|
||||
}
|
||||
bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
|
||||
HtmlTree div = new HtmlTree(HtmlTag.DIV);
|
||||
div.addStyle(HtmlStyle.header);
|
||||
PackageElement pkg = utils.containingPackage(annotationType);
|
||||
if (!pkg.isUnnamed()) {
|
||||
Content pkgNameContent = new StringContent(utils.getPackageName(pkg));
|
||||
Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
|
||||
div.addContent(pkgNameDiv);
|
||||
}
|
||||
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS_HEADER, annotationType);
|
||||
Content headerContent = new StringContent(header);
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
|
||||
HtmlStyle.title, headerContent);
|
||||
heading.addContent(getTypeParameterLinks(linkInfo));
|
||||
div.addContent(heading);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
mainTree.addContent(div);
|
||||
} else {
|
||||
bodyTree.addContent(div);
|
||||
}
|
||||
return bodyTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getAnnotationContentHeader() {
|
||||
return getContentHeader();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addFooter(Content contentTree) {
|
||||
contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
|
||||
Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
|
||||
? HtmlTree.FOOTER()
|
||||
: contentTree;
|
||||
addNavLinks(false, htmlTree);
|
||||
addBottom(htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
contentTree.addContent(htmlTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void printDocument(Content contentTree) throws IOException {
|
||||
printHtmlDocument(configuration.metakeywords.getMetaKeywords(annotationType),
|
||||
true, contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getAnnotationInfoTreeHeader() {
|
||||
return getMemberTreeHeader();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getAnnotationInfo(Content annotationInfoTree) {
|
||||
return getMemberTree(HtmlStyle.description, annotationInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addAnnotationTypeSignature(String modifiers, Content annotationInfoTree) {
|
||||
annotationInfoTree.addContent(new HtmlTree(HtmlTag.BR));
|
||||
Content pre = new HtmlTree(HtmlTag.PRE);
|
||||
addAnnotationInfo(annotationType, pre);
|
||||
pre.addContent(modifiers);
|
||||
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS_SIGNATURE, annotationType);
|
||||
Content annotationName = new StringContent(utils.getSimpleName(annotationType));
|
||||
Content parameterLinks = getTypeParameterLinks(linkInfo);
|
||||
if (configuration.linksource) {
|
||||
addSrcLink(annotationType, annotationName, pre);
|
||||
pre.addContent(parameterLinks);
|
||||
} else {
|
||||
Content span = HtmlTree.SPAN(HtmlStyle.memberNameLabel, annotationName);
|
||||
span.addContent(parameterLinks);
|
||||
pre.addContent(span);
|
||||
}
|
||||
annotationInfoTree.addContent(pre);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addAnnotationTypeDescription(Content annotationInfoTree) {
|
||||
if(!configuration.nocomment) {
|
||||
if (!utils.getBody(annotationType).isEmpty()) {
|
||||
addInlineComment(annotationType, annotationInfoTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addAnnotationTypeTagInfo(Content annotationInfoTree) {
|
||||
if(!configuration.nocomment) {
|
||||
addTagsInfo(annotationType, annotationInfoTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addAnnotationTypeDeprecationInfo(Content annotationInfoTree) {
|
||||
Content hr = new HtmlTree(HtmlTag.HR);
|
||||
annotationInfoTree.addContent(hr);
|
||||
List<? extends DocTree> deprs = utils.getBlockTags(annotationType, DocTree.Kind.DEPRECATED);
|
||||
if (utils.isDeprecated(annotationType)) {
|
||||
CommentHelper ch = utils.getCommentHelper(annotationType);
|
||||
Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
|
||||
Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
|
||||
if (!deprs.isEmpty()) {
|
||||
|
||||
List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
|
||||
if (!commentTags.isEmpty()) {
|
||||
div.addContent(getSpace());
|
||||
addInlineDeprecatedComment(annotationType, deprs.get(0), div);
|
||||
}
|
||||
}
|
||||
annotationInfoTree.addContent(div);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content getNavLinkTree() {
|
||||
Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
|
||||
treeLabel, "", "");
|
||||
Content li = HtmlTree.LI(treeLinkContent);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add summary details to the navigation bar.
|
||||
*
|
||||
* @param subDiv the content tree to which the summary detail links will be added
|
||||
*/
|
||||
@Override
|
||||
protected void addSummaryDetailLinks(Content subDiv) {
|
||||
try {
|
||||
Content div = HtmlTree.DIV(getNavSummaryLinks());
|
||||
div.addContent(getNavDetailLinks());
|
||||
subDiv.addContent(div);
|
||||
} catch (Exception e) {
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get summary links for navigation bar.
|
||||
*
|
||||
* @return the content tree for the navigation summary links
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
protected Content getNavSummaryLinks() throws Exception {
|
||||
Content li = HtmlTree.LI(summaryLabel);
|
||||
li.addContent(getSpace());
|
||||
Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
|
||||
MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
|
||||
configuration.getBuilderFactory().getMemberSummaryBuilder(this);
|
||||
Content liNavField = new HtmlTree(HtmlTag.LI);
|
||||
addNavSummaryLink(memberSummaryBuilder,
|
||||
"doclet.navField",
|
||||
VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS, liNavField);
|
||||
addNavGap(liNavField);
|
||||
ulNav.addContent(liNavField);
|
||||
Content liNavReq = new HtmlTree(HtmlTag.LI);
|
||||
addNavSummaryLink(memberSummaryBuilder,
|
||||
"doclet.navAnnotationTypeRequiredMember",
|
||||
VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED, liNavReq);
|
||||
addNavGap(liNavReq);
|
||||
ulNav.addContent(liNavReq);
|
||||
Content liNavOpt = new HtmlTree(HtmlTag.LI);
|
||||
addNavSummaryLink(memberSummaryBuilder,
|
||||
"doclet.navAnnotationTypeOptionalMember",
|
||||
VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL, liNavOpt);
|
||||
ulNav.addContent(liNavOpt);
|
||||
return ulNav;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the navigation summary link.
|
||||
*
|
||||
* @param builder builder for the member to be documented
|
||||
* @param label the label for the navigation
|
||||
* @param type type to be documented
|
||||
* @param liNav the content tree to which the navigation summary link will be added
|
||||
*/
|
||||
protected void addNavSummaryLink(MemberSummaryBuilder builder,
|
||||
String label, VisibleMemberMap.Kind type, Content liNav) {
|
||||
AbstractMemberWriter writer = ((AbstractMemberWriter) builder.
|
||||
getMemberSummaryWriter(type));
|
||||
if (writer == null) {
|
||||
liNav.addContent(getResource(label));
|
||||
} else {
|
||||
liNav.addContent(writer.getNavSummaryLink(null,
|
||||
! builder.getVisibleMemberMap(type).noVisibleMembers()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get detail links for the navigation bar.
|
||||
*
|
||||
* @return the content tree for the detail links
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
protected Content getNavDetailLinks() throws Exception {
|
||||
Content li = HtmlTree.LI(detailLabel);
|
||||
li.addContent(getSpace());
|
||||
Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
|
||||
MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
|
||||
configuration.getBuilderFactory().getMemberSummaryBuilder(this);
|
||||
AbstractMemberWriter writerField =
|
||||
((AbstractMemberWriter) memberSummaryBuilder.
|
||||
getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS));
|
||||
AbstractMemberWriter writerOptional =
|
||||
((AbstractMemberWriter) memberSummaryBuilder.
|
||||
getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL));
|
||||
AbstractMemberWriter writerRequired =
|
||||
((AbstractMemberWriter) memberSummaryBuilder.
|
||||
getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED));
|
||||
Content liNavField = new HtmlTree(HtmlTag.LI);
|
||||
if (writerField != null) {
|
||||
writerField.addNavDetailLink(!utils.getAnnotationFields(annotationType).isEmpty(), liNavField);
|
||||
} else {
|
||||
liNavField.addContent(getResource("doclet.navField"));
|
||||
}
|
||||
addNavGap(liNavField);
|
||||
ulNav.addContent(liNavField);
|
||||
if (writerOptional != null){
|
||||
Content liNavOpt = new HtmlTree(HtmlTag.LI);
|
||||
writerOptional.addNavDetailLink(!annotationType.getAnnotationMirrors().isEmpty(), liNavOpt);
|
||||
ulNav.addContent(liNavOpt);
|
||||
} else if (writerRequired != null){
|
||||
Content liNavReq = new HtmlTree(HtmlTag.LI);
|
||||
writerRequired.addNavDetailLink(!annotationType.getAnnotationMirrors().isEmpty(), liNavReq);
|
||||
ulNav.addContent(liNavReq);
|
||||
} else {
|
||||
Content liNav = HtmlTree.LI(getResource("doclet.navAnnotationTypeMember"));
|
||||
ulNav.addContent(liNav);
|
||||
}
|
||||
return ulNav;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add gap between navigation bar elements.
|
||||
*
|
||||
* @param liNav the content tree to which the gap will be added
|
||||
*/
|
||||
protected void addNavGap(Content liNav) {
|
||||
liNav.addContent(getSpace());
|
||||
liNav.addContent("|");
|
||||
liNav.addContent(getSpace());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public TypeElement getAnnotationTypeElement() {
|
||||
return annotationType;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,554 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.PackageElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
|
||||
/**
|
||||
* Generate class usage information.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Robert G. Field
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class ClassUseWriter extends SubWriterHolderWriter {
|
||||
|
||||
final TypeElement typeElement;
|
||||
Set<PackageElement> pkgToPackageAnnotations = null;
|
||||
final Map<PackageElement, List<Element>> pkgToClassTypeParameter;
|
||||
final Map<PackageElement, List<Element>> pkgToClassAnnotations;
|
||||
final Map<PackageElement, List<Element>> pkgToMethodTypeParameter;
|
||||
final Map<PackageElement, List<Element>> pkgToMethodArgTypeParameter;
|
||||
final Map<PackageElement, List<Element>> pkgToMethodReturnTypeParameter;
|
||||
final Map<PackageElement, List<Element>> pkgToMethodAnnotations;
|
||||
final Map<PackageElement, List<Element>> pkgToMethodParameterAnnotations;
|
||||
final Map<PackageElement, List<Element>> pkgToFieldTypeParameter;
|
||||
final Map<PackageElement, List<Element>> pkgToFieldAnnotations;
|
||||
final Map<PackageElement, List<Element>> pkgToSubclass;
|
||||
final Map<PackageElement, List<Element>> pkgToSubinterface;
|
||||
final Map<PackageElement, List<Element>> pkgToImplementingClass;
|
||||
final Map<PackageElement, List<Element>> pkgToField;
|
||||
final Map<PackageElement, List<Element>> pkgToMethodReturn;
|
||||
final Map<PackageElement, List<Element>> pkgToMethodArgs;
|
||||
final Map<PackageElement, List<Element>> pkgToMethodThrows;
|
||||
final Map<PackageElement, List<Element>> pkgToConstructorAnnotations;
|
||||
final Map<PackageElement, List<Element>> pkgToConstructorParameterAnnotations;
|
||||
final Map<PackageElement, List<Element>> pkgToConstructorArgs;
|
||||
final Map<PackageElement, List<Element>> pkgToConstructorArgTypeParameter;
|
||||
final Map<PackageElement, List<Element>> pkgToConstructorThrows;
|
||||
final SortedSet<PackageElement> pkgSet;
|
||||
final MethodWriterImpl methodSubWriter;
|
||||
final ConstructorWriterImpl constrSubWriter;
|
||||
final FieldWriterImpl fieldSubWriter;
|
||||
final NestedClassWriterImpl classSubWriter;
|
||||
// Summary for various use tables.
|
||||
final String classUseTableSummary;
|
||||
final String subclassUseTableSummary;
|
||||
final String subinterfaceUseTableSummary;
|
||||
final String fieldUseTableSummary;
|
||||
final String methodUseTableSummary;
|
||||
final String constructorUseTableSummary;
|
||||
|
||||
/**
|
||||
* The HTML tree for main tag.
|
||||
*/
|
||||
protected HtmlTree mainTree = HtmlTree.MAIN();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param filename the file to be generated.
|
||||
* @throws IOException
|
||||
* @throws DocletAbortException
|
||||
*/
|
||||
public ClassUseWriter(ConfigurationImpl configuration,
|
||||
ClassUseMapper mapper, DocPath filename,
|
||||
TypeElement typeElement) throws IOException {
|
||||
super(configuration, filename);
|
||||
this.typeElement = typeElement;
|
||||
if (mapper.classToPackageAnnotations.containsKey(typeElement)) {
|
||||
pkgToPackageAnnotations = new TreeSet<>(utils.makeClassUseComparator());
|
||||
pkgToPackageAnnotations.addAll(mapper.classToPackageAnnotations.get(typeElement));
|
||||
}
|
||||
configuration.currentTypeElement = typeElement;
|
||||
this.pkgSet = new TreeSet<>(utils.makePackageComparator());
|
||||
this.pkgToClassTypeParameter = pkgDivide(mapper.classToClassTypeParam);
|
||||
this.pkgToClassAnnotations = pkgDivide(mapper.classToClassAnnotations);
|
||||
this.pkgToMethodTypeParameter = pkgDivide(mapper.classToMethodTypeParam);
|
||||
this.pkgToMethodArgTypeParameter = pkgDivide(mapper.classToMethodArgTypeParam);
|
||||
this.pkgToFieldTypeParameter = pkgDivide(mapper.classToFieldTypeParam);
|
||||
this.pkgToFieldAnnotations = pkgDivide(mapper.annotationToField);
|
||||
this.pkgToMethodReturnTypeParameter = pkgDivide(mapper.classToMethodReturnTypeParam);
|
||||
this.pkgToMethodAnnotations = pkgDivide(mapper.classToMethodAnnotations);
|
||||
this.pkgToMethodParameterAnnotations = pkgDivide(mapper.classToMethodParamAnnotation);
|
||||
this.pkgToSubclass = pkgDivide(mapper.classToSubclass);
|
||||
this.pkgToSubinterface = pkgDivide(mapper.classToSubinterface);
|
||||
this.pkgToImplementingClass = pkgDivide(mapper.classToImplementingClass);
|
||||
this.pkgToField = pkgDivide(mapper.classToField);
|
||||
this.pkgToMethodReturn = pkgDivide(mapper.classToMethodReturn);
|
||||
this.pkgToMethodArgs = pkgDivide(mapper.classToMethodArgs);
|
||||
this.pkgToMethodThrows = pkgDivide(mapper.classToMethodThrows);
|
||||
this.pkgToConstructorAnnotations = pkgDivide(mapper.classToConstructorAnnotations);
|
||||
this.pkgToConstructorParameterAnnotations = pkgDivide(mapper.classToConstructorParamAnnotation);
|
||||
this.pkgToConstructorArgs = pkgDivide(mapper.classToConstructorArgs);
|
||||
this.pkgToConstructorArgTypeParameter = pkgDivide(mapper.classToConstructorArgTypeParam);
|
||||
this.pkgToConstructorThrows = pkgDivide(mapper.classToConstructorThrows);
|
||||
//tmp test
|
||||
if (pkgSet.size() > 0 &&
|
||||
mapper.classToPackage.containsKey(this.typeElement) &&
|
||||
!pkgSet.equals(mapper.classToPackage.get(this.typeElement))) {
|
||||
configuration.reporter.print(Diagnostic.Kind.WARNING,
|
||||
"Internal error: package sets don't match: "
|
||||
+ pkgSet + " with: " + mapper.classToPackage.get(this.typeElement));
|
||||
}
|
||||
methodSubWriter = new MethodWriterImpl(this);
|
||||
constrSubWriter = new ConstructorWriterImpl(this);
|
||||
fieldSubWriter = new FieldWriterImpl(this);
|
||||
classSubWriter = new NestedClassWriterImpl(this);
|
||||
classUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
|
||||
configuration.getText("doclet.classes"));
|
||||
subclassUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
|
||||
configuration.getText("doclet.subclasses"));
|
||||
subinterfaceUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
|
||||
configuration.getText("doclet.subinterfaces"));
|
||||
fieldUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
|
||||
configuration.getText("doclet.fields"));
|
||||
methodUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
|
||||
configuration.getText("doclet.methods"));
|
||||
constructorUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
|
||||
configuration.getText("doclet.constructors"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write out class use pages.
|
||||
* @throws DocletAbortException
|
||||
*/
|
||||
public static void generate(ConfigurationImpl configuration, ClassTree classtree) {
|
||||
ClassUseMapper mapper = new ClassUseMapper(configuration, classtree);
|
||||
for (TypeElement aClass : configuration.root.getIncludedClasses()) {
|
||||
// If -nodeprecated option is set and the containing package is marked
|
||||
// as deprecated, do not generate the class-use page. We will still generate
|
||||
// the class-use page if the class is marked as deprecated but the containing
|
||||
// package is not since it could still be linked from that package-use page.
|
||||
if (!(configuration.nodeprecated &&
|
||||
configuration.utils.isDeprecated(configuration.utils.containingPackage(aClass))))
|
||||
ClassUseWriter.generate(configuration, mapper, aClass);
|
||||
}
|
||||
for (PackageElement pkg : configuration.packages) {
|
||||
// If -nodeprecated option is set and the package is marked
|
||||
// as deprecated, do not generate the package-use page.
|
||||
if (!(configuration.nodeprecated && configuration.utils.isDeprecated(pkg)))
|
||||
PackageUseWriter.generate(configuration, mapper, pkg);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<PackageElement, List<Element>> pkgDivide(Map<TypeElement, ? extends List<? extends Element>> classMap) {
|
||||
Map<PackageElement, List<Element>> map = new HashMap<>();
|
||||
List<? extends Element> elements = (List<? extends Element>) classMap.get(typeElement);
|
||||
if (elements != null) {
|
||||
Collections.sort(elements, utils.makeClassUseComparator());
|
||||
for (Element e : elements) {
|
||||
PackageElement pkg = utils.containingPackage(e);
|
||||
pkgSet.add(pkg);
|
||||
List<Element> inPkg = map.get(pkg);
|
||||
if (inPkg == null) {
|
||||
inPkg = new ArrayList<>();
|
||||
map.put(pkg, inPkg);
|
||||
}
|
||||
inPkg.add(e);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a class page.
|
||||
*/
|
||||
public static void generate(ConfigurationImpl configuration, ClassUseMapper mapper,
|
||||
TypeElement typeElement) {
|
||||
ClassUseWriter clsgen;
|
||||
DocPath path = DocPath.forPackage(configuration.utils, typeElement)
|
||||
.resolve(DocPaths.CLASS_USE)
|
||||
.resolve(DocPath.forName(configuration.utils, typeElement));
|
||||
try {
|
||||
clsgen = new ClassUseWriter(configuration, mapper, path, typeElement);
|
||||
clsgen.generateClassUseFile();
|
||||
clsgen.close();
|
||||
} catch (IOException exc) {
|
||||
configuration.standardmessage.
|
||||
error("doclet.exception_encountered",
|
||||
exc.toString(), path.getPath());
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the class use elements.
|
||||
*/
|
||||
protected void generateClassUseFile() throws IOException {
|
||||
HtmlTree body = getClassUseHeader();
|
||||
HtmlTree div = new HtmlTree(HtmlTag.DIV);
|
||||
div.addStyle(HtmlStyle.classUseContainer);
|
||||
if (pkgSet.size() > 0) {
|
||||
addClassUse(div);
|
||||
} else {
|
||||
div.addContent(getResource("doclet.ClassUse_No.usage.of.0",
|
||||
utils.getFullyQualifiedName(typeElement)));
|
||||
}
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
mainTree.addContent(div);
|
||||
body.addContent(mainTree);
|
||||
} else {
|
||||
body.addContent(div);
|
||||
}
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
|
||||
? HtmlTree.FOOTER()
|
||||
: body;
|
||||
addNavLinks(false, htmlTree);
|
||||
addBottom(htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
body.addContent(htmlTree);
|
||||
}
|
||||
printHtmlDocument(null, true, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the class use documentation.
|
||||
*
|
||||
* @param contentTree the content tree to which the class use information will be added
|
||||
*/
|
||||
protected void addClassUse(Content contentTree) throws IOException {
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
ul.addStyle(HtmlStyle.blockList);
|
||||
if (configuration.packages.size() > 1) {
|
||||
addPackageList(ul);
|
||||
addPackageAnnotationList(ul);
|
||||
}
|
||||
addClassList(ul);
|
||||
contentTree.addContent(ul);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the packages elements that use the given class.
|
||||
*
|
||||
* @param contentTree the content tree to which the packages elements will be added
|
||||
*/
|
||||
protected void addPackageList(Content contentTree) throws IOException {
|
||||
Content caption = getTableCaption(configuration.getResource(
|
||||
"doclet.ClassUse_Packages.that.use.0",
|
||||
getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement))));
|
||||
Content table = (configuration.isOutputHtml5())
|
||||
? HtmlTree.TABLE(HtmlStyle.useSummary, caption)
|
||||
: HtmlTree.TABLE(HtmlStyle.useSummary, useTableSummary, caption);
|
||||
table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
|
||||
Content tbody = new HtmlTree(HtmlTag.TBODY);
|
||||
boolean altColor = true;
|
||||
for (PackageElement pkg : pkgSet) {
|
||||
HtmlTree tr = new HtmlTree(HtmlTag.TR);
|
||||
tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
|
||||
altColor = !altColor;
|
||||
addPackageUse(pkg, tr);
|
||||
tbody.addContent(tr);
|
||||
}
|
||||
table.addContent(tbody);
|
||||
Content li = HtmlTree.LI(HtmlStyle.blockList, table);
|
||||
contentTree.addContent(li);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the package annotation elements.
|
||||
*
|
||||
* @param contentTree the content tree to which the package annotation elements will be added
|
||||
*/
|
||||
protected void addPackageAnnotationList(Content contentTree) throws IOException {
|
||||
if (!utils.isAnnotationType(typeElement) ||
|
||||
pkgToPackageAnnotations == null ||
|
||||
pkgToPackageAnnotations.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Content caption = getTableCaption(configuration.getResource(
|
||||
"doclet.ClassUse_PackageAnnotation",
|
||||
getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement))));
|
||||
Content table = (configuration.isOutputHtml5())
|
||||
? HtmlTree.TABLE(HtmlStyle.useSummary, caption)
|
||||
: HtmlTree.TABLE(HtmlStyle.useSummary, useTableSummary, caption);
|
||||
table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
|
||||
Content tbody = new HtmlTree(HtmlTag.TBODY);
|
||||
boolean altColor = true;
|
||||
for (PackageElement pkg : pkgToPackageAnnotations) {
|
||||
HtmlTree tr = new HtmlTree(HtmlTag.TR);
|
||||
tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
|
||||
altColor = !altColor;
|
||||
Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst, getPackageLink(pkg));
|
||||
tr.addContent(tdFirst);
|
||||
HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
|
||||
tdLast.addStyle(HtmlStyle.colLast);
|
||||
addSummaryComment(pkg, tdLast);
|
||||
tr.addContent(tdLast);
|
||||
tbody.addContent(tr);
|
||||
}
|
||||
table.addContent(tbody);
|
||||
Content li = HtmlTree.LI(HtmlStyle.blockList, table);
|
||||
contentTree.addContent(li);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the class elements that use the given class.
|
||||
*
|
||||
* @param contentTree the content tree to which the class elements will be added
|
||||
*/
|
||||
protected void addClassList(Content contentTree) throws IOException {
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
ul.addStyle(HtmlStyle.blockList);
|
||||
for (PackageElement pkg : pkgSet) {
|
||||
Content markerAnchor = getMarkerAnchor(getPackageAnchorName(pkg));
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION(markerAnchor)
|
||||
: HtmlTree.LI(HtmlStyle.blockList, markerAnchor);
|
||||
Content link = getResource("doclet.ClassUse_Uses.of.0.in.1",
|
||||
getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER,
|
||||
typeElement)),
|
||||
getPackageLink(pkg, utils.getPackageName(pkg)));
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
|
||||
htmlTree.addContent(heading);
|
||||
addClassUse(pkg, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
|
||||
} else {
|
||||
ul.addContent(htmlTree);
|
||||
}
|
||||
}
|
||||
Content li = HtmlTree.LI(HtmlStyle.blockList, ul);
|
||||
contentTree.addContent(li);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the package use information.
|
||||
*
|
||||
* @param pkg the package that uses the given class
|
||||
* @param contentTree the content tree to which the package use information will be added
|
||||
*/
|
||||
protected void addPackageUse(PackageElement pkg, Content contentTree) throws IOException {
|
||||
Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
|
||||
getHyperLink(getPackageAnchorName(pkg), new StringContent(utils.getPackageName(pkg))));
|
||||
contentTree.addContent(tdFirst);
|
||||
HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
|
||||
tdLast.addStyle(HtmlStyle.colLast);
|
||||
addSummaryComment(pkg, tdLast);
|
||||
contentTree.addContent(tdLast);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the class use information.
|
||||
*
|
||||
* @param pkg the package that uses the given class
|
||||
* @param contentTree the content tree to which the class use information will be added
|
||||
*/
|
||||
protected void addClassUse(PackageElement pkg, Content contentTree) throws IOException {
|
||||
Content classLink = getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement));
|
||||
Content pkgLink = getPackageLink(pkg, utils.getPackageName(pkg));
|
||||
classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_Annotation", classLink,
|
||||
pkgLink), classUseTableSummary, contentTree);
|
||||
classSubWriter.addUseInfo(pkgToClassTypeParameter.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_TypeParameter", classLink,
|
||||
pkgLink), classUseTableSummary, contentTree);
|
||||
classSubWriter.addUseInfo(pkgToSubclass.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_Subclass", classLink,
|
||||
pkgLink), subclassUseTableSummary, contentTree);
|
||||
classSubWriter.addUseInfo(pkgToSubinterface.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_Subinterface", classLink,
|
||||
pkgLink), subinterfaceUseTableSummary, contentTree);
|
||||
classSubWriter.addUseInfo(pkgToImplementingClass.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_ImplementingClass", classLink,
|
||||
pkgLink), classUseTableSummary, contentTree);
|
||||
fieldSubWriter.addUseInfo(pkgToField.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_Field", classLink,
|
||||
pkgLink), fieldUseTableSummary, contentTree);
|
||||
fieldSubWriter.addUseInfo(pkgToFieldAnnotations.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_FieldAnnotations", classLink,
|
||||
pkgLink), fieldUseTableSummary, contentTree);
|
||||
fieldSubWriter.addUseInfo(pkgToFieldTypeParameter.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_FieldTypeParameter", classLink,
|
||||
pkgLink), fieldUseTableSummary, contentTree);
|
||||
methodSubWriter.addUseInfo(pkgToMethodAnnotations.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_MethodAnnotations", classLink,
|
||||
pkgLink), methodUseTableSummary, contentTree);
|
||||
methodSubWriter.addUseInfo(pkgToMethodParameterAnnotations.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_MethodParameterAnnotations", classLink,
|
||||
pkgLink), methodUseTableSummary, contentTree);
|
||||
methodSubWriter.addUseInfo(pkgToMethodTypeParameter.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_MethodTypeParameter", classLink,
|
||||
pkgLink), methodUseTableSummary, contentTree);
|
||||
methodSubWriter.addUseInfo(pkgToMethodReturn.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_MethodReturn", classLink,
|
||||
pkgLink), methodUseTableSummary, contentTree);
|
||||
methodSubWriter.addUseInfo(pkgToMethodReturnTypeParameter.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_MethodReturnTypeParameter", classLink,
|
||||
pkgLink), methodUseTableSummary, contentTree);
|
||||
methodSubWriter.addUseInfo(pkgToMethodArgs.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_MethodArgs", classLink,
|
||||
pkgLink), methodUseTableSummary, contentTree);
|
||||
methodSubWriter.addUseInfo(pkgToMethodArgTypeParameter.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_MethodArgsTypeParameters", classLink,
|
||||
pkgLink), methodUseTableSummary, contentTree);
|
||||
methodSubWriter.addUseInfo(pkgToMethodThrows.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_MethodThrows", classLink,
|
||||
pkgLink), methodUseTableSummary, contentTree);
|
||||
constrSubWriter.addUseInfo(pkgToConstructorAnnotations.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_ConstructorAnnotations", classLink,
|
||||
pkgLink), constructorUseTableSummary, contentTree);
|
||||
constrSubWriter.addUseInfo(pkgToConstructorParameterAnnotations.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_ConstructorParameterAnnotations", classLink,
|
||||
pkgLink), constructorUseTableSummary, contentTree);
|
||||
constrSubWriter.addUseInfo(pkgToConstructorArgs.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_ConstructorArgs", classLink,
|
||||
pkgLink), constructorUseTableSummary, contentTree);
|
||||
constrSubWriter.addUseInfo(pkgToConstructorArgTypeParameter.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_ConstructorArgsTypeParameters", classLink,
|
||||
pkgLink), constructorUseTableSummary, contentTree);
|
||||
constrSubWriter.addUseInfo(pkgToConstructorThrows.get(pkg),
|
||||
configuration.getResource("doclet.ClassUse_ConstructorThrows", classLink,
|
||||
pkgLink), constructorUseTableSummary, contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the header for the class use Listing.
|
||||
*
|
||||
* @return a content tree representing the class use header
|
||||
*/
|
||||
protected HtmlTree getClassUseHeader() {
|
||||
String cltype = configuration.getText(utils.isInterface(typeElement)
|
||||
? "doclet.Interface"
|
||||
: "doclet.Class");
|
||||
String clname = utils.getFullyQualifiedName(typeElement);
|
||||
String title = configuration.getText("doclet.Window_ClassUse_Header",
|
||||
cltype, clname);
|
||||
HtmlTree bodyTree = getBody(true, getWindowTitle(title));
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
|
||||
? HtmlTree.HEADER()
|
||||
: bodyTree;
|
||||
addTop(htmlTree);
|
||||
addNavLinks(true, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.HEADER)) {
|
||||
bodyTree.addContent(htmlTree);
|
||||
}
|
||||
ContentBuilder headContent = new ContentBuilder();
|
||||
headContent.addContent(getResource("doclet.ClassUse_Title", cltype));
|
||||
headContent.addContent(new HtmlTree(HtmlTag.BR));
|
||||
headContent.addContent(clname);
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING,
|
||||
true, HtmlStyle.title, headContent);
|
||||
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
mainTree.addContent(div);
|
||||
} else {
|
||||
bodyTree.addContent(div);
|
||||
}
|
||||
return bodyTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this package link.
|
||||
*
|
||||
* @return a content tree for the package link
|
||||
*/
|
||||
protected Content getNavLinkPackage() {
|
||||
Content linkContent =
|
||||
getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), packageLabel);
|
||||
Content li = HtmlTree.LI(linkContent);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class page link.
|
||||
*
|
||||
* @return a content tree for the class page link
|
||||
*/
|
||||
protected Content getNavLinkClass() {
|
||||
Content linkContent = getLink(new LinkInfoImpl(
|
||||
configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)
|
||||
.label(configuration.getText("doclet.Class")));
|
||||
Content li = HtmlTree.LI(linkContent);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the use link.
|
||||
*
|
||||
* @return a content tree for the use link
|
||||
*/
|
||||
protected Content getNavLinkClassUse() {
|
||||
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, useLabel);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tree link.
|
||||
*
|
||||
* @return a content tree for the tree link
|
||||
*/
|
||||
protected Content getNavLinkTree() {
|
||||
Content linkContent = utils.isEnclosingPackageIncluded(typeElement)
|
||||
? getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), treeLabel)
|
||||
: getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), treeLabel);
|
||||
Content li = HtmlTree.LI(linkContent);
|
||||
return li;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,759 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import javax.lang.model.element.AnnotationMirror;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.PackageElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.lang.model.util.SimpleElementVisitor8;
|
||||
|
||||
import com.sun.source.doctree.DocTree;
|
||||
import com.sun.tools.javac.util.DefinedBy;
|
||||
import com.sun.tools.javac.util.DefinedBy.Api;
|
||||
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.ClassWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.builders.MemberSummaryBuilder;
|
||||
import jdk.javadoc.internal.doclets.toolkit.taglets.ParamTaglet;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.Kind;
|
||||
|
||||
/**
|
||||
* Generate the Class Information Page.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @see javax.lang.model.element.TypeElement
|
||||
* @see java.util.Collections
|
||||
* @see java.util.List
|
||||
* @see java.util.ArrayList
|
||||
* @see java.util.HashMap
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
* @author Robert Field
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWriter {
|
||||
|
||||
protected final TypeElement typeElement;
|
||||
|
||||
protected final ClassTree classtree;
|
||||
|
||||
protected final TypeElement prev;
|
||||
|
||||
protected final TypeElement next;
|
||||
|
||||
/**
|
||||
* @param configuration the configuration data for the doclet
|
||||
* @param typeElement the class being documented.
|
||||
* @param prevClass the previous class that was documented.
|
||||
* @param nextClass the next class being documented.
|
||||
* @param classTree the class tree for the given class.
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public ClassWriterImpl(ConfigurationImpl configuration, TypeElement typeElement,
|
||||
TypeElement prevClass, TypeElement nextClass, ClassTree classTree)
|
||||
throws IOException {
|
||||
super(configuration, DocPath.forClass(configuration.utils, typeElement));
|
||||
this.typeElement = typeElement;
|
||||
configuration.currentTypeElement = typeElement;
|
||||
this.classtree = classTree;
|
||||
this.prev = prevClass;
|
||||
this.next = nextClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this package link.
|
||||
*
|
||||
* @return a content tree for the package link
|
||||
*/
|
||||
@Override
|
||||
protected Content getNavLinkPackage() {
|
||||
Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
|
||||
packageLabel);
|
||||
Content li = HtmlTree.LI(linkContent);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class link.
|
||||
*
|
||||
* @return a content tree for the class link
|
||||
*/
|
||||
@Override
|
||||
protected Content getNavLinkClass() {
|
||||
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class use link.
|
||||
*
|
||||
* @return a content tree for the class use link
|
||||
*/
|
||||
@Override
|
||||
protected Content getNavLinkClassUse() {
|
||||
Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel);
|
||||
Content li = HtmlTree.LI(linkContent);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link to previous class.
|
||||
*
|
||||
* @return a content tree for the previous class link
|
||||
*/
|
||||
@Override
|
||||
public Content getNavLinkPrevious() {
|
||||
Content li;
|
||||
if (prev != null) {
|
||||
Content prevLink = getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS, prev)
|
||||
.label(prevclassLabel).strong(true));
|
||||
li = HtmlTree.LI(prevLink);
|
||||
}
|
||||
else
|
||||
li = HtmlTree.LI(prevclassLabel);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link to next class.
|
||||
*
|
||||
* @return a content tree for the next class link
|
||||
*/
|
||||
@Override
|
||||
public Content getNavLinkNext() {
|
||||
Content li;
|
||||
if (next != null) {
|
||||
Content nextLink = getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS, next)
|
||||
.label(nextclassLabel).strong(true));
|
||||
li = HtmlTree.LI(nextLink);
|
||||
}
|
||||
else
|
||||
li = HtmlTree.LI(nextclassLabel);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getHeader(String header) {
|
||||
HtmlTree bodyTree = getBody(true, getWindowTitle(utils.getSimpleName(typeElement)));
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
|
||||
? HtmlTree.HEADER()
|
||||
: bodyTree;
|
||||
addTop(htmlTree);
|
||||
addNavLinks(true, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.HEADER)) {
|
||||
bodyTree.addContent(htmlTree);
|
||||
}
|
||||
bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
|
||||
HtmlTree div = new HtmlTree(HtmlTag.DIV);
|
||||
div.addStyle(HtmlStyle.header);
|
||||
PackageElement pkg = utils.containingPackage(typeElement);
|
||||
if (!pkg.isUnnamed()) {
|
||||
Content pkgNameContent = new StringContent(utils.getPackageName(pkg));
|
||||
Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
|
||||
div.addContent(pkgNameDiv);
|
||||
}
|
||||
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS_HEADER, typeElement);
|
||||
//Let's not link to ourselves in the header.
|
||||
linkInfo.linkToSelf = false;
|
||||
Content headerContent = new StringContent(header);
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
|
||||
HtmlStyle.title, headerContent);
|
||||
heading.addContent(getTypeParameterLinks(linkInfo));
|
||||
div.addContent(heading);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
mainTree.addContent(div);
|
||||
} else {
|
||||
bodyTree.addContent(div);
|
||||
}
|
||||
return bodyTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getClassContentHeader() {
|
||||
return getContentHeader();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addFooter(Content contentTree) {
|
||||
contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
|
||||
Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
|
||||
? HtmlTree.FOOTER()
|
||||
: contentTree;
|
||||
addNavLinks(false, htmlTree);
|
||||
addBottom(htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
contentTree.addContent(htmlTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void printDocument(Content contentTree) throws IOException {
|
||||
printHtmlDocument(configuration.metakeywords.getMetaKeywords(typeElement),
|
||||
true, contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getClassInfoTreeHeader() {
|
||||
return getMemberTreeHeader();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getClassInfo(Content classInfoTree) {
|
||||
return getMemberTree(HtmlStyle.description, classInfoTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addClassSignature(String modifiers, Content classInfoTree) {
|
||||
classInfoTree.addContent(new HtmlTree(HtmlTag.BR));
|
||||
Content pre = new HtmlTree(HtmlTag.PRE);
|
||||
addAnnotationInfo(typeElement, pre);
|
||||
pre.addContent(modifiers);
|
||||
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS_SIGNATURE, typeElement);
|
||||
//Let's not link to ourselves in the signature.
|
||||
linkInfo.linkToSelf = false;
|
||||
Content className = new StringContent(utils.getSimpleName(typeElement));
|
||||
Content parameterLinks = getTypeParameterLinks(linkInfo);
|
||||
if (configuration.linksource) {
|
||||
addSrcLink(typeElement, className, pre);
|
||||
pre.addContent(parameterLinks);
|
||||
} else {
|
||||
Content span = HtmlTree.SPAN(HtmlStyle.typeNameLabel, className);
|
||||
span.addContent(parameterLinks);
|
||||
pre.addContent(span);
|
||||
}
|
||||
if (!utils.isInterface(typeElement)) {
|
||||
TypeMirror superclass = utils.getFirstVisibleSuperClass(typeElement);
|
||||
if (superclass != null) {
|
||||
pre.addContent(DocletConstants.NL);
|
||||
pre.addContent("extends ");
|
||||
Content link = getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME,
|
||||
superclass));
|
||||
pre.addContent(link);
|
||||
}
|
||||
}
|
||||
List<? extends TypeMirror> interfaces = typeElement.getInterfaces();
|
||||
if (!interfaces.isEmpty()) {
|
||||
boolean isFirst = true;
|
||||
for (TypeMirror type : interfaces) {
|
||||
TypeElement tDoc = utils.asTypeElement(type);
|
||||
if (!(utils.isPublic(tDoc) || utils.isLinkable(tDoc))) {
|
||||
continue;
|
||||
}
|
||||
if (isFirst) {
|
||||
pre.addContent(DocletConstants.NL);
|
||||
pre.addContent(utils.isInterface(typeElement) ? "extends " : "implements ");
|
||||
isFirst = false;
|
||||
} else {
|
||||
pre.addContent(", ");
|
||||
}
|
||||
Content link = getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME,
|
||||
type));
|
||||
pre.addContent(link);
|
||||
}
|
||||
}
|
||||
classInfoTree.addContent(pre);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addClassDescription(Content classInfoTree) {
|
||||
if(!configuration.nocomment) {
|
||||
// generate documentation for the class.
|
||||
if (!utils.getBody(typeElement).isEmpty()) {
|
||||
addInlineComment(typeElement, classInfoTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addClassTagInfo(Content classInfoTree) {
|
||||
if(!configuration.nocomment) {
|
||||
// Print Information about all the tags here
|
||||
addTagsInfo(typeElement, classInfoTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class hierarchy tree for the given class.
|
||||
*
|
||||
* @param type the class to print the hierarchy for
|
||||
* @return a content tree for class inheritence
|
||||
*/
|
||||
private Content getClassInheritenceTree(TypeMirror type) {
|
||||
TypeMirror sup;
|
||||
HtmlTree classTreeUl = new HtmlTree(HtmlTag.UL);
|
||||
classTreeUl.addStyle(HtmlStyle.inheritance);
|
||||
Content liTree = null;
|
||||
do {
|
||||
sup = utils.getFirstVisibleSuperClass(type);
|
||||
if (sup != null) {
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
ul.addStyle(HtmlStyle.inheritance);
|
||||
ul.addContent(getTreeForClassHelper(type));
|
||||
if (liTree != null)
|
||||
ul.addContent(liTree);
|
||||
Content li = HtmlTree.LI(ul);
|
||||
liTree = li;
|
||||
type = sup;
|
||||
} else
|
||||
classTreeUl.addContent(getTreeForClassHelper(type));
|
||||
} while (sup != null);
|
||||
if (liTree != null)
|
||||
classTreeUl.addContent(liTree);
|
||||
return classTreeUl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class helper tree for the given class.
|
||||
*
|
||||
* @param type the class to print the helper for
|
||||
* @return a content tree for class helper
|
||||
*/
|
||||
private Content getTreeForClassHelper(TypeMirror type) {
|
||||
Content li = new HtmlTree(HtmlTag.LI);
|
||||
if (type.equals(typeElement.asType())) {
|
||||
Content typeParameters = getTypeParameterLinks(
|
||||
new LinkInfoImpl(configuration, LinkInfoImpl.Kind.TREE,
|
||||
typeElement));
|
||||
if (configuration.shouldExcludeQualifier(utils.containingPackage(typeElement).toString())) {
|
||||
li.addContent(utils.asTypeElement(type).getSimpleName().toString());
|
||||
li.addContent(typeParameters);
|
||||
} else {
|
||||
li.addContent(utils.asTypeElement(type).getQualifiedName().toString());
|
||||
li.addContent(typeParameters);
|
||||
}
|
||||
} else {
|
||||
Content link = getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS_TREE_PARENT, type)
|
||||
.label(configuration.getClassName(utils.asTypeElement(type))));
|
||||
li.addContent(link);
|
||||
}
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addClassTree(Content classContentTree) {
|
||||
if (!utils.isClass(typeElement)) {
|
||||
return;
|
||||
}
|
||||
classContentTree.addContent(getClassInheritenceTree(typeElement.asType()));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addTypeParamInfo(Content classInfoTree) {
|
||||
if (!utils.getTypeParamTrees(typeElement).isEmpty()) {
|
||||
Content typeParam = (new ParamTaglet()).getTagletOutput(typeElement,
|
||||
getTagletWriterInstance(false));
|
||||
Content dl = HtmlTree.DL(typeParam);
|
||||
classInfoTree.addContent(dl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addSubClassInfo(Content classInfoTree) {
|
||||
if (utils.isClass(typeElement)) {
|
||||
if (typeElement.getQualifiedName().toString().equals("java.lang.Object") ||
|
||||
typeElement.getQualifiedName().toString().equals("org.omg.CORBA.Object")) {
|
||||
return; // Don't generate the list, too huge
|
||||
}
|
||||
Set<TypeElement> subclasses = classtree.directSubClasses(typeElement, false);
|
||||
if (!subclasses.isEmpty()) {
|
||||
Content label = getResource(
|
||||
"doclet.Subclasses");
|
||||
Content dt = HtmlTree.DT(label);
|
||||
Content dl = HtmlTree.DL(dt);
|
||||
dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBCLASSES,
|
||||
subclasses));
|
||||
classInfoTree.addContent(dl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addSubInterfacesInfo(Content classInfoTree) {
|
||||
if (utils.isInterface(typeElement)) {
|
||||
Set<TypeElement> subInterfaces = classtree.allSubClasses(typeElement, false);
|
||||
if (!subInterfaces.isEmpty()) {
|
||||
Content label = getResource(
|
||||
"doclet.Subinterfaces");
|
||||
Content dt = HtmlTree.DT(label);
|
||||
Content dl = HtmlTree.DL(dt);
|
||||
dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBINTERFACES,
|
||||
subInterfaces));
|
||||
classInfoTree.addContent(dl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addInterfaceUsageInfo (Content classInfoTree) {
|
||||
if (!utils.isInterface(typeElement)) {
|
||||
return;
|
||||
}
|
||||
if (typeElement.getQualifiedName().toString().equals("java.lang.Cloneable") ||
|
||||
typeElement.getQualifiedName().toString().equals("java.io.Serializable")) {
|
||||
return; // Don't generate the list, too big
|
||||
}
|
||||
Set<TypeElement> implcl = classtree.implementingClasses(typeElement);
|
||||
if (!implcl.isEmpty()) {
|
||||
Content label = getResource(
|
||||
"doclet.Implementing_Classes");
|
||||
Content dt = HtmlTree.DT(label);
|
||||
Content dl = HtmlTree.DL(dt);
|
||||
dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_CLASSES,
|
||||
implcl));
|
||||
classInfoTree.addContent(dl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addImplementedInterfacesInfo(Content classInfoTree) {
|
||||
SortedSet<TypeMirror> interfaces = new TreeSet<>(utils.makeTypeMirrorClassUseComparator());
|
||||
interfaces.addAll(utils.getAllInterfaces(typeElement));
|
||||
if (utils.isClass(typeElement) && !interfaces.isEmpty()) {
|
||||
Content label = getResource(
|
||||
"doclet.All_Implemented_Interfaces");
|
||||
Content dt = HtmlTree.DT(label);
|
||||
Content dl = HtmlTree.DL(dt);
|
||||
dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_INTERFACES, interfaces));
|
||||
classInfoTree.addContent(dl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addSuperInterfacesInfo(Content classInfoTree) {
|
||||
SortedSet<TypeMirror> interfaces =
|
||||
new TreeSet<>(utils.makeTypeMirrorIndexUseComparator());
|
||||
interfaces.addAll(utils.getAllInterfaces(typeElement));
|
||||
|
||||
if (utils.isInterface(typeElement) && !interfaces.isEmpty()) {
|
||||
Content label = getResource("doclet.All_Superinterfaces");
|
||||
Content dt = HtmlTree.DT(label);
|
||||
Content dl = HtmlTree.DL(dt);
|
||||
dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUPER_INTERFACES, interfaces));
|
||||
classInfoTree.addContent(dl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addNestedClassInfo(final Content classInfoTree) {
|
||||
Element outerClass = typeElement.getEnclosingElement();
|
||||
if (outerClass == null)
|
||||
return;
|
||||
new SimpleElementVisitor8<Void, Void>() {
|
||||
@Override @DefinedBy(Api.LANGUAGE_MODEL)
|
||||
public Void visitType(TypeElement e, Void p) {
|
||||
String label = utils.isInterface(e)
|
||||
? "doclet.Enclosing_Interface"
|
||||
: "doclet.Enclosing_Class";
|
||||
Content dt = HtmlTree.DT(getResource(label));
|
||||
Content dl = HtmlTree.DL(dt);
|
||||
Content dd = new HtmlTree(HtmlTag.DD);
|
||||
dd.addContent(getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CLASS, e)));
|
||||
dl.addContent(dd);
|
||||
classInfoTree.addContent(dl);
|
||||
return null;
|
||||
}
|
||||
}.visit(outerClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addFunctionalInterfaceInfo (Content classInfoTree) {
|
||||
if (isFunctionalInterface()) {
|
||||
Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface"));
|
||||
Content dl = HtmlTree.DL(dt);
|
||||
Content dd = new HtmlTree(HtmlTag.DD);
|
||||
dd.addContent(getResource("doclet.Functional_Interface_Message"));
|
||||
dl.addContent(dd);
|
||||
classInfoTree.addContent(dl);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFunctionalInterface() {
|
||||
List<? extends AnnotationMirror> annotationMirrors = ((Element) typeElement).getAnnotationMirrors();
|
||||
for (AnnotationMirror anno : annotationMirrors) {
|
||||
if (utils.isFunctionalInterface(anno)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addClassDeprecationInfo(Content classInfoTree) {
|
||||
Content hr = new HtmlTree(HtmlTag.HR);
|
||||
classInfoTree.addContent(hr);
|
||||
List<? extends DocTree> deprs = utils.getBlockTags(typeElement, DocTree.Kind.DEPRECATED);
|
||||
if (utils.isDeprecated(typeElement)) {
|
||||
Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
|
||||
Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
|
||||
if (!deprs.isEmpty()) {
|
||||
CommentHelper ch = utils.getCommentHelper(typeElement);
|
||||
DocTree dt = deprs.get(0);
|
||||
List<? extends DocTree> commentTags = ch.getBody(configuration, dt);
|
||||
if (!commentTags.isEmpty()) {
|
||||
div.addContent(getSpace());
|
||||
addInlineDeprecatedComment(typeElement, deprs.get(0), div);
|
||||
}
|
||||
}
|
||||
classInfoTree.addContent(div);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get links to the given classes.
|
||||
*
|
||||
* @param context the id of the context where the link will be printed
|
||||
* @param list the list of classes
|
||||
* @return a content tree for the class list
|
||||
*/
|
||||
private Content getClassLinks(LinkInfoImpl.Kind context, Collection<?> list) {
|
||||
Content dd = new HtmlTree(HtmlTag.DD);
|
||||
boolean isFirst = true;
|
||||
for (Object type : list) {
|
||||
if (!isFirst) {
|
||||
Content separator = new StringContent(", ");
|
||||
dd.addContent(separator);
|
||||
} else {
|
||||
isFirst = false;
|
||||
}
|
||||
// TODO: should we simply split this method up to avoid instanceof ?
|
||||
if (type instanceof TypeElement) {
|
||||
Content link = getLink(
|
||||
new LinkInfoImpl(configuration, context, (TypeElement)(type)));
|
||||
dd.addContent(link);
|
||||
} else {
|
||||
Content link = getLink(
|
||||
new LinkInfoImpl(configuration, context, ((TypeMirror)type)));
|
||||
dd.addContent(link);
|
||||
}
|
||||
}
|
||||
return dd;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content getNavLinkTree() {
|
||||
Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
|
||||
treeLabel, "", "");
|
||||
Content li = HtmlTree.LI(treeLinkContent);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add summary details to the navigation bar.
|
||||
*
|
||||
* @param subDiv the content tree to which the summary detail links will be added
|
||||
*/
|
||||
protected void addSummaryDetailLinks(Content subDiv) {
|
||||
try {
|
||||
Content div = HtmlTree.DIV(getNavSummaryLinks());
|
||||
div.addContent(getNavDetailLinks());
|
||||
subDiv.addContent(div);
|
||||
} catch (Exception e) {
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get summary links for navigation bar.
|
||||
*
|
||||
* @return the content tree for the navigation summary links
|
||||
*/
|
||||
protected Content getNavSummaryLinks() throws Exception {
|
||||
Content li = HtmlTree.LI(summaryLabel);
|
||||
li.addContent(getSpace());
|
||||
Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
|
||||
MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
|
||||
configuration.getBuilderFactory().getMemberSummaryBuilder(this);
|
||||
for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.summarySet) {
|
||||
Content liNav = new HtmlTree(HtmlTag.LI);
|
||||
if (kind == VisibleMemberMap.Kind.ENUM_CONSTANTS && !utils.isEnum(typeElement)) {
|
||||
continue;
|
||||
}
|
||||
if (kind == VisibleMemberMap.Kind.CONSTRUCTORS && utils.isEnum(typeElement)) {
|
||||
continue;
|
||||
}
|
||||
AbstractMemberWriter writer =
|
||||
((AbstractMemberWriter) memberSummaryBuilder.getMemberSummaryWriter(kind));
|
||||
if (writer == null) {
|
||||
liNav.addContent(getResource(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
|
||||
} else {
|
||||
writer.addNavSummaryLink(
|
||||
memberSummaryBuilder.members(kind),
|
||||
memberSummaryBuilder.getVisibleMemberMap(kind), liNav);
|
||||
}
|
||||
if (kind != Kind.METHODS) {
|
||||
addNavGap(liNav);
|
||||
}
|
||||
ulNav.addContent(liNav);
|
||||
}
|
||||
return ulNav;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get detail links for the navigation bar.
|
||||
*
|
||||
* @return the content tree for the detail links
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
protected Content getNavDetailLinks() throws Exception {
|
||||
Content li = HtmlTree.LI(detailLabel);
|
||||
li.addContent(getSpace());
|
||||
Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
|
||||
MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
|
||||
configuration.getBuilderFactory().getMemberSummaryBuilder(this);
|
||||
for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.detailSet) {
|
||||
Content liNav = new HtmlTree(HtmlTag.LI);
|
||||
AbstractMemberWriter writer =
|
||||
((AbstractMemberWriter) memberSummaryBuilder.
|
||||
getMemberSummaryWriter(kind));
|
||||
if (kind == VisibleMemberMap.Kind.ENUM_CONSTANTS && !utils.isEnum(typeElement)) {
|
||||
continue;
|
||||
}
|
||||
if (kind == VisibleMemberMap.Kind.CONSTRUCTORS && utils.isEnum(typeElement)) {
|
||||
continue;
|
||||
}
|
||||
if (writer == null) {
|
||||
liNav.addContent(getResource(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
|
||||
} else {
|
||||
writer.addNavDetailLink(memberSummaryBuilder.members(kind), liNav);
|
||||
}
|
||||
if (kind != Kind.METHODS) {
|
||||
addNavGap(liNav);
|
||||
}
|
||||
ulNav.addContent(liNav);
|
||||
}
|
||||
return ulNav;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add gap between navigation bar elements.
|
||||
*
|
||||
* @param liNav the content tree to which the gap will be added
|
||||
*/
|
||||
protected void addNavGap(Content liNav) {
|
||||
liNav.addContent(getSpace());
|
||||
liNav.addContent("|");
|
||||
liNav.addContent(getSpace());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the TypeElement being documented.
|
||||
*
|
||||
* @return the TypeElement being documented.
|
||||
*/
|
||||
@Override
|
||||
public TypeElement getTypeElement() {
|
||||
return typeElement;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,747 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.PackageElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.tools.JavaFileManager;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
|
||||
import com.sun.source.util.DocTreePath;
|
||||
import com.sun.tools.doclint.DocLint;
|
||||
|
||||
import jdk.javadoc.doclet.Doclet;
|
||||
import jdk.javadoc.doclet.DocletEnvironment;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlVersion;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Configuration;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.WriterFactory;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
|
||||
|
||||
import static javax.tools.Diagnostic.Kind.*;
|
||||
|
||||
/**
|
||||
* Configure the output based on the command line options.
|
||||
* <p>
|
||||
* Also determine the length of the command line option. For example,
|
||||
* for a option "-header" there will be a string argument associated, then the
|
||||
* the length of option "-header" is two. But for option "-nohelp" no argument
|
||||
* is needed so it's length is 1.
|
||||
* </p>
|
||||
* <p>
|
||||
* Also do the error checking on the options used. For example it is illegal to
|
||||
* use "-helpfile" option when already "-nohelp" option is used.
|
||||
* </p>
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Robert Field.
|
||||
* @author Atul Dambalkar.
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class ConfigurationImpl extends Configuration {
|
||||
|
||||
/**
|
||||
* The build date. Note: For now, we will use
|
||||
* a version number instead of a date.
|
||||
*/
|
||||
public static final String BUILD_DATE = System.getProperty("java.version");
|
||||
|
||||
/**
|
||||
* Argument for command line option "-header".
|
||||
*/
|
||||
public String header = "";
|
||||
|
||||
/**
|
||||
* Argument for command line option "-packagesheader".
|
||||
*/
|
||||
public String packagesheader = "";
|
||||
|
||||
/**
|
||||
* Argument for command line option "-footer".
|
||||
*/
|
||||
public String footer = "";
|
||||
|
||||
/**
|
||||
* Argument for command line option "-doctitle".
|
||||
*/
|
||||
public String doctitle = "";
|
||||
|
||||
/**
|
||||
* Argument for command line option "-windowtitle".
|
||||
*/
|
||||
public String windowtitle = "";
|
||||
|
||||
/**
|
||||
* Argument for command line option "-top".
|
||||
*/
|
||||
public String top = "";
|
||||
|
||||
/**
|
||||
* Argument for command line option "-bottom".
|
||||
*/
|
||||
public String bottom = "";
|
||||
|
||||
/**
|
||||
* Argument for command line option "-helpfile".
|
||||
*/
|
||||
public String helpfile = "";
|
||||
|
||||
/**
|
||||
* Argument for command line option "-stylesheetfile".
|
||||
*/
|
||||
public String stylesheetfile = "";
|
||||
|
||||
/**
|
||||
* Argument for command line option "-Xdocrootparent".
|
||||
*/
|
||||
public String docrootparent = "";
|
||||
|
||||
public boolean sortedMethodDetails = false;
|
||||
|
||||
/**
|
||||
* True if command line option "-nohelp" is used. Default value is false.
|
||||
*/
|
||||
public boolean nohelp = false;
|
||||
|
||||
/**
|
||||
* True if command line option "-splitindex" is used. Default value is
|
||||
* false.
|
||||
*/
|
||||
public boolean splitindex = false;
|
||||
|
||||
/**
|
||||
* False if command line option "-noindex" is used. Default value is true.
|
||||
*/
|
||||
public boolean createindex = true;
|
||||
|
||||
/**
|
||||
* True if command line option "-use" is used. Default value is false.
|
||||
*/
|
||||
public boolean classuse = false;
|
||||
|
||||
/**
|
||||
* False if command line option "-notree" is used. Default value is true.
|
||||
*/
|
||||
public boolean createtree = true;
|
||||
|
||||
/**
|
||||
* True if command line option "-nodeprecated" is used. Default value is
|
||||
* false.
|
||||
*/
|
||||
public boolean nodeprecatedlist = false;
|
||||
|
||||
/**
|
||||
* True if command line option "-nonavbar" is used. Default value is false.
|
||||
*/
|
||||
public boolean nonavbar = false;
|
||||
|
||||
/**
|
||||
* True if command line option "-nooverview" is used. Default value is
|
||||
* false
|
||||
*/
|
||||
private boolean nooverview = false;
|
||||
|
||||
/**
|
||||
* The overview path specified with "-overview" flag.
|
||||
*/
|
||||
public String overviewpath = null;
|
||||
|
||||
/**
|
||||
* This is true if option "-overview" is used or option "-overview" is not
|
||||
* used and number of packages is more than one.
|
||||
*/
|
||||
public boolean createoverview = false;
|
||||
|
||||
/**
|
||||
* This is the HTML version of the generated pages. HTML 4.01 is the default output version.
|
||||
*/
|
||||
public HtmlVersion htmlVersion = HtmlVersion.HTML4;
|
||||
|
||||
/**
|
||||
* Collected set of doclint options
|
||||
*/
|
||||
public Map<Doclet.Option, String> doclintOpts = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* Unique Resource Handler for this package.
|
||||
*/
|
||||
public final MessageRetriever standardmessage;
|
||||
|
||||
/**
|
||||
* First file to appear in the right-hand frame in the generated
|
||||
* documentation.
|
||||
*/
|
||||
public DocPath topFile = DocPath.empty;
|
||||
|
||||
/**
|
||||
* The TypeElement for the class file getting generated.
|
||||
*/
|
||||
public TypeElement currentTypeElement = null; // Set this TypeElement in the ClassWriter.
|
||||
|
||||
protected List<SearchIndexItem> memberSearchIndex = new ArrayList<>();
|
||||
|
||||
protected List<SearchIndexItem> packageSearchIndex = new ArrayList<>();
|
||||
|
||||
protected List<SearchIndexItem> tagSearchIndex = new ArrayList<>();
|
||||
|
||||
protected List<SearchIndexItem> typeSearchIndex = new ArrayList<>();
|
||||
|
||||
protected Map<Character,List<SearchIndexItem>> tagSearchIndexMap = new HashMap<>();
|
||||
|
||||
protected Set<Character> tagSearchIndexKeys;
|
||||
|
||||
/**
|
||||
* Constructor. Initializes resource for the
|
||||
* {@link com.sun.tools.doclets.internal.toolkit.util.MessageRetriever MessageRetriever}.
|
||||
*/
|
||||
public ConfigurationImpl() {
|
||||
standardmessage = new MessageRetriever(this,
|
||||
"jdk.javadoc.internal.doclets.formats.html.resources.standard");
|
||||
}
|
||||
|
||||
private final String versionRBName = "jdk.javadoc.internal.tool.resources.version";
|
||||
private ResourceBundle versionRB;
|
||||
|
||||
/**
|
||||
* Return the build date for the doclet.
|
||||
* @return the build date
|
||||
*/
|
||||
@Override
|
||||
public String getDocletSpecificBuildDate() {
|
||||
if (versionRB == null) {
|
||||
try {
|
||||
versionRB = ResourceBundle.getBundle(versionRBName, getLocale());
|
||||
} catch (MissingResourceException e) {
|
||||
return BUILD_DATE;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return versionRB.getString("release");
|
||||
} catch (MissingResourceException e) {
|
||||
return BUILD_DATE;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean validateOptions() {
|
||||
// check shared options
|
||||
if (!generalValidOptions()) {
|
||||
return false;
|
||||
}
|
||||
boolean helpfileSeen = false;
|
||||
// otherwise look at our options
|
||||
for (Doclet.Option opt : optionsProcessed) {
|
||||
if (opt.matches("-helpfile")) {
|
||||
if (nohelp == true) {
|
||||
reporter.print(ERROR, getText("doclet.Option_conflict",
|
||||
"-helpfile", "-nohelp"));
|
||||
return false;
|
||||
}
|
||||
if (helpfileSeen) {
|
||||
reporter.print(ERROR, getText("doclet.Option_reuse",
|
||||
"-helpfile"));
|
||||
return false;
|
||||
}
|
||||
helpfileSeen = true;
|
||||
DocFile help = DocFile.createFileForInput(this, helpfile);
|
||||
if (!help.exists()) {
|
||||
reporter.print(ERROR, getText("doclet.File_not_found", helpfile));
|
||||
return false;
|
||||
}
|
||||
} else if (opt.matches("-nohelp")) {
|
||||
if (helpfileSeen) {
|
||||
reporter.print(ERROR, getText("doclet.Option_conflict",
|
||||
"-nohelp", "-helpfile"));
|
||||
return false;
|
||||
}
|
||||
} else if (opt.matches("-xdocrootparent")) {
|
||||
try {
|
||||
URL ignored = new URL(docrootparent);
|
||||
} catch (MalformedURLException e) {
|
||||
reporter.print(ERROR, getText("doclet.MalformedURL", docrootparent));
|
||||
return false;
|
||||
}
|
||||
} else if (opt.matches("-overview")) {
|
||||
if (nooverview == true) {
|
||||
reporter.print(ERROR, getText("doclet.Option_conflict",
|
||||
"-overview", "-nooverview"));
|
||||
return false;
|
||||
}
|
||||
} else if (opt.matches("-nooverview")) {
|
||||
if (overviewpath != null) {
|
||||
reporter.print(ERROR, getText("doclet.Option_conflict",
|
||||
"-nooverview", "-overview"));
|
||||
return false;
|
||||
}
|
||||
} else if (opt.matches("-splitindex")) {
|
||||
if (createindex == false) {
|
||||
reporter.print(ERROR, getText("doclet.Option_conflict",
|
||||
"-splitindex", "-noindex"));
|
||||
return false;
|
||||
}
|
||||
} else if (opt.matches("-noindex")) {
|
||||
if (splitindex == true) {
|
||||
reporter.print(ERROR, getText("doclet.Option_conflict",
|
||||
"-noindex", "-splitindex"));
|
||||
return false;
|
||||
}
|
||||
} else if (opt.matches("-xdoclint:")) {
|
||||
String dopt = doclintOpts.get(opt);
|
||||
if (dopt == null) {
|
||||
continue;
|
||||
}
|
||||
if (dopt.contains("/")) {
|
||||
reporter.print(ERROR, getText("doclet.Option_doclint_no_qualifiers"));
|
||||
return false;
|
||||
}
|
||||
if (!DocLint.isValidOption(dopt)) {
|
||||
reporter.print(ERROR, getText("doclet.Option_doclint_invalid_arg"));
|
||||
return false;
|
||||
}
|
||||
} else if (opt.matches("-xdoclint/package:")) {
|
||||
String dopt = doclintOpts.get(opt);
|
||||
if (!DocLint.isValidOption(dopt)) {
|
||||
reporter.print(ERROR, getText("doclet.Option_doclint_package_invalid_arg"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finishOptionSettings() {
|
||||
if (!validateOptions()) {
|
||||
return false;
|
||||
}
|
||||
if (!root.getSpecifiedElements().isEmpty()) {
|
||||
Map<String, PackageElement> map = new HashMap<>();
|
||||
PackageElement pkg;
|
||||
List<TypeElement> classes = new ArrayList<>(root.getIncludedClasses());
|
||||
for (TypeElement aClass : classes) {
|
||||
pkg = utils.containingPackage(aClass);
|
||||
if (!map.containsKey(utils.getPackageName(pkg))) {
|
||||
map.put(utils.getPackageName(pkg), pkg);
|
||||
}
|
||||
}
|
||||
}
|
||||
setCreateOverview();
|
||||
setTopFile(root);
|
||||
workArounds.initDocLint(doclintOpts.values(), tagletManager.getCustomTagNames(),
|
||||
Utils.toLowerCase(htmlVersion.name()));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the generated output is HTML5.
|
||||
*/
|
||||
public boolean isOutputHtml5() {
|
||||
return htmlVersion == HtmlVersion.HTML5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the tag is allowed for this specific version of HTML.
|
||||
*/
|
||||
public boolean allowTag(HtmlTag htmlTag) {
|
||||
return htmlTag.allowTag(this.htmlVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public MessageRetriever getDocletSpecificMsg() {
|
||||
return standardmessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decide the page which will appear first in the right-hand frame. It will
|
||||
* be "overview-summary.html" if "-overview" option is used or no
|
||||
* "-overview" but the number of packages is more than one. It will be
|
||||
* "package-summary.html" of the respective package if there is only one
|
||||
* package to document. It will be a class page(first in the sorted order),
|
||||
* if only classes are provided on the command line.
|
||||
*
|
||||
* @param root Root of the program structure.
|
||||
*/
|
||||
protected void setTopFile(DocletEnvironment root) {
|
||||
if (!checkForDeprecation(root)) {
|
||||
return;
|
||||
}
|
||||
if (createoverview) {
|
||||
topFile = DocPaths.OVERVIEW_SUMMARY;
|
||||
} else {
|
||||
if (packages.size() == 1 && packages.first().isUnnamed()) {
|
||||
if (!root.getIncludedClasses().isEmpty()) {
|
||||
List<TypeElement> classes = new ArrayList<>(root.getIncludedClasses());
|
||||
TypeElement te = getValidClass(classes);
|
||||
topFile = DocPath.forClass(utils, te);
|
||||
}
|
||||
} else if (!packages.isEmpty()) {
|
||||
topFile = DocPath.forPackage(packages.first()).resolve(DocPaths.PACKAGE_SUMMARY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected TypeElement getValidClass(List<TypeElement> classes) {
|
||||
if (!nodeprecated) {
|
||||
return classes.get(0);
|
||||
}
|
||||
for (TypeElement te : classes) {
|
||||
if (!utils.isDeprecated(te)) {
|
||||
return te;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean checkForDeprecation(DocletEnvironment root) {
|
||||
for (TypeElement te : root.getIncludedClasses()) {
|
||||
if (isGeneratedDoc(te)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate "overview.html" page if option "-overview" is used or number of
|
||||
* packages is more than one. Sets {@link #createoverview} field to true.
|
||||
*/
|
||||
protected void setCreateOverview() {
|
||||
if ((overviewpath != null || packages.size() > 1) && !nooverview) {
|
||||
createoverview = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WriterFactory getWriterFactory() {
|
||||
return new WriterFactoryImpl(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
if (locale == null)
|
||||
return Locale.getDefault();
|
||||
return locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the path of the overview file and null if it does not exist.
|
||||
*
|
||||
* @return the path of the overview file and null if it does not exist.
|
||||
*/
|
||||
public JavaFileObject getOverviewPath() {
|
||||
if (overviewpath != null && getFileManager() instanceof StandardJavaFileManager) {
|
||||
StandardJavaFileManager fm = (StandardJavaFileManager) getFileManager();
|
||||
return fm.getJavaFileObjects(overviewpath).iterator().next();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public JavaFileManager getFileManager() {
|
||||
return root.getJavaFileManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showMessage(DocTreePath path, String key) {
|
||||
return (path == null || workArounds.haveDocLint());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showMessage(Element e, String key) {
|
||||
return (e == null || workArounds.haveDocLint());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content newContent() {
|
||||
return new ContentBuilder();
|
||||
}
|
||||
|
||||
protected void buildSearchTagIndex() {
|
||||
for (SearchIndexItem sii : tagSearchIndex) {
|
||||
String tagLabel = sii.getLabel();
|
||||
Character unicode = (tagLabel.length() == 0)
|
||||
? '*'
|
||||
: Character.toUpperCase(tagLabel.charAt(0));
|
||||
List<SearchIndexItem> list = tagSearchIndexMap.get(unicode);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
tagSearchIndexMap.put(unicode, list);
|
||||
}
|
||||
list.add(sii);
|
||||
}
|
||||
tagSearchIndexKeys = tagSearchIndexMap.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Doclet.Option> getSupportedOptions() {
|
||||
Doclet.Option[] options = {
|
||||
new Option(this, "bottom", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
bottom = args.next();
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "charset", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
charset = args.next();
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "doctitle", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
doctitle = args.next();
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "footer", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
footer = args.next();
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "header", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
header = args.next();
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "helpfile", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
helpfile = args.next();
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "html4") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
htmlVersion = HtmlVersion.HTML4;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "html5") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
htmlVersion = HtmlVersion.HTML5;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "nohelp") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
nohelp = true;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "nodeprecatedlist") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
nodeprecatedlist = true;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "noindex") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
createindex = false;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "nonavbar") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
nonavbar = true;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Hidden(this, "nooverview") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
nooverview = true;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "notree") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
createtree = false;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Hidden(this, "overview", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
overviewpath = args.next();
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Hidden(this, "packagesheader", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
packagesheader = args.next();
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "splitindex") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
splitindex = true;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "stylesheetfile", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
stylesheetfile = args.next();
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "top", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
top = args.next();
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "use") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
classuse = true;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new Option(this, "windowtitle", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
windowtitle = args.next().replaceAll("\\<.*?>", "");
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new XOption(this, "xdoclint") {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
doclintOpts.put(this, DocLint.XMSGS_OPTION);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new XOption(this, "Xdocrootparent", 1) {
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
docrootparent = args.next();
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new XOption(this, "doclet.xusage.xdoclint-extended.", "Xdoclint:", 0) {
|
||||
@Override
|
||||
public boolean matches(String option) {
|
||||
String opt = option.startsWith("-") ? option.substring(1) : option;
|
||||
return opt.toLowerCase().startsWith(getName().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
doclintOpts.put(this, opt.replace("-Xdoclint:", DocLint.XMSGS_CUSTOM_PREFIX));
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new XOption(this, "doclet.xusage.xdoclint-package.", "Xdoclint/package:", 0) {
|
||||
@Override
|
||||
public boolean matches(String option) {
|
||||
String opt = option.startsWith("-") ? option.substring(1) : option;
|
||||
return opt.toLowerCase().startsWith(getName().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(String opt, ListIterator<String> args) {
|
||||
optionsProcessed.add(this);
|
||||
doclintOpts.put(this, opt.replace("-Xdoclint/package:", DocLint.XCHECK_PACKAGE));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
Set<Doclet.Option> oset = new TreeSet<>();
|
||||
oset.addAll(Arrays.asList(options));
|
||||
oset.addAll(super.getSupportedOptions());
|
||||
return oset;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,388 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.lang.model.element.PackageElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
|
||||
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.ConstantsSummaryWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
|
||||
|
||||
/**
|
||||
* Write the Constants Summary Page in HTML format.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements ConstantsSummaryWriter {
|
||||
|
||||
/**
|
||||
* The configuration used in this run of the standard doclet.
|
||||
*/
|
||||
ConfigurationImpl configuration;
|
||||
|
||||
/**
|
||||
* The current class being documented.
|
||||
*/
|
||||
private TypeElement currentTypeElement;
|
||||
|
||||
private final String constantsTableSummary;
|
||||
|
||||
private final List<String> constantsTableHeader;
|
||||
|
||||
/**
|
||||
* The HTML tree for main tag.
|
||||
*/
|
||||
private HtmlTree mainTree = HtmlTree.MAIN();
|
||||
|
||||
/**
|
||||
* The HTML tree for constant values summary.
|
||||
*/
|
||||
private HtmlTree summaryTree;
|
||||
|
||||
/**
|
||||
* Construct a ConstantsSummaryWriter.
|
||||
* @param configuration the configuration used in this run
|
||||
* of the standard doclet.
|
||||
*/
|
||||
public ConstantsSummaryWriterImpl(ConfigurationImpl configuration)
|
||||
throws IOException {
|
||||
super(configuration, DocPaths.CONSTANT_VALUES);
|
||||
this.configuration = configuration;
|
||||
constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary",
|
||||
configuration.getText("doclet.Constants_Summary"));
|
||||
constantsTableHeader = new ArrayList<>();
|
||||
constantsTableHeader.add(getModifierTypeHeader());
|
||||
constantsTableHeader.add(configuration.getText("doclet.ConstantField"));
|
||||
constantsTableHeader.add(configuration.getText("doclet.Value"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getHeader() {
|
||||
String label = configuration.getText("doclet.Constants_Summary");
|
||||
HtmlTree bodyTree = getBody(true, getWindowTitle(label));
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
|
||||
? HtmlTree.HEADER()
|
||||
: bodyTree;
|
||||
addTop(htmlTree);
|
||||
addNavLinks(true, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.HEADER)) {
|
||||
bodyTree.addContent(htmlTree);
|
||||
}
|
||||
return bodyTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getContentsHeader() {
|
||||
return new HtmlTree(HtmlTag.UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addLinkToPackageContent(PackageElement pkg,
|
||||
Set<PackageElement> printedPackageHeaders, Content contentListTree) {
|
||||
//add link to summary
|
||||
Content link;
|
||||
if (pkg.isUnnamed()) {
|
||||
link = getHyperLink(getDocLink(
|
||||
SectionName.UNNAMED_PACKAGE_ANCHOR),
|
||||
defaultPackageLabel, "", "");
|
||||
} else {
|
||||
String parsedPackageName = utils.parsePackageName(pkg);
|
||||
Content packageNameContent = getPackageLabel(parsedPackageName);
|
||||
packageNameContent.addContent(".*");
|
||||
link = getHyperLink(DocLink.fragment(parsedPackageName),
|
||||
packageNameContent, "", "");
|
||||
PackageElement abbrevPkg = utils.elementUtils.getPackageElement(parsedPackageName);
|
||||
printedPackageHeaders.add(abbrevPkg);
|
||||
}
|
||||
contentListTree.addContent(HtmlTree.LI(link));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addContentsList(Content contentTree, Content contentListTree) {
|
||||
Content titleContent = getResource(
|
||||
"doclet.Constants_Summary");
|
||||
Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
|
||||
HtmlStyle.title, titleContent);
|
||||
Content div = HtmlTree.DIV(HtmlStyle.header, pHeading);
|
||||
Content headingContent = getResource(
|
||||
"doclet.Contents");
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
|
||||
headingContent);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
HtmlTree section = HtmlTree.SECTION(heading);
|
||||
section.addContent(contentListTree);
|
||||
div.addContent(section);
|
||||
mainTree.addContent(div);
|
||||
} else {
|
||||
div.addContent(heading);
|
||||
div.addContent(contentListTree);
|
||||
contentTree.addContent(div);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getConstantSummaries() {
|
||||
HtmlTree summariesDiv = new HtmlTree(HtmlTag.DIV);
|
||||
summariesDiv.addStyle(HtmlStyle.constantValuesContainer);
|
||||
return summariesDiv;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addPackageName(PackageElement pkg, Content summariesTree, boolean first) {
|
||||
Content pkgNameContent;
|
||||
if (!first && configuration.allowTag(HtmlTag.SECTION)) {
|
||||
summariesTree.addContent(summaryTree);
|
||||
}
|
||||
if (pkg.isUnnamed()) {
|
||||
summariesTree.addContent(getMarkerAnchor(
|
||||
SectionName.UNNAMED_PACKAGE_ANCHOR));
|
||||
pkgNameContent = defaultPackageLabel;
|
||||
} else {
|
||||
String parsedPackageName = utils.parsePackageName(pkg);
|
||||
summariesTree.addContent(getMarkerAnchor(parsedPackageName));
|
||||
pkgNameContent = getPackageLabel(parsedPackageName);
|
||||
}
|
||||
Content headingContent = new StringContent(".*");
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
|
||||
pkgNameContent);
|
||||
heading.addContent(headingContent);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
summaryTree = HtmlTree.SECTION(heading);
|
||||
} else {
|
||||
summariesTree.addContent(heading);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getClassConstantHeader() {
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
ul.addStyle(HtmlStyle.blockList);
|
||||
return ul;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addClassConstant(Content summariesTree, Content classConstantTree) {
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
summaryTree.addContent(classConstantTree);
|
||||
} else {
|
||||
summariesTree.addContent(classConstantTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the table caption and header for the constant summary table
|
||||
*
|
||||
* @param typeElement the TypeElement to be documented
|
||||
* @return constant members header content
|
||||
*/
|
||||
public Content getConstantMembersHeader(TypeElement typeElement) {
|
||||
//generate links backward only to public classes.
|
||||
Content classlink = (utils.isPublic(typeElement) || utils.isProtected(typeElement)) ?
|
||||
getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CONSTANT_SUMMARY, typeElement)) :
|
||||
new StringContent(utils.getFullyQualifiedName(typeElement));
|
||||
|
||||
PackageElement enclosingPackage = utils.containingPackage(typeElement);
|
||||
if (!enclosingPackage.isUnnamed()) {
|
||||
Content cb = new ContentBuilder();
|
||||
cb.addContent(enclosingPackage.getQualifiedName().toString());
|
||||
cb.addContent(".");
|
||||
cb.addContent(classlink);
|
||||
return getClassName(cb);
|
||||
} else {
|
||||
return getClassName(classlink);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class name in the table caption and the table header.
|
||||
*
|
||||
* @param classStr the class name to print.
|
||||
* @return the table caption and header
|
||||
*/
|
||||
protected Content getClassName(Content classStr) {
|
||||
Content caption = getTableCaption(classStr);
|
||||
Content table = (configuration.isOutputHtml5())
|
||||
? HtmlTree.TABLE(HtmlStyle.constantsSummary, caption)
|
||||
: HtmlTree.TABLE(HtmlStyle.constantsSummary, constantsTableSummary, caption);
|
||||
table.addContent(getSummaryTableHeader(constantsTableHeader, "col"));
|
||||
return table;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addConstantMembers(TypeElement typeElement, Collection<VariableElement> fields,
|
||||
Content classConstantTree) {
|
||||
currentTypeElement = typeElement;
|
||||
Content tbody = new HtmlTree(HtmlTag.TBODY);
|
||||
boolean altColor = true;
|
||||
for (VariableElement field : fields) {
|
||||
HtmlTree tr = new HtmlTree(HtmlTag.TR);
|
||||
tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
|
||||
addConstantMember(field, tr);
|
||||
tbody.addContent(tr);
|
||||
altColor = !altColor;
|
||||
}
|
||||
Content table = getConstantMembersHeader(typeElement);
|
||||
table.addContent(tbody);
|
||||
Content li = HtmlTree.LI(HtmlStyle.blockList, table);
|
||||
classConstantTree.addContent(li);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the row for the constant summary table.
|
||||
*
|
||||
* @param member the field to be documented.
|
||||
* @param trTree an htmltree object for the table row
|
||||
*/
|
||||
private void addConstantMember(VariableElement member, HtmlTree trTree) {
|
||||
trTree.addContent(getTypeColumn(member));
|
||||
trTree.addContent(getNameColumn(member));
|
||||
trTree.addContent(getValue(member));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type column for the constant summary table row.
|
||||
*
|
||||
* @param member the field to be documented.
|
||||
* @return the type column of the constant table row
|
||||
*/
|
||||
private Content getTypeColumn(VariableElement member) {
|
||||
Content anchor = getMarkerAnchor(currentTypeElement.getQualifiedName() +
|
||||
"." + member.getSimpleName());
|
||||
Content tdType = HtmlTree.TD(HtmlStyle.colFirst, anchor);
|
||||
Content code = new HtmlTree(HtmlTag.CODE);
|
||||
for (Modifier mod : member.getModifiers()) {
|
||||
Content modifier = new StringContent(mod.toString());
|
||||
code.addContent(modifier);
|
||||
code.addContent(getSpace());
|
||||
}
|
||||
Content type = getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.CONSTANT_SUMMARY, member.asType()));
|
||||
code.addContent(type);
|
||||
tdType.addContent(code);
|
||||
return tdType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name column for the constant summary table row.
|
||||
*
|
||||
* @param member the field to be documented.
|
||||
* @return the name column of the constant table row
|
||||
*/
|
||||
private Content getNameColumn(VariableElement member) {
|
||||
Content nameContent = getDocLink(LinkInfoImpl.Kind.CONSTANT_SUMMARY,
|
||||
member, member.getSimpleName().toString(), false);
|
||||
Content code = HtmlTree.CODE(nameContent);
|
||||
return HtmlTree.TD(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value column for the constant summary table row.
|
||||
*
|
||||
* @param member the field to be documented.
|
||||
* @return the value column of the constant table row
|
||||
*/
|
||||
private Content getValue(VariableElement member) {
|
||||
String value = utils.constantValueExpresion(member);
|
||||
Content valueContent = new StringContent(value);
|
||||
Content code = HtmlTree.CODE(valueContent);
|
||||
return HtmlTree.TD(HtmlStyle.colLast, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addConstantSummaries(Content contentTree, Content summariesTree) {
|
||||
if (configuration.allowTag(HtmlTag.SECTION) && summaryTree != null) {
|
||||
summariesTree.addContent(summaryTree);
|
||||
}
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
mainTree.addContent(summariesTree);
|
||||
contentTree.addContent(mainTree);
|
||||
} else {
|
||||
contentTree.addContent(summariesTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addFooter(Content contentTree) {
|
||||
Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
|
||||
? HtmlTree.FOOTER()
|
||||
: contentTree;
|
||||
addNavLinks(false, htmlTree);
|
||||
addBottom(htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
contentTree.addContent(htmlTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void printDocument(Content contentTree) throws IOException {
|
||||
printHtmlDocument(null, true, contentTree);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,354 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Robert Field
|
||||
* @author Atul M Dambalkar
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
|
||||
implements ConstructorWriter, MemberSummaryWriter {
|
||||
|
||||
private boolean foundNonPubConstructor = false;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new ConstructorWriterImpl.
|
||||
*
|
||||
* @param writer The writer for the class that the constructors belong to.
|
||||
*/
|
||||
public ConstructorWriterImpl(SubWriterHolderWriter writer) {
|
||||
super(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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}
|
||||
*/
|
||||
public void addMemberTree(Content memberSummaryTree, Content memberTree) {
|
||||
writer.addMemberTree(memberSummaryTree, memberTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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));
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
|
||||
writer.constructorDetailsLabel);
|
||||
constructorDetailsTree.addContent(heading);
|
||||
return constructorDetailsTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setSummaryColumnStyle(HtmlTree tdTree) {
|
||||
if (foundNonPubConstructor)
|
||||
tdTree.addStyle(HtmlStyle.colLast);
|
||||
else
|
||||
tdTree.addStyle(HtmlStyle.colOne);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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;
|
||||
}
|
||||
return getMemberTree(constructorDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addNavDetailLink(boolean link, Content liNav) {
|
||||
if (link) {
|
||||
liNav.addContent(writer.getHyperLink(
|
||||
SectionName.CONSTRUCTOR_DETAIL,
|
||||
writer.getResource("doclet.navConstructor")));
|
||||
} else {
|
||||
liNav.addContent(writer.getResource("doclet.navConstructor"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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"));
|
||||
}
|
||||
tdSummaryType.addContent(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,385 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
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.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
|
||||
import static jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder.*;
|
||||
|
||||
/**
|
||||
* Generate File to list all the deprecated classes and class members with the
|
||||
* appropriate links.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @see java.util.List
|
||||
* @author Atul M Dambalkar
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class DeprecatedListWriter extends SubWriterHolderWriter {
|
||||
|
||||
private String getAnchorName(DeprElementKind kind) {
|
||||
switch (kind) {
|
||||
case PACKAGE:
|
||||
return "package";
|
||||
case INTERFACE:
|
||||
return "interface";
|
||||
case CLASS:
|
||||
return "class";
|
||||
case ENUM:
|
||||
return "enum";
|
||||
case EXCEPTION:
|
||||
return "exception";
|
||||
case ERROR:
|
||||
return "error";
|
||||
case ANNOTATION_TYPE:
|
||||
return "annotation.type";
|
||||
case FIELD:
|
||||
return "field";
|
||||
case METHOD:
|
||||
return "method";
|
||||
case CONSTRUCTOR:
|
||||
return "constructor";
|
||||
case ENUM_CONSTANT:
|
||||
return "enum.constant";
|
||||
case ANNOTATION_TYPE_MEMBER:
|
||||
return "annotation.type.member";
|
||||
default:
|
||||
throw new AssertionError("unknown kind: " + kind);
|
||||
}
|
||||
}
|
||||
|
||||
private String getHeadingKey(DeprElementKind kind) {
|
||||
switch (kind) {
|
||||
case PACKAGE:
|
||||
return "doclet.Deprecated_Packages";
|
||||
case INTERFACE:
|
||||
return "doclet.Deprecated_Interfaces";
|
||||
case CLASS:
|
||||
return "doclet.Deprecated_Classes";
|
||||
case ENUM:
|
||||
return "doclet.Deprecated_Enums";
|
||||
case EXCEPTION:
|
||||
return "doclet.Deprecated_Exceptions";
|
||||
case ERROR:
|
||||
return "doclet.Deprecated_Errors";
|
||||
case ANNOTATION_TYPE:
|
||||
return "doclet.Deprecated_Annotation_Types";
|
||||
case FIELD:
|
||||
return "doclet.Deprecated_Fields";
|
||||
case METHOD:
|
||||
return "doclet.Deprecated_Methods";
|
||||
case CONSTRUCTOR:
|
||||
return "doclet.Deprecated_Constructors";
|
||||
case ENUM_CONSTANT:
|
||||
return "doclet.Deprecated_Enum_Constants";
|
||||
case ANNOTATION_TYPE_MEMBER:
|
||||
return "doclet.Deprecated_Annotation_Type_Members";
|
||||
default:
|
||||
throw new AssertionError("unknown kind: " + kind);
|
||||
}
|
||||
}
|
||||
|
||||
private String getSummaryKey(DeprElementKind kind) {
|
||||
switch (kind) {
|
||||
case PACKAGE:
|
||||
return "doclet.deprecated_packages";
|
||||
case INTERFACE:
|
||||
return "doclet.deprecated_interfaces";
|
||||
case CLASS:
|
||||
return "doclet.deprecated_classes";
|
||||
case ENUM:
|
||||
return "doclet.deprecated_enums";
|
||||
case EXCEPTION:
|
||||
return "doclet.deprecated_exceptions";
|
||||
case ERROR:
|
||||
return "doclet.deprecated_errors";
|
||||
case ANNOTATION_TYPE:
|
||||
return "doclet.deprecated_annotation_types";
|
||||
case FIELD:
|
||||
return "doclet.deprecated_fields";
|
||||
case METHOD:
|
||||
return "doclet.deprecated_methods";
|
||||
case CONSTRUCTOR:
|
||||
return "doclet.deprecated_constructors";
|
||||
case ENUM_CONSTANT:
|
||||
return "doclet.deprecated_enum_constants";
|
||||
case ANNOTATION_TYPE_MEMBER:
|
||||
return "doclet.deprecated_annotation_type_members";
|
||||
default:
|
||||
throw new AssertionError("unknown kind: " + kind);
|
||||
}
|
||||
}
|
||||
|
||||
private String getHeaderKey(DeprElementKind kind) {
|
||||
switch (kind) {
|
||||
case PACKAGE:
|
||||
return "doclet.Package";
|
||||
case INTERFACE:
|
||||
return "doclet.Interface";
|
||||
case CLASS:
|
||||
return "doclet.Class";
|
||||
case ENUM:
|
||||
return "doclet.Enum";
|
||||
case EXCEPTION:
|
||||
return "doclet.Exceptions";
|
||||
case ERROR:
|
||||
return "doclet.Errors";
|
||||
case ANNOTATION_TYPE:
|
||||
return "doclet.AnnotationType";
|
||||
case FIELD:
|
||||
return "doclet.Field";
|
||||
case METHOD:
|
||||
return "doclet.Method";
|
||||
case CONSTRUCTOR:
|
||||
return "doclet.Constructor";
|
||||
case ENUM_CONSTANT:
|
||||
return "doclet.Enum_Constant";
|
||||
case ANNOTATION_TYPE_MEMBER:
|
||||
return "doclet.Annotation_Type_Member";
|
||||
default:
|
||||
throw new AssertionError("unknown kind: " + kind);
|
||||
}
|
||||
}
|
||||
|
||||
private EnumMap<DeprElementKind, AbstractMemberWriter> writerMap;
|
||||
|
||||
private ConfigurationImpl configuration;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param filename the file to be generated.
|
||||
*/
|
||||
|
||||
public DeprecatedListWriter(ConfigurationImpl configuration,
|
||||
DocPath filename) throws IOException {
|
||||
super(configuration, filename);
|
||||
this.configuration = configuration;
|
||||
NestedClassWriterImpl classW = new NestedClassWriterImpl(this);
|
||||
writerMap = new EnumMap<>(DeprElementKind.class);
|
||||
for (DeprElementKind kind : DeprElementKind.values()) {
|
||||
switch (kind) {
|
||||
case PACKAGE:
|
||||
case INTERFACE:
|
||||
case CLASS:
|
||||
case ENUM:
|
||||
case EXCEPTION:
|
||||
case ERROR:
|
||||
case ANNOTATION_TYPE:
|
||||
writerMap.put(kind, classW);
|
||||
break;
|
||||
case FIELD:
|
||||
writerMap.put(kind, new FieldWriterImpl(this));
|
||||
break;
|
||||
case METHOD:
|
||||
writerMap.put(kind, new MethodWriterImpl(this));
|
||||
break;
|
||||
case CONSTRUCTOR:
|
||||
writerMap.put(kind, new ConstructorWriterImpl(this));
|
||||
break;
|
||||
case ENUM_CONSTANT:
|
||||
writerMap.put(kind, new EnumConstantWriterImpl(this));
|
||||
break;
|
||||
case ANNOTATION_TYPE_MEMBER:
|
||||
writerMap.put(kind, new AnnotationTypeOptionalMemberWriterImpl(this, null));
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError("unknown kind: " + kind);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of all the deprecated classes and members in all the Packages
|
||||
* specified on the Command Line.
|
||||
* Then instantiate DeprecatedListWriter and generate File.
|
||||
*
|
||||
* @param configuration the current configuration of the doclet.
|
||||
*/
|
||||
public static void generate(ConfigurationImpl configuration) {
|
||||
DocPath filename = DocPaths.DEPRECATED_LIST;
|
||||
try {
|
||||
DeprecatedListWriter depr =
|
||||
new DeprecatedListWriter(configuration, filename);
|
||||
depr.generateDeprecatedListFile(
|
||||
new DeprecatedAPIListBuilder(configuration));
|
||||
depr.close();
|
||||
} catch (IOException exc) {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the deprecated API list.
|
||||
*
|
||||
* @param deprapi list of deprecated API built already.
|
||||
*/
|
||||
protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi)
|
||||
throws IOException {
|
||||
HtmlTree body = getHeader();
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
|
||||
? HtmlTree.MAIN()
|
||||
: body;
|
||||
htmlTree.addContent(getContentsList(deprapi));
|
||||
String memberTableSummary;
|
||||
HtmlTree div = new HtmlTree(HtmlTag.DIV);
|
||||
div.addStyle(HtmlStyle.contentContainer);
|
||||
for (DeprElementKind kind : DeprElementKind.values()) {
|
||||
if (deprapi.hasDocumentation(kind)) {
|
||||
addAnchor(deprapi, kind, div);
|
||||
memberTableSummary =
|
||||
configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText(getHeadingKey(kind)),
|
||||
configuration.getText(getSummaryKey(kind)));
|
||||
List<String> memberTableHeader = new ArrayList<>();
|
||||
memberTableHeader.add(configuration.getText("doclet.0_and_1",
|
||||
configuration.getText(getHeaderKey(kind)),
|
||||
configuration.getText("doclet.Description")));
|
||||
if (kind == DeprElementKind.PACKAGE)
|
||||
addPackageDeprecatedAPI(deprapi.getSet(kind),
|
||||
getHeadingKey(kind), memberTableSummary, memberTableHeader, div);
|
||||
else
|
||||
writerMap.get(kind).addDeprecatedAPI(deprapi.getSet(kind),
|
||||
getHeadingKey(kind), memberTableSummary, memberTableHeader, div);
|
||||
}
|
||||
}
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
htmlTree.addContent(div);
|
||||
body.addContent(htmlTree);
|
||||
} else {
|
||||
body.addContent(div);
|
||||
}
|
||||
htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
|
||||
? HtmlTree.FOOTER()
|
||||
: body;
|
||||
addNavLinks(false, htmlTree);
|
||||
addBottom(htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
body.addContent(htmlTree);
|
||||
}
|
||||
printHtmlDocument(null, true, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the index link.
|
||||
*
|
||||
* @param builder the deprecated list builder
|
||||
* @param type the type of list being documented
|
||||
* @param contentTree the content tree to which the index link will be added
|
||||
*/
|
||||
private void addIndexLink(DeprecatedAPIListBuilder builder,
|
||||
DeprElementKind kind, Content contentTree) {
|
||||
if (builder.hasDocumentation(kind)) {
|
||||
Content li = HtmlTree.LI(getHyperLink(getAnchorName(kind),
|
||||
getResource(getHeadingKey(kind))));
|
||||
contentTree.addContent(li);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the contents list.
|
||||
*
|
||||
* @param deprapi the deprecated list builder
|
||||
* @return a content tree for the contents list
|
||||
*/
|
||||
public Content getContentsList(DeprecatedAPIListBuilder deprapi) {
|
||||
Content headContent = getResource("doclet.Deprecated_API");
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
|
||||
HtmlStyle.title, headContent);
|
||||
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
|
||||
Content headingContent = getResource("doclet.Contents");
|
||||
div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
|
||||
headingContent));
|
||||
Content ul = new HtmlTree(HtmlTag.UL);
|
||||
for (DeprElementKind kind : DeprElementKind.values()) {
|
||||
addIndexLink(deprapi, kind, ul);
|
||||
}
|
||||
div.addContent(ul);
|
||||
return div;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the anchor.
|
||||
*
|
||||
* @param builder the deprecated list builder
|
||||
* @param type the type of list being documented
|
||||
* @param htmlTree the content tree to which the anchor will be added
|
||||
*/
|
||||
private void addAnchor(DeprecatedAPIListBuilder builder, DeprElementKind kind, Content htmlTree) {
|
||||
if (builder.hasDocumentation(kind)) {
|
||||
htmlTree.addContent(getMarkerAnchor(getAnchorName(kind)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the header for the deprecated API Listing.
|
||||
*
|
||||
* @return a content tree for the header
|
||||
*/
|
||||
public HtmlTree getHeader() {
|
||||
String title = configuration.getText("doclet.Window_Deprecated_List");
|
||||
HtmlTree bodyTree = getBody(true, getWindowTitle(title));
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
|
||||
? HtmlTree.HEADER()
|
||||
: bodyTree;
|
||||
addTop(htmlTree);
|
||||
addNavLinks(true, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.HEADER)) {
|
||||
bodyTree.addContent(htmlTree);
|
||||
}
|
||||
return bodyTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the deprecated label.
|
||||
*
|
||||
* @return a content tree for the deprecated label
|
||||
*/
|
||||
protected Content getNavLinkDeprecated() {
|
||||
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, deprecatedLabel);
|
||||
return li;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,330 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.EnumConstantWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
|
||||
|
||||
/**
|
||||
* Writes enum constant documentation in HTML format.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class EnumConstantWriterImpl extends AbstractMemberWriter
|
||||
implements EnumConstantWriter, MemberSummaryWriter {
|
||||
|
||||
public EnumConstantWriterImpl(SubWriterHolderWriter writer, TypeElement typeElement) {
|
||||
super(writer, typeElement);
|
||||
}
|
||||
|
||||
public EnumConstantWriterImpl(SubWriterHolderWriter writer) {
|
||||
super(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getMemberSummaryHeader(TypeElement typeElement,
|
||||
Content memberSummaryTree) {
|
||||
memberSummaryTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_SUMMARY);
|
||||
Content memberTree = writer.getMemberTreeHeader();
|
||||
writer.addSummaryHeader(this, typeElement, memberTree);
|
||||
return memberTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addMemberTree(Content memberSummaryTree, Content memberTree) {
|
||||
writer.addMemberTree(memberSummaryTree, memberTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getEnumConstantsDetailsTreeHeader(TypeElement typeElement,
|
||||
Content memberDetailsTree) {
|
||||
memberDetailsTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_DETAILS);
|
||||
Content enumConstantsDetailsTree = writer.getMemberTreeHeader();
|
||||
enumConstantsDetailsTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.ENUM_CONSTANT_DETAIL));
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
|
||||
writer.enumConstantsDetailsLabel);
|
||||
enumConstantsDetailsTree.addContent(heading);
|
||||
return enumConstantsDetailsTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getEnumConstantsTreeHeader(VariableElement enumConstant,
|
||||
Content enumConstantsDetailsTree) {
|
||||
enumConstantsDetailsTree.addContent(
|
||||
writer.getMarkerAnchor(name(enumConstant)));
|
||||
Content enumConstantsTree = writer.getMemberTreeHeader();
|
||||
Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
|
||||
heading.addContent(name(enumConstant));
|
||||
enumConstantsTree.addContent(heading);
|
||||
return enumConstantsTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getSignature(VariableElement enumConstant) {
|
||||
Content pre = new HtmlTree(HtmlTag.PRE);
|
||||
writer.addAnnotationInfo(enumConstant, pre);
|
||||
addModifiers(enumConstant, pre);
|
||||
Content enumConstantLink = writer.getLink(new LinkInfoImpl(
|
||||
configuration, LinkInfoImpl.Kind.MEMBER, enumConstant.asType()));
|
||||
pre.addContent(enumConstantLink);
|
||||
pre.addContent(" ");
|
||||
if (configuration.linksource) {
|
||||
Content enumConstantName = new StringContent(name(enumConstant));
|
||||
writer.addSrcLink(enumConstant, enumConstantName, pre);
|
||||
} else {
|
||||
addName(name(enumConstant), pre);
|
||||
}
|
||||
return pre;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addDeprecated(VariableElement enumConstant, Content enumConstantsTree) {
|
||||
addDeprecatedInfo(enumConstant, enumConstantsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addComments(VariableElement enumConstant, Content enumConstantsTree) {
|
||||
addComment(enumConstant, enumConstantsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addTags(VariableElement enumConstant, Content enumConstantsTree) {
|
||||
writer.addTagsInfo(enumConstant, enumConstantsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getEnumConstantsDetails(Content enumConstantsDetailsTree) {
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(enumConstantsDetailsTree));
|
||||
return htmlTree;
|
||||
}
|
||||
return getMemberTree(enumConstantsDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getEnumConstants(Content enumConstantsTree,
|
||||
boolean isLastContent) {
|
||||
return getMemberTree(enumConstantsTree, isLastContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addSummaryLabel(Content memberTree) {
|
||||
Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
|
||||
writer.getResource("doclet.Enum_Constant_Summary"));
|
||||
memberTree.addContent(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getTableSummary() {
|
||||
return configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Enum_Constant_Summary"),
|
||||
configuration.getText("doclet.enum_constants"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getCaption() {
|
||||
return configuration.getResource("doclet.Enum_Constants");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<String> getSummaryTableHeader(Element member) {
|
||||
List<String> header = Arrays.asList(configuration.getText("doclet.0_and_1",
|
||||
configuration.getText("doclet.Enum_Constant"),
|
||||
configuration.getText("doclet.Description")));
|
||||
return header;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
|
||||
memberTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.ENUM_CONSTANT_SUMMARY));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
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));
|
||||
Content code = HtmlTree.CODE(memberLink);
|
||||
tdSummary.addContent(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setSummaryColumnStyle(HtmlTree tdTree) {
|
||||
tdTree.addStyle(HtmlStyle.colOne);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addInheritedSummaryLink(TypeElement typeElement, Element member, Content linksTree) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addSummaryType(Element member, Content tdSummaryType) {
|
||||
//Not applicable.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content getDeprecatedLink(Element member) {
|
||||
String name = utils.getFullyQualifiedName(member) + "." + member.getSimpleName();
|
||||
return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, member, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
|
||||
if (link) {
|
||||
if (typeElement == null) {
|
||||
return writer.getHyperLink(SectionName.ENUM_CONSTANT_SUMMARY,
|
||||
writer.getResource("doclet.navEnum"));
|
||||
} else {
|
||||
return writer.getHyperLink(
|
||||
SectionName.ENUM_CONSTANTS_INHERITANCE,
|
||||
configuration.getClassName(typeElement), writer.getResource("doclet.navEnum"));
|
||||
}
|
||||
} else {
|
||||
return writer.getResource("doclet.navEnum");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addNavDetailLink(boolean link, Content liNav) {
|
||||
if (link) {
|
||||
liNav.addContent(writer.getHyperLink(
|
||||
SectionName.ENUM_CONSTANT_DETAIL,
|
||||
writer.getResource("doclet.navEnum")));
|
||||
} else {
|
||||
liNav.addContent(writer.getResource("doclet.navEnum"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,339 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.FieldWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
|
||||
|
||||
/**
|
||||
* Writes field documentation in HTML format.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Robert Field
|
||||
* @author Atul M Dambalkar
|
||||
* @author Jamie Ho (rewrite)
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class FieldWriterImpl extends AbstractMemberWriter
|
||||
implements FieldWriter, MemberSummaryWriter {
|
||||
|
||||
public FieldWriterImpl(SubWriterHolderWriter writer, TypeElement typeElement) {
|
||||
super(writer, typeElement);
|
||||
}
|
||||
|
||||
public FieldWriterImpl(SubWriterHolderWriter writer) {
|
||||
super(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getMemberSummaryHeader(TypeElement typeElement,
|
||||
Content memberSummaryTree) {
|
||||
memberSummaryTree.addContent(HtmlConstants.START_OF_FIELD_SUMMARY);
|
||||
Content memberTree = writer.getMemberTreeHeader();
|
||||
writer.addSummaryHeader(this, typeElement, memberTree);
|
||||
return memberTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addMemberTree(Content memberSummaryTree, Content memberTree) {
|
||||
writer.addMemberTree(memberSummaryTree, memberTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getFieldDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) {
|
||||
memberDetailsTree.addContent(HtmlConstants.START_OF_FIELD_DETAILS);
|
||||
Content fieldDetailsTree = writer.getMemberTreeHeader();
|
||||
fieldDetailsTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.FIELD_DETAIL));
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
|
||||
writer.fieldDetailsLabel);
|
||||
fieldDetailsTree.addContent(heading);
|
||||
return fieldDetailsTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getFieldDocTreeHeader(VariableElement field, Content fieldDetailsTree) {
|
||||
fieldDetailsTree.addContent(writer.getMarkerAnchor(name(field)));
|
||||
Content fieldTree = writer.getMemberTreeHeader();
|
||||
Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
|
||||
heading.addContent(name(field));
|
||||
fieldTree.addContent(heading);
|
||||
return fieldTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getSignature(VariableElement field) {
|
||||
Content pre = new HtmlTree(HtmlTag.PRE);
|
||||
writer.addAnnotationInfo(field, pre);
|
||||
addModifiers(field, pre);
|
||||
Content fieldlink = writer.getLink(new LinkInfoImpl(
|
||||
configuration, LinkInfoImpl.Kind.MEMBER, field.asType()));
|
||||
pre.addContent(fieldlink);
|
||||
pre.addContent(" ");
|
||||
if (configuration.linksource) {
|
||||
Content fieldName = new StringContent(name(field));
|
||||
writer.addSrcLink(field, fieldName, pre);
|
||||
} else {
|
||||
addName(name(field), pre);
|
||||
}
|
||||
return pre;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addDeprecated(VariableElement field, Content fieldTree) {
|
||||
addDeprecatedInfo(field, fieldTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addComments(VariableElement field, Content fieldTree) {
|
||||
if (!utils.getBody(field).isEmpty()) {
|
||||
writer.addInlineComment(field, fieldTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addTags(VariableElement field, Content fieldTree) {
|
||||
writer.addTagsInfo(field, fieldTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getFieldDetails(Content fieldDetailsTree) {
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(fieldDetailsTree));
|
||||
return htmlTree;
|
||||
}
|
||||
return getMemberTree(fieldDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getFieldDoc(Content fieldTree,
|
||||
boolean isLastContent) {
|
||||
return getMemberTree(fieldTree, isLastContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the writer.
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addSummaryLabel(Content memberTree) {
|
||||
Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
|
||||
writer.getResource("doclet.Field_Summary"));
|
||||
memberTree.addContent(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getTableSummary() {
|
||||
return configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Field_Summary"),
|
||||
configuration.getText("doclet.fields"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getCaption() {
|
||||
return configuration.getResource("doclet.Fields");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<String> getSummaryTableHeader(Element member) {
|
||||
List<String> header = Arrays.asList(writer.getModifierTypeHeader(),
|
||||
configuration.getText("doclet.0_and_1",
|
||||
configuration.getText("doclet.Field"),
|
||||
configuration.getText("doclet.Description")));
|
||||
return header;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
|
||||
memberTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.FIELD_SUMMARY));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) {
|
||||
inheritedTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.FIELDS_INHERITANCE, configuration.getClassName(typeElement)));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) {
|
||||
Content classLink = writer.getPreQualifiedClassLink(
|
||||
LinkInfoImpl.Kind.MEMBER, typeElement, false);
|
||||
Content label = new StringContent(utils.isClass(typeElement)
|
||||
? configuration.getText("doclet.Fields_Inherited_From_Class")
|
||||
: configuration.getText("doclet.Fields_Inherited_From_Interface"));
|
||||
Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
|
||||
label);
|
||||
labelHeading.addContent(writer.getSpace());
|
||||
labelHeading.addContent(classLink);
|
||||
inheritedTree.addContent(labelHeading);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
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));
|
||||
Content code = HtmlTree.CODE(memberLink);
|
||||
tdSummary.addContent(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addInheritedSummaryLink(TypeElement typeElement, Element member, Content linksTree) {
|
||||
linksTree.addContent(
|
||||
writer.getDocLink(LinkInfoImpl.Kind.MEMBER, typeElement, member,
|
||||
name(member), false));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addSummaryType(Element member, Content tdSummaryType) {
|
||||
addModifierAndType(member, member.asType(), tdSummaryType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content getDeprecatedLink(Element member) {
|
||||
String name = utils.getFullyQualifiedName(member) + "." + member.getSimpleName();
|
||||
return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, member, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
|
||||
if (link) {
|
||||
if (typeElement == null) {
|
||||
return writer.getHyperLink(
|
||||
SectionName.FIELD_SUMMARY,
|
||||
writer.getResource("doclet.navField"));
|
||||
} else {
|
||||
return writer.getHyperLink(
|
||||
SectionName.FIELDS_INHERITANCE,
|
||||
configuration.getClassName(typeElement), writer.getResource("doclet.navField"));
|
||||
}
|
||||
} else {
|
||||
return writer.getResource("doclet.navField");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addNavDetailLink(boolean link, Content liNav) {
|
||||
if (link) {
|
||||
liNav.addContent(writer.getHyperLink(
|
||||
SectionName.FIELD_DETAIL,
|
||||
writer.getResource("doclet.navField")));
|
||||
} else {
|
||||
liNav.addContent(writer.getResource("doclet.navField"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,177 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
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.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
|
||||
|
||||
/**
|
||||
* Generate the documentation in the Html "frame" format in the browser. The
|
||||
* generated documentation will have two or three frames depending upon the
|
||||
* number of packages on the command line. In general there will be three frames
|
||||
* in the output, a left-hand top frame will have a list of all packages with
|
||||
* links to target left-hand bottom frame. The left-hand bottom frame will have
|
||||
* the particular package contents or the all-classes list, where as the single
|
||||
* right-hand frame will have overview or package summary or class file. Also
|
||||
* take care of browsers which do not support Html frames.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
*/
|
||||
public class FrameOutputWriter extends HtmlDocletWriter {
|
||||
|
||||
/**
|
||||
* Number of packages specified on the command line.
|
||||
*/
|
||||
int noOfPackages;
|
||||
|
||||
/**
|
||||
* Constructor to construct FrameOutputWriter object.
|
||||
*
|
||||
* @param configuration for this run
|
||||
* @param filename File to be generated.
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public FrameOutputWriter(ConfigurationImpl configuration, DocPath filename) throws IOException {
|
||||
super(configuration, filename);
|
||||
noOfPackages = configuration.packages.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct FrameOutputWriter object and then use it to generate the Html
|
||||
* file which will have the description of all the frames in the
|
||||
* documentation. The name of the generated file is "index.html" which is
|
||||
* the default first file for Html documents.
|
||||
* @throws DocletAbortException
|
||||
*/
|
||||
public static void generate(ConfigurationImpl configuration) {
|
||||
FrameOutputWriter framegen;
|
||||
DocPath filename = DocPath.empty;
|
||||
try {
|
||||
filename = DocPaths.INDEX;
|
||||
framegen = new FrameOutputWriter(configuration, filename);
|
||||
framegen.generateFrameFile();
|
||||
framegen.close();
|
||||
} catch (IOException exc) {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the constants in the "index.html" file. Print the frame details
|
||||
* as well as warning if browser is not supporting the Html frames.
|
||||
*/
|
||||
protected void generateFrameFile() throws IOException {
|
||||
Content frame = getFrameDetails();
|
||||
HtmlTree body = new HtmlTree(HtmlTag.BODY);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
HtmlTree main = HtmlTree.MAIN(frame);
|
||||
body.addContent(main);
|
||||
} else {
|
||||
body.addContent(frame);
|
||||
}
|
||||
if (configuration.windowtitle.length() > 0) {
|
||||
printFramesDocument(configuration.windowtitle, configuration,
|
||||
body);
|
||||
} else {
|
||||
printFramesDocument(configuration.getText("doclet.Generated_Docs_Untitled"),
|
||||
configuration, body);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the frame sizes and their contents.
|
||||
*
|
||||
* @return a content tree for the frame details
|
||||
*/
|
||||
protected Content getFrameDetails() {
|
||||
HtmlTree leftContainerDiv = new HtmlTree(HtmlTag.DIV);
|
||||
HtmlTree rightContainerDiv = new HtmlTree(HtmlTag.DIV);
|
||||
leftContainerDiv.addStyle(HtmlStyle.leftContainer);
|
||||
rightContainerDiv.addStyle(HtmlStyle.rightContainer);
|
||||
if (noOfPackages <= 1) {
|
||||
addAllClassesFrameTag(leftContainerDiv);
|
||||
} else if (noOfPackages > 1) {
|
||||
addAllPackagesFrameTag(leftContainerDiv);
|
||||
addAllClassesFrameTag(leftContainerDiv);
|
||||
}
|
||||
addClassFrameTag(rightContainerDiv);
|
||||
HtmlTree mainContainer = HtmlTree.DIV(HtmlStyle.mainContainer, leftContainerDiv);
|
||||
mainContainer.addContent(rightContainerDiv);
|
||||
return mainContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the IFRAME tag for the frame that lists all packages.
|
||||
*
|
||||
* @param contentTree the content tree to which the information will be added
|
||||
*/
|
||||
private void addAllPackagesFrameTag(Content contentTree) {
|
||||
HtmlTree frame = HtmlTree.IFRAME(DocPaths.OVERVIEW_FRAME.getPath(),
|
||||
"packageListFrame", configuration.getText("doclet.All_Packages"));
|
||||
HtmlTree leftTop = HtmlTree.DIV(HtmlStyle.leftTop, frame);
|
||||
contentTree.addContent(leftTop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the IFRAME tag for the frame that lists all classes.
|
||||
*
|
||||
* @param contentTree the content tree to which the information will be added
|
||||
*/
|
||||
private void addAllClassesFrameTag(Content contentTree) {
|
||||
HtmlTree frame = HtmlTree.IFRAME(DocPaths.ALLCLASSES_FRAME.getPath(),
|
||||
"packageFrame", configuration.getText("doclet.All_classes_and_interfaces"));
|
||||
HtmlTree leftBottom = HtmlTree.DIV(HtmlStyle.leftBottom, frame);
|
||||
contentTree.addContent(leftBottom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the IFRAME tag for the frame that describes the class in detail.
|
||||
*
|
||||
* @param contentTree the content tree to which the information will be added
|
||||
*/
|
||||
private void addClassFrameTag(Content contentTree) {
|
||||
HtmlTree frame = HtmlTree.IFRAME(configuration.topFile.getPath(), "classFrame",
|
||||
configuration.getText("doclet.Package_class_and_interface_descriptions"));
|
||||
frame.addStyle(HtmlStyle.rightIframe);
|
||||
contentTree.addContent(frame);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,449 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
|
||||
|
||||
/**
|
||||
* Generate the Help File for the generated API documentation. The help file
|
||||
* contents are helpful for browsing the generated 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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
*/
|
||||
public class HelpWriter extends HtmlDocletWriter {
|
||||
|
||||
HtmlTree mainTree = HtmlTree.MAIN();
|
||||
|
||||
/**
|
||||
* Constructor to construct HelpWriter object.
|
||||
* @param filename File to be generated.
|
||||
*/
|
||||
public HelpWriter(ConfigurationImpl configuration,
|
||||
DocPath filename) throws IOException {
|
||||
super(configuration, filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the HelpWriter object and then use it to generate the help
|
||||
* file. The name of the generated file is "help-doc.html". The help file
|
||||
* will get generated if and only if "-helpfile" and "-nohelp" is not used
|
||||
* on the command line.
|
||||
* @throws DocletAbortException
|
||||
*/
|
||||
public static void generate(ConfigurationImpl configuration) {
|
||||
HelpWriter helpgen;
|
||||
DocPath filename = DocPath.empty;
|
||||
try {
|
||||
filename = DocPaths.HELP_DOC;
|
||||
helpgen = new HelpWriter(configuration, filename);
|
||||
helpgen.generateHelpFile();
|
||||
helpgen.close();
|
||||
} catch (IOException exc) {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the help file contents.
|
||||
*/
|
||||
protected void generateHelpFile() throws IOException {
|
||||
String title = configuration.getText("doclet.Window_Help_title");
|
||||
HtmlTree body = getBody(true, getWindowTitle(title));
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
|
||||
? HtmlTree.HEADER()
|
||||
: body;
|
||||
addTop(htmlTree);
|
||||
addNavLinks(true, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.HEADER)) {
|
||||
body.addContent(htmlTree);
|
||||
}
|
||||
addHelpFileContents(body);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
htmlTree = HtmlTree.FOOTER();
|
||||
}
|
||||
addNavLinks(false, htmlTree);
|
||||
addBottom(htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
body.addContent(htmlTree);
|
||||
}
|
||||
printHtmlDocument(null, true, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the help file contents from the resource file to the content tree. While adding the
|
||||
* help file contents it also keeps track of user options. If "-notree"
|
||||
* is used, then the "overview-tree.html" will not get added and hence
|
||||
* help information also will not get added.
|
||||
*
|
||||
* @param contentTree the content tree to which the help file contents will be added
|
||||
*/
|
||||
protected void addHelpFileContents(Content contentTree) {
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, HtmlStyle.title,
|
||||
getResource("doclet.Help_line_1"));
|
||||
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
|
||||
Content line2 = HtmlTree.DIV(HtmlStyle.subTitle,
|
||||
getResource("doclet.Help_line_2"));
|
||||
div.addContent(line2);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
mainTree.addContent(div);
|
||||
} else {
|
||||
contentTree.addContent(div);
|
||||
}
|
||||
HtmlTree htmlTree;
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
ul.addStyle(HtmlStyle.blockList);
|
||||
if (configuration.createoverview) {
|
||||
Content overviewHeading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
getResource("doclet.Overview"));
|
||||
htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION(overviewHeading)
|
||||
: HtmlTree.LI(HtmlStyle.blockList, overviewHeading);
|
||||
Content line3 = getResource("doclet.Help_line_3",
|
||||
getHyperLink(DocPaths.OVERVIEW_SUMMARY,
|
||||
configuration.getText("doclet.Overview")));
|
||||
Content overviewPara = HtmlTree.P(line3);
|
||||
htmlTree.addContent(overviewPara);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
|
||||
} else {
|
||||
ul.addContent(htmlTree);
|
||||
}
|
||||
}
|
||||
Content packageHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
getResource("doclet.Package"));
|
||||
htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION(packageHead)
|
||||
: HtmlTree.LI(HtmlStyle.blockList, packageHead);
|
||||
Content line4 = getResource("doclet.Help_line_4");
|
||||
Content packagePara = HtmlTree.P(line4);
|
||||
htmlTree.addContent(packagePara);
|
||||
HtmlTree ulPackage = new HtmlTree(HtmlTag.UL);
|
||||
ulPackage.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Interfaces_Italic")));
|
||||
ulPackage.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Classes")));
|
||||
ulPackage.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Enums")));
|
||||
ulPackage.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Exceptions")));
|
||||
ulPackage.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Errors")));
|
||||
ulPackage.addContent(HtmlTree.LI(
|
||||
getResource("doclet.AnnotationTypes")));
|
||||
htmlTree.addContent(ulPackage);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
|
||||
} else {
|
||||
ul.addContent(htmlTree);
|
||||
}
|
||||
Content classHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
getResource("doclet.Help_line_5"));
|
||||
htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION(classHead)
|
||||
: HtmlTree.LI(HtmlStyle.blockList, classHead);
|
||||
Content line6 = getResource("doclet.Help_line_6");
|
||||
Content classPara = HtmlTree.P(line6);
|
||||
htmlTree.addContent(classPara);
|
||||
HtmlTree ul1 = new HtmlTree(HtmlTag.UL);
|
||||
ul1.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Help_line_7")));
|
||||
ul1.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Help_line_8")));
|
||||
ul1.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Help_line_9")));
|
||||
ul1.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Help_line_10")));
|
||||
ul1.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Help_line_11")));
|
||||
ul1.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Help_line_12")));
|
||||
htmlTree.addContent(ul1);
|
||||
HtmlTree ul2 = new HtmlTree(HtmlTag.UL);
|
||||
ul2.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Nested_Class_Summary")));
|
||||
ul2.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Field_Summary")));
|
||||
ul2.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Constructor_Summary")));
|
||||
ul2.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Method_Summary")));
|
||||
htmlTree.addContent(ul2);
|
||||
HtmlTree ul3 = new HtmlTree(HtmlTag.UL);
|
||||
ul3.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Field_Detail")));
|
||||
ul3.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Constructor_Detail")));
|
||||
ul3.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Method_Detail")));
|
||||
htmlTree.addContent(ul3);
|
||||
Content line13 = getResource("doclet.Help_line_13");
|
||||
Content para = HtmlTree.P(line13);
|
||||
htmlTree.addContent(para);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
|
||||
} else {
|
||||
ul.addContent(htmlTree);
|
||||
}
|
||||
//Annotation Types
|
||||
Content aHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
getResource("doclet.AnnotationType"));
|
||||
htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION(aHead)
|
||||
: HtmlTree.LI(HtmlStyle.blockList, aHead);
|
||||
Content aline1 = getResource("doclet.Help_annotation_type_line_1");
|
||||
Content aPara = HtmlTree.P(aline1);
|
||||
htmlTree.addContent(aPara);
|
||||
HtmlTree aul = new HtmlTree(HtmlTag.UL);
|
||||
aul.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Help_annotation_type_line_2")));
|
||||
aul.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Help_annotation_type_line_3")));
|
||||
aul.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Annotation_Type_Required_Member_Summary")));
|
||||
aul.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Annotation_Type_Optional_Member_Summary")));
|
||||
aul.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Annotation_Type_Member_Detail")));
|
||||
htmlTree.addContent(aul);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
|
||||
} else {
|
||||
ul.addContent(htmlTree);
|
||||
}
|
||||
//Enums
|
||||
Content enumHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
getResource("doclet.Enum"));
|
||||
htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION(enumHead)
|
||||
: HtmlTree.LI(HtmlStyle.blockList, enumHead);
|
||||
Content eline1 = getResource("doclet.Help_enum_line_1");
|
||||
Content enumPara = HtmlTree.P(eline1);
|
||||
htmlTree.addContent(enumPara);
|
||||
HtmlTree eul = new HtmlTree(HtmlTag.UL);
|
||||
eul.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Help_enum_line_2")));
|
||||
eul.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Help_enum_line_3")));
|
||||
eul.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Enum_Constant_Summary")));
|
||||
eul.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Enum_Constant_Detail")));
|
||||
htmlTree.addContent(eul);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
|
||||
} else {
|
||||
ul.addContent(htmlTree);
|
||||
}
|
||||
if (configuration.classuse) {
|
||||
Content useHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
getResource("doclet.Help_line_14"));
|
||||
htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION(useHead)
|
||||
: HtmlTree.LI(HtmlStyle.blockList, useHead);
|
||||
Content line15 = getResource("doclet.Help_line_15");
|
||||
Content usePara = HtmlTree.P(line15);
|
||||
htmlTree.addContent(usePara);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
|
||||
} else {
|
||||
ul.addContent(htmlTree);
|
||||
}
|
||||
}
|
||||
if (configuration.createtree) {
|
||||
Content treeHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
getResource("doclet.Help_line_16"));
|
||||
htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION(treeHead)
|
||||
: HtmlTree.LI(HtmlStyle.blockList, treeHead);
|
||||
Content line17 = getResource("doclet.Help_line_17_with_tree_link",
|
||||
getHyperLink(DocPaths.OVERVIEW_TREE,
|
||||
configuration.getText("doclet.Class_Hierarchy")),
|
||||
HtmlTree.CODE(new StringContent("java.lang.Object")));
|
||||
Content treePara = HtmlTree.P(line17);
|
||||
htmlTree.addContent(treePara);
|
||||
HtmlTree tul = new HtmlTree(HtmlTag.UL);
|
||||
tul.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Help_line_18")));
|
||||
tul.addContent(HtmlTree.LI(
|
||||
getResource("doclet.Help_line_19")));
|
||||
htmlTree.addContent(tul);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
|
||||
} else {
|
||||
ul.addContent(htmlTree);
|
||||
}
|
||||
}
|
||||
if (!(configuration.nodeprecatedlist ||
|
||||
configuration.nodeprecated)) {
|
||||
Content dHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
getResource("doclet.Deprecated_API"));
|
||||
htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION(dHead)
|
||||
: HtmlTree.LI(HtmlStyle.blockList, dHead);
|
||||
Content line20 = getResource("doclet.Help_line_20_with_deprecated_api_link",
|
||||
getHyperLink(DocPaths.DEPRECATED_LIST,
|
||||
configuration.getText("doclet.Deprecated_API")));
|
||||
Content dPara = HtmlTree.P(line20);
|
||||
htmlTree.addContent(dPara);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
|
||||
} else {
|
||||
ul.addContent(htmlTree);
|
||||
}
|
||||
}
|
||||
if (configuration.createindex) {
|
||||
Content indexlink;
|
||||
if (configuration.splitindex) {
|
||||
indexlink = getHyperLink(DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)),
|
||||
configuration.getText("doclet.Index"));
|
||||
} else {
|
||||
indexlink = getHyperLink(DocPaths.INDEX_ALL,
|
||||
configuration.getText("doclet.Index"));
|
||||
}
|
||||
Content indexHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
getResource("doclet.Help_line_21"));
|
||||
htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION(indexHead)
|
||||
: HtmlTree.LI(HtmlStyle.blockList, indexHead);
|
||||
Content line22 = getResource("doclet.Help_line_22", indexlink);
|
||||
Content indexPara = HtmlTree.P(line22);
|
||||
htmlTree.addContent(indexPara);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
|
||||
} else {
|
||||
ul.addContent(htmlTree);
|
||||
}
|
||||
}
|
||||
Content prevHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
getResource("doclet.Help_line_23"));
|
||||
htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION(prevHead)
|
||||
: HtmlTree.LI(HtmlStyle.blockList, prevHead);
|
||||
Content line24 = getResource("doclet.Help_line_24");
|
||||
Content prevPara = HtmlTree.P(line24);
|
||||
htmlTree.addContent(prevPara);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
|
||||
} else {
|
||||
ul.addContent(htmlTree);
|
||||
}
|
||||
Content frameHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
getResource("doclet.Help_line_25"));
|
||||
htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION(frameHead)
|
||||
: HtmlTree.LI(HtmlStyle.blockList, frameHead);
|
||||
Content line26 = getResource("doclet.Help_line_26");
|
||||
Content framePara = HtmlTree.P(line26);
|
||||
htmlTree.addContent(framePara);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
|
||||
} else {
|
||||
ul.addContent(htmlTree);
|
||||
}
|
||||
Content allclassesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
getResource("doclet.All_Classes"));
|
||||
htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION(allclassesHead)
|
||||
: HtmlTree.LI(HtmlStyle.blockList, allclassesHead);
|
||||
Content line27 = getResource("doclet.Help_line_27",
|
||||
getHyperLink(DocPaths.ALLCLASSES_NOFRAME,
|
||||
configuration.getText("doclet.All_Classes")));
|
||||
Content allclassesPara = HtmlTree.P(line27);
|
||||
htmlTree.addContent(allclassesPara);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
|
||||
} else {
|
||||
ul.addContent(htmlTree);
|
||||
}
|
||||
Content sHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
getResource("doclet.Serialized_Form"));
|
||||
htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION(sHead)
|
||||
: HtmlTree.LI(HtmlStyle.blockList, sHead);
|
||||
Content line28 = getResource("doclet.Help_line_28");
|
||||
Content serialPara = HtmlTree.P(line28);
|
||||
htmlTree.addContent(serialPara);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
|
||||
} else {
|
||||
ul.addContent(htmlTree);
|
||||
}
|
||||
Content constHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
getResource("doclet.Constants_Summary"));
|
||||
htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION(constHead)
|
||||
: HtmlTree.LI(HtmlStyle.blockList, constHead);
|
||||
Content line29 = getResource("doclet.Help_line_29",
|
||||
getHyperLink(DocPaths.CONSTANT_VALUES,
|
||||
configuration.getText("doclet.Constants_Summary")));
|
||||
Content constPara = HtmlTree.P(line29);
|
||||
htmlTree.addContent(constPara);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
|
||||
} else {
|
||||
ul.addContent(htmlTree);
|
||||
}
|
||||
Content divContent = HtmlTree.DIV(HtmlStyle.contentContainer, ul);
|
||||
Content line30 = HtmlTree.SPAN(HtmlStyle.emphasizedPhrase, getResource("doclet.Help_line_30"));
|
||||
divContent.addContent(line30);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
mainTree.addContent(divContent);
|
||||
contentTree.addContent(mainTree);
|
||||
} else {
|
||||
contentTree.addContent(divContent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the help label.
|
||||
*
|
||||
* @return a content tree for the help label
|
||||
*/
|
||||
@Override
|
||||
protected Content getNavLinkHelp() {
|
||||
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, helpLabel);
|
||||
return li;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,323 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.lang.model.element.PackageElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
import jdk.javadoc.doclet.Doclet.Option;
|
||||
import jdk.javadoc.doclet.DocletEnvironment;
|
||||
import jdk.javadoc.doclet.Reporter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.AbstractDoclet;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Configuration;
|
||||
import jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
|
||||
|
||||
/**
|
||||
* The class with "start" method, calls individual Writers.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
* @author Robert Field
|
||||
* @author Jamie Ho
|
||||
*
|
||||
*/
|
||||
public class HtmlDoclet extends AbstractDoclet {
|
||||
|
||||
public HtmlDoclet() {
|
||||
configuration = new ConfigurationImpl();
|
||||
}
|
||||
|
||||
/**
|
||||
* The global configuration information for this run.
|
||||
*/
|
||||
public final ConfigurationImpl configuration;
|
||||
|
||||
|
||||
private static final DocPath DOCLET_RESOURCES = DocPath
|
||||
.create("/jdk/javadoc/internal/doclets/formats/html/resources");
|
||||
|
||||
public void init(Locale locale, Reporter reporter) {
|
||||
configuration.reporter = reporter;
|
||||
configuration.locale = locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* The "start" method as required by Javadoc.
|
||||
*
|
||||
* @param root the root of the documentation tree.
|
||||
* @see jdk.doclet.DocletEnvironment
|
||||
* @return true if the doclet ran without encountering any errors.
|
||||
*/
|
||||
public boolean run(DocletEnvironment root) {
|
||||
return startDoclet(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the configuration instance.
|
||||
* Override this method to use a different
|
||||
* configuration.
|
||||
*/
|
||||
public Configuration configuration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the generation of files. Call generate methods in the individual
|
||||
* writers, which will in turn genrate the documentation files. Call the
|
||||
* TreeWriter generation first to ensure the Class Hierarchy is built
|
||||
* first and then can be used in the later generation.
|
||||
*
|
||||
* For new format.
|
||||
*
|
||||
* @see jdk.doclet.RootDoc
|
||||
*/
|
||||
protected void generateOtherFiles(DocletEnvironment root, ClassTree classtree)
|
||||
throws Exception {
|
||||
super.generateOtherFiles(root, classtree);
|
||||
if (configuration.linksource) {
|
||||
SourceToHTMLConverter.convertRoot(configuration,
|
||||
root, DocPaths.SOURCE_OUTPUT);
|
||||
}
|
||||
|
||||
if (configuration.topFile.isEmpty()) {
|
||||
configuration.standardmessage.
|
||||
error("doclet.No_Non_Deprecated_Classes_To_Document");
|
||||
return;
|
||||
}
|
||||
boolean nodeprecated = configuration.nodeprecated;
|
||||
performCopy(configuration.helpfile);
|
||||
performCopy(configuration.stylesheetfile);
|
||||
// do early to reduce memory footprint
|
||||
if (configuration.classuse) {
|
||||
ClassUseWriter.generate(configuration, classtree);
|
||||
}
|
||||
IndexBuilder indexbuilder = new IndexBuilder(configuration, nodeprecated);
|
||||
|
||||
if (configuration.createtree) {
|
||||
TreeWriter.generate(configuration, classtree);
|
||||
}
|
||||
if (configuration.createindex) {
|
||||
configuration.buildSearchTagIndex();
|
||||
if (configuration.splitindex) {
|
||||
SplitIndexWriter.generate(configuration, indexbuilder);
|
||||
} else {
|
||||
SingleIndexWriter.generate(configuration, indexbuilder);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(configuration.nodeprecatedlist || nodeprecated)) {
|
||||
DeprecatedListWriter.generate(configuration);
|
||||
}
|
||||
|
||||
AllClassesFrameWriter.generate(configuration,
|
||||
new IndexBuilder(configuration, nodeprecated, true));
|
||||
|
||||
FrameOutputWriter.generate(configuration);
|
||||
|
||||
if (configuration.createoverview) {
|
||||
PackageIndexWriter.generate(configuration);
|
||||
}
|
||||
if (configuration.helpfile.length() == 0 &&
|
||||
!configuration.nohelp) {
|
||||
HelpWriter.generate(configuration);
|
||||
}
|
||||
// If a stylesheet file is not specified, copy the default stylesheet
|
||||
// and replace newline with platform-specific newline.
|
||||
DocFile f;
|
||||
if (configuration.stylesheetfile.length() == 0) {
|
||||
f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET);
|
||||
f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.STYLESHEET), false, true);
|
||||
}
|
||||
f = DocFile.createFileForOutput(configuration, DocPaths.JAVASCRIPT);
|
||||
f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.JAVASCRIPT), true, true);
|
||||
if (configuration.createindex) {
|
||||
f = DocFile.createFileForOutput(configuration, DocPaths.SEARCH_JS);
|
||||
f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.SEARCH_JS), true, true);
|
||||
|
||||
f = DocFile.createFileForOutput(configuration, DocPaths.RESOURCES.resolve(DocPaths.GLASS_IMG));
|
||||
f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.GLASS_IMG), true, false);
|
||||
|
||||
f = DocFile.createFileForOutput(configuration, DocPaths.RESOURCES.resolve(DocPaths.X_IMG));
|
||||
f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.X_IMG), true, false);
|
||||
copyJqueryFiles();
|
||||
}
|
||||
}
|
||||
|
||||
protected void copyJqueryFiles() {
|
||||
List<String> files = Arrays.asList(
|
||||
"jquery-1.10.2.js",
|
||||
"jquery-ui.js",
|
||||
"jquery-ui.css",
|
||||
"jquery-ui.min.js",
|
||||
"jquery-ui.min.css",
|
||||
"jquery-ui.structure.min.css",
|
||||
"jquery-ui.structure.css",
|
||||
"external/jquery/jquery.js",
|
||||
"jszip/dist/jszip.js",
|
||||
"jszip/dist/jszip.min.js",
|
||||
"jszip-utils/dist/jszip-utils.js",
|
||||
"jszip-utils/dist/jszip-utils.min.js",
|
||||
"jszip-utils/dist/jszip-utils-ie.js",
|
||||
"jszip-utils/dist/jszip-utils-ie.min.js",
|
||||
"images/ui-bg_flat_0_aaaaaa_40x100.png",
|
||||
"images/ui-icons_454545_256x240.png",
|
||||
"images/ui-bg_glass_95_fef1ec_1x400.png",
|
||||
"images/ui-bg_glass_75_dadada_1x400.png",
|
||||
"images/ui-bg_highlight-soft_75_cccccc_1x100.png",
|
||||
"images/ui-icons_888888_256x240.png",
|
||||
"images/ui-icons_2e83ff_256x240.png",
|
||||
"images/ui-bg_glass_65_ffffff_1x400.png",
|
||||
"images/ui-icons_cd0a0a_256x240.png",
|
||||
"images/ui-bg_glass_55_fbf9ee_1x400.png",
|
||||
"images/ui-icons_222222_256x240.png",
|
||||
"images/ui-bg_glass_75_e6e6e6_1x400.png",
|
||||
"images/ui-bg_flat_75_ffffff_40x100.png");
|
||||
DocFile f;
|
||||
for (String file : files) {
|
||||
DocPath filePath = DocPaths.JQUERY_FILES.resolve(file);
|
||||
f = DocFile.createFileForOutput(configuration, filePath);
|
||||
f.copyResource(DOCLET_RESOURCES.resolve(filePath), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected void generateClassFiles(SortedSet<TypeElement> arr, ClassTree classtree) {
|
||||
List<TypeElement> list = new ArrayList<>(arr);
|
||||
ListIterator<TypeElement> iterator = list.listIterator();
|
||||
TypeElement klass = null;
|
||||
while (iterator.hasNext()) {
|
||||
TypeElement prev = iterator.hasPrevious() ? klass : null;
|
||||
klass = iterator.next();
|
||||
TypeElement next = iterator.nextIndex() == list.size()
|
||||
? null : list.get(iterator.nextIndex());
|
||||
if (!(configuration.isGeneratedDoc(klass) && utils.isIncluded(klass))) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
if (utils.isAnnotationType(klass)) {
|
||||
AbstractBuilder annotationTypeBuilder =
|
||||
configuration.getBuilderFactory()
|
||||
.getAnnotationTypeBuilder(klass,
|
||||
prev == null ? null : prev.asType(),
|
||||
next == null ? null : next.asType());
|
||||
annotationTypeBuilder.build();
|
||||
} else {
|
||||
AbstractBuilder classBuilder =
|
||||
configuration.getBuilderFactory().getClassBuilder(klass,
|
||||
prev, next, classtree);
|
||||
classBuilder.build();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new DocletAbortException(e);
|
||||
} catch (DocletAbortException de) {
|
||||
throw de;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected void generatePackageFiles(ClassTree classtree) throws Exception {
|
||||
Set<PackageElement> packages = configuration.packages;
|
||||
if (packages.size() > 1) {
|
||||
PackageIndexFrameWriter.generate(configuration);
|
||||
}
|
||||
List<PackageElement> pList = new ArrayList<>(packages);
|
||||
PackageElement prev = null;
|
||||
for (int i = 0 ; i < pList.size() ; i++) {
|
||||
// if -nodeprecated option is set and the package is marked as
|
||||
// deprecated, do not generate the package-summary.html, package-frame.html
|
||||
// and package-tree.html pages for that package.
|
||||
PackageElement pkg = pList.get(i);
|
||||
if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) {
|
||||
PackageFrameWriter.generate(configuration, pkg);
|
||||
int nexti = i + 1;
|
||||
PackageElement next = null;
|
||||
if (nexti < pList.size()) {
|
||||
next = pList.get(nexti);
|
||||
// If the next package is unnamed package, skip 2 ahead if possible
|
||||
if (next.isUnnamed() && ++nexti < pList.size()) {
|
||||
next = pList.get(nexti);
|
||||
}
|
||||
}
|
||||
AbstractBuilder packageSummaryBuilder =
|
||||
configuration.getBuilderFactory().getPackageSummaryBuilder(
|
||||
pkg, prev, next);
|
||||
packageSummaryBuilder.build();
|
||||
if (configuration.createtree) {
|
||||
PackageTreeWriter.generate(configuration, pkg, prev, next,
|
||||
configuration.nodeprecated);
|
||||
}
|
||||
prev = pkg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Set<Option> getSupportedOptions() {
|
||||
return configuration.getSupportedOptions();
|
||||
}
|
||||
|
||||
private void performCopy(String filename) {
|
||||
if (filename.isEmpty())
|
||||
return;
|
||||
|
||||
try {
|
||||
DocFile fromfile = DocFile.createFileForInput(configuration, filename);
|
||||
DocPath path = DocPath.create(fromfile.getName());
|
||||
DocFile toFile = DocFile.createFileForOutput(configuration, path);
|
||||
if (toFile.isSameFile(fromfile))
|
||||
return;
|
||||
|
||||
configuration.message.notice("doclet.Copying_File_0_To_File_1",
|
||||
fromfile.toString(), path.getPath());
|
||||
toFile.copyFile(fromfile);
|
||||
} catch (IOException exc) {
|
||||
configuration.message.error("doclet.perform_copy_exception_encountered",
|
||||
exc.toString());
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,221 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
|
||||
import com.sun.source.doctree.DocTree;
|
||||
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
|
||||
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.RawHtml;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
|
||||
|
||||
/**
|
||||
* Generate serialized form for serializable fields.
|
||||
* Documentation denoted by the tags <code>serial</code> and
|
||||
* <code>serialField</code> is processed.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Joe Fialli
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class HtmlSerialFieldWriter extends FieldWriterImpl
|
||||
implements SerializedFormWriter.SerialFieldWriter {
|
||||
|
||||
public HtmlSerialFieldWriter(SubWriterHolderWriter writer, TypeElement typeElement) {
|
||||
super(writer, typeElement);
|
||||
}
|
||||
|
||||
public SortedSet<VariableElement> members(TypeElement te) {
|
||||
return utils.serializableFields(te);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the header for serializable fields section.
|
||||
*
|
||||
* @return a content tree for the header
|
||||
*/
|
||||
public Content getSerializableFieldsHeader() {
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
ul.addStyle(HtmlStyle.blockList);
|
||||
return ul;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the header for serializable fields content section.
|
||||
*
|
||||
* @param isLastContent true if the cotent being documented is the last content.
|
||||
* @return a content tree for the header
|
||||
*/
|
||||
public Content getFieldsContentHeader(boolean isLastContent) {
|
||||
HtmlTree li = new HtmlTree(HtmlTag.LI);
|
||||
if (isLastContent)
|
||||
li.addStyle(HtmlStyle.blockListLast);
|
||||
else
|
||||
li.addStyle(HtmlStyle.blockList);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add serializable fields.
|
||||
*
|
||||
* @param heading the heading for the section
|
||||
* @param serializableFieldsTree the tree to be added to the serializable fileds
|
||||
* content tree
|
||||
* @return a content tree for the serializable fields content
|
||||
*/
|
||||
public Content getSerializableFields(String heading, Content serializableFieldsTree) {
|
||||
HtmlTree li = new HtmlTree(HtmlTag.LI);
|
||||
li.addStyle(HtmlStyle.blockList);
|
||||
if (serializableFieldsTree.isValid()) {
|
||||
Content headingContent = new StringContent(heading);
|
||||
Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
|
||||
headingContent);
|
||||
li.addContent(serialHeading);
|
||||
li.addContent(serializableFieldsTree);
|
||||
}
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the member header.
|
||||
*
|
||||
* @param fieldType the class document to be listed
|
||||
* @param fieldTypeStr the string for the field type to be documented
|
||||
* @param fieldDimensions the dimensions of the field string to be added
|
||||
* @param fieldName name of the field to be added
|
||||
* @param contentTree the content tree to which the member header will be added
|
||||
*/
|
||||
public void addMemberHeader(TypeElement fieldType, String fieldTypeStr,
|
||||
String fieldDimensions, String fieldName, Content contentTree) {
|
||||
Content nameContent = new RawHtml(fieldName);
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, nameContent);
|
||||
contentTree.addContent(heading);
|
||||
Content pre = new HtmlTree(HtmlTag.PRE);
|
||||
if (fieldType == null) {
|
||||
pre.addContent(fieldTypeStr);
|
||||
} else {
|
||||
Content fieldContent = writer.getLink(new LinkInfoImpl(
|
||||
configuration, LinkInfoImpl.Kind.SERIAL_MEMBER, fieldType));
|
||||
pre.addContent(fieldContent);
|
||||
}
|
||||
pre.addContent(fieldDimensions + " ");
|
||||
pre.addContent(fieldName);
|
||||
contentTree.addContent(pre);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the deprecated information for this member.
|
||||
*
|
||||
* @param field the field to document.
|
||||
* @param contentTree the tree to which the deprecated info will be added
|
||||
*/
|
||||
public void addMemberDeprecatedInfo(VariableElement field, Content contentTree) {
|
||||
addDeprecatedInfo(field, contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the description text for this member.
|
||||
*
|
||||
* @param field the field to document.
|
||||
* @param contentTree the tree to which the deprecated info will be added
|
||||
*/
|
||||
public void addMemberDescription(VariableElement field, Content contentTree) {
|
||||
if (!utils.getBody(field).isEmpty()) {
|
||||
writer.addInlineComment(field, contentTree);
|
||||
}
|
||||
List<? extends DocTree> tags = utils.getBlockTags(field, DocTree.Kind.SERIAL);
|
||||
if (!tags.isEmpty()) {
|
||||
writer.addInlineComment(field, tags.get(0), contentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the description text for this member represented by the tag.
|
||||
*
|
||||
* @param serialFieldTag the field to document (represented by tag)
|
||||
* @param contentTree the tree to which the deprecated info will be added
|
||||
*/
|
||||
public void addMemberDescription(VariableElement field, DocTree serialFieldTag, Content contentTree) {
|
||||
CommentHelper ch = utils.getCommentHelper(field);
|
||||
List<? extends DocTree> description = ch.getDescription(configuration, serialFieldTag);
|
||||
if (!description.isEmpty()) {
|
||||
Content serialFieldContent = new RawHtml(ch.getText(description));
|
||||
Content div = HtmlTree.DIV(HtmlStyle.block, serialFieldContent);
|
||||
contentTree.addContent(div);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the tag information for this member.
|
||||
*
|
||||
* @param field the field to document.
|
||||
* @param contentTree the tree to which the member tags info will be added
|
||||
*/
|
||||
public void addMemberTags(VariableElement field, Content contentTree) {
|
||||
Content tagContent = new ContentBuilder();
|
||||
TagletWriter.genTagOutput(configuration.tagletManager, field,
|
||||
configuration.tagletManager.getCustomTaglets(field),
|
||||
writer.getTagletWriterInstance(false), tagContent);
|
||||
Content dlTags = new HtmlTree(HtmlTag.DL);
|
||||
dlTags.addContent(tagContent);
|
||||
contentTree.addContent(dlTags); // TODO: what if empty?
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if overview details should be printed. If
|
||||
* nocomment option set or if there is no text to be printed
|
||||
* for deprecation info, comment or tags, do not print overview details.
|
||||
*
|
||||
* @param field the field to check overview details for.
|
||||
* @return true if overview details need to be printed
|
||||
*/
|
||||
public boolean shouldPrintOverview(VariableElement field) {
|
||||
if (!configuration.nocomment) {
|
||||
if(!utils.getBody(field).isEmpty() ||
|
||||
writer.hasSerializationOverviewTags(field))
|
||||
return true;
|
||||
}
|
||||
if (utils.isDeprecated(field))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.taglets.TagletManager;
|
||||
import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
|
||||
|
||||
|
||||
/**
|
||||
* Generate serialized form for Serializable/Externalizable methods.
|
||||
* Documentation denoted by the <code>serialData</code> tag is processed.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Joe Fialli
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class HtmlSerialMethodWriter extends MethodWriterImpl implements
|
||||
SerializedFormWriter.SerialMethodWriter{
|
||||
|
||||
public HtmlSerialMethodWriter(SubWriterHolderWriter writer, TypeElement typeElement) {
|
||||
super(writer, typeElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the header for serializable methods section.
|
||||
*
|
||||
* @return a content tree for the header
|
||||
*/
|
||||
public Content getSerializableMethodsHeader() {
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
ul.addStyle(HtmlStyle.blockList);
|
||||
return ul;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the header for serializable methods content section.
|
||||
*
|
||||
* @param isLastContent true if the cotent being documented is the last content.
|
||||
* @return a content tree for the header
|
||||
*/
|
||||
public Content getMethodsContentHeader(boolean isLastContent) {
|
||||
HtmlTree li = new HtmlTree(HtmlTag.LI);
|
||||
if (isLastContent)
|
||||
li.addStyle(HtmlStyle.blockListLast);
|
||||
else
|
||||
li.addStyle(HtmlStyle.blockList);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add serializable methods.
|
||||
*
|
||||
* @param heading the heading for the section
|
||||
* @param serializableMethodContent the tree to be added to the serializable methods
|
||||
* content tree
|
||||
* @return a content tree for the serializable methods content
|
||||
*/
|
||||
public Content getSerializableMethods(String heading, Content serializableMethodContent) {
|
||||
Content headingContent = new StringContent(heading);
|
||||
Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
|
||||
headingContent);
|
||||
Content li = HtmlTree.LI(HtmlStyle.blockList, serialHeading);
|
||||
li.addContent(serializableMethodContent);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the no customization message.
|
||||
*
|
||||
* @param msg the message to be displayed
|
||||
* @return no customization message content
|
||||
*/
|
||||
public Content getNoCustomizationMsg(String msg) {
|
||||
Content noCustomizationMsg = new StringContent(msg);
|
||||
return noCustomizationMsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the member header.
|
||||
*
|
||||
* @param member the method document to be listed
|
||||
* @param methodsContentTree the content tree to which the member header will be added
|
||||
*/
|
||||
public void addMemberHeader(ExecutableElement member, Content methodsContentTree) {
|
||||
methodsContentTree.addContent(getHead(member));
|
||||
methodsContentTree.addContent(getSignature(member));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the deprecated information for this member.
|
||||
*
|
||||
* @param member the method to document.
|
||||
* @param methodsContentTree the tree to which the deprecated info will be added
|
||||
*/
|
||||
public void addDeprecatedMemberInfo(ExecutableElement member, Content methodsContentTree) {
|
||||
addDeprecatedInfo(member, methodsContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the description text for this member.
|
||||
*
|
||||
* @param member the method to document.
|
||||
* @param methodsContentTree the tree to which the deprecated info will be added
|
||||
*/
|
||||
public void addMemberDescription(ExecutableElement member, Content methodsContentTree) {
|
||||
addComment(member, methodsContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the tag information for this member.
|
||||
*
|
||||
* @param member the method to document.
|
||||
* @param methodsContentTree the tree to which the member tags info will be added
|
||||
*/
|
||||
public void addMemberTags(ExecutableElement member, Content methodsContentTree) {
|
||||
Content tagContent = new ContentBuilder();
|
||||
TagletManager tagletManager =
|
||||
configuration.tagletManager;
|
||||
TagletWriter.genTagOutput(tagletManager, member,
|
||||
tagletManager.getSerializedFormTaglets(),
|
||||
writer.getTagletWriterInstance(false), tagContent);
|
||||
Content dlTags = new HtmlTree(HtmlTag.DL);
|
||||
dlTags.addContent(tagContent);
|
||||
methodsContentTree.addContent(dlTags);
|
||||
if (name(member).compareTo("writeExternal") == 0
|
||||
&& utils.getSerialDataTrees(member).isEmpty()) {
|
||||
serialWarning(member, "doclet.MissingSerialDataTag",
|
||||
utils.getFullyQualifiedName(member.getEnclosingElement()), name(member));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.lang.model.element.AnnotationMirror;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Configuration;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.links.LinkFactory;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.links.LinkInfo;
|
||||
|
||||
import static jdk.javadoc.internal.doclets.formats.html.LinkInfoImpl.Kind.MEMBER_TYPE_PARAMS;
|
||||
|
||||
/**
|
||||
* A factory that returns a link given the information about it.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
*/
|
||||
public class LinkFactoryImpl extends LinkFactory {
|
||||
|
||||
private final HtmlDocletWriter m_writer;
|
||||
|
||||
public LinkFactoryImpl(HtmlDocletWriter writer) {
|
||||
m_writer = writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content newContent() {
|
||||
return new ContentBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content getClassLink(LinkInfo linkInfo) {
|
||||
Configuration configuration = m_writer.configuration;
|
||||
Utils utils = configuration.utils;
|
||||
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.
|
||||
String title = "";
|
||||
if (classLinkInfo.where == null || classLinkInfo.where.length() == 0) {
|
||||
boolean isTypeLink = classLinkInfo.type != null &&
|
||||
utils.isTypeVariable(utils.getComponentType(classLinkInfo.type));
|
||||
title = getClassToolTip(typeElement, isTypeLink);
|
||||
}
|
||||
Content label = classLinkInfo.getClassLinkLabel(m_writer.configuration);
|
||||
|
||||
Content link = new ContentBuilder();
|
||||
if (utils.isIncluded(typeElement)) {
|
||||
if (configuration.isGeneratedDoc(typeElement)) {
|
||||
DocPath filename = getPath(classLinkInfo);
|
||||
if (linkInfo.linkToSelf ||
|
||||
!(DocPath.forName(utils, typeElement)).equals(m_writer.filename)) {
|
||||
link.addContent(m_writer.getHyperLink(
|
||||
filename.fragment(classLinkInfo.where),
|
||||
label,
|
||||
classLinkInfo.isStrong, classLinkInfo.styleName,
|
||||
title, classLinkInfo.target));
|
||||
if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
|
||||
link.addContent(getTypeParameterLinks(linkInfo));
|
||||
}
|
||||
return link;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Content crossLink = m_writer.getCrossClassLink(
|
||||
typeElement.getQualifiedName().toString(), classLinkInfo.where,
|
||||
label, classLinkInfo.isStrong, classLinkInfo.styleName,
|
||||
true);
|
||||
if (crossLink != null) {
|
||||
link.addContent(crossLink);
|
||||
if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
|
||||
link.addContent(getTypeParameterLinks(linkInfo));
|
||||
}
|
||||
return link;
|
||||
}
|
||||
}
|
||||
// Can't link so just write label.
|
||||
link.addContent(label);
|
||||
if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
|
||||
link.addContent(getTypeParameterLinks(linkInfo));
|
||||
}
|
||||
return link;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content getTypeParameterLink(LinkInfo linkInfo, TypeMirror typeParam) {
|
||||
LinkInfoImpl typeLinkInfo = new LinkInfoImpl(m_writer.configuration,
|
||||
((LinkInfoImpl) linkInfo).getContext(), typeParam);
|
||||
typeLinkInfo.excludeTypeBounds = linkInfo.excludeTypeBounds;
|
||||
typeLinkInfo.excludeTypeParameterLinks = linkInfo.excludeTypeParameterLinks;
|
||||
typeLinkInfo.linkToSelf = linkInfo.linkToSelf;
|
||||
typeLinkInfo.isJava5DeclarationLocation = false;
|
||||
return getLink(typeLinkInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Content getTypeAnnotationLink(LinkInfo linkInfo, AnnotationMirror annotation) {
|
||||
throw new RuntimeException("Not implemented yet!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getTypeAnnotationLinks(LinkInfo linkInfo) {
|
||||
Utils utils = ((LinkInfoImpl)linkInfo).utils;
|
||||
ContentBuilder links = new ContentBuilder();
|
||||
List<? extends AnnotationMirror> annotations;
|
||||
if (utils.isAnnotated(linkInfo.type)) {
|
||||
annotations = linkInfo.type.getAnnotationMirrors();
|
||||
} else if (utils.isTypeVariable(linkInfo.type)) {
|
||||
// TODO: use the context for now, and special case for Receiver_Types,
|
||||
// which takes the default case.
|
||||
switch (((LinkInfoImpl)linkInfo).context) {
|
||||
case MEMBER_TYPE_PARAMS:
|
||||
case EXECUTABLE_MEMBER_PARAM:
|
||||
case CLASS_SIGNATURE:
|
||||
Element element = utils.typeUtils.asElement(linkInfo.type);
|
||||
annotations = element.getAnnotationMirrors();
|
||||
break;
|
||||
default:
|
||||
annotations = linkInfo.type.getAnnotationMirrors();
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
return links;
|
||||
}
|
||||
|
||||
if (annotations.isEmpty())
|
||||
return links;
|
||||
|
||||
List<Content> annos = m_writer.getAnnotations(0, annotations, false, linkInfo.isJava5DeclarationLocation);
|
||||
|
||||
boolean isFirst = true;
|
||||
for (Content anno : annos) {
|
||||
if (!isFirst) {
|
||||
links.addContent(" ");
|
||||
}
|
||||
links.addContent(anno);
|
||||
isFirst = false;
|
||||
}
|
||||
if (!annos.isEmpty()) {
|
||||
links.addContent(" ");
|
||||
}
|
||||
|
||||
return links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a class, return the appropriate tool tip.
|
||||
*
|
||||
* @param typeElement the class to get the tool tip for.
|
||||
* @return the tool tip for the appropriate class.
|
||||
*/
|
||||
private String getClassToolTip(TypeElement typeElement, boolean isTypeLink) {
|
||||
Configuration configuration = m_writer.configuration;
|
||||
Utils utils = configuration.utils;
|
||||
if (isTypeLink) {
|
||||
return configuration.getText("doclet.Href_Type_Param_Title",
|
||||
utils.getSimpleName(typeElement));
|
||||
} else if (utils.isInterface(typeElement)){
|
||||
return configuration.getText("doclet.Href_Interface_Title",
|
||||
utils.getPackageName(utils.containingPackage(typeElement)));
|
||||
} else if (utils.isAnnotationType(typeElement)) {
|
||||
return configuration.getText("doclet.Href_Annotation_Title",
|
||||
utils.getPackageName(utils.containingPackage(typeElement)));
|
||||
} else if (utils.isEnum(typeElement)) {
|
||||
return configuration.getText("doclet.Href_Enum_Title",
|
||||
utils.getPackageName(utils.containingPackage(typeElement)));
|
||||
} else {
|
||||
return configuration.getText("doclet.Href_Class_Title",
|
||||
utils.getPackageName(utils.containingPackage(typeElement)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return path to the given file name in the given package. So if the name
|
||||
* passed is "Object.html" and the name of the package is "java.lang", and
|
||||
* if the relative path is "../.." then returned string will be
|
||||
* "../../java/lang/Object.html"
|
||||
*
|
||||
* @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 DocPath.forName(linkInfo.utils, linkInfo.typeElement);
|
||||
}
|
||||
return m_writer.pathToRoot.resolve(DocPath.forClass(linkInfo.utils, linkInfo.typeElement));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,450 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.links.LinkInfo;
|
||||
|
||||
|
||||
/**
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public class LinkInfoImpl extends LinkInfo {
|
||||
|
||||
public enum Kind {
|
||||
DEFAULT,
|
||||
|
||||
/**
|
||||
* Indicate that the link appears in a class list.
|
||||
*/
|
||||
ALL_CLASSES_FRAME,
|
||||
|
||||
/**
|
||||
* Indicate that the link appears in a class documentation.
|
||||
*/
|
||||
CLASS,
|
||||
|
||||
/**
|
||||
* Indicate that the link appears in member documentation.
|
||||
*/
|
||||
MEMBER,
|
||||
|
||||
/**
|
||||
* Indicate that the link appears in class use documentation.
|
||||
*/
|
||||
CLASS_USE,
|
||||
|
||||
/**
|
||||
* Indicate that the link appears in index documentation.
|
||||
*/
|
||||
INDEX,
|
||||
|
||||
/**
|
||||
* Indicate that the link appears in constant value summary.
|
||||
*/
|
||||
CONSTANT_SUMMARY,
|
||||
|
||||
/**
|
||||
* Indicate that the link appears in serialized form documentation.
|
||||
*/
|
||||
SERIALIZED_FORM,
|
||||
|
||||
/**
|
||||
* Indicate that the link appears in serial member documentation.
|
||||
*/
|
||||
SERIAL_MEMBER,
|
||||
|
||||
/**
|
||||
* Indicate that the link appears in package documentation.
|
||||
*/
|
||||
PACKAGE,
|
||||
|
||||
/**
|
||||
* Indicate that the link appears in see tag documentation.
|
||||
*/
|
||||
SEE_TAG,
|
||||
|
||||
/**
|
||||
* Indicate that the link appears in value tag documentation.
|
||||
*/
|
||||
VALUE_TAG,
|
||||
|
||||
/**
|
||||
* Indicate that the link appears in tree documentation.
|
||||
*/
|
||||
TREE,
|
||||
|
||||
/**
|
||||
* Indicate that the link appears in a class list.
|
||||
*/
|
||||
PACKAGE_FRAME,
|
||||
|
||||
/**
|
||||
* The header in the class documentation.
|
||||
*/
|
||||
CLASS_HEADER,
|
||||
|
||||
/**
|
||||
* The signature in the class documentation.
|
||||
*/
|
||||
CLASS_SIGNATURE,
|
||||
|
||||
/**
|
||||
* The return type of a method.
|
||||
*/
|
||||
RETURN_TYPE,
|
||||
|
||||
/**
|
||||
* The return type of a method in a member summary.
|
||||
*/
|
||||
SUMMARY_RETURN_TYPE,
|
||||
|
||||
/**
|
||||
* The type of a method/constructor parameter.
|
||||
*/
|
||||
EXECUTABLE_MEMBER_PARAM,
|
||||
|
||||
/**
|
||||
* Super interface links.
|
||||
*/
|
||||
SUPER_INTERFACES,
|
||||
|
||||
/**
|
||||
* Implemented interface links.
|
||||
*/
|
||||
IMPLEMENTED_INTERFACES,
|
||||
|
||||
/**
|
||||
* Implemented class links.
|
||||
*/
|
||||
IMPLEMENTED_CLASSES,
|
||||
|
||||
/**
|
||||
* Subinterface links.
|
||||
*/
|
||||
SUBINTERFACES,
|
||||
|
||||
/**
|
||||
* Subclasses links.
|
||||
*/
|
||||
SUBCLASSES,
|
||||
|
||||
/**
|
||||
* The signature in the class documentation (implements/extends portion).
|
||||
*/
|
||||
CLASS_SIGNATURE_PARENT_NAME,
|
||||
|
||||
/**
|
||||
* The header for method documentation copied from parent.
|
||||
*/
|
||||
EXECUTABLE_ELEMENT_COPY,
|
||||
|
||||
/**
|
||||
* Method "specified by" link.
|
||||
*/
|
||||
METHOD_SPECIFIED_BY,
|
||||
|
||||
/**
|
||||
* Method "overrides" link.
|
||||
*/
|
||||
METHOD_OVERRIDES,
|
||||
|
||||
/**
|
||||
* Annotation link.
|
||||
*/
|
||||
ANNOTATION,
|
||||
|
||||
/**
|
||||
* The header for field documentation copied from parent.
|
||||
*/
|
||||
VARIABLE_ELEMENT_COPY,
|
||||
|
||||
/**
|
||||
* The parent nodes in the class tree.
|
||||
*/
|
||||
CLASS_TREE_PARENT,
|
||||
|
||||
/**
|
||||
* The type parameters of a method or constructor.
|
||||
*/
|
||||
MEMBER_TYPE_PARAMS,
|
||||
|
||||
/**
|
||||
* Indicate that the link appears in class use documentation.
|
||||
*/
|
||||
CLASS_USE_HEADER,
|
||||
|
||||
/**
|
||||
* The header for property documentation copied from parent.
|
||||
*/
|
||||
PROPERTY_COPY,
|
||||
|
||||
/**
|
||||
* A receiver type
|
||||
*/
|
||||
RECEIVER_TYPE
|
||||
}
|
||||
|
||||
public final ConfigurationImpl configuration;
|
||||
|
||||
/**
|
||||
* The location of the link.
|
||||
*/
|
||||
public Kind context = Kind.DEFAULT;
|
||||
|
||||
/**
|
||||
* The value of the marker #.
|
||||
*/
|
||||
public String where = "";
|
||||
|
||||
/**
|
||||
* String style of text defined in style sheet.
|
||||
*/
|
||||
public String styleName = "";
|
||||
|
||||
/**
|
||||
* The value of the target.
|
||||
*/
|
||||
public String target = "";
|
||||
public final Utils utils;
|
||||
/**
|
||||
* Construct a LinkInfo object.
|
||||
*
|
||||
* @param configuration the configuration data for the doclet
|
||||
* @param context the context of the link.
|
||||
* @param ee the member to link to.
|
||||
*/
|
||||
public LinkInfoImpl(ConfigurationImpl configuration, Kind context, ExecutableElement ee) {
|
||||
this.configuration = configuration;
|
||||
this.utils = configuration.utils;
|
||||
this.executableElement = ee;
|
||||
setContext(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content newContent() {
|
||||
return new ContentBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a LinkInfo object.
|
||||
*
|
||||
* @param configuration the configuration data for the doclet
|
||||
* @param context the context of the link.
|
||||
* @param typeElement the class to link to.
|
||||
*/
|
||||
public LinkInfoImpl(ConfigurationImpl configuration, Kind context, TypeElement typeElement) {
|
||||
this.configuration = configuration;
|
||||
this.utils = configuration.utils;
|
||||
this.typeElement = typeElement;
|
||||
setContext(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a LinkInfo object.
|
||||
*
|
||||
* @param configuration the configuration data for the doclet
|
||||
* @param context the context of the link.
|
||||
* @param type the class to link to.
|
||||
*/
|
||||
public LinkInfoImpl(ConfigurationImpl configuration, Kind context, TypeMirror type) {
|
||||
this.configuration = configuration;
|
||||
this.utils = configuration.utils;
|
||||
this.type = type;
|
||||
setContext(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the label for the link.
|
||||
* @param label plain-text label for the link
|
||||
*/
|
||||
public LinkInfoImpl label(String label) {
|
||||
this.label = new StringContent(label);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the label for the link.
|
||||
*/
|
||||
public LinkInfoImpl label(Content label) {
|
||||
this.label = label;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not the link should be strong.
|
||||
*/
|
||||
public LinkInfoImpl strong(boolean strong) {
|
||||
this.isStrong = strong;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the style to be used for the link.
|
||||
* @param styleName String style of text defined in style sheet.
|
||||
*/
|
||||
public LinkInfoImpl styleName(String styleName) {
|
||||
this.styleName = styleName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the target to be used for the link.
|
||||
* @param styleName String style of text defined in style sheet.
|
||||
*/
|
||||
public LinkInfoImpl target(String target) {
|
||||
this.target = target;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not this is a link to a varargs parameter.
|
||||
*/
|
||||
public LinkInfoImpl varargs(boolean varargs) {
|
||||
this.isVarArg = varargs;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fragment specifier for the link.
|
||||
*/
|
||||
public LinkInfoImpl where(String where) {
|
||||
this.where = where;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Kind getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* This method sets the link attributes to the appropriate values
|
||||
* based on the context.
|
||||
*
|
||||
* @param c the context id to set.
|
||||
*/
|
||||
public final void setContext(Kind c) {
|
||||
//NOTE: Put context specific link code here.
|
||||
switch (c) {
|
||||
case ALL_CLASSES_FRAME:
|
||||
case PACKAGE_FRAME:
|
||||
case IMPLEMENTED_CLASSES:
|
||||
case SUBCLASSES:
|
||||
case EXECUTABLE_ELEMENT_COPY:
|
||||
case VARIABLE_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:
|
||||
case CLASS_TREE_PARENT:
|
||||
case TREE:
|
||||
case CLASS_SIGNATURE_PARENT_NAME:
|
||||
excludeTypeParameterLinks = true;
|
||||
excludeTypeBounds = true;
|
||||
includeTypeInClassLinkLabel = false;
|
||||
includeTypeAsSepLink = true;
|
||||
break;
|
||||
|
||||
case PACKAGE:
|
||||
case CLASS_USE:
|
||||
case CLASS_HEADER:
|
||||
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:
|
||||
case SUMMARY_RETURN_TYPE:
|
||||
excludeTypeBounds = true;
|
||||
break;
|
||||
case EXECUTABLE_MEMBER_PARAM:
|
||||
excludeTypeBounds = true;
|
||||
break;
|
||||
}
|
||||
context = c;
|
||||
if (type != null &&
|
||||
utils.isTypeVariable(type) &&
|
||||
utils.isExecutableElement(utils.asTypeElement(type).getEnclosingElement())) {
|
||||
excludeTypeParameterLinks = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return 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
|
||||
* desired place.
|
||||
*/
|
||||
@Override
|
||||
public boolean isLinkable() {
|
||||
return configuration.utils.isLinkable(typeElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LinkInfoImpl{" +
|
||||
"context=" + context +
|
||||
", where=" + where +
|
||||
", styleName=" + styleName +
|
||||
", target=" + target +
|
||||
super.toString() + '}';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.links.LinkOutput;
|
||||
|
||||
/**
|
||||
* Stores output of a link.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
*/
|
||||
public class LinkOutputImpl implements LinkOutput {
|
||||
|
||||
/**
|
||||
* The output of the link.
|
||||
*/
|
||||
public StringBuilder output;
|
||||
|
||||
/**
|
||||
* Construct a new LinkOutputImpl.
|
||||
*/
|
||||
public LinkOutputImpl() {
|
||||
output = new StringBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void append(Object o) {
|
||||
output.append(o instanceof String ?
|
||||
(String) o : ((LinkOutputImpl)o).toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void insert(int offset, Object o) {
|
||||
output.insert(offset, o.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String toString() {
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,457 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.MethodWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.ImplementedMethods;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
|
||||
|
||||
/**
|
||||
* Writes method documentation in HTML format.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Robert Field
|
||||
* @author Atul M Dambalkar
|
||||
* @author Jamie Ho (rewrite)
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class MethodWriterImpl extends AbstractExecutableMemberWriter
|
||||
implements MethodWriter, MemberSummaryWriter {
|
||||
|
||||
/**
|
||||
* Construct a new MethodWriterImpl.
|
||||
*
|
||||
* @param writer the writer for the class that the methods belong to.
|
||||
* @param typeElement the class being documented.
|
||||
*/
|
||||
public MethodWriterImpl(SubWriterHolderWriter writer, TypeElement typeElement) {
|
||||
super(writer, typeElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new MethodWriterImpl.
|
||||
*
|
||||
* @param writer The writer for the class that the methods belong to.
|
||||
*/
|
||||
public MethodWriterImpl(SubWriterHolderWriter writer) {
|
||||
super(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) {
|
||||
memberSummaryTree.addContent(HtmlConstants.START_OF_METHOD_SUMMARY);
|
||||
Content memberTree = writer.getMemberTreeHeader();
|
||||
writer.addSummaryHeader(this, typeElement, memberTree);
|
||||
return memberTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addMemberTree(Content memberSummaryTree, Content memberTree) {
|
||||
writer.addMemberTree(memberSummaryTree, memberTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getMethodDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) {
|
||||
memberDetailsTree.addContent(HtmlConstants.START_OF_METHOD_DETAILS);
|
||||
Content methodDetailsTree = writer.getMemberTreeHeader();
|
||||
methodDetailsTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.METHOD_DETAIL));
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
|
||||
writer.methodDetailsLabel);
|
||||
methodDetailsTree.addContent(heading);
|
||||
return methodDetailsTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getMethodDocTreeHeader(ExecutableElement method, Content methodDetailsTree) {
|
||||
String erasureAnchor;
|
||||
if ((erasureAnchor = getErasureAnchor(method)) != null) {
|
||||
methodDetailsTree.addContent(writer.getMarkerAnchor((erasureAnchor)));
|
||||
}
|
||||
methodDetailsTree.addContent(
|
||||
writer.getMarkerAnchor(writer.getAnchor(method)));
|
||||
Content methodDocTree = writer.getMemberTreeHeader();
|
||||
Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
|
||||
heading.addContent(name(method));
|
||||
methodDocTree.addContent(heading);
|
||||
return methodDocTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the signature for the given method.
|
||||
*
|
||||
* @param method the method being documented.
|
||||
* @return a content object for the signature
|
||||
*/
|
||||
@Override
|
||||
public Content getSignature(ExecutableElement method) {
|
||||
Content pre = new HtmlTree(HtmlTag.PRE);
|
||||
writer.addAnnotationInfo(method, pre);
|
||||
int annotationLength = pre.charCount();
|
||||
addModifiers(method, pre);
|
||||
addTypeParameters(method, pre);
|
||||
addReturnType(method, pre);
|
||||
if (configuration.linksource) {
|
||||
Content methodName = new StringContent(name(method));
|
||||
writer.addSrcLink(method, methodName, pre);
|
||||
} else {
|
||||
addName(name(method), pre);
|
||||
}
|
||||
int indent = pre.charCount() - annotationLength;
|
||||
addParameters(method, pre, indent);
|
||||
addExceptions(method, pre, indent);
|
||||
return pre;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addDeprecated(ExecutableElement method, Content methodDocTree) {
|
||||
addDeprecatedInfo(method, methodDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addComments(TypeMirror holderType, ExecutableElement method, Content methodDocTree) {
|
||||
TypeElement holder = utils.asTypeElement(holderType);
|
||||
if (!utils.getBody(method).isEmpty()) {
|
||||
if (holder.equals(typeElement) ||
|
||||
!(utils.isPublic(holder) ||
|
||||
utils.isLinkable(holder))) {
|
||||
writer.addInlineComment(method, methodDocTree);
|
||||
} else {
|
||||
Content link =
|
||||
writer.getDocLink(LinkInfoImpl.Kind.EXECUTABLE_ELEMENT_COPY,
|
||||
holder, method,
|
||||
utils.isIncluded(holder)
|
||||
? utils.getSimpleName(holder)
|
||||
: utils.getFullyQualifiedName(holder),
|
||||
false);
|
||||
Content codelLink = HtmlTree.CODE(link);
|
||||
Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel,
|
||||
utils.isClass(holder)
|
||||
? writer.descfrmClassLabel
|
||||
: writer.descfrmInterfaceLabel);
|
||||
descfrmLabel.addContent(writer.getSpace());
|
||||
descfrmLabel.addContent(codelLink);
|
||||
methodDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel));
|
||||
writer.addInlineComment(method, methodDocTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addTags(ExecutableElement method, Content methodDocTree) {
|
||||
writer.addTagsInfo(method, methodDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getMethodDetails(Content methodDetailsTree) {
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(methodDetailsTree));
|
||||
return htmlTree;
|
||||
}
|
||||
return getMemberTree(methodDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getMethodDoc(Content methodDocTree,
|
||||
boolean isLastContent) {
|
||||
return getMemberTree(methodDocTree, isLastContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the writer.
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addSummaryLabel(Content memberTree) {
|
||||
Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
|
||||
writer.getResource("doclet.Method_Summary"));
|
||||
memberTree.addContent(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getTableSummary() {
|
||||
return configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Method_Summary"),
|
||||
configuration.getText("doclet.methods"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getCaption() {
|
||||
return configuration.getResource("doclet.Methods");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<String> getSummaryTableHeader(Element member) {
|
||||
List<String> header = Arrays.asList(writer.getModifierTypeHeader(),
|
||||
configuration.getText("doclet.0_and_1",
|
||||
configuration.getText("doclet.Method"),
|
||||
configuration.getText("doclet.Description")));
|
||||
return header;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
|
||||
memberTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.METHOD_SUMMARY));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) {
|
||||
inheritedTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.METHODS_INHERITANCE, configuration.getClassName(typeElement)));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) {
|
||||
Content classLink = writer.getPreQualifiedClassLink(
|
||||
LinkInfoImpl.Kind.MEMBER, typeElement, false);
|
||||
Content label = new StringContent(utils.isClass(typeElement)
|
||||
? configuration.getText("doclet.Methods_Inherited_From_Class")
|
||||
: configuration.getText("doclet.Methods_Inherited_From_Interface"));
|
||||
Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
|
||||
label);
|
||||
labelHeading.addContent(writer.getSpace());
|
||||
labelHeading.addContent(classLink);
|
||||
inheritedTree.addContent(labelHeading);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addSummaryType(Element member, Content tdSummaryType) {
|
||||
ExecutableElement meth = (ExecutableElement)member;
|
||||
addModifierAndType(meth, utils.getReturnType(meth), tdSummaryType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected static void addOverridden(HtmlDocletWriter writer,
|
||||
TypeMirror overriddenType, ExecutableElement method, Content dl) {
|
||||
if (writer.configuration.nocomment) {
|
||||
return;
|
||||
}
|
||||
Utils utils = writer.configuration().utils;
|
||||
TypeElement holder = utils.getEnclosingTypeElement(method);
|
||||
if (!(utils.isPublic(holder) ||
|
||||
utils.isLinkable(holder))) {
|
||||
//This is an implementation detail that should not be documented.
|
||||
return;
|
||||
}
|
||||
if (utils.isIncluded(holder) && ! utils.isIncluded(method)) {
|
||||
//The class is included but the method is not. That means that it
|
||||
//is not visible so don't document this.
|
||||
return;
|
||||
}
|
||||
Content label = writer.overridesLabel;
|
||||
LinkInfoImpl.Kind context = LinkInfoImpl.Kind.METHOD_OVERRIDES;
|
||||
|
||||
if (method != null) {
|
||||
if (utils.isAbstract(holder) && utils.isAbstract(method)){
|
||||
//Abstract method is implemented from abstract class,
|
||||
//not overridden
|
||||
label = writer.specifiedByLabel;
|
||||
context = LinkInfoImpl.Kind.METHOD_SPECIFIED_BY;
|
||||
}
|
||||
Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, label));
|
||||
dl.addContent(dt);
|
||||
Content overriddenTypeLink =
|
||||
writer.getLink(new LinkInfoImpl(writer.configuration, context, overriddenType));
|
||||
Content codeOverridenTypeLink = HtmlTree.CODE(overriddenTypeLink);
|
||||
String name = method.getSimpleName().toString();
|
||||
Content methlink = writer.getLink(
|
||||
new LinkInfoImpl(writer.configuration, LinkInfoImpl.Kind.MEMBER,
|
||||
holder)
|
||||
.where(writer.getName(writer.getAnchor(method))).label(name));
|
||||
Content codeMethLink = HtmlTree.CODE(methlink);
|
||||
Content dd = HtmlTree.DD(codeMethLink);
|
||||
dd.addContent(writer.getSpace());
|
||||
dd.addContent(writer.getResource("doclet.in_class"));
|
||||
dd.addContent(writer.getSpace());
|
||||
dd.addContent(codeOverridenTypeLink);
|
||||
dl.addContent(dd);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected static void addImplementsInfo(HtmlDocletWriter writer,
|
||||
ExecutableElement method, Content dl) {
|
||||
if (writer.configuration.nocomment) {
|
||||
return;
|
||||
}
|
||||
Utils utils = writer.utils;
|
||||
ImplementedMethods implementedMethodsFinder =
|
||||
new ImplementedMethods(method, writer.configuration);
|
||||
SortedSet<ExecutableElement> implementedMethods =
|
||||
new TreeSet<>(utils.makeOverrideUseComparator());
|
||||
implementedMethods.addAll(implementedMethodsFinder.build());
|
||||
for (ExecutableElement implementedMeth : implementedMethods) {
|
||||
TypeMirror intfac = implementedMethodsFinder.getMethodHolder(implementedMeth);
|
||||
intfac = utils.getDeclaredType(utils.getEnclosingTypeElement(method), intfac);
|
||||
Content intfaclink = writer.getLink(new LinkInfoImpl(
|
||||
writer.configuration, LinkInfoImpl.Kind.METHOD_SPECIFIED_BY, intfac));
|
||||
Content codeIntfacLink = HtmlTree.CODE(intfaclink);
|
||||
Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, writer.specifiedByLabel));
|
||||
dl.addContent(dt);
|
||||
Content methlink = writer.getDocLink(
|
||||
LinkInfoImpl.Kind.MEMBER, implementedMeth,
|
||||
implementedMeth.getSimpleName().toString(), false);
|
||||
Content codeMethLink = HtmlTree.CODE(methlink);
|
||||
Content dd = HtmlTree.DD(codeMethLink);
|
||||
dd.addContent(writer.getSpace());
|
||||
dd.addContent(writer.getResource("doclet.in_interface"));
|
||||
dd.addContent(writer.getSpace());
|
||||
dd.addContent(codeIntfacLink);
|
||||
dl.addContent(dd);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the return type.
|
||||
*
|
||||
* @param method the method being documented.
|
||||
* @param htmltree the content tree to which the return type will be added
|
||||
*/
|
||||
protected void addReturnType(ExecutableElement method, Content htmltree) {
|
||||
TypeMirror type = utils.getReturnType(method);
|
||||
if (type != null) {
|
||||
Content linkContent = writer.getLink(
|
||||
new LinkInfoImpl(configuration, LinkInfoImpl.Kind.RETURN_TYPE, type));
|
||||
htmltree.addContent(linkContent);
|
||||
htmltree.addContent(writer.getSpace());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
|
||||
if (link) {
|
||||
if (typeElement == null) {
|
||||
return writer.getHyperLink(
|
||||
SectionName.METHOD_SUMMARY,
|
||||
writer.getResource("doclet.navMethod"));
|
||||
} else {
|
||||
return writer.getHyperLink(
|
||||
SectionName.METHODS_INHERITANCE,
|
||||
configuration.getClassName(typeElement), writer.getResource("doclet.navMethod"));
|
||||
}
|
||||
} else {
|
||||
return writer.getResource("doclet.navMethod");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addNavDetailLink(boolean link, Content liNav) {
|
||||
if (link) {
|
||||
liNav.addContent(writer.getHyperLink(
|
||||
SectionName.METHOD_DETAIL, writer.getResource("doclet.navMethod")));
|
||||
} else {
|
||||
liNav.addContent(writer.getResource("doclet.navMethod"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,241 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
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.HtmlTree;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
|
||||
|
||||
/**
|
||||
* Writes nested class documentation in HTML format.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Robert Field
|
||||
* @author Atul M Dambalkar
|
||||
* @author Jamie Ho (rewrite)
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class NestedClassWriterImpl extends AbstractMemberWriter
|
||||
implements MemberSummaryWriter {
|
||||
|
||||
public NestedClassWriterImpl(SubWriterHolderWriter writer, TypeElement typeElement) {
|
||||
super(writer, typeElement);
|
||||
}
|
||||
|
||||
public NestedClassWriterImpl(SubWriterHolderWriter writer) {
|
||||
super(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getMemberSummaryHeader(TypeElement typeElement,
|
||||
Content memberSummaryTree) {
|
||||
memberSummaryTree.addContent(HtmlConstants.START_OF_NESTED_CLASS_SUMMARY);
|
||||
Content memberTree = writer.getMemberTreeHeader();
|
||||
writer.addSummaryHeader(this, typeElement, memberTree);
|
||||
return memberTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addMemberTree(Content memberSummaryTree, Content memberTree) {
|
||||
writer.addMemberTree(memberSummaryTree, memberTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the writer.
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addSummaryLabel(Content memberTree) {
|
||||
Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
|
||||
writer.getResource("doclet.Nested_Class_Summary"));
|
||||
memberTree.addContent(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getTableSummary() {
|
||||
return configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Nested_Class_Summary"),
|
||||
configuration.getText("doclet.nested_classes"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getCaption() {
|
||||
return configuration.getResource("doclet.Nested_Classes");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<String> getSummaryTableHeader(Element member) {
|
||||
if (utils.isInterface(member)) {
|
||||
return Arrays.asList(writer.getModifierTypeHeader(),
|
||||
configuration.getText("doclet.0_and_1",
|
||||
configuration.getText("doclet.Interface"),
|
||||
configuration.getText("doclet.Description")));
|
||||
|
||||
} else {
|
||||
return Arrays.asList(writer.getModifierTypeHeader(),
|
||||
configuration.getText("doclet.0_and_1",
|
||||
configuration.getText("doclet.Class"),
|
||||
configuration.getText("doclet.Description")));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
|
||||
memberTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.NESTED_CLASS_SUMMARY));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) {
|
||||
inheritedTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.NESTED_CLASSES_INHERITANCE,
|
||||
utils.getFullyQualifiedName(typeElement)));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) {
|
||||
Content classLink = writer.getPreQualifiedClassLink(
|
||||
LinkInfoImpl.Kind.MEMBER, typeElement, false);
|
||||
Content label = new StringContent(utils.isInterface(typeElement)
|
||||
? configuration.getText("doclet.Nested_Classes_Interface_Inherited_From_Interface")
|
||||
: configuration.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class"));
|
||||
Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
|
||||
label);
|
||||
labelHeading.addContent(writer.getSpace());
|
||||
labelHeading.addContent(classLink);
|
||||
inheritedTree.addContent(labelHeading);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element member,
|
||||
Content tdSummary) {
|
||||
Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink,
|
||||
writer.getLink(new LinkInfoImpl(configuration, context, (TypeElement)member)));
|
||||
Content code = HtmlTree.CODE(memberLink);
|
||||
tdSummary.addContent(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addInheritedSummaryLink(TypeElement typeElement, Element member, Content linksTree) {
|
||||
linksTree.addContent(
|
||||
writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER,
|
||||
(TypeElement)member)));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addSummaryType(Element member, Content tdSummaryType) {
|
||||
addModifierAndType(member, null, tdSummaryType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content getDeprecatedLink(Element member) {
|
||||
return writer.getQualifiedClassLink(LinkInfoImpl.Kind.MEMBER, member);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
|
||||
if (link) {
|
||||
if (typeElement == null) {
|
||||
return writer.getHyperLink(
|
||||
SectionName.NESTED_CLASS_SUMMARY,
|
||||
writer.getResource("doclet.navNested"));
|
||||
} else {
|
||||
return writer.getHyperLink(
|
||||
SectionName.NESTED_CLASSES_INHERITANCE,
|
||||
utils.getFullyQualifiedName(typeElement), writer.getResource("doclet.navNested"));
|
||||
}
|
||||
} else {
|
||||
return writer.getResource("doclet.navNested");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addNavDetailLink(boolean link, Content liNav) {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.lang.model.element.PackageElement;
|
||||
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.Configuration;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
|
||||
|
||||
/**
|
||||
* Class to generate file for each package contents in the left-hand bottom
|
||||
* frame. This will list all the Class Kinds in the package. A click on any
|
||||
* class-kind will update the right-hand frame with the clicked class-kind page.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class PackageFrameWriter extends HtmlDocletWriter {
|
||||
|
||||
/**
|
||||
* The package being documented.
|
||||
*/
|
||||
private PackageElement packageElement;
|
||||
|
||||
/**
|
||||
* The classes to be documented. Use this to filter out classes
|
||||
* that will not be documented.
|
||||
*/
|
||||
private SortedSet<TypeElement> documentedClasses;
|
||||
|
||||
/**
|
||||
* Constructor to construct PackageFrameWriter object and to generate
|
||||
* "package-frame.html" file in the respective package directory.
|
||||
* For example for package "java.lang" this will generate file
|
||||
* "package-frame.html" file in the "java/lang" directory. It will also
|
||||
* create "java/lang" directory in the current or the destination directory
|
||||
* if it doesn't exist.
|
||||
*
|
||||
* @param configuration the configuration of the doclet.
|
||||
* @param packageElement PackageElement under consideration.
|
||||
*/
|
||||
public PackageFrameWriter(ConfigurationImpl configuration, PackageElement packageElement)
|
||||
throws IOException {
|
||||
super(configuration, DocPath.forPackage(packageElement).resolve(DocPaths.PACKAGE_FRAME));
|
||||
this.packageElement = packageElement;
|
||||
if (utils.getSpecifiedPackages().isEmpty()) {
|
||||
documentedClasses = new TreeSet<>(utils.makeGeneralPurposeComparator());
|
||||
documentedClasses.addAll(configuration.root.getIncludedClasses());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a package summary page for the left-hand bottom frame. Construct
|
||||
* the PackageFrameWriter object and then uses it generate the file.
|
||||
*
|
||||
* @param configuration the current configuration of the doclet.
|
||||
* @param packageElement The package for which "pacakge-frame.html" is to be generated.
|
||||
*/
|
||||
public static void generate(ConfigurationImpl configuration, PackageElement packageElement) {
|
||||
PackageFrameWriter packgen;
|
||||
try {
|
||||
packgen = new PackageFrameWriter(configuration, packageElement);
|
||||
String pkgName = configuration.utils.getPackageName(packageElement);
|
||||
HtmlTree body = packgen.getBody(false, packgen.getWindowTitle(pkgName));
|
||||
Content pkgNameContent = new StringContent(pkgName);
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
|
||||
? HtmlTree.MAIN()
|
||||
: body;
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
|
||||
packgen.getTargetPackageLink(packageElement, "classFrame", pkgNameContent));
|
||||
htmlTree.addContent(heading);
|
||||
HtmlTree div = new HtmlTree(HtmlTag.DIV);
|
||||
div.addStyle(HtmlStyle.indexContainer);
|
||||
packgen.addClassListing(div);
|
||||
htmlTree.addContent(div);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
body.addContent(htmlTree);
|
||||
}
|
||||
packgen.printHtmlDocument(
|
||||
configuration.metakeywords.getMetaKeywords(packageElement), false, body);
|
||||
packgen.close();
|
||||
} catch (IOException exc) {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), DocPaths.PACKAGE_FRAME.getPath());
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add class listing for all the classes in this package. Divide class
|
||||
* listing as per the class kind and generate separate listing for
|
||||
* Classes, Interfaces, Exceptions and Errors.
|
||||
*
|
||||
* @param contentTree the content tree to which the listing will be added
|
||||
*/
|
||||
protected void addClassListing(HtmlTree contentTree) {
|
||||
Configuration config = configuration;
|
||||
if (utils.isIncluded(packageElement)) {
|
||||
addClassKindListing(utils.getInterfaces(packageElement),
|
||||
getResource("doclet.Interfaces"), contentTree);
|
||||
addClassKindListing(utils.getOrdinaryClasses(packageElement),
|
||||
getResource("doclet.Classes"), contentTree);
|
||||
addClassKindListing(utils.getEnums(packageElement),
|
||||
getResource("doclet.Enums"), contentTree);
|
||||
addClassKindListing(utils.getExceptions(packageElement),
|
||||
getResource("doclet.Exceptions"), contentTree);
|
||||
addClassKindListing(utils.getErrors(packageElement),
|
||||
getResource("doclet.Errors"), contentTree);
|
||||
addClassKindListing(utils.getAnnotationTypes(packageElement),
|
||||
getResource("doclet.AnnotationTypes"), contentTree);
|
||||
} else {
|
||||
addClassKindListing(config.typeElementCatalog.interfaces(packageElement),
|
||||
getResource("doclet.Interfaces"), contentTree);
|
||||
addClassKindListing(config.typeElementCatalog.ordinaryClasses(packageElement),
|
||||
getResource("doclet.Classes"), contentTree);
|
||||
addClassKindListing(config.typeElementCatalog.enums(packageElement),
|
||||
getResource("doclet.Enums"), contentTree);
|
||||
addClassKindListing(config.typeElementCatalog.exceptions(packageElement),
|
||||
getResource("doclet.Exceptions"), contentTree);
|
||||
addClassKindListing(config.typeElementCatalog.errors(packageElement),
|
||||
getResource("doclet.Errors"), contentTree);
|
||||
addClassKindListing(config.typeElementCatalog.annotationTypes(packageElement),
|
||||
getResource("doclet.AnnotationTypes"), contentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add specific class kind listing. Also add label to the listing.
|
||||
*
|
||||
* @param arr Array of specific class kinds, namely Class or Interface or Exception or Error
|
||||
* @param labelContent content tree of the label to be added
|
||||
* @param contentTree the content tree to which the class kind listing will be added
|
||||
*/
|
||||
protected void addClassKindListing(Iterable<TypeElement> list, Content labelContent,
|
||||
HtmlTree contentTree) {
|
||||
SortedSet<TypeElement> tset = utils.filterOutPrivateClasses(list, configuration.javafx);
|
||||
if(!tset.isEmpty()) {
|
||||
boolean printedHeader = false;
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.SECTION()
|
||||
: contentTree;
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
ul.setTitle(labelContent);
|
||||
for (TypeElement typeElement : tset) {
|
||||
if (documentedClasses != null && !documentedClasses.contains(typeElement)) {
|
||||
continue;
|
||||
}
|
||||
if (!utils.isCoreClass(typeElement) || !configuration.isGeneratedDoc(typeElement)) {
|
||||
continue;
|
||||
}
|
||||
if (!printedHeader) {
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
|
||||
true, labelContent);
|
||||
htmlTree.addContent(heading);
|
||||
printedHeader = true;
|
||||
}
|
||||
Content arr_i_name = new StringContent(utils.getSimpleName(typeElement));
|
||||
if (utils.isInterface(typeElement))
|
||||
arr_i_name = HtmlTree.SPAN(HtmlStyle.interfaceName, arr_i_name);
|
||||
Content link = getLink(new LinkInfoImpl(configuration,
|
||||
LinkInfoImpl.Kind.PACKAGE_FRAME, typeElement).label(arr_i_name).target("classFrame"));
|
||||
Content li = HtmlTree.LI(link);
|
||||
ul.addContent(li);
|
||||
}
|
||||
htmlTree.addContent(ul);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
contentTree.addContent(htmlTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.lang.model.element.PackageElement;
|
||||
|
||||
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.RawHtml;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
|
||||
|
||||
/**
|
||||
* Generate the package index for the left-hand frame in the generated output.
|
||||
* A click on the package name in this frame will update the page in the bottom
|
||||
* left hand frame with the listing of contents of the clicked package.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
*/
|
||||
public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
|
||||
|
||||
/**
|
||||
* Construct the PackageIndexFrameWriter object.
|
||||
*
|
||||
* @param filename Name of the package index file to be generated.
|
||||
*/
|
||||
public PackageIndexFrameWriter(ConfigurationImpl configuration,
|
||||
DocPath filename) throws IOException {
|
||||
super(configuration, filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the package index file named "overview-frame.html".
|
||||
* @throws DocletAbortException
|
||||
*/
|
||||
public static void generate(ConfigurationImpl configuration) {
|
||||
PackageIndexFrameWriter packgen;
|
||||
DocPath filename = DocPaths.OVERVIEW_FRAME;
|
||||
try {
|
||||
packgen = new PackageIndexFrameWriter(configuration, filename);
|
||||
packgen.buildPackageIndexFile("doclet.Window_Overview", false);
|
||||
packgen.close();
|
||||
} catch (IOException exc) {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected void addPackagesList(Collection<PackageElement> packages, String text,
|
||||
String tableSummary, Content body) {
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
|
||||
packagesLabel);
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
|
||||
? HtmlTree.MAIN(HtmlStyle.indexContainer, heading)
|
||||
: HtmlTree.DIV(HtmlStyle.indexContainer, heading);
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
ul.setTitle(packagesLabel);
|
||||
for (PackageElement aPackage : packages) {
|
||||
// Do not list the package if -nodeprecated option is set and the
|
||||
// package is marked as deprecated.
|
||||
if (aPackage != null &&
|
||||
(!(configuration.nodeprecated && utils.isDeprecated(aPackage)))) {
|
||||
ul.addContent(getPackage(aPackage));
|
||||
}
|
||||
}
|
||||
htmlTree.addContent(ul);
|
||||
body.addContent(htmlTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns each package name as a separate link.
|
||||
*
|
||||
* @param pe PackageElement
|
||||
* @return content for the package link
|
||||
*/
|
||||
protected Content getPackage(PackageElement pe) {
|
||||
Content packageLinkContent;
|
||||
Content packageLabel;
|
||||
if (pe.isUnnamed()) {
|
||||
packageLabel = new StringContent("<unnamed package>");
|
||||
packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME,
|
||||
packageLabel, "", "packageFrame");
|
||||
} else {
|
||||
packageLabel = getPackageLabel(pe.getQualifiedName().toString());
|
||||
packageLinkContent = getHyperLink(pathString(pe,
|
||||
DocPaths.PACKAGE_FRAME), packageLabel, "",
|
||||
"packageFrame");
|
||||
}
|
||||
Content li = HtmlTree.LI(packageLinkContent);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected void addNavigationBarHeader(Content body) {
|
||||
Content headerContent;
|
||||
if (configuration.packagesheader.length() > 0) {
|
||||
headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
|
||||
} else {
|
||||
headerContent = new RawHtml(replaceDocRootDir(configuration.header));
|
||||
}
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
|
||||
HtmlStyle.bar, headerContent);
|
||||
body.addContent(heading);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do nothing as there is no overview information in this page.
|
||||
*/
|
||||
protected void addOverviewHeader(Content body) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds "All Classes" link for the top of the left-hand frame page to the
|
||||
* documentation tree.
|
||||
*
|
||||
* @param ul the Content object to which the "All Classes" link should be added
|
||||
*/
|
||||
protected void addAllClassesLink(Content ul) {
|
||||
Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME,
|
||||
allclassesLabel, "", "packageFrame");
|
||||
Content li = HtmlTree.LI(linkContent);
|
||||
ul.addContent(li);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected void addNavigationBarFooter(Content body) {
|
||||
Content p = HtmlTree.P(getSpace());
|
||||
body.addContent(p);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,274 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.lang.model.element.PackageElement;
|
||||
|
||||
import jdk.javadoc.doclet.DocletEnvironment;
|
||||
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.RawHtml;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.Group;
|
||||
|
||||
/**
|
||||
* Generate the package index page "overview-summary.html" for the right-hand
|
||||
* frame. A click on the package name on this page will update the same frame
|
||||
* with the "package-summary.html" file for the clicked package.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class PackageIndexWriter extends AbstractPackageIndexWriter {
|
||||
|
||||
/**
|
||||
* Root of the program structure. Used for "overview" documentation.
|
||||
*/
|
||||
private DocletEnvironment root;
|
||||
|
||||
/**
|
||||
* Map representing the group of packages as specified on the command line.
|
||||
*
|
||||
* @see Group
|
||||
*/
|
||||
private Map<String, SortedSet<PackageElement>> groupPackageMap;
|
||||
|
||||
/**
|
||||
* List to store the order groups as specified on the command line.
|
||||
*/
|
||||
private List<String> groupList;
|
||||
|
||||
/**
|
||||
* HTML tree for main tag.
|
||||
*/
|
||||
private HtmlTree htmlTree = HtmlTree.MAIN();
|
||||
|
||||
/**
|
||||
* Construct the PackageIndexWriter. Also constructs the grouping
|
||||
* information as provided on the command line by "-group" option. Stores
|
||||
* the order of groups specified by the user.
|
||||
*
|
||||
* @see Group
|
||||
*/
|
||||
public PackageIndexWriter(ConfigurationImpl configuration, DocPath filename) throws IOException {
|
||||
super(configuration, filename);
|
||||
this.root = configuration.root;
|
||||
groupPackageMap = configuration.group.groupPackages(packages);
|
||||
groupList = configuration.group.getGroupList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the package index page for the right-hand frame.
|
||||
*
|
||||
* @param configuration the current configuration of the doclet.
|
||||
*/
|
||||
public static void generate(ConfigurationImpl configuration) {
|
||||
PackageIndexWriter packgen;
|
||||
DocPath filename = DocPaths.OVERVIEW_SUMMARY;
|
||||
try {
|
||||
packgen = new PackageIndexWriter(configuration, filename);
|
||||
packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true);
|
||||
packgen.close();
|
||||
} catch (IOException exc) {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Depending upon the grouping information and their titles, add
|
||||
* separate table indices for each package group.
|
||||
*
|
||||
* @param body the documentation tree to which the index will be added
|
||||
*/
|
||||
protected void addIndex(Content body) {
|
||||
for (String groupname : groupList) {
|
||||
SortedSet<PackageElement> list = groupPackageMap.get(groupname);
|
||||
if (list != null && !list.isEmpty()) {
|
||||
addIndexContents(list,
|
||||
groupname, configuration.getText("doclet.Member_Table_Summary",
|
||||
groupname, configuration.getText("doclet.packages")), body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected void addPackagesList(Collection<PackageElement> packages, String text,
|
||||
String tableSummary, Content body) {
|
||||
Content table = (configuration.isOutputHtml5())
|
||||
? HtmlTree.TABLE(HtmlStyle.overviewSummary, getTableCaption(new RawHtml(text)))
|
||||
: HtmlTree.TABLE(HtmlStyle.overviewSummary, tableSummary, getTableCaption(new RawHtml(text)));
|
||||
table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
|
||||
Content tbody = new HtmlTree(HtmlTag.TBODY);
|
||||
addPackagesList(packages, tbody);
|
||||
table.addContent(tbody);
|
||||
Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
htmlTree.addContent(div);
|
||||
} else {
|
||||
body.addContent(div);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds list of packages in the index table. Generate link to each package.
|
||||
*
|
||||
* @param packages Packages to which link is to be generated
|
||||
* @param tbody the documentation tree to which the list will be added
|
||||
*/
|
||||
protected void addPackagesList(Collection<PackageElement> packages, Content tbody) {
|
||||
boolean altColor = true;
|
||||
for (PackageElement pkg : packages) {
|
||||
if (!pkg.isUnnamed()) {
|
||||
if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) {
|
||||
Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg));
|
||||
Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent);
|
||||
HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
|
||||
tdSummary.addStyle(HtmlStyle.colLast);
|
||||
addSummaryComment(pkg, tdSummary);
|
||||
HtmlTree tr = HtmlTree.TR(tdPackage);
|
||||
tr.addContent(tdSummary);
|
||||
tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
|
||||
tbody.addContent(tr);
|
||||
}
|
||||
}
|
||||
altColor = !altColor;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the overview summary comment for this documentation. Add one line
|
||||
* summary at the top of the page and generate a link to the description,
|
||||
* which is added at the end of this page.
|
||||
*
|
||||
* @param body the documentation tree to which the overview header will be added
|
||||
*/
|
||||
protected void addOverviewHeader(Content body) {
|
||||
addConfigurationTitle(body);
|
||||
if (!utils.getBody(configuration.overviewElement).isEmpty()) {
|
||||
HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
|
||||
subTitleDiv.addStyle(HtmlStyle.subTitle);
|
||||
addSummaryComment(configuration.overviewElement, subTitleDiv);
|
||||
Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv);
|
||||
Content see = seeLabel;
|
||||
see.addContent(" ");
|
||||
Content descPara = HtmlTree.P(see);
|
||||
Content descLink = getHyperLink(getDocLink(
|
||||
SectionName.OVERVIEW_DESCRIPTION),
|
||||
descriptionLabel, "", "");
|
||||
descPara.addContent(descLink);
|
||||
div.addContent(descPara);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
htmlTree.addContent(div);
|
||||
} else {
|
||||
body.addContent(div);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the overview comment as provided in the file specified by the
|
||||
* "-overview" option on the command line.
|
||||
*
|
||||
* @param htmltree the documentation tree to which the overview comment will
|
||||
* be added
|
||||
*/
|
||||
protected void addOverviewComment(Content htmltree) {
|
||||
if (!utils.getBody(configuration.overviewElement).isEmpty()) {
|
||||
htmltree.addContent(getMarkerAnchor(SectionName.OVERVIEW_DESCRIPTION));
|
||||
addInlineComment(configuration.overviewElement, htmltree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the tag information as provided in the file specified by the
|
||||
* "-overview" option on the command line.
|
||||
*
|
||||
* @param body the documentation tree to which the overview will be added
|
||||
*/
|
||||
protected void addOverview(Content body) throws IOException {
|
||||
HtmlTree div = new HtmlTree(HtmlTag.DIV);
|
||||
div.addStyle(HtmlStyle.contentContainer);
|
||||
addOverviewComment(div);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
htmlTree.addContent(div);
|
||||
body.addContent(htmlTree);
|
||||
} else {
|
||||
body.addContent(div);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the top text (from the -top option), the upper
|
||||
* navigation bar, and then the title (from the"-title"
|
||||
* option), at the top of page.
|
||||
*
|
||||
* @param body the documentation tree to which the navigation bar header will be added
|
||||
*/
|
||||
protected void addNavigationBarHeader(Content body) {
|
||||
Content htmlTree = (configuration.allowTag(HtmlTag.HEADER))
|
||||
? HtmlTree.HEADER()
|
||||
: body;
|
||||
addTop(htmlTree);
|
||||
addNavLinks(true, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.HEADER)) {
|
||||
body.addContent(htmlTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the lower navigation bar and the bottom text
|
||||
* (from the -bottom option) at the bottom of page.
|
||||
*
|
||||
* @param body the documentation tree to which the navigation bar footer will be added
|
||||
*/
|
||||
protected void addNavigationBarFooter(Content body) {
|
||||
Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
|
||||
? HtmlTree.FOOTER()
|
||||
: body;
|
||||
addNavLinks(false, htmlTree);
|
||||
addBottom(htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
body.addContent(htmlTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import javax.lang.model.element.PackageElement;
|
||||
|
||||
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.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
|
||||
|
||||
/**
|
||||
* Class to generate Tree page for a package. The name of the file generated is
|
||||
* "package-tree.html" and it is generated in the respective package directory.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class PackageTreeWriter extends AbstractTreeWriter {
|
||||
|
||||
/**
|
||||
* Package for which tree is to be generated.
|
||||
*/
|
||||
protected PackageElement packageElement;
|
||||
|
||||
/**
|
||||
* The previous package name in the alpha-order list.
|
||||
*/
|
||||
protected PackageElement prev;
|
||||
|
||||
/**
|
||||
* The next package name in the alpha-order list.
|
||||
*/
|
||||
protected PackageElement next;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param configuration the configuration
|
||||
* @param path the docpath to generate files into
|
||||
* @param packageElement the current package
|
||||
* @param prev the previous package
|
||||
* @param next the next package
|
||||
* @throws IOException
|
||||
* @throws DocletAbortException
|
||||
*/
|
||||
public PackageTreeWriter(ConfigurationImpl configuration,
|
||||
DocPath path,
|
||||
PackageElement packageElement,
|
||||
PackageElement prev, PackageElement next)
|
||||
throws IOException {
|
||||
super(configuration, path,
|
||||
new ClassTree(configuration.typeElementCatalog.allClasses(packageElement), configuration));
|
||||
this.packageElement = packageElement;
|
||||
this.prev = prev;
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a PackageTreeWriter object and then use it to generate the
|
||||
* package tree page.
|
||||
*
|
||||
* @param configuration the configuration for this run.
|
||||
* @param pkg Package for which tree file is to be generated.
|
||||
* @param prev Previous package in the alpha-ordered list.
|
||||
* @param next Next package in the alpha-ordered list.
|
||||
* @param noDeprecated If true, do not generate any information for
|
||||
* deprecated classe or interfaces.
|
||||
* @throws DocletAbortException
|
||||
*/
|
||||
public static void generate(ConfigurationImpl configuration,
|
||||
PackageElement pkg, PackageElement prev,
|
||||
PackageElement next, boolean noDeprecated) {
|
||||
PackageTreeWriter packgen;
|
||||
DocPath path = DocPath.forPackage(pkg).resolve(DocPaths.PACKAGE_TREE);
|
||||
try {
|
||||
packgen = new PackageTreeWriter(configuration, path, pkg,
|
||||
prev, next);
|
||||
packgen.generatePackageTreeFile();
|
||||
packgen.close();
|
||||
} catch (IOException exc) {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), path.getPath());
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a separate tree file for each package.
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
protected void generatePackageTreeFile() throws IOException {
|
||||
HtmlTree body = getPackageTreeHeader();
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
|
||||
? HtmlTree.MAIN()
|
||||
: body;
|
||||
Content headContent = getResource("doclet.Hierarchy_For_Package",
|
||||
utils.getPackageName(packageElement));
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
|
||||
HtmlStyle.title, headContent);
|
||||
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
|
||||
if (configuration.packages.size() > 1) {
|
||||
addLinkToMainTree(div);
|
||||
}
|
||||
htmlTree.addContent(div);
|
||||
HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
|
||||
divTree.addStyle(HtmlStyle.contentContainer);
|
||||
addTree(classtree.baseClasses(), "doclet.Class_Hierarchy", divTree);
|
||||
addTree(classtree.baseInterfaces(), "doclet.Interface_Hierarchy", divTree);
|
||||
addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree);
|
||||
addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree, true);
|
||||
htmlTree.addContent(divTree);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
body.addContent(htmlTree);
|
||||
}
|
||||
HtmlTree tree = (configuration.allowTag(HtmlTag.FOOTER))
|
||||
? HtmlTree.FOOTER()
|
||||
: body;
|
||||
addNavLinks(false, tree);
|
||||
addBottom(tree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
body.addContent(tree);
|
||||
}
|
||||
printHtmlDocument(null, true, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the package tree header.
|
||||
*
|
||||
* @return a content tree for the header
|
||||
*/
|
||||
protected HtmlTree getPackageTreeHeader() {
|
||||
String packageName = packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement);
|
||||
String title = packageName + " " + configuration.getText("doclet.Window_Class_Hierarchy");
|
||||
HtmlTree bodyTree = getBody(true, getWindowTitle(title));
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
|
||||
? HtmlTree.HEADER()
|
||||
: bodyTree;
|
||||
addTop(htmlTree);
|
||||
addNavLinks(true, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.HEADER)) {
|
||||
bodyTree.addContent(htmlTree);
|
||||
}
|
||||
return bodyTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a link to the tree for all the packages.
|
||||
*
|
||||
* @param div the content tree to which the link will be added
|
||||
*/
|
||||
protected void addLinkToMainTree(Content div) {
|
||||
Content span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel,
|
||||
getResource("doclet.Package_Hierarchies"));
|
||||
div.addContent(span);
|
||||
HtmlTree ul = new HtmlTree (HtmlTag.UL);
|
||||
ul.addStyle(HtmlStyle.horizontal);
|
||||
ul.addContent(getNavLinkMainTree(configuration.getText("doclet.All_Packages")));
|
||||
div.addContent(ul);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link for the previous package tree file.
|
||||
*
|
||||
* @return a content tree for the link
|
||||
*/
|
||||
protected Content getNavLinkPrevious() {
|
||||
if (prev == null) {
|
||||
return getNavLinkPrevious(null);
|
||||
} else {
|
||||
DocPath path = DocPath.relativePath(packageElement, prev);
|
||||
return getNavLinkPrevious(path.resolve(DocPaths.PACKAGE_TREE));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link for the next package tree file.
|
||||
*
|
||||
* @return a content tree for the link
|
||||
*/
|
||||
protected Content getNavLinkNext() {
|
||||
if (next == null) {
|
||||
return getNavLinkNext(null);
|
||||
} else {
|
||||
DocPath path = DocPath.relativePath(packageElement, next);
|
||||
return getNavLinkNext(path.resolve(DocPaths.PACKAGE_TREE));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link to the package summary page for the package of this tree.
|
||||
*
|
||||
* @return a content tree for the package link
|
||||
*/
|
||||
protected Content getNavLinkPackage() {
|
||||
Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
|
||||
packageLabel);
|
||||
Content li = HtmlTree.LI(linkContent);
|
||||
return li;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,339 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.lang.model.element.PackageElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
|
||||
/**
|
||||
* Generate package usage information.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Robert G. Field
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class PackageUseWriter extends SubWriterHolderWriter {
|
||||
|
||||
final PackageElement packageElement;
|
||||
final SortedMap<String, Set<TypeElement>> usingPackageToUsedClasses = new TreeMap<>();
|
||||
protected HtmlTree mainTree = HtmlTree.MAIN();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param filename the file to be generated.
|
||||
* @throws IOException
|
||||
* @throws DocletAbortException
|
||||
*/
|
||||
public PackageUseWriter(ConfigurationImpl configuration,
|
||||
ClassUseMapper mapper, DocPath filename,
|
||||
PackageElement pkgElement) throws IOException {
|
||||
super(configuration, DocPath.forPackage(pkgElement).resolve(filename));
|
||||
this.packageElement = pkgElement;
|
||||
|
||||
// by examining all classes in this package, find what packages
|
||||
// use these classes - produce a map between using package and
|
||||
// used classes.
|
||||
for (TypeElement usedClass : utils.getEnclosedTypeElements(pkgElement)) {
|
||||
Set<TypeElement> usingClasses = mapper.classToClass.get(usedClass);
|
||||
if (usingClasses != null) {
|
||||
for (TypeElement usingClass : usingClasses) {
|
||||
PackageElement usingPackage = utils.containingPackage(usingClass);
|
||||
Set<TypeElement> usedClasses = usingPackageToUsedClasses
|
||||
.get(utils.getPackageName(usingPackage));
|
||||
if (usedClasses == null) {
|
||||
usedClasses = new TreeSet<>(utils.makeGeneralPurposeComparator());
|
||||
usingPackageToUsedClasses.put(utils.getPackageName(usingPackage),
|
||||
usedClasses);
|
||||
}
|
||||
usedClasses.add(usedClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a class page.
|
||||
*
|
||||
* @param configuration the current configuration of the doclet.
|
||||
* @param mapper the mapping of the class usage.
|
||||
* @param pkgElement the package being documented.
|
||||
*/
|
||||
public static void generate(ConfigurationImpl configuration,
|
||||
ClassUseMapper mapper, PackageElement pkgElement) {
|
||||
PackageUseWriter pkgusegen;
|
||||
DocPath filename = DocPaths.PACKAGE_USE;
|
||||
try {
|
||||
pkgusegen = new PackageUseWriter(configuration, mapper, filename, pkgElement);
|
||||
pkgusegen.generatePackageUseFile();
|
||||
pkgusegen.close();
|
||||
} catch (IOException exc) {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the package use list.
|
||||
*/
|
||||
protected void generatePackageUseFile() throws IOException {
|
||||
HtmlTree body = getPackageUseHeader();
|
||||
HtmlTree div = new HtmlTree(HtmlTag.DIV);
|
||||
div.addStyle(HtmlStyle.contentContainer);
|
||||
if (usingPackageToUsedClasses.isEmpty()) {
|
||||
div.addContent(getResource("doclet.ClassUse_No.usage.of.0", utils.getPackageName(packageElement)));
|
||||
} else {
|
||||
addPackageUse(div);
|
||||
}
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
mainTree.addContent(div);
|
||||
body.addContent(mainTree);
|
||||
} else {
|
||||
body.addContent(div);
|
||||
}
|
||||
HtmlTree tree = (configuration.allowTag(HtmlTag.FOOTER))
|
||||
? HtmlTree.FOOTER()
|
||||
: body;
|
||||
addNavLinks(false, tree);
|
||||
addBottom(tree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
body.addContent(tree);
|
||||
}
|
||||
printHtmlDocument(null, true, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the package use information.
|
||||
*
|
||||
* @param contentTree the content tree to which the package use information will be added
|
||||
*/
|
||||
protected void addPackageUse(Content contentTree) throws IOException {
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
ul.addStyle(HtmlStyle.blockList);
|
||||
if (configuration.packages.size() > 1) {
|
||||
addPackageList(ul);
|
||||
}
|
||||
addClassList(ul);
|
||||
contentTree.addContent(ul);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the list of packages that use the given package.
|
||||
*
|
||||
* @param contentTree the content tree to which the package list will be added
|
||||
*/
|
||||
protected void addPackageList(Content contentTree) throws IOException {
|
||||
Content caption = getTableCaption(configuration.getResource(
|
||||
"doclet.ClassUse_Packages.that.use.0",
|
||||
getPackageLink(packageElement, utils.getPackageName(packageElement))));
|
||||
Content table = (configuration.isOutputHtml5())
|
||||
? HtmlTree.TABLE(HtmlStyle.useSummary, caption)
|
||||
: HtmlTree.TABLE(HtmlStyle.useSummary, useTableSummary, caption);
|
||||
table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
|
||||
Content tbody = new HtmlTree(HtmlTag.TBODY);
|
||||
boolean altColor = true;
|
||||
for (String pkgname: usingPackageToUsedClasses.keySet()) {
|
||||
PackageElement pkg = utils.elementUtils.getPackageElement(pkgname);
|
||||
HtmlTree tr = new HtmlTree(HtmlTag.TR);
|
||||
tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
|
||||
altColor = !altColor;
|
||||
addPackageUse(pkg, tr);
|
||||
tbody.addContent(tr);
|
||||
}
|
||||
table.addContent(tbody);
|
||||
Content li = HtmlTree.LI(HtmlStyle.blockList, table);
|
||||
contentTree.addContent(li);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the list of classes that use the given package.
|
||||
*
|
||||
* @param contentTree the content tree to which the class list will be added
|
||||
*/
|
||||
protected void addClassList(Content contentTree) throws IOException {
|
||||
List<String> classTableHeader = Arrays.asList(
|
||||
configuration.getText("doclet.0_and_1",
|
||||
configuration.getText("doclet.Class"),
|
||||
configuration.getText("doclet.Description")));
|
||||
for (String packageName : usingPackageToUsedClasses.keySet()) {
|
||||
PackageElement usingPackage = utils.elementUtils.getPackageElement(packageName);
|
||||
HtmlTree li = new HtmlTree(HtmlTag.LI);
|
||||
li.addStyle(HtmlStyle.blockList);
|
||||
if (usingPackage != null) {
|
||||
li.addContent(getMarkerAnchor(utils.getPackageName(usingPackage)));
|
||||
}
|
||||
String tableSummary = configuration.getText("doclet.Use_Table_Summary",
|
||||
configuration.getText("doclet.classes"));
|
||||
Content caption = getTableCaption(configuration.getResource(
|
||||
"doclet.ClassUse_Classes.in.0.used.by.1",
|
||||
getPackageLink(packageElement, utils.getPackageName(packageElement)),
|
||||
getPackageLink(usingPackage, utils.getPackageName(usingPackage))));
|
||||
Content table = (configuration.isOutputHtml5())
|
||||
? HtmlTree.TABLE(HtmlStyle.useSummary, caption)
|
||||
: HtmlTree.TABLE(HtmlStyle.useSummary, tableSummary, caption);
|
||||
table.addContent(getSummaryTableHeader(classTableHeader, "col"));
|
||||
Content tbody = new HtmlTree(HtmlTag.TBODY);
|
||||
boolean altColor = true;
|
||||
for (TypeElement te : usingPackageToUsedClasses.get(packageName)) {
|
||||
HtmlTree tr = new HtmlTree(HtmlTag.TR);
|
||||
tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
|
||||
altColor = !altColor;
|
||||
addClassRow(te, usingPackage, tr);
|
||||
tbody.addContent(tr);
|
||||
}
|
||||
table.addContent(tbody);
|
||||
li.addContent(table);
|
||||
contentTree.addContent(li);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a row for the class that uses the given package.
|
||||
*
|
||||
* @param usedClass the class that uses the given package
|
||||
* @param pkg the package to which the class belongs
|
||||
* @param contentTree the content tree to which the row will be added
|
||||
*/
|
||||
protected void addClassRow(TypeElement usedClass, PackageElement pkg,
|
||||
Content contentTree) {
|
||||
DocPath dp = pathString(usedClass,
|
||||
DocPaths.CLASS_USE.resolve(DocPath.forName(utils, usedClass)));
|
||||
StringContent stringContent = new StringContent(utils.getSimpleName(usedClass));
|
||||
Content td = HtmlTree.TD(HtmlStyle.colOne,
|
||||
getHyperLink(dp.fragment(getPackageAnchorName(pkg)), stringContent));
|
||||
addIndexComment(usedClass, td);
|
||||
contentTree.addContent(td);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the package use information.
|
||||
*
|
||||
* @param pkg the package that used the given package
|
||||
* @param contentTree the content tree to which the information will be added
|
||||
*/
|
||||
protected void addPackageUse(PackageElement pkg, Content contentTree) throws IOException {
|
||||
Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
|
||||
getHyperLink(utils.getPackageName(pkg),
|
||||
new StringContent(utils.getPackageName(pkg))));
|
||||
contentTree.addContent(tdFirst);
|
||||
HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
|
||||
tdLast.addStyle(HtmlStyle.colLast);
|
||||
if (pkg != null && !pkg.isUnnamed()) {
|
||||
addSummaryComment(pkg, tdLast);
|
||||
} else {
|
||||
tdLast.addContent(getSpace());
|
||||
}
|
||||
contentTree.addContent(tdLast);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the header for the package use listing.
|
||||
*
|
||||
* @return a content tree representing the package use header
|
||||
*/
|
||||
protected HtmlTree getPackageUseHeader() {
|
||||
String packageText = configuration.getText("doclet.Package");
|
||||
String name = packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement);
|
||||
String title = configuration.getText("doclet.Window_ClassUse_Header", packageText, name);
|
||||
HtmlTree bodyTree = getBody(true, getWindowTitle(title));
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
|
||||
? HtmlTree.HEADER()
|
||||
: bodyTree;
|
||||
addTop(htmlTree);
|
||||
addNavLinks(true, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.HEADER)) {
|
||||
bodyTree.addContent(htmlTree);
|
||||
}
|
||||
ContentBuilder headContent = new ContentBuilder();
|
||||
headContent.addContent(getResource("doclet.ClassUse_Title", packageText));
|
||||
headContent.addContent(new HtmlTree(HtmlTag.BR));
|
||||
headContent.addContent(name);
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
|
||||
HtmlStyle.title, headContent);
|
||||
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
mainTree.addContent(div);
|
||||
} else {
|
||||
bodyTree.addContent(div);
|
||||
}
|
||||
return bodyTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this package link.
|
||||
*
|
||||
* @return a content tree for the package link
|
||||
*/
|
||||
protected Content getNavLinkPackage() {
|
||||
Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
|
||||
packageLabel);
|
||||
Content li = HtmlTree.LI(linkContent);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the use link.
|
||||
*
|
||||
* @return a content tree for the use link
|
||||
*/
|
||||
protected Content getNavLinkClassUse() {
|
||||
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, useLabel);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tree link.
|
||||
*
|
||||
* @return a content tree for the tree link
|
||||
*/
|
||||
protected Content getNavLinkTree() {
|
||||
Content linkContent = getHyperLink(DocPaths.PACKAGE_TREE,
|
||||
treeLabel);
|
||||
Content li = HtmlTree.LI(linkContent);
|
||||
return li;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,377 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.lang.model.element.PackageElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
import com.sun.source.doctree.DocTree;
|
||||
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.RawHtml;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
|
||||
/**
|
||||
* Class to generate file for each package contents in the right-hand
|
||||
* frame. This will list all the Class Kinds in the package. A click on any
|
||||
* class-kind will update the frame with the clicked class-kind page.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class PackageWriterImpl extends HtmlDocletWriter
|
||||
implements PackageSummaryWriter {
|
||||
|
||||
/**
|
||||
* The prev package name in the alpha-order list.
|
||||
*/
|
||||
protected PackageElement prev;
|
||||
|
||||
/**
|
||||
* The next package name in the alpha-order list.
|
||||
*/
|
||||
protected PackageElement next;
|
||||
|
||||
/**
|
||||
* The package being documented.
|
||||
*/
|
||||
protected PackageElement packageElement;
|
||||
|
||||
/**
|
||||
* The HTML tree for main tag.
|
||||
*/
|
||||
protected HtmlTree mainTree = HtmlTree.MAIN();
|
||||
|
||||
/**
|
||||
* The HTML tree for section tag.
|
||||
*/
|
||||
protected HtmlTree sectionTree = HtmlTree.SECTION();
|
||||
|
||||
/**
|
||||
* Constructor to construct PackageWriter object and to generate
|
||||
* "package-summary.html" file in the respective package directory.
|
||||
* For example for package "java.lang" this will generate file
|
||||
* "package-summary.html" file in the "java/lang" directory. It will also
|
||||
* create "java/lang" directory in the current or the destination directory
|
||||
* if it doesn't exist.
|
||||
*
|
||||
* @param configuration the configuration of the doclet.
|
||||
* @param packageElement PackageElement under consideration.
|
||||
* @param prev Previous package in the sorted array.
|
||||
* @param next Next package in the sorted array.
|
||||
*/
|
||||
public PackageWriterImpl(ConfigurationImpl configuration,
|
||||
PackageElement packageElement, PackageElement prev, PackageElement next)
|
||||
throws IOException {
|
||||
super(configuration, DocPath
|
||||
.forPackage(packageElement)
|
||||
.resolve(DocPaths.PACKAGE_SUMMARY));
|
||||
this.prev = prev;
|
||||
this.next = next;
|
||||
this.packageElement = packageElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getPackageHeader(String heading) {
|
||||
HtmlTree bodyTree = getBody(true, getWindowTitle(utils.getPackageName(packageElement)));
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
|
||||
? HtmlTree.HEADER()
|
||||
: bodyTree;
|
||||
addTop(htmlTree);
|
||||
addNavLinks(true, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.HEADER)) {
|
||||
bodyTree.addContent(htmlTree);
|
||||
}
|
||||
HtmlTree div = new HtmlTree(HtmlTag.DIV);
|
||||
div.addStyle(HtmlStyle.header);
|
||||
Content annotationContent = new HtmlTree(HtmlTag.P);
|
||||
addAnnotationInfo(packageElement, annotationContent);
|
||||
div.addContent(annotationContent);
|
||||
Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
|
||||
HtmlStyle.title, packageLabel);
|
||||
tHeading.addContent(getSpace());
|
||||
Content packageHead = new StringContent(heading);
|
||||
tHeading.addContent(packageHead);
|
||||
div.addContent(tHeading);
|
||||
addDeprecationInfo(div);
|
||||
if (!utils.getBody(packageElement).isEmpty() && !configuration.nocomment) {
|
||||
HtmlTree docSummaryDiv = new HtmlTree(HtmlTag.DIV);
|
||||
docSummaryDiv.addStyle(HtmlStyle.docSummary);
|
||||
addSummaryComment(packageElement, docSummaryDiv);
|
||||
div.addContent(docSummaryDiv);
|
||||
Content space = getSpace();
|
||||
Content descLink = getHyperLink(getDocLink(
|
||||
SectionName.PACKAGE_DESCRIPTION),
|
||||
descriptionLabel, "", "");
|
||||
Content descPara = new HtmlTree(HtmlTag.P, seeLabel, space, descLink);
|
||||
div.addContent(descPara);
|
||||
}
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
mainTree.addContent(div);
|
||||
} else {
|
||||
bodyTree.addContent(div);
|
||||
}
|
||||
return bodyTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getContentHeader() {
|
||||
HtmlTree div = new HtmlTree(HtmlTag.DIV);
|
||||
div.addStyle(HtmlStyle.contentContainer);
|
||||
return div;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the package deprecation information to the documentation tree.
|
||||
*
|
||||
* @param div the content tree to which the deprecation information will be added
|
||||
*/
|
||||
public void addDeprecationInfo(Content div) {
|
||||
List<? extends DocTree> deprs = utils.getBlockTags(packageElement, DocTree.Kind.DEPRECATED);
|
||||
if (utils.isDeprecated(packageElement)) {
|
||||
CommentHelper ch = utils.getCommentHelper(packageElement);
|
||||
HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV);
|
||||
deprDiv.addStyle(HtmlStyle.deprecatedContent);
|
||||
Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
|
||||
deprDiv.addContent(deprPhrase);
|
||||
if (!deprs.isEmpty()) {
|
||||
List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
|
||||
if (!commentTags.isEmpty()) {
|
||||
addInlineDeprecatedComment(packageElement, deprs.get(0), deprDiv);
|
||||
}
|
||||
}
|
||||
div.addContent(deprDiv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getSummaryHeader() {
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
ul.addStyle(HtmlStyle.blockList);
|
||||
return ul;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addClassesSummary(SortedSet<TypeElement> classes, String label,
|
||||
String tableSummary, List<String> tableHeader, Content summaryContentTree) {
|
||||
if(!classes.isEmpty()) {
|
||||
Content caption = getTableCaption(new RawHtml(label));
|
||||
Content table = (configuration.isOutputHtml5())
|
||||
? HtmlTree.TABLE(HtmlStyle.typeSummary, caption)
|
||||
: HtmlTree.TABLE(HtmlStyle.typeSummary, tableSummary, caption);
|
||||
table.addContent(getSummaryTableHeader(tableHeader, "col"));
|
||||
Content tbody = new HtmlTree(HtmlTag.TBODY);
|
||||
boolean altColor = false;
|
||||
for (TypeElement klass : classes) {
|
||||
altColor = !altColor;
|
||||
if (!utils.isCoreClass(klass) ||
|
||||
!configuration.isGeneratedDoc(klass)) {
|
||||
continue;
|
||||
}
|
||||
Content classContent = getLink(new LinkInfoImpl(
|
||||
configuration, LinkInfoImpl.Kind.PACKAGE, klass));
|
||||
Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent);
|
||||
HtmlTree tr = HtmlTree.TR(tdClass);
|
||||
tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
|
||||
|
||||
HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD);
|
||||
tdClassDescription.addStyle(HtmlStyle.colLast);
|
||||
if (utils.isDeprecated(klass)) {
|
||||
tdClassDescription.addContent(deprecatedLabel);
|
||||
List<? extends DocTree> tags = utils.getDeprecatedTrees(klass);
|
||||
if (!tags.isEmpty()) {
|
||||
addSummaryDeprecatedComment(klass, tags.get(0), tdClassDescription);
|
||||
}
|
||||
} else {
|
||||
addSummaryComment(klass, tdClassDescription);
|
||||
}
|
||||
tr.addContent(tdClassDescription);
|
||||
tbody.addContent(tr);
|
||||
}
|
||||
table.addContent(tbody);
|
||||
Content li = HtmlTree.LI(HtmlStyle.blockList, table);
|
||||
summaryContentTree.addContent(li);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addPackageDescription(Content packageContentTree) {
|
||||
if (!utils.getBody(packageElement).isEmpty()) {
|
||||
packageContentTree.addContent(
|
||||
getMarkerAnchor(SectionName.PACKAGE_DESCRIPTION));
|
||||
Content h2Content = new StringContent(
|
||||
configuration.getText("doclet.Package_Description",
|
||||
packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement)));
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, h2Content);
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
sectionTree.addContent(heading);
|
||||
addInlineComment(packageElement, sectionTree);
|
||||
} else {
|
||||
packageContentTree.addContent(heading);
|
||||
addInlineComment(packageElement, packageContentTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addPackageTags(Content packageContentTree) {
|
||||
Content htmlTree = (configuration.allowTag(HtmlTag.SECTION))
|
||||
? sectionTree
|
||||
: packageContentTree;
|
||||
addTagsInfo(packageElement, htmlTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addPackageContent(Content contentTree, Content packageContentTree) {
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
packageContentTree.addContent(sectionTree);
|
||||
mainTree.addContent(packageContentTree);
|
||||
contentTree.addContent(mainTree);
|
||||
} else {
|
||||
contentTree.addContent(packageContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addPackageFooter(Content contentTree) {
|
||||
Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
|
||||
? HtmlTree.FOOTER()
|
||||
: contentTree;
|
||||
addNavLinks(false, htmlTree);
|
||||
addBottom(htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
contentTree.addContent(htmlTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void printDocument(Content contentTree) throws IOException {
|
||||
printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageElement),
|
||||
true, contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get "Use" link for this pacakge in the navigation bar.
|
||||
*
|
||||
* @return a content tree for the class use link
|
||||
*/
|
||||
protected Content getNavLinkClassUse() {
|
||||
Content useLink = getHyperLink(DocPaths.PACKAGE_USE,
|
||||
useLabel, "", "");
|
||||
Content li = HtmlTree.LI(useLink);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get "PREV PACKAGE" link in the navigation bar.
|
||||
*
|
||||
* @return a content tree for the previous link
|
||||
*/
|
||||
public Content getNavLinkPrevious() {
|
||||
Content li;
|
||||
if (prev == null) {
|
||||
li = HtmlTree.LI(prevpackageLabel);
|
||||
} else {
|
||||
DocPath path = DocPath.relativePath(packageElement, prev);
|
||||
li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
|
||||
prevpackageLabel, "", ""));
|
||||
}
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get "NEXT PACKAGE" link in the navigation bar.
|
||||
*
|
||||
* @return a content tree for the next link
|
||||
*/
|
||||
public Content getNavLinkNext() {
|
||||
Content li;
|
||||
if (next == null) {
|
||||
li = HtmlTree.LI(nextpackageLabel);
|
||||
} else {
|
||||
DocPath path = DocPath.relativePath(packageElement, next);
|
||||
li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
|
||||
nextpackageLabel, "", ""));
|
||||
}
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get "Tree" link in the navigation bar. This will be link to the package
|
||||
* tree file.
|
||||
*
|
||||
* @return a content tree for the tree link
|
||||
*/
|
||||
protected Content getNavLinkTree() {
|
||||
Content useLink = getHyperLink(DocPaths.PACKAGE_TREE,
|
||||
treeLabel, "", "");
|
||||
Content li = HtmlTree.LI(useLink);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlight "Package" in the navigation bar, as this is the package page.
|
||||
*
|
||||
* @return a content tree for the package link
|
||||
*/
|
||||
protected Content getNavLinkPackage() {
|
||||
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, packageLabel);
|
||||
return li;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,369 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.PropertyWriter;
|
||||
|
||||
|
||||
/**
|
||||
* Writes property documentation in HTML format.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Robert Field
|
||||
* @author Atul M Dambalkar
|
||||
* @author Jamie Ho (rewrite)
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class PropertyWriterImpl extends AbstractMemberWriter
|
||||
implements PropertyWriter, MemberSummaryWriter {
|
||||
|
||||
public PropertyWriterImpl(SubWriterHolderWriter writer, TypeElement typeElement) {
|
||||
super(writer, typeElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getMemberSummaryHeader(TypeElement typeElement,
|
||||
Content memberSummaryTree) {
|
||||
memberSummaryTree.addContent(HtmlConstants.START_OF_PROPERTY_SUMMARY);
|
||||
Content memberTree = writer.getMemberTreeHeader();
|
||||
writer.addSummaryHeader(this, typeElement, memberTree);
|
||||
return memberTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addMemberTree(Content memberSummaryTree, Content memberTree) {
|
||||
writer.addMemberTree(memberSummaryTree, memberTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getPropertyDetailsTreeHeader(TypeElement typeElement,
|
||||
Content memberDetailsTree) {
|
||||
memberDetailsTree.addContent(HtmlConstants.START_OF_PROPERTY_DETAILS);
|
||||
Content propertyDetailsTree = writer.getMemberTreeHeader();
|
||||
propertyDetailsTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.PROPERTY_DETAIL));
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
|
||||
writer.propertyDetailsLabel);
|
||||
propertyDetailsTree.addContent(heading);
|
||||
return propertyDetailsTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getPropertyDocTreeHeader(ExecutableElement property,
|
||||
Content propertyDetailsTree) {
|
||||
propertyDetailsTree.addContent(
|
||||
writer.getMarkerAnchor(name(property)));
|
||||
Content propertyDocTree = writer.getMemberTreeHeader();
|
||||
Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
|
||||
heading.addContent(utils.getPropertyLabel(name(property)));
|
||||
propertyDocTree.addContent(heading);
|
||||
return propertyDocTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getSignature(ExecutableElement property) {
|
||||
Content pre = new HtmlTree(HtmlTag.PRE);
|
||||
writer.addAnnotationInfo(property, pre);
|
||||
addModifiers(property, pre);
|
||||
Content propertylink = writer.getLink(new LinkInfoImpl(
|
||||
configuration, LinkInfoImpl.Kind.MEMBER,
|
||||
utils.getReturnType(property)));
|
||||
pre.addContent(propertylink);
|
||||
pre.addContent(" ");
|
||||
if (configuration.linksource) {
|
||||
Content propertyName = new StringContent(name(property));
|
||||
writer.addSrcLink(property, propertyName, pre);
|
||||
} else {
|
||||
addName(name(property), pre);
|
||||
}
|
||||
return pre;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addDeprecated(ExecutableElement property, Content propertyDocTree) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addComments(ExecutableElement property, Content propertyDocTree) {
|
||||
TypeElement holder = (TypeElement)property.getEnclosingElement();
|
||||
if (!utils.getBody(property).isEmpty()) {
|
||||
if (holder.equals(typeElement) ||
|
||||
(!utils.isPublic(holder) || utils.isLinkable(holder))) {
|
||||
writer.addInlineComment(property, propertyDocTree);
|
||||
} else {
|
||||
Content link =
|
||||
writer.getDocLink(LinkInfoImpl.Kind.PROPERTY_COPY,
|
||||
holder, property,
|
||||
utils.isIncluded(holder)
|
||||
? holder.toString() : utils.getFullyQualifiedName(holder),
|
||||
false);
|
||||
Content codeLink = HtmlTree.CODE(link);
|
||||
Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel,
|
||||
utils.isClass(holder)
|
||||
? writer.descfrmClassLabel
|
||||
: writer.descfrmInterfaceLabel);
|
||||
descfrmLabel.addContent(writer.getSpace());
|
||||
descfrmLabel.addContent(codeLink);
|
||||
propertyDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel));
|
||||
writer.addInlineComment(property, propertyDocTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addTags(ExecutableElement property, Content propertyDocTree) {
|
||||
writer.addTagsInfo(property, propertyDocTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getPropertyDetails(Content propertyDetailsTree) {
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(propertyDetailsTree));
|
||||
return htmlTree;
|
||||
}
|
||||
return getMemberTree(propertyDetailsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getPropertyDoc(Content propertyDocTree,
|
||||
boolean isLastContent) {
|
||||
return getMemberTree(propertyDocTree, isLastContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the writer.
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addSummaryLabel(Content memberTree) {
|
||||
Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
|
||||
writer.getResource("doclet.Property_Summary"));
|
||||
memberTree.addContent(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getTableSummary() {
|
||||
return configuration.getText("doclet.Member_Table_Summary",
|
||||
configuration.getText("doclet.Property_Summary"),
|
||||
configuration.getText("doclet.properties"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Content getCaption() {
|
||||
return configuration.getResource("doclet.Properties");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<String> getSummaryTableHeader(Element member) {
|
||||
List<String> header = Arrays.asList(configuration.getText("doclet.Type"),
|
||||
configuration.getText("doclet.0_and_1",
|
||||
configuration.getText("doclet.Property"),
|
||||
configuration.getText("doclet.Description")));
|
||||
return header;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
|
||||
memberTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.PROPERTY_SUMMARY));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) {
|
||||
inheritedTree.addContent(writer.getMarkerAnchor(
|
||||
SectionName.PROPERTIES_INHERITANCE,
|
||||
configuration.getClassName(typeElement)));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) {
|
||||
Content classLink = writer.getPreQualifiedClassLink(
|
||||
LinkInfoImpl.Kind.MEMBER, typeElement, false);
|
||||
Content label = new StringContent(
|
||||
utils.isClass(typeElement)
|
||||
? configuration.getText("doclet.Properties_Inherited_From_Class")
|
||||
: configuration.getText("doclet.Properties_Inherited_From_Interface"));
|
||||
Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
|
||||
label);
|
||||
labelHeading.addContent(writer.getSpace());
|
||||
labelHeading.addContent(classLink);
|
||||
inheritedTree.addContent(labelHeading);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element member,
|
||||
Content tdSummary) {
|
||||
Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink,
|
||||
writer.getDocLink(context, typeElement,
|
||||
member,
|
||||
utils.getPropertyLabel(name(member)),
|
||||
false,
|
||||
true));
|
||||
|
||||
Content code = HtmlTree.CODE(memberLink);
|
||||
tdSummary.addContent(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
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);
|
||||
linksTree.addContent(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addSummaryType(Element member, Content tdSummaryType) {
|
||||
addModifierAndType(member, utils.getReturnType((ExecutableElement)member), tdSummaryType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content getDeprecatedLink(Element member) {
|
||||
return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, member,
|
||||
utils.getFullyQualifiedName(member));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
|
||||
if (link) {
|
||||
if (typeElement == null) {
|
||||
return writer.getHyperLink(
|
||||
SectionName.PROPERTY_SUMMARY,
|
||||
writer.getResource("doclet.navProperty"));
|
||||
} else {
|
||||
return writer.getHyperLink(
|
||||
SectionName.PROPERTIES_INHERITANCE,
|
||||
configuration.getClassName(typeElement), writer.getResource("doclet.navProperty"));
|
||||
}
|
||||
} else {
|
||||
return writer.getResource("doclet.navProperty");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void addNavDetailLink(boolean link, Content liNav) {
|
||||
if (link) {
|
||||
liNav.addContent(writer.getHyperLink(
|
||||
SectionName.PROPERTY_DETAIL,
|
||||
writer.getResource("doclet.navProperty")));
|
||||
} else {
|
||||
liNav.addContent(writer.getResource("doclet.navProperty"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
* 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.formats.html;
|
||||
|
||||
/**
|
||||
* Index item for search.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public class SearchIndexItem {
|
||||
|
||||
private String label = "";
|
||||
private String url = "";
|
||||
private String category = "";
|
||||
private String containingPackage = "";
|
||||
private String containingClass = "";
|
||||
private String holder = "";
|
||||
private String description = "";
|
||||
|
||||
public void setLabel(String l) {
|
||||
label = l;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setUrl(String u) {
|
||||
url = u;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setContainingPackage(String p) {
|
||||
containingPackage = p;
|
||||
}
|
||||
|
||||
public void setContainingClass(String c) {
|
||||
containingClass = c;
|
||||
}
|
||||
|
||||
public void setCategory(String c) {
|
||||
category = c;
|
||||
}
|
||||
|
||||
public void setHolder(String h) {
|
||||
holder = h;
|
||||
}
|
||||
|
||||
public String getHolder() {
|
||||
return holder;
|
||||
}
|
||||
|
||||
public void setDescription(String d) {
|
||||
description = d;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder item = new StringBuilder("");
|
||||
if (category.equals("Packages")) {
|
||||
item.append("{")
|
||||
.append("\"l\":\"").append(label).append("\"")
|
||||
.append("}");
|
||||
} else if (category.equals("Types")) {
|
||||
item.append("{")
|
||||
.append("\"p\":\"").append(containingPackage).append("\",")
|
||||
.append("\"l\":\"").append(label).append("\"")
|
||||
.append("}");
|
||||
} else if (category.equals("Members")) {
|
||||
item.append("{")
|
||||
.append("\"p\":\"").append(containingPackage).append("\",")
|
||||
.append("\"c\":\"").append(containingClass).append("\",")
|
||||
.append("\"l\":\"").append(label).append("\"");
|
||||
if (!url.equals("")) {
|
||||
item.append(",\"url\":\"").append(url).append("\"");
|
||||
}
|
||||
item.append("}");
|
||||
} else {
|
||||
item.append("{")
|
||||
.append("\"l\":\"").append(label).append("\",")
|
||||
.append("\"h\":\"").append(holder).append("\",");
|
||||
if (!description.equals("")) {
|
||||
item.append("\"d\":\"").append(description).append("\",");
|
||||
}
|
||||
item.append("\"u\":\"").append(url).append("\"")
|
||||
.append("}");
|
||||
}
|
||||
return item.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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
|
||||
* 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.formats.html;
|
||||
|
||||
/**
|
||||
* Enum representing various section names of generated API 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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
*/
|
||||
public enum SectionName {
|
||||
|
||||
ANNOTATION_TYPE_ELEMENT_DETAIL("annotation.type.element.detail"),
|
||||
ANNOTATION_TYPE_FIELD_DETAIL("annotation.type.field.detail"),
|
||||
ANNOTATION_TYPE_FIELD_SUMMARY("annotation.type.field.summary"),
|
||||
ANNOTATION_TYPE_OPTIONAL_ELEMENT_SUMMARY("annotation.type.optional.element.summary"),
|
||||
ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY("annotation.type.required.element.summary"),
|
||||
CONSTRUCTOR_DETAIL("constructor.detail"),
|
||||
CONSTRUCTOR_SUMMARY("constructor.summary"),
|
||||
ENUM_CONSTANT_DETAIL("enum.constant.detail"),
|
||||
ENUM_CONSTANTS_INHERITANCE("enum.constants.inherited.from.class."),
|
||||
ENUM_CONSTANT_SUMMARY("enum.constant.summary"),
|
||||
FIELD_DETAIL("field.detail"),
|
||||
FIELDS_INHERITANCE("fields.inherited.from.class."),
|
||||
FIELD_SUMMARY("field.summary"),
|
||||
METHOD_DETAIL("method.detail"),
|
||||
METHODS_INHERITANCE("methods.inherited.from.class."),
|
||||
METHOD_SUMMARY("method.summary"),
|
||||
NAVBAR_BOTTOM("navbar.bottom"),
|
||||
NAVBAR_BOTTOM_FIRSTROW("navbar.bottom.firstrow"),
|
||||
NAVBAR_TOP("navbar.top"),
|
||||
NAVBAR_TOP_FIRSTROW("navbar.top.firstrow"),
|
||||
NESTED_CLASSES_INHERITANCE("nested.classes.inherited.from.class."),
|
||||
NESTED_CLASS_SUMMARY("nested.class.summary"),
|
||||
OVERVIEW_DESCRIPTION("overview.description"),
|
||||
PACKAGE_DESCRIPTION("package.description"),
|
||||
PROPERTY_DETAIL("property.detail"),
|
||||
PROPERTIES_INHERITANCE("properties.inherited.from.class."),
|
||||
PROPERTY_SUMMARY("property.summary"),
|
||||
SKIP_NAVBAR_BOTTOM("skip.navbar.bottom"),
|
||||
SKIP_NAVBAR_TOP("skip.navbar.top"),
|
||||
UNNAMED_PACKAGE_ANCHOR("unnamed.package");
|
||||
|
||||
private final String value;
|
||||
|
||||
SectionName(String sName) {
|
||||
this.value = sName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,301 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter.SerialFieldWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter.SerialMethodWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
|
||||
/**
|
||||
* Generate the Serialized Form Information Page.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
*/
|
||||
public class SerializedFormWriterImpl extends SubWriterHolderWriter
|
||||
implements SerializedFormWriter {
|
||||
|
||||
Set<TypeElement> visibleClasses;
|
||||
|
||||
/**
|
||||
* HTML tree for main tag.
|
||||
*/
|
||||
private HtmlTree mainTree = HtmlTree.MAIN();
|
||||
|
||||
/**
|
||||
* @param configuration the configuration data for the doclet
|
||||
* @throws IOException
|
||||
* @throws DocletAbortException
|
||||
*/
|
||||
public SerializedFormWriterImpl(ConfigurationImpl configuration)
|
||||
throws IOException {
|
||||
super(configuration, DocPaths.SERIALIZED_FORM);
|
||||
visibleClasses = configuration.root.getIncludedClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the given header.
|
||||
*
|
||||
* @param header the header to write
|
||||
* @return the body content tree
|
||||
*/
|
||||
public Content getHeader(String header) {
|
||||
HtmlTree bodyTree = getBody(true, getWindowTitle(header));
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
|
||||
? HtmlTree.HEADER()
|
||||
: bodyTree;
|
||||
addTop(htmlTree);
|
||||
addNavLinks(true, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.HEADER)) {
|
||||
bodyTree.addContent(htmlTree);
|
||||
}
|
||||
Content h1Content = new StringContent(header);
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
|
||||
HtmlStyle.title, h1Content);
|
||||
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
mainTree.addContent(div);
|
||||
} else {
|
||||
bodyTree.addContent(div);
|
||||
}
|
||||
return bodyTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the serialized form summaries header.
|
||||
*
|
||||
* @return the serialized form summary header tree
|
||||
*/
|
||||
public Content getSerializedSummariesHeader() {
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
ul.addStyle(HtmlStyle.blockList);
|
||||
return ul;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the package serialized form header.
|
||||
*
|
||||
* @return the package serialized form header tree
|
||||
*/
|
||||
public Content getPackageSerializedHeader() {
|
||||
HtmlTree htmlTree;
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
htmlTree = HtmlTree.SECTION();
|
||||
} else {
|
||||
htmlTree = new HtmlTree(HtmlTag.LI);
|
||||
htmlTree.addStyle(HtmlStyle.blockList);
|
||||
}
|
||||
return htmlTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the given package header.
|
||||
*
|
||||
* @param packageName the package header to write
|
||||
* @return a content tree for the package header
|
||||
*/
|
||||
public Content getPackageHeader(String packageName) {
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
|
||||
packageLabel);
|
||||
heading.addContent(getSpace());
|
||||
heading.addContent(packageName);
|
||||
return heading;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the serialized class header.
|
||||
*
|
||||
* @return a content tree for the serialized class header
|
||||
*/
|
||||
public Content getClassSerializedHeader() {
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
ul.addStyle(HtmlStyle.blockList);
|
||||
return ul;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a class is generated and is visible.
|
||||
*
|
||||
* @param typeElement the class being processed.
|
||||
* @return true if the class, that is being processed, is generated and is visible.
|
||||
*/
|
||||
public boolean isVisibleClass(TypeElement typeElement) {
|
||||
return visibleClasses.contains(typeElement) && configuration.isGeneratedDoc(typeElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the serializable class heading.
|
||||
*
|
||||
* @param typeElement the class being processed
|
||||
* @return a content tree for the class header
|
||||
*/
|
||||
public Content getClassHeader(TypeElement typeElement) {
|
||||
Content classLink = (isVisibleClass(typeElement))
|
||||
? getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, typeElement)
|
||||
.label(configuration.getClassName(typeElement)))
|
||||
: new StringContent(utils.getFullyQualifiedName(typeElement));
|
||||
Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(
|
||||
utils.getFullyQualifiedName(typeElement)));
|
||||
Content superClassLink = typeElement.getSuperclass() != null
|
||||
? getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.SERIALIZED_FORM,
|
||||
typeElement.getSuperclass()))
|
||||
: null;
|
||||
|
||||
//Print the heading.
|
||||
Content className = superClassLink == null ?
|
||||
configuration.getResource(
|
||||
"doclet.Class_0_implements_serializable", classLink) :
|
||||
configuration.getResource(
|
||||
"doclet.Class_0_extends_implements_serializable", classLink,
|
||||
superClassLink);
|
||||
li.addContent(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
|
||||
className));
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the serial UID info header.
|
||||
*
|
||||
* @return a content tree for the serial uid info header
|
||||
*/
|
||||
public Content getSerialUIDInfoHeader() {
|
||||
HtmlTree dl = new HtmlTree(HtmlTag.DL);
|
||||
dl.addStyle(HtmlStyle.nameValue);
|
||||
return dl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the serial UID info.
|
||||
*
|
||||
* @param header the header that will show up before the UID.
|
||||
* @param serialUID the serial UID to print.
|
||||
* @param serialUidTree the serial UID content tree to which the serial UID
|
||||
* content will be added
|
||||
*/
|
||||
public void addSerialUIDInfo(String header, String serialUID,
|
||||
Content serialUidTree) {
|
||||
Content headerContent = new StringContent(header);
|
||||
serialUidTree.addContent(HtmlTree.DT(headerContent));
|
||||
Content serialContent = new StringContent(serialUID);
|
||||
serialUidTree.addContent(HtmlTree.DD(serialContent));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class serialize content header.
|
||||
*
|
||||
* @return a content tree for the class serialize content header
|
||||
*/
|
||||
public Content getClassContentHeader() {
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
ul.addStyle(HtmlStyle.blockList);
|
||||
return ul;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the serialized content tree section.
|
||||
*
|
||||
* @param serializedTreeContent the serialized content tree to be added
|
||||
* @return a div content tree
|
||||
*/
|
||||
public Content getSerializedContent(Content serializedTreeContent) {
|
||||
HtmlTree divContent = HtmlTree.DIV(HtmlStyle.serializedFormContainer,
|
||||
serializedTreeContent);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
mainTree.addContent(divContent);
|
||||
return mainTree;
|
||||
} else {
|
||||
return divContent;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void addPackageSerializedTree(Content serializedSummariesTree,
|
||||
Content packageSerializedTree) {
|
||||
serializedSummariesTree.addContent((configuration.allowTag(HtmlTag.SECTION))
|
||||
? HtmlTree.LI(HtmlStyle.blockList, packageSerializedTree)
|
||||
: packageSerializedTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the footer.
|
||||
*
|
||||
* @param serializedTree the serialized tree to be added
|
||||
*/
|
||||
public void addFooter(Content serializedTree) {
|
||||
Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
|
||||
? HtmlTree.FOOTER()
|
||||
: serializedTree;
|
||||
addNavLinks(false, htmlTree);
|
||||
addBottom(htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
serializedTree.addContent(htmlTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void printDocument(Content serializedTree) throws IOException {
|
||||
printHtmlDocument(null, true, serializedTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of a SerialFieldWriter.
|
||||
*
|
||||
* @return an instance of a SerialFieldWriter.
|
||||
*/
|
||||
public SerialFieldWriter getSerialFieldWriter(TypeElement typeElement) {
|
||||
return new HtmlSerialFieldWriter(this, typeElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance of a SerialMethodWriter.
|
||||
*
|
||||
* @return an instance of a SerialMethodWriter.
|
||||
*/
|
||||
public SerialMethodWriter getSerialMethodWriter(TypeElement typeElement) {
|
||||
return new HtmlSerialMethodWriter(this, typeElement);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Generate only one index file for all the Member Names with Indexing in
|
||||
* Unicode Order. The name of the generated file is "index-all.html" and it is
|
||||
* generated in current or the destination directory.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @see java.lang.Character
|
||||
* @author Atul M Dambalkar
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class SingleIndexWriter extends AbstractIndexWriter {
|
||||
|
||||
private Set<Character> elements;
|
||||
|
||||
/**
|
||||
* Construct the SingleIndexWriter with filename "index-all.html" and the
|
||||
* {@link IndexBuilder}
|
||||
*
|
||||
* @param filename Name of the index file to be generated.
|
||||
* @param indexbuilder Unicode based Index from {@link IndexBuilder}
|
||||
*/
|
||||
public SingleIndexWriter(ConfigurationImpl configuration,
|
||||
DocPath filename,
|
||||
IndexBuilder indexbuilder) throws IOException {
|
||||
super(configuration, filename, indexbuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate single index file, for all Unicode characters.
|
||||
*
|
||||
* @param indexbuilder IndexBuilder built by {@link IndexBuilder}
|
||||
* @throws DocletAbortException
|
||||
*/
|
||||
public static void generate(ConfigurationImpl configuration,
|
||||
IndexBuilder indexbuilder) {
|
||||
SingleIndexWriter indexgen;
|
||||
DocPath filename = DocPaths.INDEX_ALL;
|
||||
try {
|
||||
indexgen = new SingleIndexWriter(configuration,
|
||||
filename, indexbuilder);
|
||||
indexgen.generateIndexFile();
|
||||
indexgen.close();
|
||||
} catch (IOException exc) {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the contents of each index file, with Header, Footer,
|
||||
* Member Field, Method and Constructor Description.
|
||||
*/
|
||||
protected void generateIndexFile() throws IOException {
|
||||
String title = configuration.getText("doclet.Window_Single_Index");
|
||||
HtmlTree body = getBody(true, getWindowTitle(title));
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
|
||||
? HtmlTree.HEADER()
|
||||
: body;
|
||||
addTop(htmlTree);
|
||||
addNavLinks(true, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.HEADER)) {
|
||||
body.addContent(htmlTree);
|
||||
}
|
||||
HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
|
||||
divTree.addStyle(HtmlStyle.contentContainer);
|
||||
elements = new TreeSet<>(indexbuilder.getIndexMap().keySet());
|
||||
elements.addAll(configuration.tagSearchIndexKeys);
|
||||
addLinksForIndexes(divTree);
|
||||
for (Character unicode : elements) {
|
||||
if (configuration.tagSearchIndexMap.get(unicode) == null) {
|
||||
addContents(unicode, indexbuilder.getMemberList(unicode), divTree);
|
||||
} else if (indexbuilder.getMemberList(unicode) == null) {
|
||||
addSearchContents(unicode, configuration.tagSearchIndexMap.get(unicode), divTree);
|
||||
} else {
|
||||
addContents(unicode, indexbuilder.getMemberList(unicode),
|
||||
configuration.tagSearchIndexMap.get(unicode), divTree);
|
||||
}
|
||||
}
|
||||
addLinksForIndexes(divTree);
|
||||
body.addContent((configuration.allowTag(HtmlTag.MAIN))
|
||||
? HtmlTree.MAIN(divTree)
|
||||
: divTree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
htmlTree = HtmlTree.FOOTER();
|
||||
}
|
||||
addNavLinks(false, htmlTree);
|
||||
addBottom(htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
body.addContent(htmlTree);
|
||||
}
|
||||
createSearchIndexFiles();
|
||||
printHtmlDocument(null, true, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add links for all the Index Files per unicode character.
|
||||
*
|
||||
* @param contentTree the content tree to which the links for indexes will be added
|
||||
*/
|
||||
protected void addLinksForIndexes(Content contentTree) {
|
||||
for (Object ch : elements) {
|
||||
String unicode = ch.toString();
|
||||
contentTree.addContent(
|
||||
getHyperLink(getNameForIndex(unicode),
|
||||
new StringContent(unicode)));
|
||||
contentTree.addContent(getSpace());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,295 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.PackageElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.tools.FileObject;
|
||||
|
||||
import jdk.javadoc.doclet.DocletEnvironment;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.DocType;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument;
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
|
||||
|
||||
/**
|
||||
* Converts Java Source Code to HTML.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class SourceToHTMLConverter {
|
||||
|
||||
/**
|
||||
* The number of trailing blank lines at the end of the page.
|
||||
* This is inserted so that anchors at the bottom of small pages
|
||||
* can be reached.
|
||||
*/
|
||||
private static final int NUM_BLANK_LINES = 60;
|
||||
|
||||
/**
|
||||
* New line to be added to the documentation.
|
||||
*/
|
||||
private static final String NEW_LINE = DocletConstants.NL;
|
||||
|
||||
private final ConfigurationImpl configuration;
|
||||
private final Utils utils;
|
||||
|
||||
private final DocletEnvironment rootDoc;
|
||||
|
||||
private DocPath outputdir;
|
||||
|
||||
/**
|
||||
* Relative path from the documentation root to the file that is being
|
||||
* generated.
|
||||
*/
|
||||
private DocPath relativePath = DocPath.empty;
|
||||
|
||||
private SourceToHTMLConverter(ConfigurationImpl configuration, DocletEnvironment rd,
|
||||
DocPath outputdir) {
|
||||
this.configuration = configuration;
|
||||
this.utils = configuration.utils;
|
||||
this.rootDoc = rd;
|
||||
this.outputdir = outputdir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the TypeElements in the given DocletEnvironment to HTML representation.
|
||||
*
|
||||
* @param configuration the configuration.
|
||||
* @param root the DocletEnvironment to convert.
|
||||
* @param outputdir the name of the directory to output to.
|
||||
*/
|
||||
public static void convertRoot(ConfigurationImpl configuration, DocletEnvironment root,
|
||||
DocPath outputdir) {
|
||||
new SourceToHTMLConverter(configuration, root, outputdir).generate();
|
||||
}
|
||||
|
||||
void generate() {
|
||||
if (rootDoc == null || outputdir == null) {
|
||||
return;
|
||||
}
|
||||
for (PackageElement pkg : utils.getSpecifiedPackages()) {
|
||||
// If -nodeprecated option is set and the package is marked as deprecated,
|
||||
// do not convert the package files to HTML.
|
||||
if (!(configuration.nodeprecated && utils.isDeprecated(pkg)))
|
||||
convertPackage(pkg, outputdir);
|
||||
}
|
||||
for (TypeElement te : utils.getSpecifiedClasses()) {
|
||||
// If -nodeprecated option is set and the class is marked as deprecated
|
||||
// or the containing package is deprecated, do not convert the
|
||||
// package files to HTML.
|
||||
if (!(configuration.nodeprecated &&
|
||||
(utils.isDeprecated(te) || utils.isDeprecated(utils.containingPackage(te)))))
|
||||
convertClass(te, outputdir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the Classes in the given Package to an HTML.
|
||||
*
|
||||
* @param pkg the Package to convert.
|
||||
* @param outputdir the name of the directory to output to.
|
||||
*/
|
||||
public void convertPackage(PackageElement pkg, DocPath outputdir) {
|
||||
if (pkg == null) {
|
||||
return;
|
||||
}
|
||||
for (Element te : utils.getAllClasses(pkg)) {
|
||||
// If -nodeprecated option is set and the class is marked as deprecated,
|
||||
// do not convert the package files to HTML. We do not check for
|
||||
// containing package deprecation since it is already check in
|
||||
// the calling method above.
|
||||
if (!(configuration.nodeprecated && utils.isDeprecated(te)))
|
||||
convertClass((TypeElement)te, outputdir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given Class to an HTML.
|
||||
*
|
||||
* @param te the class to convert.
|
||||
* @param outputdir the name of the directory to output to.
|
||||
*/
|
||||
public void convertClass(TypeElement te, DocPath outputdir) {
|
||||
if (te == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
FileObject fo = utils.getFileObject(te);
|
||||
if (fo == null)
|
||||
return;
|
||||
Reader r = fo.openReader(true);
|
||||
int lineno = 1;
|
||||
String line;
|
||||
relativePath = DocPaths.SOURCE_OUTPUT
|
||||
.resolve(DocPath.forPackage(utils, te))
|
||||
.invert();
|
||||
Content body = getHeader();
|
||||
Content pre = new HtmlTree(HtmlTag.PRE);
|
||||
try (LineNumberReader reader = new LineNumberReader(r)) {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
addLineNo(pre, lineno);
|
||||
addLine(pre, line, lineno);
|
||||
lineno++;
|
||||
}
|
||||
}
|
||||
addBlankLines(pre);
|
||||
Content div = HtmlTree.DIV(HtmlStyle.sourceContainer, pre);
|
||||
body.addContent((configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(div) : div);
|
||||
writeToFile(body, outputdir.resolve(DocPath.forClass(utils, te)));
|
||||
} catch (IOException e) {
|
||||
throw new DocletAbortException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the output to the file.
|
||||
*
|
||||
* @param body the documentation content to be written to the file.
|
||||
* @param path the path for the file.
|
||||
*/
|
||||
private void writeToFile(Content body, DocPath path) throws IOException {
|
||||
Content htmlDocType = configuration.isOutputHtml5()
|
||||
? DocType.HTML5
|
||||
: DocType.TRANSITIONAL;
|
||||
Content head = new HtmlTree(HtmlTag.HEAD);
|
||||
head.addContent(HtmlTree.TITLE(new StringContent(
|
||||
configuration.getText("doclet.Window_Source_title"))));
|
||||
head.addContent(getStyleSheetProperties());
|
||||
Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
|
||||
head, body);
|
||||
Content htmlDocument = new HtmlDocument(htmlDocType, htmlTree);
|
||||
configuration.message.notice("doclet.Generating_0", path.getPath());
|
||||
DocFile df = DocFile.createFileForOutput(configuration, path);
|
||||
try (Writer w = df.openWriter()) {
|
||||
htmlDocument.write(w, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a link to the stylesheet file.
|
||||
*
|
||||
* @return an HtmlTree for the lINK tag which provides the stylesheet location
|
||||
*/
|
||||
public HtmlTree getStyleSheetProperties() {
|
||||
String filename = configuration.stylesheetfile;
|
||||
DocPath stylesheet;
|
||||
if (filename.length() > 0) {
|
||||
DocFile file = DocFile.createFileForInput(configuration, filename);
|
||||
stylesheet = DocPath.create(file.getName());
|
||||
} else {
|
||||
stylesheet = DocPaths.STYLESHEET;
|
||||
}
|
||||
DocPath p = relativePath.resolve(stylesheet);
|
||||
HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", p.getPath(), "Style");
|
||||
return link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the header.
|
||||
*
|
||||
* @return the header content for the HTML file
|
||||
*/
|
||||
private static Content getHeader() {
|
||||
return new HtmlTree(HtmlTag.BODY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the line numbers for the source code.
|
||||
*
|
||||
* @param pre the content tree to which the line number will be added
|
||||
* @param lineno The line number
|
||||
*/
|
||||
private static void addLineNo(Content pre, int lineno) {
|
||||
HtmlTree span = new HtmlTree(HtmlTag.SPAN);
|
||||
span.addStyle(HtmlStyle.sourceLineNo);
|
||||
if (lineno < 10) {
|
||||
span.addContent("00" + Integer.toString(lineno));
|
||||
} else if (lineno < 100) {
|
||||
span.addContent("0" + Integer.toString(lineno));
|
||||
} else {
|
||||
span.addContent(Integer.toString(lineno));
|
||||
}
|
||||
pre.addContent(span);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a line from source to the HTML file that is generated.
|
||||
*
|
||||
* @param pre the content tree to which the line will be added.
|
||||
* @param line the string to format.
|
||||
* @param currentLineNo the current number.
|
||||
*/
|
||||
private void addLine(Content pre, String line, int currentLineNo) {
|
||||
if (line != null) {
|
||||
Content anchor = HtmlTree.A(configuration.htmlVersion,
|
||||
"line." + Integer.toString(currentLineNo),
|
||||
new StringContent(utils.replaceTabs(line)));
|
||||
pre.addContent(anchor);
|
||||
pre.addContent(NEW_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add trailing blank lines at the end of the page.
|
||||
*
|
||||
* @param pre the content tree to which the blank lines will be added.
|
||||
*/
|
||||
private static void addBlankLines(Content pre) {
|
||||
for (int i = 0; i < NUM_BLANK_LINES; i++) {
|
||||
pre.addContent(NEW_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a <code>Doc</code>, return an anchor name for it.
|
||||
*
|
||||
* @param d the <code>Doc</code> to check.
|
||||
* @return the name of the anchor.
|
||||
*/
|
||||
public static String getAnchorName(Utils utils, Element e) {
|
||||
return "line." + utils.getLineNumber(e);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,218 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Generate Separate Index Files for all the member names with Indexing in
|
||||
* Unicode Order. This will create "index-files" directory in the current or
|
||||
* destination directory and will generate separate file for each unicode index.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @see java.lang.Character
|
||||
* @author Atul M Dambalkar
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class SplitIndexWriter extends AbstractIndexWriter {
|
||||
|
||||
/**
|
||||
* Previous unicode character index in the built index.
|
||||
*/
|
||||
protected int prev;
|
||||
|
||||
/**
|
||||
* Next unicode character in the built index.
|
||||
*/
|
||||
protected int next;
|
||||
|
||||
private List<Character> indexElements;
|
||||
|
||||
/**
|
||||
* Construct the SplitIndexWriter. Uses path to this file and relative path
|
||||
* from this file.
|
||||
*
|
||||
* @param path Path to the file which is getting generated.
|
||||
* @param indexbuilder Unicode based Index from {@link IndexBuilder}
|
||||
*/
|
||||
public SplitIndexWriter(ConfigurationImpl configuration,
|
||||
DocPath path,
|
||||
IndexBuilder indexbuilder,
|
||||
Collection<Character> elements,
|
||||
int prev, int next) throws IOException {
|
||||
super(configuration, path, indexbuilder);
|
||||
this.indexElements = new ArrayList<>(elements);
|
||||
this.prev = prev;
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate separate index files, for each Unicode character, listing all
|
||||
* the members starting with the particular unicode character.
|
||||
*
|
||||
* @param indexbuilder IndexBuilder built by {@link IndexBuilder}
|
||||
* @throws DocletAbortException
|
||||
*/
|
||||
public static void generate(ConfigurationImpl configuration,
|
||||
IndexBuilder indexbuilder) {
|
||||
SplitIndexWriter indexgen;
|
||||
DocPath filename = DocPath.empty;
|
||||
DocPath path = DocPaths.INDEX_FILES;
|
||||
try {
|
||||
Set<Character> keys = new TreeSet<>(indexbuilder.getIndexMap().keySet());
|
||||
keys.addAll(configuration.tagSearchIndexKeys);
|
||||
ListIterator<Character> li = new ArrayList<>(keys).listIterator();
|
||||
while (li.hasNext()) {
|
||||
Object ch = li.next();
|
||||
filename = DocPaths.indexN(li.nextIndex());
|
||||
indexgen = new SplitIndexWriter(configuration,
|
||||
path.resolve(filename),
|
||||
indexbuilder, keys, li.previousIndex(), li.nextIndex());
|
||||
indexgen.generateIndexFile((Character) ch);
|
||||
if (!li.hasNext()) {
|
||||
indexgen.createSearchIndexFiles();
|
||||
}
|
||||
indexgen.close();
|
||||
}
|
||||
} catch (IOException exc) {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename.getPath());
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the contents of each index file, with Header, Footer,
|
||||
* Member Field, Method and Constructor Description.
|
||||
*
|
||||
* @param unicode Unicode character referring to the character for the
|
||||
* index.
|
||||
*/
|
||||
protected void generateIndexFile(Character unicode) throws IOException {
|
||||
String title = configuration.getText("doclet.Window_Split_Index",
|
||||
unicode.toString());
|
||||
HtmlTree body = getBody(true, getWindowTitle(title));
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
|
||||
? HtmlTree.HEADER()
|
||||
: body;
|
||||
addTop(htmlTree);
|
||||
addNavLinks(true, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.HEADER)) {
|
||||
body.addContent(htmlTree);
|
||||
}
|
||||
HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
|
||||
divTree.addStyle(HtmlStyle.contentContainer);
|
||||
addLinksForIndexes(divTree);
|
||||
if (configuration.tagSearchIndexMap.get(unicode) == null) {
|
||||
addContents(unicode, indexbuilder.getMemberList(unicode), divTree);
|
||||
} else if (indexbuilder.getMemberList(unicode) == null) {
|
||||
addSearchContents(unicode, configuration.tagSearchIndexMap.get(unicode), divTree);
|
||||
} else {
|
||||
addContents(unicode, indexbuilder.getMemberList(unicode),
|
||||
configuration.tagSearchIndexMap.get(unicode), divTree);
|
||||
}
|
||||
addLinksForIndexes(divTree);
|
||||
body.addContent((configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(divTree) : divTree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
htmlTree = HtmlTree.FOOTER();
|
||||
}
|
||||
addNavLinks(false, htmlTree);
|
||||
addBottom(htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
body.addContent(htmlTree);
|
||||
}
|
||||
printHtmlDocument(null, true, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add links for all the Index Files per unicode character.
|
||||
*
|
||||
* @param contentTree the content tree to which the links for indexes will be added
|
||||
*/
|
||||
protected void addLinksForIndexes(Content contentTree) {
|
||||
for (int i = 0; i < indexElements.size(); i++) {
|
||||
int j = i + 1;
|
||||
contentTree.addContent(getHyperLink(DocPaths.indexN(j),
|
||||
new StringContent(indexElements.get(i).toString())));
|
||||
contentTree.addContent(getSpace());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link to the previous unicode character.
|
||||
*
|
||||
* @return a content tree for the link
|
||||
*/
|
||||
public Content getNavLinkPrevious() {
|
||||
Content prevletterLabel = getResource("doclet.Prev_Letter");
|
||||
if (prev == -1) {
|
||||
return HtmlTree.LI(prevletterLabel);
|
||||
}
|
||||
else {
|
||||
Content prevLink = getHyperLink(DocPaths.indexN(prev),
|
||||
prevletterLabel);
|
||||
return HtmlTree.LI(prevLink);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link to the next unicode character.
|
||||
*
|
||||
* @return a content tree for the link
|
||||
*/
|
||||
public Content getNavLinkNext() {
|
||||
Content nextletterLabel = getResource("doclet.Next_Letter");
|
||||
if (next == -1) {
|
||||
return HtmlTree.LI(nextletterLabel);
|
||||
}
|
||||
else {
|
||||
Content nextLink = getHyperLink(DocPaths.indexN(next),
|
||||
nextletterLabel);
|
||||
return HtmlTree.LI(nextLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,368 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
import com.sun.source.doctree.DocTree;
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.MethodTypes;
|
||||
|
||||
/**
|
||||
* This abstract class exists to provide functionality needed in the
|
||||
* the formatting of member information. Since AbstractSubWriter and its
|
||||
* subclasses control this, they would be the logical place to put this.
|
||||
* However, because each member type has its own subclass, subclassing
|
||||
* can not be used effectively to change formatting. The concrete
|
||||
* class subclass of this class can be subclassed to change formatting.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @see AbstractMemberWriter
|
||||
* @see ClassWriterImpl
|
||||
*
|
||||
* @author Robert Field
|
||||
* @author Atul M Dambalkar
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
|
||||
|
||||
/**
|
||||
* The HTML tree for main tag.
|
||||
*/
|
||||
protected HtmlTree mainTree = HtmlTree.MAIN();
|
||||
|
||||
public SubWriterHolderWriter(ConfigurationImpl configuration, DocPath filename)
|
||||
throws IOException {
|
||||
super(configuration, filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the summary header.
|
||||
*
|
||||
* @param mw the writer for the member being documented
|
||||
* @param typeElement the te to be documented
|
||||
* @param memberTree the content tree to which the summary header will be added
|
||||
*/
|
||||
public void addSummaryHeader(AbstractMemberWriter mw, TypeElement typeElement,
|
||||
Content memberTree) {
|
||||
mw.addSummaryAnchor(typeElement, memberTree);
|
||||
mw.addSummaryLabel(memberTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the summary table.
|
||||
*
|
||||
* @param mw the writer for the member being documented
|
||||
* @param typeElement the te to be documented
|
||||
* @param tableContents list of summary table contents
|
||||
* @param showTabs true if the table needs to show tabs
|
||||
* @return the content tree for the summary table
|
||||
*/
|
||||
public Content getSummaryTableTree(AbstractMemberWriter mw, TypeElement typeElement,
|
||||
List<Content> tableContents, boolean showTabs) {
|
||||
Content caption;
|
||||
if (showTabs) {
|
||||
caption = getTableCaption(mw.methodTypes);
|
||||
generateMethodTypesScript(mw.typeMap, mw.methodTypes);
|
||||
}
|
||||
else {
|
||||
caption = getTableCaption(mw.getCaption());
|
||||
}
|
||||
Content table = (configuration.isOutputHtml5())
|
||||
? HtmlTree.TABLE(HtmlStyle.memberSummary, caption)
|
||||
: HtmlTree.TABLE(HtmlStyle.memberSummary, mw.getTableSummary(), caption);
|
||||
table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(typeElement), "col"));
|
||||
for (Content tableContent : tableContents) {
|
||||
table.addContent(tableContent);
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the summary table caption.
|
||||
*
|
||||
* @param methodTypes set comprising of method types to show as table caption
|
||||
* @return the caption for the summary table
|
||||
*/
|
||||
public Content getTableCaption(Set<MethodTypes> methodTypes) {
|
||||
Content tabbedCaption = new HtmlTree(HtmlTag.CAPTION);
|
||||
for (MethodTypes type : methodTypes) {
|
||||
Content captionSpan;
|
||||
Content span;
|
||||
if (type.isDefaultTab()) {
|
||||
captionSpan = HtmlTree.SPAN(configuration.getResource(type.resourceKey()));
|
||||
span = HtmlTree.SPAN(type.tabId(),
|
||||
HtmlStyle.activeTableTab, captionSpan);
|
||||
} else {
|
||||
captionSpan = HtmlTree.SPAN(getMethodTypeLinks(type));
|
||||
span = HtmlTree.SPAN(type.tabId(),
|
||||
HtmlStyle.tableTab, captionSpan);
|
||||
}
|
||||
Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, getSpace());
|
||||
span.addContent(tabSpan);
|
||||
tabbedCaption.addContent(span);
|
||||
}
|
||||
return tabbedCaption;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the method type links for the table caption.
|
||||
*
|
||||
* @param methodType the method type to be displayed as link
|
||||
* @return the content tree for the method type link
|
||||
*/
|
||||
public Content getMethodTypeLinks(MethodTypes methodType) {
|
||||
String jsShow = "javascript:show(" + methodType.value() +");";
|
||||
HtmlTree link = HtmlTree.A(jsShow, configuration.getResource(methodType.resourceKey()));
|
||||
return link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the inherited summary header.
|
||||
*
|
||||
* @param mw the writer for the member being documented
|
||||
* @param typeElement the te to be documented
|
||||
* @param inheritedTree the content tree to which the inherited summary header will be added
|
||||
*/
|
||||
public void addInheritedSummaryHeader(AbstractMemberWriter mw, TypeElement typeElement,
|
||||
Content inheritedTree) {
|
||||
mw.addInheritedSummaryAnchor(typeElement, inheritedTree);
|
||||
mw.addInheritedSummaryLabel(typeElement, inheritedTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the index comment.
|
||||
*
|
||||
* @param member the member being documented
|
||||
* @param contentTree the content tree to which the comment will be added
|
||||
*/
|
||||
protected void addIndexComment(Element member, Content contentTree) {
|
||||
List<? extends DocTree> tags = utils.getFirstSentenceTrees(member);
|
||||
addIndexComment(member, tags, contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the index comment.
|
||||
*
|
||||
* @param member the member being documented
|
||||
* @param firstSentenceTags the first sentence tags for the member to be documented
|
||||
* @param tdSummary the content tree to which the comment will be added
|
||||
*/
|
||||
protected void addIndexComment(Element member, List<? extends DocTree> firstSentenceTags,
|
||||
Content tdSummary) {
|
||||
List<? extends DocTree> deprs = utils.getBlockTags(member, DocTree.Kind.DEPRECATED);
|
||||
Content div;
|
||||
if (utils.isDeprecated(member)) {
|
||||
Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
|
||||
div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
|
||||
div.addContent(getSpace());
|
||||
if (!deprs.isEmpty()) {
|
||||
addInlineDeprecatedComment(member, deprs.get(0), div);
|
||||
}
|
||||
tdSummary.addContent(div);
|
||||
return;
|
||||
} else {
|
||||
Element te = member.getEnclosingElement();
|
||||
if (te != null && utils.isTypeElement(te) && utils.isDeprecated(te)) {
|
||||
Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
|
||||
div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
|
||||
div.addContent(getSpace());
|
||||
tdSummary.addContent(div);
|
||||
}
|
||||
}
|
||||
addSummaryComment(member, firstSentenceTags, tdSummary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the summary type for the member.
|
||||
*
|
||||
* @param mw the writer for the member being documented
|
||||
* @param member the member to be documented
|
||||
* @param tdSummaryType the content tree to which the type will be added
|
||||
*/
|
||||
public void addSummaryType(AbstractMemberWriter mw, Element member, Content tdSummaryType) {
|
||||
mw.addSummaryType(member, tdSummaryType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the summary link for the member.
|
||||
*
|
||||
* @param mw the writer for the member being documented
|
||||
* @param member the member to be documented
|
||||
* @param contentTree the content tree to which the link will be added
|
||||
*/
|
||||
public void addSummaryLinkComment(AbstractMemberWriter mw, Element member, Content contentTree) {
|
||||
List<? extends DocTree> tags = utils.getFirstSentenceTrees(member);
|
||||
addSummaryLinkComment(mw, member, tags, contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the summary link comment.
|
||||
*
|
||||
* @param mw the writer for the member being documented
|
||||
* @param member the member being documented
|
||||
* @param firstSentenceTags the first sentence tags for the member to be documented
|
||||
* @param tdSummary the content tree to which the comment will be added
|
||||
*/
|
||||
public void addSummaryLinkComment(AbstractMemberWriter mw,
|
||||
Element member, List<? extends DocTree> firstSentenceTags, Content tdSummary) {
|
||||
addIndexComment(member, firstSentenceTags, tdSummary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the inherited member summary.
|
||||
*
|
||||
* @param mw the writer for the member being documented
|
||||
* @param typeElement the class being documented
|
||||
* @param member the member being documented
|
||||
* @param isFirst true if its the first link being documented
|
||||
* @param linksTree the content tree to which the summary will be added
|
||||
*/
|
||||
public void addInheritedMemberSummary(AbstractMemberWriter mw, TypeElement typeElement,
|
||||
Element member, boolean isFirst, Content linksTree) {
|
||||
if (! isFirst) {
|
||||
linksTree.addContent(", ");
|
||||
}
|
||||
mw.addInheritedSummaryLink(typeElement, member, linksTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the document content header tree
|
||||
*
|
||||
* @return a content tree the document content header
|
||||
*/
|
||||
public Content getContentHeader() {
|
||||
HtmlTree div = new HtmlTree(HtmlTag.DIV);
|
||||
div.addStyle(HtmlStyle.contentContainer);
|
||||
return div;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the class content tree.
|
||||
*
|
||||
* @param contentTree content tree to which the class content will be added
|
||||
* @param classContentTree class content tree which will be added to the content tree
|
||||
*/
|
||||
public void addClassContentTree(Content contentTree, Content classContentTree) {
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
mainTree.addContent(classContentTree);
|
||||
contentTree.addContent(mainTree);
|
||||
} else {
|
||||
contentTree.addContent(classContentTree);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the annotation content tree.
|
||||
*
|
||||
* @param contentTree content tree to which the annotation content will be added
|
||||
* @param annotationContentTree annotation content tree which will be added to the content tree
|
||||
*/
|
||||
public void addAnnotationContentTree(Content contentTree, Content annotationContentTree) {
|
||||
addClassContentTree(contentTree, annotationContentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the member header tree
|
||||
*
|
||||
* @return a content tree the member header
|
||||
*/
|
||||
public Content getMemberTreeHeader() {
|
||||
HtmlTree li = new HtmlTree(HtmlTag.LI);
|
||||
li.addStyle(HtmlStyle.blockList);
|
||||
return li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the member tree.
|
||||
*
|
||||
* @param memberSummaryTree the content tree representing the member summary
|
||||
* @param memberTree the content tree representing the member
|
||||
*/
|
||||
public void addMemberTree(Content memberSummaryTree, Content memberTree) {
|
||||
if (configuration.allowTag(HtmlTag.SECTION)) {
|
||||
HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(memberTree));
|
||||
memberSummaryTree.addContent(htmlTree);
|
||||
} else {
|
||||
memberSummaryTree.addContent(getMemberTree(memberTree));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the member tree
|
||||
*
|
||||
* @param contentTree the tree used to generate the complete member tree
|
||||
* @return a content tree for the member
|
||||
*/
|
||||
public Content getMemberTree(Content contentTree) {
|
||||
Content ul = HtmlTree.UL(HtmlStyle.blockList, contentTree);
|
||||
return ul;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the member summary tree
|
||||
*
|
||||
* @param contentTree the tree used to generate the member summary tree
|
||||
* @return a content tree for the member summary
|
||||
*/
|
||||
public Content getMemberSummaryTree(Content contentTree) {
|
||||
return getMemberTree(HtmlStyle.summary, contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the member details tree
|
||||
*
|
||||
* @param contentTree the tree used to generate the member details tree
|
||||
* @return a content tree for the member details
|
||||
*/
|
||||
public Content getMemberDetailsTree(Content contentTree) {
|
||||
return getMemberTree(HtmlStyle.details, contentTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the member tree
|
||||
*
|
||||
* @param style the style class to be added to the content tree
|
||||
* @param contentTree the tree used to generate the complete member tree
|
||||
*/
|
||||
public Content getMemberTree(HtmlStyle style, Content contentTree) {
|
||||
Content div = HtmlTree.DIV(style, getMemberTree(contentTree));
|
||||
return div;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,445 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.util.List;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.PackageElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.lang.model.util.SimpleElementVisitor9;
|
||||
|
||||
import com.sun.source.doctree.DocTree;
|
||||
import com.sun.source.doctree.IndexTree;
|
||||
import com.sun.tools.javac.util.DefinedBy;
|
||||
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Configuration;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.builders.SerializedFormBuilder;
|
||||
import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
|
||||
|
||||
/**
|
||||
* The taglet writer that writes HTML.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
|
||||
public class TagletWriterImpl extends TagletWriter {
|
||||
|
||||
private final HtmlDocletWriter htmlWriter;
|
||||
private final ConfigurationImpl configuration;
|
||||
private final Utils utils;
|
||||
|
||||
public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence) {
|
||||
super(isFirstSentence);
|
||||
this.htmlWriter = htmlWriter;
|
||||
configuration = htmlWriter.configuration;
|
||||
this.utils = configuration.utils;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getOutputInstance() {
|
||||
return new ContentBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected Content codeTagOutput(Element element, DocTree tag) {
|
||||
CommentHelper ch = utils.getCommentHelper(element);
|
||||
String str = utils.normalizeNewlines(ch.getText(tag));
|
||||
StringContent content = new StringContent(str);
|
||||
Content result = HtmlTree.CODE(content);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected Content indexTagOutput(Element element, DocTree tag) {
|
||||
CommentHelper ch = utils.getCommentHelper(element);
|
||||
IndexTree itt = (IndexTree)tag;
|
||||
|
||||
String tagText = ch.getText(itt.getSearchTerm());
|
||||
if (tagText.charAt(0) == '"' && tagText.charAt(tagText.length() - 1) == '"') {
|
||||
tagText = tagText.substring(1, tagText.length() - 1);
|
||||
}
|
||||
String desc = ch.getText(itt.getDescription());
|
||||
|
||||
String anchorName = htmlWriter.getName(tagText);
|
||||
Content result = HtmlTree.A_ID(anchorName, new StringContent(tagText));
|
||||
if (configuration.createindex && !tagText.isEmpty()) {
|
||||
SearchIndexItem si = new SearchIndexItem();
|
||||
si.setLabel(tagText);
|
||||
si.setDescription(desc);
|
||||
new SimpleElementVisitor9<Void, Void>() {
|
||||
@Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
|
||||
public Void visitPackage(PackageElement e, Void p) {
|
||||
si.setUrl(DocPath.forPackage(e).getPath()
|
||||
+ "/" + DocPaths.PACKAGE_SUMMARY.getPath() + "#" + anchorName);
|
||||
si.setHolder(utils.getSimpleName(element));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
|
||||
public Void visitType(TypeElement e, Void p) {
|
||||
si.setUrl(DocPath.forClass(utils, e).getPath() + "#" + anchorName);
|
||||
si.setHolder(utils.getFullyQualifiedName(e));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
|
||||
public Void visitVariable(VariableElement e, Void p) {
|
||||
TypeElement te = utils.getEnclosingTypeElement(e);
|
||||
si.setUrl(DocPath.forClass(utils, te).getPath() + "#" + anchorName);
|
||||
si.setHolder(utils.getFullyQualifiedName(e) + "." + utils.getSimpleName(e));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
|
||||
protected Void defaultAction(Element e, Void p) {
|
||||
TypeElement te = utils.getEnclosingTypeElement(e);
|
||||
si.setUrl(DocPath.forClass(utils, te).getPath() + "#" + anchorName);
|
||||
si.setHolder(utils.getFullyQualifiedName(e));
|
||||
return null;
|
||||
}
|
||||
}.visit(element);
|
||||
si.setCategory(configuration.getResource("doclet.SearchTags").toString());
|
||||
configuration.tagSearchIndex.add(si);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getDocRootOutput() {
|
||||
String path;
|
||||
if (htmlWriter.pathToRoot.isEmpty())
|
||||
path = ".";
|
||||
else
|
||||
path = htmlWriter.pathToRoot.getPath();
|
||||
return new StringContent(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content deprecatedTagOutput(Element element) {
|
||||
ContentBuilder result = new ContentBuilder();
|
||||
CommentHelper ch = utils.getCommentHelper(element);
|
||||
List<? extends DocTree> deprs = utils.getBlockTags(element, DocTree.Kind.DEPRECATED);
|
||||
if (utils.isTypeElement(element)) {
|
||||
if (utils.isDeprecated(element)) {
|
||||
result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel,
|
||||
new StringContent(configuration.getText("doclet.Deprecated"))));
|
||||
result.addContent(RawHtml.nbsp);
|
||||
if (!deprs.isEmpty()) {
|
||||
List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
|
||||
if (!commentTags.isEmpty()) {
|
||||
result.addContent(commentTagsToOutput(null, element, commentTags, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (utils.isDeprecated(element)) {
|
||||
result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel,
|
||||
new StringContent(configuration.getText("doclet.Deprecated"))));
|
||||
result.addContent(RawHtml.nbsp);
|
||||
if (!deprs.isEmpty()) {
|
||||
List<? extends DocTree> bodyTags = ch.getBody(configuration, deprs.get(0));
|
||||
Content body = commentTagsToOutput(null, element, bodyTags, false);
|
||||
if (!body.isEmpty())
|
||||
result.addContent(HtmlTree.SPAN(HtmlStyle.deprecationComment, body));
|
||||
}
|
||||
} else {
|
||||
if (utils.isDeprecated(utils.getEnclosingTypeElement(element))) {
|
||||
result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel,
|
||||
new StringContent(configuration.getText("doclet.Deprecated"))));
|
||||
result.addContent(RawHtml.nbsp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected Content literalTagOutput(Element element, DocTree tag) {
|
||||
CommentHelper ch = utils.getCommentHelper(element);
|
||||
Content result = new StringContent(utils.normalizeNewlines(ch.getText(tag)));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public MessageRetriever getMsgRetriever() {
|
||||
return configuration.message;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getParamHeader(String header) {
|
||||
HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.paramLabel,
|
||||
new StringContent(header)));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content paramTagOutput(Element element, DocTree paramTag, String paramName) {
|
||||
ContentBuilder body = new ContentBuilder();
|
||||
CommentHelper ch = utils.getCommentHelper(element);
|
||||
body.addContent(HtmlTree.CODE(new RawHtml(paramName)));
|
||||
body.addContent(" - ");
|
||||
List<? extends DocTree> description = ch.getDescription(configuration, paramTag);
|
||||
body.addContent(htmlWriter.commentTagsToContent(paramTag, element, description, false));
|
||||
HtmlTree result = HtmlTree.DD(body);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content propertyTagOutput(Element element, DocTree tag, String prefix) {
|
||||
Content body = new ContentBuilder();
|
||||
CommentHelper ch = utils.getCommentHelper(element);
|
||||
body.addContent(new RawHtml(prefix));
|
||||
body.addContent(" ");
|
||||
body.addContent(HtmlTree.CODE(new RawHtml(ch.getText(tag))));
|
||||
body.addContent(".");
|
||||
Content result = HtmlTree.P(body);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content returnTagOutput(Element element, DocTree returnTag) {
|
||||
ContentBuilder result = new ContentBuilder();
|
||||
CommentHelper ch = utils.getCommentHelper(element);
|
||||
result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.returnLabel,
|
||||
new StringContent(configuration.getText("doclet.Returns")))));
|
||||
result.addContent(HtmlTree.DD(htmlWriter.commentTagsToContent(
|
||||
returnTag, element, ch.getDescription(configuration, returnTag), false)));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content seeTagOutput(Element holder, List<? extends DocTree> seeTags) {
|
||||
ContentBuilder body = new ContentBuilder();
|
||||
if (!seeTags.isEmpty()) {
|
||||
for (DocTree dt : seeTags) {
|
||||
appendSeparatorIfNotEmpty(body);
|
||||
body.addContent(htmlWriter.seeTagToContent(holder, dt));
|
||||
}
|
||||
}
|
||||
if (utils.isVariableElement(holder) && ((VariableElement)holder).getConstantValue() != null &&
|
||||
htmlWriter instanceof ClassWriterImpl) {
|
||||
//Automatically add link to constant values page for constant fields.
|
||||
appendSeparatorIfNotEmpty(body);
|
||||
DocPath constantsPath =
|
||||
htmlWriter.pathToRoot.resolve(DocPaths.CONSTANT_VALUES);
|
||||
String whichConstant =
|
||||
((ClassWriterImpl) htmlWriter).getTypeElement().getQualifiedName() + "." +
|
||||
utils.getSimpleName(holder);
|
||||
DocLink link = constantsPath.fragment(whichConstant);
|
||||
body.addContent(htmlWriter.getHyperLink(link,
|
||||
new StringContent(configuration.getText("doclet.Constants_Summary"))));
|
||||
}
|
||||
if (utils.isClass(holder) && utils.isSerializable((TypeElement)holder)) {
|
||||
//Automatically add link to serialized form page for serializable classes.
|
||||
if (SerializedFormBuilder.serialInclude(utils, holder) &&
|
||||
SerializedFormBuilder.serialInclude(utils, utils.containingPackage(holder))) {
|
||||
appendSeparatorIfNotEmpty(body);
|
||||
DocPath serialPath = htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM);
|
||||
DocLink link = serialPath.fragment(utils.getFullyQualifiedName(holder));
|
||||
body.addContent(htmlWriter.getHyperLink(link,
|
||||
new StringContent(configuration.getText("doclet.Serialized_Form"))));
|
||||
}
|
||||
}
|
||||
if (body.isEmpty())
|
||||
return body;
|
||||
|
||||
ContentBuilder result = new ContentBuilder();
|
||||
result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.seeLabel,
|
||||
new StringContent(configuration.getText("doclet.See_Also")))));
|
||||
result.addContent(HtmlTree.DD(body));
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private void appendSeparatorIfNotEmpty(ContentBuilder body) {
|
||||
if (!body.isEmpty()) {
|
||||
body.addContent(", ");
|
||||
body.addContent(DocletConstants.NL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content simpleTagOutput(Element element, List<? extends DocTree> simpleTags, String header) {
|
||||
CommentHelper ch = utils.getCommentHelper(element);
|
||||
ContentBuilder result = new ContentBuilder();
|
||||
result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.simpleTagLabel, new RawHtml(header))));
|
||||
ContentBuilder body = new ContentBuilder();
|
||||
boolean many = false;
|
||||
for (DocTree simpleTag : simpleTags) {
|
||||
if (many) {
|
||||
body.addContent(", ");
|
||||
}
|
||||
List<? extends DocTree> bodyTags = ch.getBody(configuration, simpleTag);
|
||||
body.addContent(htmlWriter.commentTagsToContent(simpleTag, element, bodyTags, false));
|
||||
many = true;
|
||||
}
|
||||
result.addContent(HtmlTree.DD(body));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content simpleTagOutput(Element element, DocTree simpleTag, String header) {
|
||||
ContentBuilder result = new ContentBuilder();
|
||||
result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.simpleTagLabel, new RawHtml(header))));
|
||||
CommentHelper ch = utils.getCommentHelper(element);
|
||||
List<? extends DocTree> description = ch.getDescription(configuration, simpleTag);
|
||||
Content body = htmlWriter.commentTagsToContent(simpleTag, element, description, false);
|
||||
result.addContent(HtmlTree.DD(body));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content getThrowsHeader() {
|
||||
HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.throwsLabel,
|
||||
new StringContent(configuration.getText("doclet.Throws"))));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content throwsTagOutput(Element element, DocTree throwsTag) {
|
||||
ContentBuilder body = new ContentBuilder();
|
||||
CommentHelper ch = utils.getCommentHelper(element);
|
||||
Element exception = ch.getException(configuration, throwsTag);
|
||||
Content excName;
|
||||
if (exception == null) {
|
||||
excName = new RawHtml(ch.getExceptionName(throwsTag).toString());
|
||||
} else if (exception.asType() == null) {
|
||||
excName = new RawHtml(utils.getFullyQualifiedName(exception));
|
||||
} else {
|
||||
LinkInfoImpl link = new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER,
|
||||
exception.asType());
|
||||
link.excludeTypeBounds = true;
|
||||
excName = htmlWriter.getLink(link);
|
||||
}
|
||||
body.addContent(HtmlTree.CODE(excName));
|
||||
List<? extends DocTree> description = ch.getDescription(configuration, throwsTag);
|
||||
Content desc = htmlWriter.commentTagsToContent(throwsTag, element, description, false);
|
||||
if (desc != null && !desc.isEmpty()) {
|
||||
body.addContent(" - ");
|
||||
body.addContent(desc);
|
||||
}
|
||||
HtmlTree result = HtmlTree.DD(body);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content throwsTagOutput(TypeMirror throwsType) {
|
||||
HtmlTree result = HtmlTree.DD(HtmlTree.CODE(htmlWriter.getLink(
|
||||
new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, throwsType))));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content valueTagOutput(VariableElement field, String constantVal, boolean includeLink) {
|
||||
return includeLink ?
|
||||
htmlWriter.getDocLink(LinkInfoImpl.Kind.VALUE_TAG, field,
|
||||
constantVal, false) : new RawHtml(constantVal);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content commentTagsToOutput(DocTree holderTag, List<? extends DocTree> tags) {
|
||||
return commentTagsToOutput(holderTag, null, tags, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content commentTagsToOutput(Element holder, List<? extends DocTree> tags) {
|
||||
return commentTagsToOutput(null, holder, tags, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Content commentTagsToOutput(DocTree holderTag,
|
||||
Element holder, List<? extends DocTree> tags, boolean isFirstSentence) {
|
||||
return htmlWriter.commentTagsToContent(holderTag, holder,
|
||||
tags, isFirstSentence);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Configuration configuration() {
|
||||
return configuration;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,206 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import javax.lang.model.element.PackageElement;
|
||||
|
||||
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.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
|
||||
/**
|
||||
* Generate Class Hierarchy page for all the Classes in this run. Use
|
||||
* ClassTree for building the Tree. The name of
|
||||
* the generated file is "overview-tree.html" and it is generated in the
|
||||
* current or the destination directory.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class TreeWriter extends AbstractTreeWriter {
|
||||
|
||||
/**
|
||||
* Packages in this run.
|
||||
*/
|
||||
SortedSet<PackageElement> packages;
|
||||
|
||||
/**
|
||||
* True if there are no packages specified on the command line,
|
||||
* False otherwise.
|
||||
*/
|
||||
private boolean classesonly;
|
||||
|
||||
/**
|
||||
* Constructor to construct TreeWriter object.
|
||||
*
|
||||
* @param configuration the current configuration of the doclet.
|
||||
* @param filename String filename
|
||||
* @param classtree the tree being built.
|
||||
*/
|
||||
public TreeWriter(ConfigurationImpl configuration,
|
||||
DocPath filename, ClassTree classtree) throws IOException {
|
||||
super(configuration, filename, classtree);
|
||||
packages = configuration.packages;
|
||||
classesonly = packages.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a TreeWriter object and use it to generate the
|
||||
* "overview-tree.html" file.
|
||||
*
|
||||
* @param classtree the class tree being documented.
|
||||
* @throws DocletAbortException
|
||||
*/
|
||||
public static void generate(ConfigurationImpl configuration,
|
||||
ClassTree classtree) {
|
||||
TreeWriter treegen;
|
||||
DocPath filename = DocPaths.OVERVIEW_TREE;
|
||||
try {
|
||||
treegen = new TreeWriter(configuration, filename, classtree);
|
||||
treegen.generateTreeFile();
|
||||
treegen.close();
|
||||
} catch (IOException exc) {
|
||||
configuration.standardmessage.error(
|
||||
"doclet.exception_encountered",
|
||||
exc.toString(), filename);
|
||||
throw new DocletAbortException(exc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the interface hierarchy and class hierarchy.
|
||||
*/
|
||||
public void generateTreeFile() throws IOException {
|
||||
HtmlTree body = getTreeHeader();
|
||||
Content headContent = getResource("doclet.Hierarchy_For_All_Packages");
|
||||
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
|
||||
HtmlStyle.title, headContent);
|
||||
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
|
||||
addPackageTreeLinks(div);
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
|
||||
? HtmlTree.MAIN()
|
||||
: body;
|
||||
htmlTree.addContent(div);
|
||||
HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
|
||||
divTree.addStyle(HtmlStyle.contentContainer);
|
||||
addTree(classtree.baseClasses(), "doclet.Class_Hierarchy", divTree);
|
||||
addTree(classtree.baseInterfaces(), "doclet.Interface_Hierarchy", divTree);
|
||||
addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree);
|
||||
addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree, true);
|
||||
htmlTree.addContent(divTree);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
body.addContent(htmlTree);
|
||||
}
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
htmlTree = HtmlTree.FOOTER();
|
||||
} else {
|
||||
htmlTree = body;
|
||||
}
|
||||
addNavLinks(false, htmlTree);
|
||||
addBottom(htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.FOOTER)) {
|
||||
body.addContent(htmlTree);
|
||||
}
|
||||
printHtmlDocument(null, true, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the links to all the package tree files.
|
||||
*
|
||||
* @param contentTree the content tree to which the links will be added
|
||||
*/
|
||||
protected void addPackageTreeLinks(Content contentTree) {
|
||||
//Do nothing if only unnamed package is used
|
||||
if (isUnnamedPackage()) {
|
||||
return;
|
||||
}
|
||||
if (!classesonly) {
|
||||
Content span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel,
|
||||
getResource("doclet.Package_Hierarchies"));
|
||||
contentTree.addContent(span);
|
||||
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
||||
ul.addStyle(HtmlStyle.horizontal);
|
||||
int i = 0;
|
||||
for (PackageElement pkg : packages) {
|
||||
// If the package name length is 0 or if -nodeprecated option
|
||||
// is set and the package is marked as deprecated, do not include
|
||||
// the page in the list of package hierarchies.
|
||||
if (pkg.isUnnamed() ||
|
||||
(configuration.nodeprecated && utils.isDeprecated(pkg))) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
DocPath link = pathString(pkg, DocPaths.PACKAGE_TREE);
|
||||
Content li = HtmlTree.LI(getHyperLink(link,
|
||||
new StringContent(utils.getPackageName(pkg))));
|
||||
if (i < packages.size() - 1) {
|
||||
li.addContent(", ");
|
||||
}
|
||||
ul.addContent(li);
|
||||
i++;
|
||||
}
|
||||
contentTree.addContent(ul);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tree header.
|
||||
*
|
||||
* @return a content tree for the tree header
|
||||
*/
|
||||
protected HtmlTree getTreeHeader() {
|
||||
String title = configuration.getText("doclet.Window_Class_Hierarchy");
|
||||
HtmlTree bodyTree = getBody(true, getWindowTitle(title));
|
||||
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
|
||||
? HtmlTree.HEADER()
|
||||
: bodyTree;
|
||||
addTop(htmlTree);
|
||||
addNavLinks(true, htmlTree);
|
||||
if (configuration.allowTag(HtmlTag.HEADER)) {
|
||||
bodyTree.addContent(htmlTree);
|
||||
}
|
||||
return bodyTree;
|
||||
}
|
||||
|
||||
private boolean isUnnamedPackage() {
|
||||
return packages.size() == 1 && packages.first().isUnnamed();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,238 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
* 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.formats.html;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.lang.model.element.PackageElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeFieldWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeOptionalMemberWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeRequiredMemberWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.ClassWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.ConstantsSummaryWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.WriterFactory;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
|
||||
|
||||
import static jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.Kind.*;
|
||||
|
||||
/**
|
||||
* The factory that returns HTML writers.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Jamie Ho
|
||||
*/
|
||||
public class WriterFactoryImpl implements WriterFactory {
|
||||
|
||||
private final ConfigurationImpl configuration;
|
||||
public WriterFactoryImpl(ConfigurationImpl configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConstantsSummaryWriter getConstantsSummaryWriter() throws Exception {
|
||||
return new ConstantsSummaryWriterImpl(configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public PackageSummaryWriter getPackageSummaryWriter(PackageElement packageElement,
|
||||
PackageElement prevPkg, PackageElement nextPkg) throws Exception {
|
||||
return new PackageWriterImpl(configuration, packageElement, prevPkg, nextPkg);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ClassWriter getClassWriter(TypeElement typeElement, TypeElement prevClass,
|
||||
TypeElement nextClass, ClassTree classTree) throws IOException {
|
||||
return new ClassWriterImpl(configuration, typeElement, prevClass, nextClass, classTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public AnnotationTypeWriter getAnnotationTypeWriter(TypeElement annotationType,
|
||||
TypeMirror prevType, TypeMirror nextType) throws Exception {
|
||||
return new AnnotationTypeWriterImpl(configuration, annotationType, prevType, nextType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public AnnotationTypeFieldWriter
|
||||
getAnnotationTypeFieldWriter(AnnotationTypeWriter annotationTypeWriter) throws Exception {
|
||||
TypeElement te = annotationTypeWriter.getAnnotationTypeElement();
|
||||
return new AnnotationTypeFieldWriterImpl(
|
||||
(SubWriterHolderWriter) annotationTypeWriter, te);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public AnnotationTypeOptionalMemberWriter
|
||||
getAnnotationTypeOptionalMemberWriter(
|
||||
AnnotationTypeWriter annotationTypeWriter) throws Exception {
|
||||
TypeElement te = annotationTypeWriter.getAnnotationTypeElement();
|
||||
return new AnnotationTypeOptionalMemberWriterImpl(
|
||||
(SubWriterHolderWriter) annotationTypeWriter, te);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public AnnotationTypeRequiredMemberWriter
|
||||
getAnnotationTypeRequiredMemberWriter(AnnotationTypeWriter annotationTypeWriter) throws Exception {
|
||||
TypeElement te = annotationTypeWriter.getAnnotationTypeElement();
|
||||
return new AnnotationTypeRequiredMemberWriterImpl(
|
||||
(SubWriterHolderWriter) annotationTypeWriter, te);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public EnumConstantWriterImpl getEnumConstantWriter(ClassWriter classWriter)
|
||||
throws Exception {
|
||||
return new EnumConstantWriterImpl((SubWriterHolderWriter) classWriter,
|
||||
classWriter.getTypeElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public FieldWriterImpl getFieldWriter(ClassWriter classWriter)
|
||||
throws Exception {
|
||||
return new FieldWriterImpl((SubWriterHolderWriter) classWriter, classWriter.getTypeElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public PropertyWriterImpl getPropertyWriter(ClassWriter classWriter)
|
||||
throws Exception {
|
||||
return new PropertyWriterImpl((SubWriterHolderWriter) classWriter,
|
||||
classWriter.getTypeElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public MethodWriterImpl getMethodWriter(ClassWriter classWriter)
|
||||
throws Exception {
|
||||
return new MethodWriterImpl((SubWriterHolderWriter) classWriter, classWriter.getTypeElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ConstructorWriterImpl getConstructorWriter(ClassWriter classWriter)
|
||||
throws Exception {
|
||||
return new ConstructorWriterImpl((SubWriterHolderWriter) classWriter,
|
||||
classWriter.getTypeElement());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public MemberSummaryWriter getMemberSummaryWriter(
|
||||
ClassWriter classWriter, VisibleMemberMap.Kind memberType)
|
||||
throws Exception {
|
||||
switch (memberType) {
|
||||
case CONSTRUCTORS:
|
||||
return getConstructorWriter(classWriter);
|
||||
case ENUM_CONSTANTS:
|
||||
return getEnumConstantWriter(classWriter);
|
||||
case FIELDS:
|
||||
return getFieldWriter(classWriter);
|
||||
case PROPERTIES:
|
||||
return getPropertyWriter(classWriter);
|
||||
case INNER_CLASSES:
|
||||
return new NestedClassWriterImpl((SubWriterHolderWriter)
|
||||
classWriter, classWriter.getTypeElement());
|
||||
case METHODS:
|
||||
return getMethodWriter(classWriter);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public MemberSummaryWriter getMemberSummaryWriter(
|
||||
AnnotationTypeWriter annotationTypeWriter, VisibleMemberMap.Kind memberType)
|
||||
throws Exception {
|
||||
switch (memberType) {
|
||||
case ANNOTATION_TYPE_FIELDS:
|
||||
return (AnnotationTypeFieldWriterImpl)
|
||||
getAnnotationTypeFieldWriter(annotationTypeWriter);
|
||||
case ANNOTATION_TYPE_MEMBER_OPTIONAL:
|
||||
return (AnnotationTypeOptionalMemberWriterImpl)
|
||||
getAnnotationTypeOptionalMemberWriter(annotationTypeWriter);
|
||||
case ANNOTATION_TYPE_MEMBER_REQUIRED:
|
||||
return (AnnotationTypeRequiredMemberWriterImpl)
|
||||
getAnnotationTypeRequiredMemberWriter(annotationTypeWriter);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public SerializedFormWriter getSerializedFormWriter() throws Exception {
|
||||
return new SerializedFormWriterImpl(configuration);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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
|
||||
* 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.formats.html.markup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
|
||||
|
||||
/**
|
||||
* Class for generating a comment for HTML pages of javadoc output.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
*/
|
||||
public class Comment extends Content {
|
||||
|
||||
private String commentText;
|
||||
|
||||
/**
|
||||
* Constructor to construct a Comment object.
|
||||
*
|
||||
* @param comment comment text for the comment
|
||||
*/
|
||||
public Comment(String comment) {
|
||||
commentText = nullCheck(comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is not supported by the class.
|
||||
*
|
||||
* @param content content that needs to be added
|
||||
* @throws DocletAbortException this method will always throw a
|
||||
* DocletAbortException because it
|
||||
* is not supported.
|
||||
*/
|
||||
public void addContent(Content content) {
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is not supported by the class.
|
||||
*
|
||||
* @param stringContent string content that needs to be added
|
||||
* @throws DocletAbortException this method will always throw a
|
||||
* DocletAbortException because it
|
||||
* is not supported.
|
||||
*/
|
||||
public void addContent(String stringContent) {
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return commentText.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean write(Writer out, boolean atNewline) throws IOException {
|
||||
if (!atNewline)
|
||||
out.write(DocletConstants.NL);
|
||||
out.write("<!-- ");
|
||||
out.write(commentText);
|
||||
out.write(" -->" + DocletConstants.NL);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
* 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.formats.html.markup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
|
||||
/**
|
||||
* A sequence of Content nodes.
|
||||
*/
|
||||
public class ContentBuilder extends Content {
|
||||
protected List<Content> contents = Collections.<Content>emptyList();
|
||||
|
||||
@Override
|
||||
public void addContent(Content content) {
|
||||
nullCheck(content);
|
||||
ensureMutableContents();
|
||||
if (content instanceof ContentBuilder) {
|
||||
contents.addAll(((ContentBuilder) content).contents);
|
||||
} else
|
||||
contents.add(content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addContent(String text) {
|
||||
if (text.isEmpty())
|
||||
return;
|
||||
ensureMutableContents();
|
||||
Content c = contents.isEmpty() ? null : contents.get(contents.size() - 1);
|
||||
StringContent sc;
|
||||
if (c != null && c instanceof StringContent) {
|
||||
sc = (StringContent) c;
|
||||
} else {
|
||||
contents.add(sc = new StringContent());
|
||||
}
|
||||
sc.addContent(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(Writer writer, boolean atNewline) throws IOException {
|
||||
for (Content content: contents) {
|
||||
atNewline = content.write(writer, atNewline);
|
||||
}
|
||||
return atNewline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
for (Content content: contents) {
|
||||
if (!content.isEmpty())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int charCount() {
|
||||
int n = 0;
|
||||
for (Content c : contents)
|
||||
n += c.charCount();
|
||||
return n;
|
||||
}
|
||||
|
||||
private void ensureMutableContents() {
|
||||
if (contents.isEmpty())
|
||||
contents = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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
|
||||
* 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.formats.html.markup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
|
||||
|
||||
/**
|
||||
* Class for generating document type for HTML pages of javadoc output.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
*/
|
||||
public class DocType extends Content {
|
||||
|
||||
private String docType;
|
||||
|
||||
public static final DocType TRANSITIONAL =
|
||||
new DocType("Transitional", "http://www.w3.org/TR/html4/loose.dtd");
|
||||
|
||||
public static final DocType HTML5 = new DocType();
|
||||
|
||||
/**
|
||||
* Constructor to construct a DocType object.
|
||||
*
|
||||
* @param type the doctype to be added
|
||||
* @param dtd the dtd of the doctype
|
||||
*/
|
||||
private DocType(String type, String dtd) {
|
||||
docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " + type +
|
||||
"//EN\" \"" + dtd + "\">" + DocletConstants.NL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor to construct a DocType object.
|
||||
*/
|
||||
private DocType() {
|
||||
docType = "<!DOCTYPE HTML>" + DocletConstants.NL;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is not supported by the class.
|
||||
*
|
||||
* @param content content that needs to be added
|
||||
* @throws DocletAbortException this method will always throw a
|
||||
* DocletAbortException because it
|
||||
* is not supported.
|
||||
*/
|
||||
public void addContent(Content content) {
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is not supported by the class.
|
||||
*
|
||||
* @param stringContent string content that needs to be added
|
||||
* @throws DocletAbortException this method will always throw a
|
||||
* DocletAbortException because it
|
||||
* is not supported.
|
||||
*/
|
||||
public void addContent(String stringContent) {
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return (docType.length() == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean write(Writer out, boolean atNewline) throws IOException {
|
||||
out.write(docType);
|
||||
return true; // guaranteed by constructor
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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
|
||||
* 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.formats.html.markup;
|
||||
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
|
||||
|
||||
/**
|
||||
* Enum representing HTML tag attributes.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
*/
|
||||
public enum HtmlAttr {
|
||||
ALT,
|
||||
CLASS,
|
||||
CLEAR,
|
||||
COLS,
|
||||
CONTENT,
|
||||
DISABLED,
|
||||
HREF,
|
||||
HTTP_EQUIV("http-equiv"),
|
||||
ID,
|
||||
LANG,
|
||||
NAME,
|
||||
ONLOAD,
|
||||
REL,
|
||||
ROLE,
|
||||
ROWS,
|
||||
SCOPE,
|
||||
SCROLLING,
|
||||
SRC,
|
||||
SUMMARY,
|
||||
TARGET,
|
||||
TITLE,
|
||||
TYPE,
|
||||
VALUE,
|
||||
WIDTH;
|
||||
|
||||
private final String value;
|
||||
|
||||
public enum Role {
|
||||
|
||||
BANNER,
|
||||
CONTENTINFO,
|
||||
MAIN,
|
||||
NAVIGATION,
|
||||
REGION;
|
||||
|
||||
private final String role;
|
||||
|
||||
Role() {
|
||||
role = Utils.toLowerCase(name());
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return role;
|
||||
}
|
||||
}
|
||||
|
||||
HtmlAttr() {
|
||||
this.value = Utils.toLowerCase(name());
|
||||
}
|
||||
|
||||
HtmlAttr(String name) {
|
||||
this.value = name;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,223 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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
|
||||
* 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.formats.html.markup;
|
||||
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
|
||||
/**
|
||||
* Stores constants for Html Doclet.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
*/
|
||||
public class HtmlConstants {
|
||||
|
||||
/**
|
||||
* Marker to identify start of top navigation bar.
|
||||
*/
|
||||
public static final Content START_OF_TOP_NAVBAR =
|
||||
new Comment("========= START OF TOP NAVBAR =======");
|
||||
|
||||
/**
|
||||
* Marker to identify start of bottom navigation bar.
|
||||
*/
|
||||
public static final Content START_OF_BOTTOM_NAVBAR =
|
||||
new Comment("======= START OF BOTTOM NAVBAR ======");
|
||||
|
||||
/**
|
||||
* Marker to identify end of top navigation bar.
|
||||
*/
|
||||
public static final Content END_OF_TOP_NAVBAR =
|
||||
new Comment("========= END OF TOP NAVBAR =========");
|
||||
|
||||
/**
|
||||
* Marker to identify end of bottom navigation bar.
|
||||
*/
|
||||
public static final Content END_OF_BOTTOM_NAVBAR =
|
||||
new Comment("======== END OF BOTTOM NAVBAR =======");
|
||||
|
||||
/**
|
||||
* Marker to identify start of class data.
|
||||
*/
|
||||
public static final Content START_OF_CLASS_DATA =
|
||||
new Comment("======== START OF CLASS DATA ========");
|
||||
|
||||
/**
|
||||
* Marker to identify end of class data.
|
||||
*/
|
||||
public static final Content END_OF_CLASS_DATA =
|
||||
new Comment("========= END OF CLASS DATA =========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of nested class summary.
|
||||
*/
|
||||
public static final Content START_OF_NESTED_CLASS_SUMMARY =
|
||||
new Comment("======== NESTED CLASS SUMMARY ========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of annotation type optional member summary.
|
||||
*/
|
||||
public static final Content START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY =
|
||||
new Comment("=========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY ===========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of annotation type required member summary.
|
||||
*/
|
||||
public static final Content START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY =
|
||||
new Comment("=========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY ===========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of annotation type required member summary.
|
||||
*/
|
||||
public static final Content START_OF_ANNOTATION_TYPE_FIELD_SUMMARY =
|
||||
new Comment("=========== ANNOTATION TYPE FIELD SUMMARY ===========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of constructor summary.
|
||||
*/
|
||||
public static final Content START_OF_CONSTRUCTOR_SUMMARY =
|
||||
new Comment("======== CONSTRUCTOR SUMMARY ========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of enum constants summary.
|
||||
*/
|
||||
public static final Content START_OF_ENUM_CONSTANT_SUMMARY =
|
||||
new Comment("=========== ENUM CONSTANT SUMMARY ===========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of field summary.
|
||||
*/
|
||||
public static final Content START_OF_FIELD_SUMMARY =
|
||||
new Comment("=========== FIELD SUMMARY ===========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of properties summary.
|
||||
*/
|
||||
public static final Content START_OF_PROPERTY_SUMMARY =
|
||||
new Comment("=========== PROPERTY SUMMARY ===========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of method summary.
|
||||
*/
|
||||
public static final Content START_OF_METHOD_SUMMARY =
|
||||
new Comment("========== METHOD SUMMARY ===========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of annotation type details.
|
||||
*/
|
||||
public static final Content START_OF_ANNOTATION_TYPE_DETAILS =
|
||||
new Comment("============ ANNOTATION TYPE MEMBER DETAIL ===========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of annotation type field details.
|
||||
*/
|
||||
public static final Content START_OF_ANNOTATION_TYPE_FIELD_DETAILS =
|
||||
new Comment("============ ANNOTATION TYPE FIELD DETAIL ===========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of method details.
|
||||
*/
|
||||
public static final Content START_OF_METHOD_DETAILS =
|
||||
new Comment("============ METHOD DETAIL ==========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of field details.
|
||||
*/
|
||||
public static final Content START_OF_FIELD_DETAILS =
|
||||
new Comment("============ FIELD DETAIL ===========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of property details.
|
||||
*/
|
||||
public static final Content START_OF_PROPERTY_DETAILS =
|
||||
new Comment("============ PROPERTY DETAIL ===========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of constructor details.
|
||||
*/
|
||||
public static final Content START_OF_CONSTRUCTOR_DETAILS =
|
||||
new Comment("========= CONSTRUCTOR DETAIL ========");
|
||||
|
||||
/**
|
||||
* Marker to identify start of enum constants details.
|
||||
*/
|
||||
public static final Content START_OF_ENUM_CONSTANT_DETAILS =
|
||||
new Comment("============ ENUM CONSTANT DETAIL ===========");
|
||||
|
||||
/**
|
||||
* Html tag for the page title heading.
|
||||
*/
|
||||
public static final HtmlTag TITLE_HEADING = HtmlTag.H1;
|
||||
|
||||
/**
|
||||
* Html tag for the class page title heading.
|
||||
*/
|
||||
public static final HtmlTag CLASS_PAGE_HEADING = HtmlTag.H2;
|
||||
|
||||
/**
|
||||
* Html tag for the content heading.
|
||||
*/
|
||||
public static final HtmlTag CONTENT_HEADING = HtmlTag.H2;
|
||||
|
||||
/**
|
||||
* Html tag for the package name heading.
|
||||
*/
|
||||
public static final HtmlTag PACKAGE_HEADING = HtmlTag.H2;
|
||||
|
||||
/**
|
||||
* Html tag for the member summary heading.
|
||||
*/
|
||||
public static final HtmlTag SUMMARY_HEADING = HtmlTag.H3;
|
||||
|
||||
/**
|
||||
* Html tag for the inherited member summary heading.
|
||||
*/
|
||||
public static final HtmlTag INHERITED_SUMMARY_HEADING = HtmlTag.H3;
|
||||
|
||||
/**
|
||||
* Html tag for the member details heading.
|
||||
*/
|
||||
public static final HtmlTag DETAILS_HEADING = HtmlTag.H3;
|
||||
|
||||
/**
|
||||
* Html tag for the serialized member heading.
|
||||
*/
|
||||
public static final HtmlTag SERIALIZED_MEMBER_HEADING = HtmlTag.H3;
|
||||
|
||||
/**
|
||||
* Html tag for the member heading.
|
||||
*/
|
||||
public static final HtmlTag MEMBER_HEADING = HtmlTag.H4;
|
||||
|
||||
/**
|
||||
* Default charset for HTML.
|
||||
*/
|
||||
public static final String HTML_DEFAULT_CHARSET = "utf-8";
|
||||
}
|
||||
@ -0,0 +1,361 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html.markup;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.lang.model.element.PackageElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
import jdk.javadoc.internal.doclets.formats.html.ConfigurationImpl;
|
||||
import jdk.javadoc.internal.doclets.formats.html.SectionName;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Configuration;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
|
||||
|
||||
/**
|
||||
* Class for the Html Format Code Generation specific to JavaDoc.
|
||||
* This Class contains methods related to the Html Code Generation which
|
||||
* are used by the Sub-Classes in the package jdk.javadoc.internal.tool.standard.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
* @author Robert Field
|
||||
*/
|
||||
public abstract class HtmlDocWriter extends HtmlWriter {
|
||||
|
||||
public static final String CONTENT_TYPE = "text/html";
|
||||
|
||||
DocPath pathToRoot;
|
||||
|
||||
/**
|
||||
* Constructor. Initializes the destination file name through the super
|
||||
* class HtmlWriter.
|
||||
*
|
||||
* @param filename String file name.
|
||||
*/
|
||||
public HtmlDocWriter(Configuration configuration, DocPath filename)
|
||||
throws IOException {
|
||||
super(configuration, filename);
|
||||
this.pathToRoot = filename.parent().invert();
|
||||
configuration.message.notice("doclet.Generating_0",
|
||||
DocFile.createFileForOutput(configuration, filename).getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessor for configuration.
|
||||
*/
|
||||
public abstract Configuration configuration();
|
||||
|
||||
public Content getHyperLink(DocPath link, String label) {
|
||||
return getHyperLink(link, new StringContent(label), false, "", "", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Html Hyper Link Content.
|
||||
*
|
||||
* @param where Position of the link in the file. Character '#' is not
|
||||
* needed.
|
||||
* @param label Tag for the link.
|
||||
* @return a content tree for the hyper link
|
||||
*/
|
||||
public Content getHyperLink(String where,
|
||||
Content label) {
|
||||
return getHyperLink(getDocLink(where), label, "", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Html Hyper Link Content.
|
||||
*
|
||||
* @param sectionName The section name to which the link will be created.
|
||||
* @param label Tag for the link.
|
||||
* @return a content tree for the hyper link
|
||||
*/
|
||||
public Content getHyperLink(SectionName sectionName,
|
||||
Content label) {
|
||||
return getHyperLink(getDocLink(sectionName), label, "", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Html Hyper Link Content.
|
||||
*
|
||||
* @param sectionName The section name combined with where to which the link
|
||||
* will be created.
|
||||
* @param where The fragment combined with sectionName to which the link
|
||||
* will be created.
|
||||
* @param label Tag for the link.
|
||||
* @return a content tree for the hyper link
|
||||
*/
|
||||
public Content getHyperLink(SectionName sectionName, String where,
|
||||
Content label) {
|
||||
return getHyperLink(getDocLink(sectionName, where), label, "", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the link.
|
||||
*
|
||||
* @param where Position of the link in the file.
|
||||
* @return a DocLink object for the hyper link
|
||||
*/
|
||||
public DocLink getDocLink(String where) {
|
||||
return DocLink.fragment(getName(where));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the link.
|
||||
*
|
||||
* @param sectionName The section name to which the link will be created.
|
||||
* @return a DocLink object for the hyper link
|
||||
*/
|
||||
public DocLink getDocLink(SectionName sectionName) {
|
||||
return DocLink.fragment(sectionName.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the link.
|
||||
*
|
||||
* @param sectionName The section name combined with where to which the link
|
||||
* will be created.
|
||||
* @param where The fragment combined with sectionName to which the link
|
||||
* will be created.
|
||||
* @return a DocLink object for the hyper link
|
||||
*/
|
||||
public DocLink getDocLink(SectionName sectionName, String where) {
|
||||
return DocLink.fragment(sectionName.getName() + getName(where));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the name to a valid HTML name.
|
||||
*
|
||||
* @param name the name that needs to be converted to valid HTML name.
|
||||
* @return a valid HTML name string.
|
||||
*/
|
||||
public String getName(String name) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
char ch;
|
||||
/* The HTML 4 spec at http://www.w3.org/TR/html4/types.html#h-6.2 mentions
|
||||
* that the name/id should begin with a letter followed by other valid characters.
|
||||
* The HTML 5 spec (draft) is more permissive on names/ids where the only restriction
|
||||
* is that it should be at least one character long and should not contain spaces.
|
||||
* The spec draft is @ http://www.w3.org/html/wg/drafts/html/master/dom.html#the-id-attribute.
|
||||
*
|
||||
* For HTML 4, we need to check for non-characters at the beginning of the name and
|
||||
* substitute it accordingly, "_" and "$" can appear at the beginning of a member name.
|
||||
* The method substitutes "$" with "Z:Z:D" and will prefix "_" with "Z:Z".
|
||||
*/
|
||||
for (int i = 0; i < name.length(); i++) {
|
||||
ch = name.charAt(i);
|
||||
switch (ch) {
|
||||
case '(':
|
||||
case ')':
|
||||
case '<':
|
||||
case '>':
|
||||
case ',':
|
||||
sb.append('-');
|
||||
break;
|
||||
case ' ':
|
||||
case '[':
|
||||
break;
|
||||
case ']':
|
||||
sb.append(":A");
|
||||
break;
|
||||
// Any appearance of $ needs to be substituted with ":D" and not with hyphen
|
||||
// since a field name "P$$ and a method P(), both valid member names, can end
|
||||
// up as "P--". A member name beginning with $ needs to be substituted with
|
||||
// "Z:Z:D".
|
||||
case '$':
|
||||
if (i == 0)
|
||||
sb.append("Z:Z");
|
||||
sb.append(":D");
|
||||
break;
|
||||
// A member name beginning with _ needs to be prefixed with "Z:Z" since valid anchor
|
||||
// names can only begin with a letter.
|
||||
case '_':
|
||||
if (i == 0)
|
||||
sb.append("Z:Z");
|
||||
sb.append(ch);
|
||||
break;
|
||||
default:
|
||||
sb.append(ch);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Html hyperlink.
|
||||
*
|
||||
* @param link path of the file.
|
||||
* @param label Tag for the link.
|
||||
* @return a content tree for the hyper link
|
||||
*/
|
||||
public Content getHyperLink(DocPath link, Content label) {
|
||||
return getHyperLink(link, label, "", "");
|
||||
}
|
||||
|
||||
public Content getHyperLink(DocLink link, Content label) {
|
||||
return getHyperLink(link, label, "", "");
|
||||
}
|
||||
|
||||
public Content getHyperLink(DocPath link,
|
||||
Content label, boolean strong,
|
||||
String stylename, String title, String target) {
|
||||
return getHyperLink(new DocLink(link), label, strong,
|
||||
stylename, title, target);
|
||||
}
|
||||
|
||||
public Content getHyperLink(DocLink link,
|
||||
Content label, boolean strong,
|
||||
String stylename, String title, String target) {
|
||||
Content body = label;
|
||||
if (strong) {
|
||||
body = HtmlTree.SPAN(HtmlStyle.typeNameLink, body);
|
||||
}
|
||||
if (stylename != null && stylename.length() != 0) {
|
||||
HtmlTree t = new HtmlTree(HtmlTag.FONT, body);
|
||||
t.addAttr(HtmlAttr.CLASS, stylename);
|
||||
body = t;
|
||||
}
|
||||
HtmlTree l = HtmlTree.A(link.toString(), body);
|
||||
if (title != null && title.length() != 0) {
|
||||
l.addAttr(HtmlAttr.TITLE, title);
|
||||
}
|
||||
if (target != null && target.length() != 0) {
|
||||
l.addAttr(HtmlAttr.TARGET, target);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Html Hyper Link.
|
||||
*
|
||||
* @param link String name of the file.
|
||||
* @param label Tag for the link.
|
||||
* @param title String that describes the link's content for accessibility.
|
||||
* @param target Target frame.
|
||||
* @return a content tree for the hyper link.
|
||||
*/
|
||||
public Content getHyperLink(DocPath link, Content label, String title, String target) {
|
||||
return getHyperLink(new DocLink(link), label, title, target);
|
||||
}
|
||||
|
||||
public Content getHyperLink(DocLink link, Content label, String title, String target) {
|
||||
HtmlTree anchor = HtmlTree.A(link.toString(), label);
|
||||
if (title != null && title.length() != 0) {
|
||||
anchor.addAttr(HtmlAttr.TITLE, title);
|
||||
}
|
||||
if (target != null && target.length() != 0) {
|
||||
anchor.addAttr(HtmlAttr.TARGET, target);
|
||||
}
|
||||
return anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the enclosed name of the package
|
||||
*
|
||||
* @param te TypeElement
|
||||
* @return the name
|
||||
*/
|
||||
public String getEnclosingPackageName(TypeElement te) {
|
||||
|
||||
PackageElement encl = configuration.utils.containingPackage(te);
|
||||
return (encl.isUnnamed()) ? "" : (encl.getQualifiedName() + ".");
|
||||
}
|
||||
|
||||
public boolean getMemberDetailsListPrinted() {
|
||||
return memberDetailsListPrinted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the frames version of the Html file header.
|
||||
* Called only when generating an HTML frames file.
|
||||
*
|
||||
* @param title Title of this HTML document
|
||||
* @param configuration the configuration object
|
||||
* @param body the body content tree to be added to the HTML document
|
||||
*/
|
||||
public void printFramesDocument(String title, ConfigurationImpl configuration,
|
||||
HtmlTree body) throws IOException {
|
||||
Content htmlDocType = configuration.isOutputHtml5()
|
||||
? DocType.HTML5
|
||||
: DocType.TRANSITIONAL;
|
||||
Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
|
||||
Content head = new HtmlTree(HtmlTag.HEAD);
|
||||
head.addContent(getGeneratedBy(!configuration.notimestamp));
|
||||
Content windowTitle = HtmlTree.TITLE(new StringContent(title));
|
||||
head.addContent(windowTitle);
|
||||
Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE,
|
||||
(configuration.charset.length() > 0) ?
|
||||
configuration.charset : HtmlConstants.HTML_DEFAULT_CHARSET);
|
||||
head.addContent(meta);
|
||||
head.addContent(getStyleSheetProperties(configuration));
|
||||
head.addContent(getFramesJavaScript());
|
||||
Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
|
||||
head, body);
|
||||
Content htmlDocument = new HtmlDocument(htmlDocType,
|
||||
htmlComment, htmlTree);
|
||||
write(htmlDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a link to the stylesheet file.
|
||||
*
|
||||
* @return an HtmlTree for the lINK tag which provides the stylesheet location
|
||||
*/
|
||||
public HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) {
|
||||
String stylesheetfile = configuration.stylesheetfile;
|
||||
DocPath stylesheet;
|
||||
if (stylesheetfile.isEmpty()) {
|
||||
stylesheet = DocPaths.STYLESHEET;
|
||||
} else {
|
||||
DocFile file = DocFile.createFileForInput(configuration, stylesheetfile);
|
||||
stylesheet = DocPath.create(file.getName());
|
||||
}
|
||||
HtmlTree link = HtmlTree.LINK("stylesheet", "text/css",
|
||||
pathToRoot.resolve(stylesheet).getPath(),
|
||||
"Style");
|
||||
return link;
|
||||
}
|
||||
|
||||
protected Comment getGeneratedBy(boolean timestamp) {
|
||||
String text = "Generated by javadoc"; // marker string, deliberately not localized
|
||||
if (timestamp) {
|
||||
Calendar calendar = new GregorianCalendar(TimeZone.getDefault());
|
||||
Date today = calendar.getTime();
|
||||
text += " ("+ configuration.getDocletSpecificBuildDate() + ") on " + today;
|
||||
}
|
||||
return new Comment(text);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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
|
||||
* 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.formats.html.markup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.*;
|
||||
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
|
||||
/**
|
||||
* Class for generating an HTML document for javadoc output.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
*/
|
||||
public class HtmlDocument extends Content {
|
||||
|
||||
private List<Content> docContent = Collections.<Content>emptyList();
|
||||
|
||||
/**
|
||||
* Constructor to construct an HTML document.
|
||||
*
|
||||
* @param docType document type for the HTML document
|
||||
* @param docComment comment for the document
|
||||
* @param htmlTree HTML tree of the document
|
||||
*/
|
||||
public HtmlDocument(Content docType, Content docComment, Content htmlTree) {
|
||||
docContent = new ArrayList<>();
|
||||
addContent(nullCheck(docType));
|
||||
addContent(nullCheck(docComment));
|
||||
addContent(nullCheck(htmlTree));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor to construct an HTML document.
|
||||
*
|
||||
* @param docType document type for the HTML document
|
||||
* @param htmlTree HTML tree of the document
|
||||
*/
|
||||
public HtmlDocument(Content docType, Content htmlTree) {
|
||||
docContent = new ArrayList<>();
|
||||
addContent(nullCheck(docType));
|
||||
addContent(nullCheck(htmlTree));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds content for the HTML document.
|
||||
*
|
||||
* @param htmlContent html content to be added
|
||||
*/
|
||||
public final void addContent(Content htmlContent) {
|
||||
if (htmlContent.isValid())
|
||||
docContent.add(htmlContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is not supported by the class.
|
||||
*
|
||||
* @param stringContent string content that needs to be added
|
||||
* @throws DocletAbortException this method will always throw a
|
||||
* DocletAbortException because it
|
||||
* is not supported.
|
||||
*/
|
||||
public void addContent(String stringContent) {
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return (docContent.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean write(Writer out, boolean atNewline) throws IOException {
|
||||
for (Content c : docContent)
|
||||
atNewline = c.write(out, atNewline);
|
||||
return atNewline;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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
|
||||
* 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.formats.html.markup;
|
||||
|
||||
/**
|
||||
* Enum representing HTML styles. The name map to values in the CSS file.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
*/
|
||||
public enum HtmlStyle {
|
||||
aboutLanguage,
|
||||
activeTableTab,
|
||||
altColor,
|
||||
bar,
|
||||
block,
|
||||
blockList,
|
||||
blockListLast,
|
||||
bottomNav,
|
||||
circle,
|
||||
classUseContainer,
|
||||
colFirst,
|
||||
colLast,
|
||||
colOne,
|
||||
constantsSummary,
|
||||
constantValuesContainer,
|
||||
contentContainer,
|
||||
deprecatedContent,
|
||||
deprecatedLabel,
|
||||
deprecatedSummary,
|
||||
deprecationComment,
|
||||
description,
|
||||
descfrmTypeLabel,
|
||||
details,
|
||||
docSummary,
|
||||
emphasizedPhrase,
|
||||
fixedNav,
|
||||
header,
|
||||
horizontal,
|
||||
footer,
|
||||
indexContainer,
|
||||
indexNav,
|
||||
inheritance,
|
||||
interfaceName,
|
||||
leftContainer,
|
||||
leftTop,
|
||||
leftBottom,
|
||||
legalCopy,
|
||||
mainContainer,
|
||||
memberNameLabel,
|
||||
memberNameLink,
|
||||
memberSummary,
|
||||
nameValue,
|
||||
navBarCell1Rev,
|
||||
navList,
|
||||
navListSearch,
|
||||
overrideSpecifyLabel,
|
||||
overviewSummary,
|
||||
packageHierarchyLabel,
|
||||
paramLabel,
|
||||
returnLabel,
|
||||
rightContainer,
|
||||
rightIframe,
|
||||
rowColor,
|
||||
searchTagLink,
|
||||
seeLabel,
|
||||
serializedFormContainer,
|
||||
simpleTagLabel,
|
||||
skipNav,
|
||||
sourceContainer,
|
||||
sourceLineNo,
|
||||
subNav,
|
||||
subNavList,
|
||||
subTitle,
|
||||
summary,
|
||||
tabEnd,
|
||||
tableTab,
|
||||
throwsLabel,
|
||||
title,
|
||||
topNav,
|
||||
typeNameLabel,
|
||||
typeNameLink,
|
||||
typeSummary,
|
||||
useSummary
|
||||
}
|
||||
@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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
|
||||
* 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.formats.html.markup;
|
||||
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
|
||||
|
||||
/**
|
||||
* Enum representing HTML tags.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
*/
|
||||
public enum HtmlTag {
|
||||
A(BlockType.INLINE, EndTag.END),
|
||||
BLOCKQUOTE,
|
||||
BODY(BlockType.OTHER, EndTag.END),
|
||||
BR(BlockType.INLINE, EndTag.NOEND),
|
||||
CAPTION,
|
||||
CENTER(HtmlVersion.HTML4),
|
||||
CODE(BlockType.INLINE, EndTag.END),
|
||||
DD,
|
||||
DIR(HtmlVersion.HTML4),
|
||||
DIV,
|
||||
DL,
|
||||
DT,
|
||||
EM(BlockType.INLINE, EndTag.END),
|
||||
FONT(HtmlVersion.HTML4, BlockType.INLINE, EndTag.END),
|
||||
FOOTER(HtmlVersion.HTML5),
|
||||
H1,
|
||||
H2,
|
||||
H3,
|
||||
H4,
|
||||
H5,
|
||||
H6,
|
||||
HEAD(BlockType.OTHER, EndTag.END),
|
||||
HEADER(HtmlVersion.HTML5),
|
||||
HR(BlockType.BLOCK, EndTag.NOEND),
|
||||
HTML(BlockType.OTHER, EndTag.END),
|
||||
I(BlockType.INLINE, EndTag.END),
|
||||
IFRAME(BlockType.OTHER, EndTag.END),
|
||||
IMG(BlockType.INLINE, EndTag.NOEND),
|
||||
INPUT(BlockType.BLOCK, EndTag.NOEND),
|
||||
LI,
|
||||
LISTING,
|
||||
LINK(BlockType.OTHER, EndTag.NOEND),
|
||||
MAIN(HtmlVersion.HTML5),
|
||||
MENU,
|
||||
META(BlockType.OTHER, EndTag.NOEND),
|
||||
NAV(HtmlVersion.HTML5),
|
||||
NOSCRIPT(BlockType.OTHER, EndTag.END),
|
||||
OL,
|
||||
P,
|
||||
PRE,
|
||||
SCRIPT(BlockType.OTHER, EndTag.END),
|
||||
SECTION(HtmlVersion.HTML5),
|
||||
SMALL(BlockType.INLINE, EndTag.END),
|
||||
SPAN(BlockType.INLINE, EndTag.END),
|
||||
STRONG(BlockType.INLINE, EndTag.END),
|
||||
SUB(BlockType.INLINE, EndTag.END),
|
||||
TABLE,
|
||||
TBODY,
|
||||
TD,
|
||||
TH,
|
||||
TITLE(BlockType.OTHER, EndTag.END),
|
||||
TR,
|
||||
TT(HtmlVersion.HTML4, BlockType.INLINE, EndTag.END),
|
||||
UL;
|
||||
|
||||
public final BlockType blockType;
|
||||
public final EndTag endTag;
|
||||
public final String value;
|
||||
public final HtmlVersion htmlVersion;
|
||||
|
||||
/**
|
||||
* Enum representing the type of HTML element.
|
||||
*/
|
||||
public static enum BlockType {
|
||||
BLOCK,
|
||||
INLINE,
|
||||
OTHER
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum representing HTML end tag requirement.
|
||||
*/
|
||||
public static enum EndTag {
|
||||
END,
|
||||
NOEND
|
||||
}
|
||||
|
||||
HtmlTag() {
|
||||
this(HtmlVersion.ALL, BlockType.BLOCK, EndTag.END);
|
||||
}
|
||||
|
||||
HtmlTag(HtmlVersion htmlVersion) {
|
||||
this(htmlVersion, BlockType.BLOCK, EndTag.END);
|
||||
}
|
||||
|
||||
HtmlTag(BlockType blockType, EndTag endTag ) {
|
||||
this(HtmlVersion.ALL, blockType, endTag);
|
||||
}
|
||||
|
||||
HtmlTag(HtmlVersion htmlVersion, BlockType blockType, EndTag endTag ) {
|
||||
this.htmlVersion = htmlVersion;
|
||||
this.blockType = blockType;
|
||||
this.endTag = endTag;
|
||||
this.value = Utils.toLowerCase(name());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the end tag is required. This is specific to the standard
|
||||
* doclet and does not exactly resemble the W3C specifications.
|
||||
*
|
||||
* @return true if end tag needs to be displayed else return false
|
||||
*/
|
||||
public boolean endTagRequired() {
|
||||
return (endTag == EndTag.END);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the tag is allowed in the output HTML version of this javadoc run.
|
||||
*
|
||||
* @param htmlVer the output HTML version for this javadoc run
|
||||
* @return true if the tag is allowed
|
||||
*/
|
||||
public boolean allowTag(HtmlVersion htmlVer) {
|
||||
return (this.htmlVersion == HtmlVersion.ALL || this.htmlVersion == htmlVer);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,978 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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
|
||||
* 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.formats.html.markup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr.Role;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
|
||||
|
||||
/**
|
||||
* Class for generating HTML tree for javadoc output.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
*/
|
||||
public class HtmlTree extends Content {
|
||||
|
||||
private HtmlTag htmlTag;
|
||||
private Map<HtmlAttr,String> attrs = Collections.<HtmlAttr,String>emptyMap();
|
||||
private List<Content> content = Collections.<Content>emptyList();
|
||||
public static final Content EMPTY = new StringContent("");
|
||||
|
||||
/**
|
||||
* Constructor to construct HtmlTree object.
|
||||
*
|
||||
* @param tag HTML tag for the HtmlTree object
|
||||
*/
|
||||
public HtmlTree(HtmlTag tag) {
|
||||
htmlTag = nullCheck(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor to construct HtmlTree object.
|
||||
*
|
||||
* @param tag HTML tag for the HtmlTree object
|
||||
* @param contents contents to be added to the tree
|
||||
*/
|
||||
public HtmlTree(HtmlTag tag, Content... contents) {
|
||||
this(tag);
|
||||
for (Content content: contents)
|
||||
addContent(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an attribute for the HTML tag.
|
||||
*
|
||||
* @param attrName name of the attribute
|
||||
* @param attrValue value of the attribute
|
||||
*/
|
||||
public void addAttr(HtmlAttr attrName, String attrValue) {
|
||||
if (attrs.isEmpty())
|
||||
attrs = new LinkedHashMap<>(3);
|
||||
attrs.put(nullCheck(attrName), escapeHtmlChars(attrValue));
|
||||
}
|
||||
|
||||
public void setTitle(Content body) {
|
||||
addAttr(HtmlAttr.TITLE, stripHtml(body));
|
||||
}
|
||||
|
||||
public void setRole(Role role) {
|
||||
addAttr(HtmlAttr.ROLE, role.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a style for the HTML tag.
|
||||
*
|
||||
* @param style style to be added
|
||||
*/
|
||||
public void addStyle(HtmlStyle style) {
|
||||
addAttr(HtmlAttr.CLASS, style.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds content for the HTML tag.
|
||||
*
|
||||
* @param tagContent tag content to be added
|
||||
*/
|
||||
public void addContent(Content tagContent) {
|
||||
if (tagContent instanceof ContentBuilder) {
|
||||
for (Content content: ((ContentBuilder)tagContent).contents) {
|
||||
addContent(content);
|
||||
}
|
||||
}
|
||||
else if (tagContent == HtmlTree.EMPTY || tagContent.isValid()) {
|
||||
if (content.isEmpty())
|
||||
content = new ArrayList<>();
|
||||
content.add(tagContent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds a string content to the htmltree. If the last content member
|
||||
* added is a StringContent, append the string to that StringContent or else
|
||||
* create a new StringContent and add it to the html tree.
|
||||
*
|
||||
* @param stringContent string content that needs to be added
|
||||
*/
|
||||
public void addContent(String stringContent) {
|
||||
if (!content.isEmpty()) {
|
||||
Content lastContent = content.get(content.size() - 1);
|
||||
if (lastContent instanceof StringContent)
|
||||
lastContent.addContent(stringContent);
|
||||
else
|
||||
addContent(new StringContent(stringContent));
|
||||
}
|
||||
else
|
||||
addContent(new StringContent(stringContent));
|
||||
}
|
||||
|
||||
public int charCount() {
|
||||
int n = 0;
|
||||
for (Content c : content)
|
||||
n += c.charCount();
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a string, escape all special html characters and
|
||||
* return the result.
|
||||
*
|
||||
* @param s The string to check.
|
||||
* @return the original string with all of the HTML characters escaped.
|
||||
*/
|
||||
private static String escapeHtmlChars(String s) {
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char ch = s.charAt(i);
|
||||
switch (ch) {
|
||||
// only start building a new string if we need to
|
||||
case '<': case '>': case '&':
|
||||
StringBuilder sb = new StringBuilder(s.substring(0, i));
|
||||
for ( ; i < s.length(); i++) {
|
||||
ch = s.charAt(i);
|
||||
switch (ch) {
|
||||
case '<': sb.append("<"); break;
|
||||
case '>': sb.append(">"); break;
|
||||
case '&': sb.append("&"); break;
|
||||
default: sb.append(ch); break;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* A set of ASCII URI characters to be left unencoded.
|
||||
*/
|
||||
public static final BitSet NONENCODING_CHARS = new BitSet(256);
|
||||
|
||||
static {
|
||||
// alphabetic characters
|
||||
for (int i = 'a'; i <= 'z'; i++) {
|
||||
NONENCODING_CHARS.set(i);
|
||||
}
|
||||
for (int i = 'A'; i <= 'Z'; i++) {
|
||||
NONENCODING_CHARS.set(i);
|
||||
}
|
||||
// numeric characters
|
||||
for (int i = '0'; i <= '9'; i++) {
|
||||
NONENCODING_CHARS.set(i);
|
||||
}
|
||||
// Reserved characters as per RFC 3986. These are set of delimiting characters.
|
||||
String noEnc = ":/?#[]@!$&'()*+,;=";
|
||||
// Unreserved characters as per RFC 3986 which should not be percent encoded.
|
||||
noEnc += "-._~";
|
||||
for (int i = 0; i < noEnc.length(); i++) {
|
||||
NONENCODING_CHARS.set(noEnc.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
private static String encodeURL(String url) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte c : url.getBytes(Charset.forName("UTF-8"))) {
|
||||
if (NONENCODING_CHARS.get(c & 0xFF)) {
|
||||
sb.append((char) c);
|
||||
} else {
|
||||
sb.append(String.format("%%%02X", c & 0xFF));
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an HTML anchor tag.
|
||||
*
|
||||
* @param ref reference url for the anchor tag
|
||||
* @param body content for the anchor tag
|
||||
* @return an HtmlTree object
|
||||
*/
|
||||
public static HtmlTree A(String ref, Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.A, nullCheck(body));
|
||||
htmltree.addAttr(HtmlAttr.HREF, encodeURL(ref));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an HTML anchor tag with an id or a name attribute and content.
|
||||
*
|
||||
* @param htmlVersion the version of the generated HTML
|
||||
* @param attr name or id attribute for the anchor tag
|
||||
* @param body content for the anchor tag
|
||||
* @return an HtmlTree object
|
||||
*/
|
||||
public static HtmlTree A(HtmlVersion htmlVersion, String attr, Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.A);
|
||||
htmltree.addAttr((htmlVersion == HtmlVersion.HTML4)
|
||||
? HtmlAttr.NAME
|
||||
: HtmlAttr.ID,
|
||||
nullCheck(attr));
|
||||
htmltree.addContent(nullCheck(body));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an HTML anchor tag with id attribute and a body.
|
||||
*
|
||||
* @param id id for the anchor tag
|
||||
* @param body body for the anchor tag
|
||||
* @return an HtmlTree object
|
||||
*/
|
||||
public static HtmlTree A_ID(String id, Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.A);
|
||||
htmltree.addAttr(HtmlAttr.ID, nullCheck(id));
|
||||
htmltree.addContent(nullCheck(body));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a CAPTION tag with some content.
|
||||
*
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the CAPTION tag
|
||||
*/
|
||||
public static HtmlTree CAPTION(Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.CAPTION, nullCheck(body));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a CODE tag with some content.
|
||||
*
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the CODE tag
|
||||
*/
|
||||
public static HtmlTree CODE(Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.CODE, nullCheck(body));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a DD tag with some content.
|
||||
*
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the DD tag
|
||||
*/
|
||||
public static HtmlTree DD(Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.DD, nullCheck(body));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a DL tag with some content.
|
||||
*
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the DL tag
|
||||
*/
|
||||
public static HtmlTree DL(Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.DL, nullCheck(body));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a DIV tag with the style class attributes. It also encloses
|
||||
* a content.
|
||||
*
|
||||
* @param styleClass stylesheet class for the tag
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the DIV tag
|
||||
*/
|
||||
public static HtmlTree DIV(HtmlStyle styleClass, Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.DIV, nullCheck(body));
|
||||
if (styleClass != null)
|
||||
htmltree.addStyle(styleClass);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a DIV tag with some content.
|
||||
*
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the DIV tag
|
||||
*/
|
||||
public static HtmlTree DIV(Content body) {
|
||||
return DIV(null, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a DT tag with some content.
|
||||
*
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the DT tag
|
||||
*/
|
||||
public static HtmlTree DT(Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.DT, nullCheck(body));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a FOOTER tag with role attribute.
|
||||
*
|
||||
* @return an HtmlTree object for the FOOTER tag
|
||||
*/
|
||||
public static HtmlTree FOOTER() {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.FOOTER);
|
||||
htmltree.setRole(Role.CONTENTINFO);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a HEADER tag with role attribute.
|
||||
*
|
||||
* @return an HtmlTree object for the HEADER tag
|
||||
*/
|
||||
public static HtmlTree HEADER() {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.HEADER);
|
||||
htmltree.setRole(Role.BANNER);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a heading tag (h1 to h6) with the title and style class attributes. It also encloses
|
||||
* a content.
|
||||
*
|
||||
* @param headingTag the heading tag to be generated
|
||||
* @param printTitle true if title for the tag needs to be printed else false
|
||||
* @param styleClass stylesheet class for the tag
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the tag
|
||||
*/
|
||||
public static HtmlTree HEADING(HtmlTag headingTag, boolean printTitle,
|
||||
HtmlStyle styleClass, Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(headingTag, nullCheck(body));
|
||||
if (printTitle)
|
||||
htmltree.setTitle(body);
|
||||
if (styleClass != null)
|
||||
htmltree.addStyle(styleClass);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a heading tag (h1 to h6) with style class attribute. It also encloses
|
||||
* a content.
|
||||
*
|
||||
* @param headingTag the heading tag to be generated
|
||||
* @param styleClass stylesheet class for the tag
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the tag
|
||||
*/
|
||||
public static HtmlTree HEADING(HtmlTag headingTag, HtmlStyle styleClass, Content body) {
|
||||
return HEADING(headingTag, false, styleClass, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a heading tag (h1 to h6) with the title attribute. It also encloses
|
||||
* a content.
|
||||
*
|
||||
* @param headingTag the heading tag to be generated
|
||||
* @param printTitle true if the title for the tag needs to be printed else false
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the tag
|
||||
*/
|
||||
public static HtmlTree HEADING(HtmlTag headingTag, boolean printTitle, Content body) {
|
||||
return HEADING(headingTag, printTitle, null, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a heading tag (h1 to h6) with some content.
|
||||
*
|
||||
* @param headingTag the heading tag to be generated
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the tag
|
||||
*/
|
||||
public static HtmlTree HEADING(HtmlTag headingTag, Content body) {
|
||||
return HEADING(headingTag, false, null, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an HTML tag with lang attribute. It also adds head and body
|
||||
* content to the HTML tree.
|
||||
*
|
||||
* @param lang language for the HTML document
|
||||
* @param head head for the HTML tag
|
||||
* @param body body for the HTML tag
|
||||
* @return an HtmlTree object for the HTML tag
|
||||
*/
|
||||
public static HtmlTree HTML(String lang, Content head, Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.HTML, nullCheck(head), nullCheck(body));
|
||||
htmltree.addAttr(HtmlAttr.LANG, nullCheck(lang));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a IFRAME tag.
|
||||
*
|
||||
* @param src the url of the document to be shown in the frame
|
||||
* @param name specifies the name of the frame
|
||||
* @param title the title for the frame
|
||||
* @return an HtmlTree object for the IFRAME tag
|
||||
*/
|
||||
public static HtmlTree IFRAME(String src, String name, String title) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.IFRAME);
|
||||
htmltree.addAttr(HtmlAttr.SRC, nullCheck(src));
|
||||
htmltree.addAttr(HtmlAttr.NAME, nullCheck(name));
|
||||
htmltree.addAttr(HtmlAttr.TITLE, nullCheck(title));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a INPUT tag with some id.
|
||||
*
|
||||
* @param type the type of input
|
||||
* @param id id for the tag
|
||||
* @return an HtmlTree object for the INPUT tag
|
||||
*/
|
||||
public static HtmlTree INPUT(String type, String id) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.INPUT);
|
||||
htmltree.addAttr(HtmlAttr.TYPE, nullCheck(type));
|
||||
htmltree.addAttr(HtmlAttr.ID, nullCheck(id));
|
||||
htmltree.addAttr(HtmlAttr.VALUE, " ");
|
||||
htmltree.addAttr(HtmlAttr.DISABLED, "disabled");
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a LI tag with some content.
|
||||
*
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the LI tag
|
||||
*/
|
||||
public static HtmlTree LI(Content body) {
|
||||
return LI(null, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a LI tag with some content.
|
||||
*
|
||||
* @param styleClass style for the tag
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the LI tag
|
||||
*/
|
||||
public static HtmlTree LI(HtmlStyle styleClass, Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.LI, nullCheck(body));
|
||||
if (styleClass != null)
|
||||
htmltree.addStyle(styleClass);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a LINK tag with the rel, type, href and title attributes.
|
||||
*
|
||||
* @param rel relevance of the link
|
||||
* @param type type of link
|
||||
* @param href the path for the link
|
||||
* @param title title for the link
|
||||
* @return an HtmlTree object for the LINK tag
|
||||
*/
|
||||
public static HtmlTree LINK(String rel, String type, String href, String title) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.LINK);
|
||||
htmltree.addAttr(HtmlAttr.REL, nullCheck(rel));
|
||||
htmltree.addAttr(HtmlAttr.TYPE, nullCheck(type));
|
||||
htmltree.addAttr(HtmlAttr.HREF, nullCheck(href));
|
||||
htmltree.addAttr(HtmlAttr.TITLE, nullCheck(title));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a MAIN tag with role attribute.
|
||||
*
|
||||
* @return an HtmlTree object for the MAIN tag
|
||||
*/
|
||||
public static HtmlTree MAIN() {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.MAIN);
|
||||
htmltree.setRole(Role.MAIN);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a MAIN tag with role attribute and some content.
|
||||
*
|
||||
* @param body content of the MAIN tag
|
||||
* @return an HtmlTree object for the MAIN tag
|
||||
*/
|
||||
public static HtmlTree MAIN(Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.MAIN, nullCheck(body));
|
||||
htmltree.setRole(Role.MAIN);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a MAIN tag with role attribute, style attribute and some content.
|
||||
*
|
||||
* @param styleClass style of the MAIN tag
|
||||
* @param body content of the MAIN tag
|
||||
* @return an HtmlTree object for the MAIN tag
|
||||
*/
|
||||
public static HtmlTree MAIN(HtmlStyle styleClass, Content body) {
|
||||
HtmlTree htmltree = HtmlTree.MAIN(body);
|
||||
if (styleClass != null) {
|
||||
htmltree.addStyle(styleClass);
|
||||
}
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a META tag with the http-equiv, content and charset attributes.
|
||||
*
|
||||
* @param httpEquiv http equiv attribute for the META tag
|
||||
* @param content type of content
|
||||
* @param charSet character set used
|
||||
* @return an HtmlTree object for the META tag
|
||||
*/
|
||||
public static HtmlTree META(String httpEquiv, String content, String charSet) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.META);
|
||||
String contentCharset = content + "; charset=" + charSet;
|
||||
htmltree.addAttr(HtmlAttr.HTTP_EQUIV, nullCheck(httpEquiv));
|
||||
htmltree.addAttr(HtmlAttr.CONTENT, contentCharset);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a META tag with the name and content attributes.
|
||||
*
|
||||
* @param name name attribute
|
||||
* @param content type of content
|
||||
* @return an HtmlTree object for the META tag
|
||||
*/
|
||||
public static HtmlTree META(String name, String content) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.META);
|
||||
htmltree.addAttr(HtmlAttr.NAME, nullCheck(name));
|
||||
htmltree.addAttr(HtmlAttr.CONTENT, nullCheck(content));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a NAV tag with the role attribute.
|
||||
*
|
||||
* @return an HtmlTree object for the NAV tag
|
||||
*/
|
||||
public static HtmlTree NAV() {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.NAV);
|
||||
htmltree.setRole(Role.NAVIGATION);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a NOSCRIPT tag with some content.
|
||||
*
|
||||
* @param body content of the noscript tag
|
||||
* @return an HtmlTree object for the NOSCRIPT tag
|
||||
*/
|
||||
public static HtmlTree NOSCRIPT(Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.NOSCRIPT, nullCheck(body));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a P tag with some content.
|
||||
*
|
||||
* @param body content of the Paragraph tag
|
||||
* @return an HtmlTree object for the P tag
|
||||
*/
|
||||
public static HtmlTree P(Content body) {
|
||||
return P(null, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a P tag with some content.
|
||||
*
|
||||
* @param styleClass style of the Paragraph tag
|
||||
* @param body content of the Paragraph tag
|
||||
* @return an HtmlTree object for the P tag
|
||||
*/
|
||||
public static HtmlTree P(HtmlStyle styleClass, Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.P, nullCheck(body));
|
||||
if (styleClass != null)
|
||||
htmltree.addStyle(styleClass);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a SCRIPT tag with the type and src attributes.
|
||||
*
|
||||
* @param type type of link
|
||||
* @param src the path for the script
|
||||
* @return an HtmlTree object for the SCRIPT tag
|
||||
*/
|
||||
public static HtmlTree SCRIPT(String src) {
|
||||
HtmlTree htmltree = HtmlTree.SCRIPT();
|
||||
htmltree.addAttr(HtmlAttr.SRC, nullCheck(src));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a SCRIPT tag with the type attribute.
|
||||
*
|
||||
* @return an HtmlTree object for the SCRIPT tag
|
||||
*/
|
||||
public static HtmlTree SCRIPT() {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.SCRIPT);
|
||||
htmltree.addAttr(HtmlAttr.TYPE, "text/javascript");
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a SECTION tag with role attribute.
|
||||
*
|
||||
* @return an HtmlTree object for the SECTION tag
|
||||
*/
|
||||
public static HtmlTree SECTION() {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.SECTION);
|
||||
htmltree.setRole(Role.REGION);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a SECTION tag with role attribute and some content.
|
||||
*
|
||||
* @param body content of the section tag
|
||||
* @return an HtmlTree object for the SECTION tag
|
||||
*/
|
||||
public static HtmlTree SECTION(Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.SECTION, nullCheck(body));
|
||||
htmltree.setRole(Role.REGION);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a SMALL tag with some content.
|
||||
*
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the SMALL tag
|
||||
*/
|
||||
public static HtmlTree SMALL(Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.SMALL, nullCheck(body));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a SPAN tag with some content.
|
||||
*
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the SPAN tag
|
||||
*/
|
||||
public static HtmlTree SPAN(Content body) {
|
||||
return SPAN(null, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a SPAN tag with style class attribute and some content.
|
||||
*
|
||||
* @param styleClass style class for the tag
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the SPAN tag
|
||||
*/
|
||||
public static HtmlTree SPAN(HtmlStyle styleClass, Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.SPAN, nullCheck(body));
|
||||
if (styleClass != null)
|
||||
htmltree.addStyle(styleClass);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a SPAN tag with id and style class attributes. It also encloses
|
||||
* a content.
|
||||
*
|
||||
* @param id the id for the tag
|
||||
* @param styleClass stylesheet class for the tag
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the SPAN tag
|
||||
*/
|
||||
public static HtmlTree SPAN(String id, HtmlStyle styleClass, Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.SPAN, nullCheck(body));
|
||||
htmltree.addAttr(HtmlAttr.ID, nullCheck(id));
|
||||
if (styleClass != null)
|
||||
htmltree.addStyle(styleClass);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a Table tag with style class and summary attributes and some content.
|
||||
*
|
||||
* @param styleClass style of the table
|
||||
* @param summary summary for the table
|
||||
* @param body content for the table
|
||||
* @return an HtmlTree object for the TABLE tag
|
||||
*/
|
||||
public static HtmlTree TABLE(HtmlStyle styleClass, String summary, Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.TABLE, nullCheck(body));
|
||||
if (styleClass != null)
|
||||
htmltree.addStyle(styleClass);
|
||||
htmltree.addAttr(HtmlAttr.SUMMARY, nullCheck(summary));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a Table tag with style class attribute and some content.
|
||||
*
|
||||
* @param styleClass style of the table
|
||||
* @param body content for the table
|
||||
* @return an HtmlTree object for the TABLE tag
|
||||
*/
|
||||
public static HtmlTree TABLE(HtmlStyle styleClass, Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.TABLE, nullCheck(body));
|
||||
if (styleClass != null) {
|
||||
htmltree.addStyle(styleClass);
|
||||
}
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a TD tag with style class attribute and some content.
|
||||
*
|
||||
* @param styleClass style for the tag
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the TD tag
|
||||
*/
|
||||
public static HtmlTree TD(HtmlStyle styleClass, Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.TD, nullCheck(body));
|
||||
if (styleClass != null)
|
||||
htmltree.addStyle(styleClass);
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a TD tag for an HTML table with some content.
|
||||
*
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the TD tag
|
||||
*/
|
||||
public static HtmlTree TD(Content body) {
|
||||
return TD(null, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a TH tag with style class and scope attributes and some content.
|
||||
*
|
||||
* @param styleClass style for the tag
|
||||
* @param scope scope of the tag
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the TH tag
|
||||
*/
|
||||
public static HtmlTree TH(HtmlStyle styleClass, String scope, Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.TH, nullCheck(body));
|
||||
if (styleClass != null)
|
||||
htmltree.addStyle(styleClass);
|
||||
htmltree.addAttr(HtmlAttr.SCOPE, nullCheck(scope));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a TH tag with scope attribute and some content.
|
||||
*
|
||||
* @param scope scope of the tag
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the TH tag
|
||||
*/
|
||||
public static HtmlTree TH(String scope, Content body) {
|
||||
return TH(null, scope, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a TITLE tag with some content.
|
||||
*
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the TITLE tag
|
||||
*/
|
||||
public static HtmlTree TITLE(Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.TITLE, nullCheck(body));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a TR tag for an HTML table with some content.
|
||||
*
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the TR tag
|
||||
*/
|
||||
public static HtmlTree TR(Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.TR, nullCheck(body));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a UL tag with the style class attribute and some content.
|
||||
*
|
||||
* @param styleClass style for the tag
|
||||
* @param body content for the tag
|
||||
* @return an HtmlTree object for the UL tag
|
||||
*/
|
||||
public static HtmlTree UL(HtmlStyle styleClass, Content body) {
|
||||
HtmlTree htmltree = new HtmlTree(HtmlTag.UL, nullCheck(body));
|
||||
htmltree.addStyle(nullCheck(styleClass));
|
||||
return htmltree;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return (!hasContent() && !hasAttrs());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the HTML tree has content.
|
||||
*
|
||||
* @return true if the HTML tree has content else return false
|
||||
*/
|
||||
public boolean hasContent() {
|
||||
return (!content.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the HTML tree has attributes.
|
||||
*
|
||||
* @return true if the HTML tree has attributes else return false
|
||||
*/
|
||||
public boolean hasAttrs() {
|
||||
return (!attrs.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the HTML tree has a specific attribute.
|
||||
*
|
||||
* @param attrName name of the attribute to check within the HTML tree
|
||||
* @return true if the HTML tree has the specified attribute else return false
|
||||
*/
|
||||
public boolean hasAttr(HtmlAttr attrName) {
|
||||
return (attrs.containsKey(attrName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the HTML tree is valid. This check is more specific to
|
||||
* standard doclet and not exactly similar to W3C specifications. But it
|
||||
* ensures HTML validation.
|
||||
*
|
||||
* @return true if the HTML tree is valid
|
||||
*/
|
||||
public boolean isValid() {
|
||||
switch (htmlTag) {
|
||||
case A :
|
||||
return (hasAttr(HtmlAttr.NAME) || hasAttr(HtmlAttr.ID) || (hasAttr(HtmlAttr.HREF) && hasContent()));
|
||||
case BR :
|
||||
return (!hasContent() && (!hasAttrs() || hasAttr(HtmlAttr.CLEAR)));
|
||||
case IFRAME :
|
||||
return (hasAttr(HtmlAttr.SRC) && !hasContent());
|
||||
case HR :
|
||||
case INPUT:
|
||||
return (!hasContent());
|
||||
case IMG :
|
||||
return (hasAttr(HtmlAttr.SRC) && hasAttr(HtmlAttr.ALT) && !hasContent());
|
||||
case LINK :
|
||||
return (hasAttr(HtmlAttr.HREF) && !hasContent());
|
||||
case META :
|
||||
return (hasAttr(HtmlAttr.CONTENT) && !hasContent());
|
||||
case SCRIPT :
|
||||
return ((hasAttr(HtmlAttr.TYPE) && hasAttr(HtmlAttr.SRC) && !hasContent()) ||
|
||||
(hasAttr(HtmlAttr.TYPE) && hasContent()));
|
||||
default :
|
||||
return hasContent();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the element is an inline element.
|
||||
*
|
||||
* @return true if the HTML tag is an inline element
|
||||
*/
|
||||
public boolean isInline() {
|
||||
return (htmlTag.blockType == HtmlTag.BlockType.INLINE);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean write(Writer out, boolean atNewline) throws IOException {
|
||||
if (!isInline() && !atNewline)
|
||||
out.write(DocletConstants.NL);
|
||||
String tagString = htmlTag.toString();
|
||||
out.write("<");
|
||||
out.write(tagString);
|
||||
Iterator<HtmlAttr> iterator = attrs.keySet().iterator();
|
||||
HtmlAttr key;
|
||||
String value;
|
||||
while (iterator.hasNext()) {
|
||||
key = iterator.next();
|
||||
value = attrs.get(key);
|
||||
out.write(" ");
|
||||
out.write(key.toString());
|
||||
if (!value.isEmpty()) {
|
||||
out.write("=\"");
|
||||
out.write(value);
|
||||
out.write("\"");
|
||||
}
|
||||
}
|
||||
out.write(">");
|
||||
boolean nl = false;
|
||||
for (Content c : content)
|
||||
nl = c.write(out, nl);
|
||||
if (htmlTag.endTagRequired()) {
|
||||
out.write("</");
|
||||
out.write(tagString);
|
||||
out.write(">");
|
||||
}
|
||||
if (!isInline()) {
|
||||
out.write(DocletConstants.NL);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a Content node, strips all html characters and
|
||||
* return the result.
|
||||
*
|
||||
* @param body The content node to check.
|
||||
* @return the plain text from the content node
|
||||
*
|
||||
*/
|
||||
private static String stripHtml(Content body) {
|
||||
String rawString = body.toString();
|
||||
// remove HTML tags
|
||||
rawString = rawString.replaceAll("\\<.*?>", " ");
|
||||
// consolidate multiple spaces between a word to a single space
|
||||
rawString = rawString.replaceAll("\\b\\s{2,}\\b", " ");
|
||||
// remove extra whitespaces
|
||||
return rawString.trim();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
* 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.formats.html.markup;
|
||||
|
||||
/**
|
||||
* Enum representing the version of HTML generated by javadoc.
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
*/
|
||||
public enum HtmlVersion {
|
||||
HTML4,
|
||||
HTML5,
|
||||
ALL
|
||||
}
|
||||
@ -0,0 +1,515 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.formats.html.markup;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import jdk.javadoc.internal.doclets.toolkit.Configuration;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.MethodTypes;
|
||||
|
||||
|
||||
/**
|
||||
* Class for the Html format code generation.
|
||||
* Initializes PrintWriter with FileWriter, to enable print
|
||||
* related methods to generate the code to the named File through FileWriter.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Atul M Dambalkar
|
||||
* @author Bhavesh Patel (Modified)
|
||||
*/
|
||||
public class HtmlWriter {
|
||||
|
||||
/**
|
||||
* The window title of this file
|
||||
*/
|
||||
protected String winTitle;
|
||||
|
||||
/**
|
||||
* The configuration
|
||||
*/
|
||||
protected Configuration configuration;
|
||||
|
||||
/**
|
||||
* The flag to indicate whether a member details list is printed or not.
|
||||
*/
|
||||
protected boolean memberDetailsListPrinted;
|
||||
|
||||
/**
|
||||
* Header for tables displaying packages and description..
|
||||
*/
|
||||
protected final List<String> packageTableHeader;
|
||||
|
||||
/**
|
||||
* Summary for use tables displaying class and package use.
|
||||
*/
|
||||
protected final String useTableSummary;
|
||||
|
||||
/**
|
||||
* Column header for class docs displaying Modifier and Type header.
|
||||
*/
|
||||
protected final String modifierTypeHeader;
|
||||
|
||||
public final Content overviewLabel;
|
||||
|
||||
public final Content defaultPackageLabel;
|
||||
|
||||
public final Content packageLabel;
|
||||
|
||||
public final Content useLabel;
|
||||
|
||||
public final Content prevLabel;
|
||||
|
||||
public final Content nextLabel;
|
||||
|
||||
public final Content prevclassLabel;
|
||||
|
||||
public final Content nextclassLabel;
|
||||
|
||||
public final Content summaryLabel;
|
||||
|
||||
public final Content detailLabel;
|
||||
|
||||
public final Content framesLabel;
|
||||
|
||||
public final Content noframesLabel;
|
||||
|
||||
public final Content treeLabel;
|
||||
|
||||
public final Content classLabel;
|
||||
|
||||
public final Content deprecatedLabel;
|
||||
|
||||
public final Content deprecatedPhrase;
|
||||
|
||||
public final Content allclassesLabel;
|
||||
|
||||
public final Content allpackagesLabel;
|
||||
|
||||
public final Content indexLabel;
|
||||
|
||||
public final Content helpLabel;
|
||||
|
||||
public final Content seeLabel;
|
||||
|
||||
public final Content descriptionLabel;
|
||||
|
||||
public final Content prevpackageLabel;
|
||||
|
||||
public final Content nextpackageLabel;
|
||||
|
||||
public final Content packagesLabel;
|
||||
|
||||
public final Content methodDetailsLabel;
|
||||
|
||||
public final Content annotationTypeDetailsLabel;
|
||||
|
||||
public final Content fieldDetailsLabel;
|
||||
|
||||
public final Content propertyDetailsLabel;
|
||||
|
||||
public final Content constructorDetailsLabel;
|
||||
|
||||
public final Content enumConstantsDetailsLabel;
|
||||
|
||||
public final Content specifiedByLabel;
|
||||
|
||||
public final Content overridesLabel;
|
||||
|
||||
public final Content descfrmClassLabel;
|
||||
|
||||
public final Content descfrmInterfaceLabel;
|
||||
|
||||
private final Writer writer;
|
||||
|
||||
protected Content script;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param path The directory path to be created for this file
|
||||
* or null if none to be created.
|
||||
* @exception IOException Exception raised by the FileWriter is passed on
|
||||
* to next level.
|
||||
* @exception UnsupportedEncodingException Exception raised by the
|
||||
* OutputStreamWriter is passed on to next level.
|
||||
*/
|
||||
public HtmlWriter(Configuration configuration, DocPath path)
|
||||
throws IOException, UnsupportedEncodingException {
|
||||
writer = DocFile.createFileForOutput(configuration, path).openWriter();
|
||||
this.configuration = configuration;
|
||||
this.memberDetailsListPrinted = false;
|
||||
packageTableHeader = new ArrayList<>();
|
||||
packageTableHeader.add(configuration.getText("doclet.Package"));
|
||||
packageTableHeader.add(configuration.getText("doclet.Description"));
|
||||
useTableSummary = configuration.getText("doclet.Use_Table_Summary",
|
||||
configuration.getText("doclet.packages"));
|
||||
modifierTypeHeader = configuration.getText("doclet.0_and_1",
|
||||
configuration.getText("doclet.Modifier"),
|
||||
configuration.getText("doclet.Type"));
|
||||
overviewLabel = getResource("doclet.Overview");
|
||||
defaultPackageLabel = new StringContent(DocletConstants.DEFAULT_PACKAGE_NAME);
|
||||
packageLabel = getResource("doclet.Package");
|
||||
useLabel = getResource("doclet.navClassUse");
|
||||
prevLabel = getResource("doclet.Prev");
|
||||
nextLabel = getResource("doclet.Next");
|
||||
prevclassLabel = getNonBreakResource("doclet.Prev_Class");
|
||||
nextclassLabel = getNonBreakResource("doclet.Next_Class");
|
||||
summaryLabel = getResource("doclet.Summary");
|
||||
detailLabel = getResource("doclet.Detail");
|
||||
framesLabel = getResource("doclet.Frames");
|
||||
noframesLabel = getNonBreakResource("doclet.No_Frames");
|
||||
treeLabel = getResource("doclet.Tree");
|
||||
classLabel = getResource("doclet.Class");
|
||||
deprecatedLabel = getResource("doclet.navDeprecated");
|
||||
deprecatedPhrase = getResource("doclet.Deprecated");
|
||||
allclassesLabel = getNonBreakResource("doclet.All_Classes");
|
||||
allpackagesLabel = getNonBreakResource("doclet.All_Packages");
|
||||
indexLabel = getResource("doclet.Index");
|
||||
helpLabel = getResource("doclet.Help");
|
||||
seeLabel = getResource("doclet.See");
|
||||
descriptionLabel = getResource("doclet.Description");
|
||||
prevpackageLabel = getNonBreakResource("doclet.Prev_Package");
|
||||
nextpackageLabel = getNonBreakResource("doclet.Next_Package");
|
||||
packagesLabel = getResource("doclet.Packages");
|
||||
methodDetailsLabel = getResource("doclet.Method_Detail");
|
||||
annotationTypeDetailsLabel = getResource("doclet.Annotation_Type_Member_Detail");
|
||||
fieldDetailsLabel = getResource("doclet.Field_Detail");
|
||||
propertyDetailsLabel = getResource("doclet.Property_Detail");
|
||||
constructorDetailsLabel = getResource("doclet.Constructor_Detail");
|
||||
enumConstantsDetailsLabel = getResource("doclet.Enum_Constant_Detail");
|
||||
specifiedByLabel = getResource("doclet.Specified_By");
|
||||
overridesLabel = getResource("doclet.Overrides");
|
||||
descfrmClassLabel = getResource("doclet.Description_From_Class");
|
||||
descfrmInterfaceLabel = getResource("doclet.Description_From_Interface");
|
||||
}
|
||||
|
||||
public void write(Content c) throws IOException {
|
||||
c.write(writer, true);
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration string as a content.
|
||||
*
|
||||
* @param key the key to look for in the configuration file
|
||||
* @return a content tree for the text
|
||||
*/
|
||||
public Content getResource(String key) {
|
||||
return configuration.getResource(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration string as a content, replacing spaces
|
||||
* with non-breaking spaces.
|
||||
*
|
||||
* @param key the key to look for in the configuration file
|
||||
* @return a content tree for the text
|
||||
*/
|
||||
public Content getNonBreakResource(String key) {
|
||||
String text = configuration.getText(key);
|
||||
Content c = configuration.newContent();
|
||||
int start = 0;
|
||||
int p;
|
||||
while ((p = text.indexOf(" ", start)) != -1) {
|
||||
c.addContent(text.substring(start, p));
|
||||
c.addContent(RawHtml.nbsp);
|
||||
start = p + 1;
|
||||
}
|
||||
c.addContent(text.substring(start));
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration string as a content.
|
||||
*
|
||||
* @param key the key to look for in the configuration file
|
||||
* @param o string or content argument added to configuration text
|
||||
* @return a content tree for the text
|
||||
*/
|
||||
public Content getResource(String key, Object o) {
|
||||
return configuration.getResource(key, o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration string as a content.
|
||||
*
|
||||
* @param key the key to look for in the configuration file
|
||||
* @param o1 string or content argument added to configuration text
|
||||
* @param o2 string or content argument added to configuration text
|
||||
* @return a content tree for the text
|
||||
*/
|
||||
public Content getResource(String key, Object o0, Object o1) {
|
||||
return configuration.getResource(key, o0, o1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an HtmlTree for the SCRIPT tag.
|
||||
*
|
||||
* @return an HtmlTree for the SCRIPT tag
|
||||
*/
|
||||
protected HtmlTree getWinTitleScript(){
|
||||
HtmlTree script = HtmlTree.SCRIPT();
|
||||
if(winTitle != null && winTitle.length() > 0) {
|
||||
String scriptCode = "<!--" + DocletConstants.NL +
|
||||
" try {" + DocletConstants.NL +
|
||||
" if (location.href.indexOf('is-external=true') == -1) {" + DocletConstants.NL +
|
||||
" parent.document.title=\"" + escapeJavaScriptChars(winTitle) + "\";" + DocletConstants.NL +
|
||||
" }" + DocletConstants.NL +
|
||||
" }" + DocletConstants.NL +
|
||||
" catch(err) {" + DocletConstants.NL +
|
||||
" }" + DocletConstants.NL +
|
||||
"//-->" + DocletConstants.NL;
|
||||
RawHtml scriptContent = new RawHtml(scriptCode);
|
||||
script.addContent(scriptContent);
|
||||
}
|
||||
return script;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String with escaped special JavaScript characters.
|
||||
*
|
||||
* @param s String that needs to be escaped
|
||||
* @return a valid escaped JavaScript string
|
||||
*/
|
||||
private static String escapeJavaScriptChars(String s) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char ch = s.charAt(i);
|
||||
switch (ch) {
|
||||
case '\b':
|
||||
sb.append("\\b");
|
||||
break;
|
||||
case '\t':
|
||||
sb.append("\\t");
|
||||
break;
|
||||
case '\n':
|
||||
sb.append("\\n");
|
||||
break;
|
||||
case '\f':
|
||||
sb.append("\\f");
|
||||
break;
|
||||
case '\r':
|
||||
sb.append("\\r");
|
||||
break;
|
||||
case '"':
|
||||
sb.append("\\\"");
|
||||
break;
|
||||
case '\'':
|
||||
sb.append("\\\'");
|
||||
break;
|
||||
case '\\':
|
||||
sb.append("\\\\");
|
||||
break;
|
||||
default:
|
||||
if (ch < 32 || ch >= 127) {
|
||||
sb.append(String.format("\\u%04X", (int)ch));
|
||||
} else {
|
||||
sb.append(ch);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a content tree for the SCRIPT tag for the main page(index.html).
|
||||
*
|
||||
* @return a content for the SCRIPT tag
|
||||
*/
|
||||
protected Content getFramesJavaScript() {
|
||||
HtmlTree script = HtmlTree.SCRIPT();
|
||||
String scriptCode = DocletConstants.NL +
|
||||
" targetPage = \"\" + window.location.search;" + DocletConstants.NL +
|
||||
" if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL +
|
||||
" targetPage = targetPage.substring(1);" + DocletConstants.NL +
|
||||
" if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + DocletConstants.NL +
|
||||
" targetPage = \"undefined\";" + DocletConstants.NL +
|
||||
" function validURL(url) {" + DocletConstants.NL +
|
||||
" try {" + DocletConstants.NL +
|
||||
" url = decodeURIComponent(url);" + DocletConstants.NL +
|
||||
" }" + DocletConstants.NL +
|
||||
" catch (error) {" + DocletConstants.NL +
|
||||
" return false;" + DocletConstants.NL +
|
||||
" }" + DocletConstants.NL +
|
||||
" var pos = url.indexOf(\".html\");" + DocletConstants.NL +
|
||||
" if (pos == -1 || pos != url.length - 5)" + DocletConstants.NL +
|
||||
" return false;" + DocletConstants.NL +
|
||||
" var allowNumber = false;" + DocletConstants.NL +
|
||||
" var allowSep = false;" + DocletConstants.NL +
|
||||
" var seenDot = false;" + DocletConstants.NL +
|
||||
" for (var i = 0; i < url.length - 5; i++) {" + DocletConstants.NL +
|
||||
" var ch = url.charAt(i);" + DocletConstants.NL +
|
||||
" if ('a' <= ch && ch <= 'z' ||" + DocletConstants.NL +
|
||||
" 'A' <= ch && ch <= 'Z' ||" + DocletConstants.NL +
|
||||
" ch == '$' ||" + DocletConstants.NL +
|
||||
" ch == '_' ||" + DocletConstants.NL +
|
||||
" ch.charCodeAt(0) > 127) {" + DocletConstants.NL +
|
||||
" allowNumber = true;" + DocletConstants.NL +
|
||||
" allowSep = true;" + DocletConstants.NL +
|
||||
" } else if ('0' <= ch && ch <= '9'" + DocletConstants.NL +
|
||||
" || ch == '-') {" + DocletConstants.NL +
|
||||
" if (!allowNumber)" + DocletConstants.NL +
|
||||
" return false;" + DocletConstants.NL +
|
||||
" } else if (ch == '/' || ch == '.') {" + DocletConstants.NL +
|
||||
" if (!allowSep)" + DocletConstants.NL +
|
||||
" return false;" + DocletConstants.NL +
|
||||
" allowNumber = false;" + DocletConstants.NL +
|
||||
" allowSep = false;" + DocletConstants.NL +
|
||||
" if (ch == '.')" + DocletConstants.NL +
|
||||
" seenDot = true;" + DocletConstants.NL +
|
||||
" if (ch == '/' && seenDot)" + DocletConstants.NL +
|
||||
" return false;" + DocletConstants.NL +
|
||||
" } else {" + DocletConstants.NL +
|
||||
" return false;"+ DocletConstants.NL +
|
||||
" }" + DocletConstants.NL +
|
||||
" }" + DocletConstants.NL +
|
||||
" return true;" + DocletConstants.NL +
|
||||
" }" + DocletConstants.NL;
|
||||
RawHtml scriptContent = new RawHtml(scriptCode);
|
||||
script.addContent(scriptContent);
|
||||
return script;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an HtmlTree for the BODY tag.
|
||||
*
|
||||
* @param includeScript set true if printing windowtitle script
|
||||
* @param title title for the window
|
||||
* @return an HtmlTree for the BODY tag
|
||||
*/
|
||||
public HtmlTree getBody(boolean includeScript, String title) {
|
||||
HtmlTree body = new HtmlTree(HtmlTag.BODY);
|
||||
// Set window title string which is later printed
|
||||
this.winTitle = title;
|
||||
// Don't print windowtitle script for overview-frame, allclasses-frame
|
||||
// and package-frame
|
||||
if (includeScript) {
|
||||
this.script = getWinTitleScript();
|
||||
body.addContent(script);
|
||||
Content noScript = HtmlTree.NOSCRIPT(
|
||||
HtmlTree.DIV(getResource("doclet.No_Script_Message")));
|
||||
body.addContent(noScript);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generated javascript variables for the document.
|
||||
*
|
||||
* @param typeMap map comprising of method and type relationship
|
||||
* @param methodTypes set comprising of all methods types for this class
|
||||
*/
|
||||
public void generateMethodTypesScript(Map<String,Integer> typeMap,
|
||||
Set<MethodTypes> methodTypes) {
|
||||
String sep = "";
|
||||
StringBuilder vars = new StringBuilder("var methods = {");
|
||||
for (Map.Entry<String,Integer> entry : typeMap.entrySet()) {
|
||||
vars.append(sep);
|
||||
sep = ",";
|
||||
vars.append("\"")
|
||||
.append(entry.getKey())
|
||||
.append("\":")
|
||||
.append(entry.getValue());
|
||||
}
|
||||
vars.append("};").append(DocletConstants.NL);
|
||||
sep = "";
|
||||
vars.append("var tabs = {");
|
||||
for (MethodTypes entry : methodTypes) {
|
||||
vars.append(sep);
|
||||
sep = ",";
|
||||
vars.append(entry.value())
|
||||
.append(":")
|
||||
.append("[")
|
||||
.append("\"")
|
||||
.append(entry.tabId())
|
||||
.append("\"")
|
||||
.append(sep)
|
||||
.append("\"")
|
||||
.append(configuration.getText(entry.resourceKey()))
|
||||
.append("\"]");
|
||||
}
|
||||
vars.append("};")
|
||||
.append(DocletConstants.NL);
|
||||
addStyles(HtmlStyle.altColor, vars);
|
||||
addStyles(HtmlStyle.rowColor, vars);
|
||||
addStyles(HtmlStyle.tableTab, vars);
|
||||
addStyles(HtmlStyle.activeTableTab, vars);
|
||||
script.addContent(new RawHtml(vars.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds javascript style variables to the document.
|
||||
*
|
||||
* @param style style to be added as a javascript variable
|
||||
* @param vars variable string to which the style variable will be added
|
||||
*/
|
||||
public void addStyles(HtmlStyle style, StringBuilder vars) {
|
||||
vars.append("var ").append(style).append(" = \"").append(style)
|
||||
.append("\";").append(DocletConstants.NL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an HtmlTree for the TITLE tag.
|
||||
*
|
||||
* @return an HtmlTree for the TITLE tag
|
||||
*/
|
||||
public HtmlTree getTitle() {
|
||||
HtmlTree title = HtmlTree.TITLE(new StringContent(winTitle));
|
||||
return title;
|
||||
}
|
||||
|
||||
public String codeText(String text) {
|
||||
return "<code>" + text + "</code>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return "&nbsp;", non-breaking space.
|
||||
*/
|
||||
public Content getSpace() {
|
||||
return RawHtml.nbsp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a header for Modifier and Type column of a table.
|
||||
*/
|
||||
public String getModifierTypeHeader() {
|
||||
return modifierTypeHeader;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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
|
||||
* 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.formats.html.markup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
|
||||
|
||||
/**
|
||||
* Class for generating raw HTML content to be added to HTML pages of javadoc output.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
*/
|
||||
public class RawHtml extends Content {
|
||||
|
||||
private String rawHtmlContent;
|
||||
|
||||
public static final Content nbsp = new RawHtml(" ");
|
||||
|
||||
/**
|
||||
* Constructor to construct a RawHtml object.
|
||||
*
|
||||
* @param rawHtml raw HTML text to be added
|
||||
*/
|
||||
public RawHtml(String rawHtml) {
|
||||
rawHtmlContent = nullCheck(rawHtml);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is not supported by the class.
|
||||
*
|
||||
* @param content content that needs to be added
|
||||
* @throws DocletAbortException this method will always throw a
|
||||
* DocletAbortException because it
|
||||
* is not supported.
|
||||
*/
|
||||
public void addContent(Content content) {
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is not supported by the class.
|
||||
*
|
||||
* @param stringContent string content that needs to be added
|
||||
* @throws DocletAbortException this method will always throw a
|
||||
* DocletAbortException because it
|
||||
* is not supported.
|
||||
*/
|
||||
public void addContent(String stringContent) {
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return rawHtmlContent.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return rawHtmlContent;
|
||||
}
|
||||
|
||||
private enum State { TEXT, ENTITY, TAG, STRING }
|
||||
|
||||
@Override
|
||||
public int charCount() {
|
||||
return charCount(rawHtmlContent);
|
||||
}
|
||||
|
||||
static int charCount(String htmlText) {
|
||||
State state = State.TEXT;
|
||||
int count = 0;
|
||||
for (int i = 0; i < htmlText.length(); i++) {
|
||||
char c = htmlText.charAt(i);
|
||||
switch (state) {
|
||||
case TEXT:
|
||||
switch (c) {
|
||||
case '<':
|
||||
state = State.TAG;
|
||||
break;
|
||||
case '&':
|
||||
state = State.ENTITY;
|
||||
count++;
|
||||
break;
|
||||
default:
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
|
||||
case ENTITY:
|
||||
if (!Character.isLetterOrDigit(c))
|
||||
state = State.TEXT;
|
||||
break;
|
||||
|
||||
case TAG:
|
||||
switch (c) {
|
||||
case '"':
|
||||
state = State.STRING;
|
||||
break;
|
||||
case '>':
|
||||
state = State.TEXT;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case STRING:
|
||||
switch (c) {
|
||||
case '"':
|
||||
state = State.TAG;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean write(Writer out, boolean atNewline) throws IOException {
|
||||
out.write(rawHtmlContent);
|
||||
return rawHtmlContent.endsWith(DocletConstants.NL);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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
|
||||
* 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.formats.html.markup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
|
||||
|
||||
/**
|
||||
* Class for generating string content for HTML tags of javadoc output.
|
||||
*
|
||||
* <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.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*
|
||||
* @author Bhavesh Patel
|
||||
*/
|
||||
public class StringContent extends Content {
|
||||
|
||||
private StringBuilder stringContent;
|
||||
|
||||
/**
|
||||
* Constructor to construct StringContent object.
|
||||
*/
|
||||
public StringContent() {
|
||||
stringContent = new StringBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor to construct StringContent object with some initial content.
|
||||
*
|
||||
* @param initialContent initial content for the object
|
||||
*/
|
||||
public StringContent(String initialContent) {
|
||||
stringContent = new StringBuilder();
|
||||
appendChars(initialContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is not supported by the class.
|
||||
*
|
||||
* @param content content that needs to be added
|
||||
* @throws DocletAbortException this method will always throw a
|
||||
* DocletAbortException because it
|
||||
* is not supported.
|
||||
*/
|
||||
@Override
|
||||
public void addContent(Content content) {
|
||||
throw new DocletAbortException("not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds content for the StringContent object. The method escapes
|
||||
* HTML characters for the string content that is added.
|
||||
*
|
||||
* @param strContent string content to be added
|
||||
*/
|
||||
@Override
|
||||
public void addContent(String strContent) {
|
||||
appendChars(strContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return (stringContent.length() == 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int charCount() {
|
||||
return RawHtml.charCount(stringContent.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return stringContent.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean write(Writer out, boolean atNewline) throws IOException {
|
||||
String s = stringContent.toString();
|
||||
out.write(s);
|
||||
return s.endsWith(DocletConstants.NL);
|
||||
}
|
||||
|
||||
private void appendChars(String s) {
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char ch = s.charAt(i);
|
||||
switch (ch) {
|
||||
case '<': stringContent.append("<"); break;
|
||||
case '>': stringContent.append(">"); break;
|
||||
case '&': stringContent.append("&"); break;
|
||||
default: stringContent.append(ch); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
This package contains classes that write HTML markup tags.
|
||||
|
||||
<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.
|
||||
This code and its internal interfaces are subject to change or
|
||||
deletion without notice.</b>
|
||||
*/
|
||||
|
||||
package jdk.javadoc.internal.doclets.formats.html.markup;
|
||||
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is the default HTML doclet provided with the JDK.
|
||||
*
|
||||
* <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. This code and its internal interfaces are subject to change or deletion without
|
||||
* notice.</b>
|
||||
*/
|
||||
package jdk.javadoc.internal.doclets.formats.html;
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 499 B |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 212 B |
Binary file not shown.
|
After Width: | Height: | Size: 208 B |
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user