8149138: [javadoc] Fix SerialFormBuilder eliminate String bashing
Reviewed-by: jjg
This commit is contained in:
parent
58bdabcd40
commit
6d1f3ac749
@ -109,29 +109,10 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
|
|||||||
return HtmlTree.LI(section);
|
return HtmlTree.LI(section);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addMemberHeader(TypeElement fieldType, String fieldTypeStr,
|
|
||||||
String fieldDimensions, String fieldName, Content contentTree) {
|
|
||||||
Content nameContent = Text.of(fieldName);
|
|
||||||
Content heading = HtmlTree.HEADING(Headings.SerializedForm.MEMBER_HEADING, nameContent);
|
|
||||||
contentTree.add(heading);
|
|
||||||
Content pre = new HtmlTree(TagName.PRE);
|
|
||||||
if (fieldType == null) {
|
|
||||||
pre.add(fieldTypeStr);
|
|
||||||
} else {
|
|
||||||
Content fieldContent = writer.getLink(new HtmlLinkInfo(
|
|
||||||
configuration, HtmlLinkInfo.Kind.SERIAL_MEMBER, fieldType));
|
|
||||||
pre.add(fieldContent);
|
|
||||||
}
|
|
||||||
pre.add(fieldDimensions + " ");
|
|
||||||
pre.add(fieldName);
|
|
||||||
contentTree.add(pre);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addMemberHeader(TypeMirror fieldType, String fieldName, Content contentTree) {
|
public void addMemberHeader(TypeMirror fieldType, String fieldName, Content contentTree) {
|
||||||
Content nameContent = Text.of(fieldName);
|
Content nameContent = Text.of(fieldName);
|
||||||
Content heading = HtmlTree.HEADING(TagName.H5, nameContent);
|
Content heading = HtmlTree.HEADING(Headings.SerializedForm.MEMBER_HEADING, nameContent);
|
||||||
contentTree.add(heading);
|
contentTree.add(heading);
|
||||||
Content pre = new HtmlTree(TagName.PRE);
|
Content pre = new HtmlTree(TagName.PRE);
|
||||||
Content fieldContent = writer.getLink(new HtmlLinkInfo(
|
Content fieldContent = writer.getLink(new HtmlLinkInfo(
|
||||||
|
@ -227,19 +227,6 @@ public interface SerializedFormWriter {
|
|||||||
*/
|
*/
|
||||||
void addMemberTags(VariableElement field, Content contentTree);
|
void addMemberTags(VariableElement field, Content contentTree);
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the member header.
|
|
||||||
*
|
|
||||||
* @param fieldType the type of the field
|
|
||||||
* @param fieldTypeStr the type of the field in string format, used
|
|
||||||
* only if the type cannot be linked
|
|
||||||
* @param fieldDimensions the dimensions of the field
|
|
||||||
* @param fieldName the name of the field
|
|
||||||
* @param contentTree content tree to which the member header will be added
|
|
||||||
*/
|
|
||||||
void addMemberHeader(TypeElement fieldType, String fieldTypeStr, String fieldDimensions,
|
|
||||||
String fieldName, Content contentTree);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the member header.
|
* Adds the member header.
|
||||||
*
|
*
|
||||||
|
@ -35,6 +35,7 @@ import javax.lang.model.element.ExecutableElement;
|
|||||||
import javax.lang.model.element.PackageElement;
|
import javax.lang.model.element.PackageElement;
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.lang.model.element.TypeElement;
|
||||||
import javax.lang.model.element.VariableElement;
|
import javax.lang.model.element.VariableElement;
|
||||||
|
import javax.lang.model.type.TypeMirror;
|
||||||
|
|
||||||
import com.sun.source.doctree.SerialFieldTree;
|
import com.sun.source.doctree.SerialFieldTree;
|
||||||
import com.sun.source.doctree.SerialTree;
|
import com.sun.source.doctree.SerialTree;
|
||||||
@ -478,22 +479,8 @@ public class SerializedFormBuilder extends AbstractBuilder {
|
|||||||
if (tag.getName() == null || tag.getType() == null) // ignore malformed @serialField tags
|
if (tag.getName() == null || tag.getType() == null) // ignore malformed @serialField tags
|
||||||
continue;
|
continue;
|
||||||
Content fieldsContentTree = fieldWriter.getFieldsContentHeader(tag.equals(tags.last()));
|
Content fieldsContentTree = fieldWriter.getFieldsContentHeader(tag.equals(tags.last()));
|
||||||
TypeElement te = ch.getReferencedClass(tag);
|
TypeMirror type = ch.getReferencedType(tag);
|
||||||
String fieldType = ch.getReferencedMemberName(tag);
|
fieldWriter.addMemberHeader(type, tag.getName().getName().toString(), fieldsContentTree);
|
||||||
if (te != null && utils.isPrimitive(te.asType())) {
|
|
||||||
fieldType = utils.getTypeName(te.asType(), false);
|
|
||||||
te = null;
|
|
||||||
}
|
|
||||||
String refSignature = ch.getReferencedSignature(tag);
|
|
||||||
// TODO: Print the signature directly, if it is an array, the
|
|
||||||
// current DocTree APIs makes it very hard to distinguish
|
|
||||||
// an as these are returned back as "Array" a DeclaredType.
|
|
||||||
if (refSignature != null && refSignature.endsWith("[]")) {
|
|
||||||
te = null;
|
|
||||||
fieldType = refSignature;
|
|
||||||
}
|
|
||||||
fieldWriter.addMemberHeader(te, fieldType, "",
|
|
||||||
tag.getName().getName().toString(), fieldsContentTree);
|
|
||||||
fieldWriter.addMemberDescription(field, tag, fieldsContentTree);
|
fieldWriter.addMemberDescription(field, tag, fieldsContentTree);
|
||||||
serializableFieldsTree.add(fieldsContentTree);
|
serializableFieldsTree.add(fieldsContentTree);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2021 Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -32,14 +32,19 @@ public class SerializedForm implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* @serialField name String a test
|
* @serialField name String a test
|
||||||
* @serialField longs Long[] the longs
|
* @serialField longs Long[] the longs
|
||||||
|
* @serialField i int an int
|
||||||
|
* @serialField m double[][] the doubles
|
||||||
|
* @serialField next SerializedForm a linked reference
|
||||||
* @see TestSerializedForm
|
* @see TestSerializedForm
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private static final ObjectStreamField[] serialPersistentFields = {
|
private static final ObjectStreamField[] serialPersistentFields = {
|
||||||
new ObjectStreamField("i", int.class),
|
new ObjectStreamField("i", int.class),
|
||||||
|
new ObjectStreamField("m", double[][].class),
|
||||||
new ObjectStreamField("count", Integer.TYPE),
|
new ObjectStreamField("count", Integer.TYPE),
|
||||||
new ObjectStreamField("name", String.class),
|
new ObjectStreamField("name", String.class),
|
||||||
new ObjectStreamField("longs", Long[].class)
|
new ObjectStreamField("longs", Long[].class),
|
||||||
|
new ObjectStreamField("next", SerializedForm.class)
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,14 +108,29 @@ public class TestSerializedForm extends JavadocTester {
|
|||||||
<h4>Serialized Fields</h4>
|
<h4>Serialized Fields</h4>
|
||||||
<ul class="block-list">
|
<ul class="block-list">
|
||||||
<li class="block-list">
|
<li class="block-list">
|
||||||
|
<h5>i</h5>
|
||||||
|
<pre>int i</pre>
|
||||||
|
<div class="block">an int</div>
|
||||||
|
</li>
|
||||||
|
<li class="block-list">
|
||||||
<h5>longs</h5>
|
<h5>longs</h5>
|
||||||
<pre>Long[] longs</pre>
|
<pre>java.lang.Long[] longs</pre>
|
||||||
<div class="block">the longs</div>
|
<div class="block">the longs</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="block-list">
|
<li class="block-list">
|
||||||
|
<h5>m</h5>
|
||||||
|
<pre>double[][] m</pre>
|
||||||
|
<div class="block">the doubles</div>
|
||||||
|
</li>
|
||||||
|
<li class="block-list">
|
||||||
<h5>name</h5>
|
<h5>name</h5>
|
||||||
<pre>java.lang.String name</pre>
|
<pre>java.lang.String name</pre>
|
||||||
<div class="block">a test</div>""");
|
<div class="block">a test</div>
|
||||||
|
</li>
|
||||||
|
<li class="block-list">
|
||||||
|
<h5>next</h5>
|
||||||
|
<pre><a href="SerializedForm.html" title="class in Unnamed Package">SerializedForm</a> next</pre>
|
||||||
|
<div class="block">a linked reference</div>""");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -160,14 +175,29 @@ public class TestSerializedForm extends JavadocTester {
|
|||||||
<h4>Serialized Fields</h4>
|
<h4>Serialized Fields</h4>
|
||||||
<ul class="block-list">
|
<ul class="block-list">
|
||||||
<li class="block-list">
|
<li class="block-list">
|
||||||
|
<h5>i</h5>
|
||||||
|
<pre>int i</pre>
|
||||||
|
<div class="block">an int</div>
|
||||||
|
</li>
|
||||||
|
<li class="block-list">
|
||||||
<h5>longs</h5>
|
<h5>longs</h5>
|
||||||
<pre>Long[] longs</pre>
|
<pre>java.lang.Long[] longs</pre>
|
||||||
<div class="block">the longs</div>
|
<div class="block">the longs</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="block-list">
|
<li class="block-list">
|
||||||
|
<h5>m</h5>
|
||||||
|
<pre>double[][] m</pre>
|
||||||
|
<div class="block">the doubles</div>
|
||||||
|
</li>
|
||||||
|
<li class="block-list">
|
||||||
<h5>name</h5>
|
<h5>name</h5>
|
||||||
<pre>java.lang.String name</pre>
|
<pre>java.lang.String name</pre>
|
||||||
<div class="block">a test</div>""");
|
<div class="block">a test</div>
|
||||||
|
</li>
|
||||||
|
<li class="block-list">
|
||||||
|
<h5>next</h5>
|
||||||
|
<pre><a href="SerializedForm.html" title="class in Unnamed Package">SerializedForm</a> next</pre>
|
||||||
|
<div class="block">a linked reference</div>""");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -180,8 +210,10 @@ public class TestSerializedForm extends JavadocTester {
|
|||||||
checkExit(Exit.OK);
|
checkExit(Exit.OK);
|
||||||
|
|
||||||
checkOrder("serialized-form.html",
|
checkOrder("serialized-form.html",
|
||||||
"int[] a1",
|
"""
|
||||||
"int[][] a2",
|
int[] a1""",
|
||||||
|
"""
|
||||||
|
int[][] a2""",
|
||||||
"""
|
"""
|
||||||
<a href="pkg2/Fields.html" title="class in pkg2">Fields</a>[][] doubleArray""",
|
<a href="pkg2/Fields.html" title="class in pkg2">Fields</a>[][] doubleArray""",
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user