8238646: Cleanup signature and use of CommentHelper

Reviewed-by: prappo
This commit is contained in:
Jonathan Gibbons 2020-02-10 13:29:03 -08:00
parent f0cdbbe120
commit b83285facc
16 changed files with 127 additions and 127 deletions

@ -202,7 +202,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
Content div = HtmlTree.DIV(HtmlStyle.deprecationBlock, deprLabel);
if (!deprs.isEmpty()) {
List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
List<? extends DocTree> commentTags = ch.getDescription(deprs.get(0));
if (!commentTags.isEmpty()) {
addInlineDeprecatedComment(annotationType, deprs.get(0), div);
}

@ -495,7 +495,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
if (!deprs.isEmpty()) {
CommentHelper ch = utils.getCommentHelper(typeElement);
DocTree dt = deprs.get(0);
List<? extends DocTree> commentTags = ch.getBody(configuration, dt);
List<? extends DocTree> commentTags = ch.getBody(dt);
if (!commentTags.isEmpty()) {
addInlineDeprecatedComment(typeElement, deprs.get(0), div);
}

@ -1038,14 +1038,14 @@ public class HtmlDocletWriter {
return new RawHtml(seetext);
}
boolean isLinkPlain = kind == LINK_PLAIN;
Content label = plainOrCode(isLinkPlain, new RawHtml(ch.getLabel(configuration, see)));
Content label = plainOrCode(isLinkPlain, new RawHtml(ch.getLabel(see)));
//The text from the @see tag. We will output this text when a label is not specified.
Content text = plainOrCode(kind == LINK_PLAIN, new RawHtml(seetext));
TypeElement refClass = ch.getReferencedClass(configuration, see);
String refClassName = ch.getReferencedClassName(configuration, see);
Element refMem = ch.getReferencedMember(configuration, see);
TypeElement refClass = ch.getReferencedClass(see);
String refClassName = ch.getReferencedClassName(see);
Element refMem = ch.getReferencedMember(see);
String refMemName = ch.getReferencedMemberName(see);
if (refMemName == null && refMem != null) {
@ -1053,7 +1053,7 @@ public class HtmlDocletWriter {
}
if (refClass == null) {
//@see is not referencing an included class
PackageElement refPackage = ch.getReferencedPackage(configuration, see);
PackageElement refPackage = ch.getReferencedPackage(see);
if (refPackage != null && utils.isIncluded(refPackage)) {
//@see is referencing an included package
if (label.isEmpty())
@ -1169,7 +1169,7 @@ public class HtmlDocletWriter {
*/
public void addInlineComment(Element element, DocTree tag, Content htmltree) {
CommentHelper ch = utils.getCommentHelper(element);
List<? extends DocTree> description = ch.getDescription(configuration, tag);
List<? extends DocTree> description = ch.getDescription(tag);
addCommentTags(element, tag, description, false, false, false, htmltree);
}
@ -1194,7 +1194,7 @@ public class HtmlDocletWriter {
*/
public void addInlineDeprecatedComment(Element e, DocTree tag, Content htmltree) {
CommentHelper ch = utils.getCommentHelper(e);
addCommentTags(e, ch.getBody(configuration, tag), true, false, false, htmltree);
addCommentTags(e, ch.getBody(tag), true, false, false, htmltree);
}
/**
@ -1220,8 +1220,8 @@ public class HtmlDocletWriter {
public void addSummaryDeprecatedComment(Element element, DocTree tag, Content htmltree) {
CommentHelper ch = utils.getCommentHelper(element);
List<? extends DocTree> body = ch.getBody(configuration, tag);
addCommentTags(element, ch.getFirstSentenceTrees(configuration, body), true, true, true, htmltree);
List<? extends DocTree> body = ch.getBody(tag);
addCommentTags(element, ch.getFirstSentenceTrees(body), true, true, true, htmltree);
}
/**

@ -180,7 +180,7 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
@Override
public void addMemberDescription(VariableElement field, DocTree serialFieldTag, Content contentTree) {
CommentHelper ch = utils.getCommentHelper(field);
List<? extends DocTree> description = ch.getDescription(configuration, serialFieldTag);
List<? extends DocTree> description = ch.getDescription(serialFieldTag);
if (!description.isEmpty()) {
Content serialFieldContent = new RawHtml(ch.getText(description));
Content div = HtmlTree.DIV(HtmlStyle.block, serialFieldContent);

@ -375,16 +375,16 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
});
// Generate the map of all services listed using @provides, and the description.
(utils.getBlockTags(mdle, DocTree.Kind.PROVIDES)).forEach((tree) -> {
TypeElement t = ch.getServiceType(configuration, tree);
TypeElement t = ch.getServiceType(tree);
if (t != null) {
providesTrees.put(t, commentTagsToContent(tree, mdle, ch.getDescription(configuration, tree), false, true));
providesTrees.put(t, commentTagsToContent(tree, mdle, ch.getDescription(tree), false, true));
}
});
// Generate the map of all services listed using @uses, and the description.
(utils.getBlockTags(mdle, DocTree.Kind.USES)).forEach((tree) -> {
TypeElement t = ch.getServiceType(configuration, tree);
TypeElement t = ch.getServiceType(tree);
if (t != null) {
usesTrees.put(t, commentTagsToContent(tree, mdle, ch.getDescription(configuration, tree), false, true));
usesTrees.put(t, commentTagsToContent(tree, mdle, ch.getDescription(tree), false, true));
}
});
}
@ -827,7 +827,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, getDeprecatedPhrase(mdle));
deprDiv.add(deprPhrase);
if (!deprs.isEmpty()) {
List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
List<? extends DocTree> commentTags = ch.getDescription(deprs.get(0));
if (!commentTags.isEmpty()) {
addInlineDeprecatedComment(mdle, deprs.get(0), deprDiv);
}
@ -892,7 +892,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
deprDiv.add(deprPhrase);
if (!deprs.isEmpty()) {
CommentHelper ch = utils.getCommentHelper(pkg);
List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
List<? extends DocTree> commentTags = ch.getDescription(deprs.get(0));
if (!commentTags.isEmpty()) {
addInlineDeprecatedComment(pkg, deprs.get(0), deprDiv);
}

@ -153,7 +153,7 @@ public class PackageWriterImpl extends HtmlDocletWriter
Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, getDeprecatedPhrase(packageElement));
deprDiv.add(deprPhrase);
if (!deprs.isEmpty()) {
List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
List<? extends DocTree> commentTags = ch.getDescription(deprs.get(0));
if (!commentTags.isEmpty()) {
addInlineDeprecatedComment(packageElement, deprs.get(0), deprDiv);
}

@ -139,7 +139,7 @@ public class TagletWriterImpl extends TagletWriter {
result.add(HtmlTree.SPAN(HtmlStyle.deprecatedLabel,
htmlWriter.getDeprecatedPhrase(element)));
if (!deprs.isEmpty()) {
List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
List<? extends DocTree> commentTags = ch.getDescription(deprs.get(0));
if (!commentTags.isEmpty()) {
result.add(commentTagsToOutput(null, element, commentTags, false));
}
@ -150,7 +150,7 @@ public class TagletWriterImpl extends TagletWriter {
result.add(HtmlTree.SPAN(HtmlStyle.deprecatedLabel,
htmlWriter.getDeprecatedPhrase(element)));
if (!deprs.isEmpty()) {
List<? extends DocTree> bodyTags = ch.getBody(configuration, deprs.get(0));
List<? extends DocTree> bodyTags = ch.getBody(deprs.get(0));
Content body = commentTagsToOutput(null, element, bodyTags, false);
if (!body.isEmpty())
result.add(HtmlTree.DIV(HtmlStyle.deprecationComment, body));
@ -191,7 +191,7 @@ public class TagletWriterImpl extends TagletWriter {
Content nameTree = new StringContent(paramName);
body.add(HtmlTree.CODE(defineID ? HtmlTree.SPAN_ID("param-" + paramName, nameTree) : nameTree));
body.add(" - ");
List<? extends DocTree> description = ch.getDescription(configuration, paramTag);
List<? extends DocTree> description = ch.getDescription(paramTag);
body.add(htmlWriter.commentTagsToContent(paramTag, element, description, false, inSummary));
return HtmlTree.DD(body);
}
@ -215,7 +215,7 @@ public class TagletWriterImpl extends TagletWriter {
result.add(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.returnLabel,
new StringContent(resources.getText("doclet.Returns")))));
result.add(HtmlTree.DD(htmlWriter.commentTagsToContent(
returnTag, element, ch.getDescription(configuration, returnTag), false, inSummary)));
returnTag, element, ch.getDescription(returnTag), false, inSummary)));
return result;
}
@ -279,7 +279,7 @@ public class TagletWriterImpl extends TagletWriter {
if (many) {
body.add(", ");
}
List<? extends DocTree> bodyTags = ch.getBody(configuration, simpleTag);
List<? extends DocTree> bodyTags = ch.getBody(simpleTag);
body.add(htmlWriter.commentTagsToContent(simpleTag, element, bodyTags, false, inSummary));
many = true;
}
@ -292,7 +292,7 @@ public class TagletWriterImpl extends TagletWriter {
ContentBuilder result = new ContentBuilder();
result.add(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.simpleTagLabel, new RawHtml(header))));
CommentHelper ch = utils.getCommentHelper(element);
List<? extends DocTree> description = ch.getDescription(configuration, simpleTag);
List<? extends DocTree> description = ch.getDescription(simpleTag);
Content body = htmlWriter.commentTagsToContent(simpleTag, element, description, false, inSummary);
result.add(HtmlTree.DD(body));
return result;
@ -317,7 +317,7 @@ public class TagletWriterImpl extends TagletWriter {
public Content throwsTagOutput(Element element, DocTree throwsTag, TypeMirror substituteType) {
ContentBuilder body = new ContentBuilder();
CommentHelper ch = utils.getCommentHelper(element);
Element exception = ch.getException(configuration, throwsTag);
Element exception = ch.getException(throwsTag);
Content excName;
if (substituteType != null) {
excName = htmlWriter.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER,
@ -333,7 +333,7 @@ public class TagletWriterImpl extends TagletWriter {
excName = htmlWriter.getLink(link);
}
body.add(HtmlTree.CODE(excName));
List<? extends DocTree> description = ch.getDescription(configuration, throwsTag);
List<? extends DocTree> description = ch.getDescription(throwsTag);
Content desc = htmlWriter.commentTagsToContent(throwsTag, element, description, false, inSummary);
if (desc != null && !desc.isEmpty()) {
body.add(" - ");

@ -482,7 +482,7 @@ public class SerializedFormBuilder extends AbstractBuilder {
if (tag.getName() == null || tag.getType() == null) // ignore malformed @serialField tags
continue;
Content fieldsContentTree = fieldWriter.getFieldsContentHeader(tag.equals(tags.last()));
TypeElement te = ch.getReferencedClass(configuration, tag);
TypeElement te = ch.getReferencedClass(tag);
String fieldType = ch.getReferencedMemberName(tag);
if (te != null && utils.isPrimitive(te.asType())) {
fieldType = utils.getTypeName(te.asType(), false);

@ -126,7 +126,7 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet {
if (rankMap.containsKey(paramName) && rankMap.get(paramName).equals((input.tagId))) {
output.holder = input.element;
output.holderTag = tag;
output.inlineTags = ch.getBody(utils.configuration, tag);
output.inlineTags = ch.getBody(tag);
return;
}
}

@ -64,8 +64,8 @@ public class ReturnTaglet extends BaseTaglet implements InheritableTaglet {
output.holder = input.element;
output.holderTag = tags.get(0);
output.inlineTags = input.isFirstSentence
? ch.getFirstSentenceTrees(input.utils.configuration, output.holderTag)
: ch.getDescription(input.utils.configuration, output.holderTag);
? ch.getFirstSentenceTrees(output.holderTag)
: ch.getDescription(output.holderTag);
}
}

@ -60,7 +60,7 @@ public class SeeTaglet extends BaseTaglet implements InheritableTaglet {
output.holder = input.element;
output.holderTag = tags.get(0);
output.inlineTags = input.isFirstSentence
? ch.getFirstSentenceTrees(input.utils.configuration, output.holderTag)
? ch.getFirstSentenceTrees(output.holderTag)
: ch.getReference(output.holderTag);
}
}

@ -173,8 +173,8 @@ public class SimpleTaglet extends BaseTaglet implements InheritableTaglet {
output.holderTag = tags.get(0);
CommentHelper ch = input.utils.getCommentHelper(output.holder);
output.inlineTags = input.isFirstSentence
? ch.getFirstSentenceTrees(input.utils.configuration, output.holderTag)
: ch.getTags(input.utils.configuration, output.holderTag);
? ch.getFirstSentenceTrees(output.holderTag)
: ch.getTags(output.holderTag);
}
}

@ -72,7 +72,7 @@ public class ThrowsTaglet extends BaseTaglet
Element exception;
CommentHelper ch = utils.getCommentHelper(input.element);
if (input.tagId == null) {
exception = ch.getException(utils.configuration, input.docTreeInfo.docTree);
exception = ch.getException(input.docTreeInfo.docTree);
input.tagId = exception == null
? ch.getExceptionName(input.docTreeInfo.docTree).getSignature()
: utils.getFullyQualifiedName(exception);
@ -81,12 +81,12 @@ public class ThrowsTaglet extends BaseTaglet
}
for (DocTree dt : input.utils.getThrowsTrees(input.element)) {
Element exc = ch.getException(utils.configuration, dt);
Element exc = ch.getException(dt);
if (exc != null && (input.tagId.equals(utils.getSimpleName(exc)) ||
(input.tagId.equals(utils.getFullyQualifiedName(exc))))) {
output.holder = input.element;
output.holderTag = dt;
output.inlineTags = ch.getBody(input.utils.configuration, output.holderTag);
output.inlineTags = ch.getBody(output.holderTag);
output.tagList.add(dt);
} else if (exception != null && exc != null &&
utils.isTypeElement(exc) && utils.isTypeElement(exception) &&
@ -193,7 +193,7 @@ public class ThrowsTaglet extends BaseTaglet
CommentHelper ch = utils.getCommentHelper(entry.getValue());
Element e = entry.getValue();
for (DocTree dt : entry.getKey()) {
Element te = ch.getException(utils.configuration, dt);
Element te = ch.getException(dt);
String excName = ch.getExceptionName(dt).toString();
TypeMirror substituteType = typeSubstitutions.get(excName);
if ((!allowDuplicates) &&

@ -77,7 +77,7 @@ public class ValueTaglet extends BaseTaglet {
Element e = signature == null
? holder
: ch.getReferencedMember(config, tag);
: ch.getReferencedMember(tag);
return (e != null && config.utils.isVariableElement(e))
? (VariableElement) e

@ -28,11 +28,10 @@ package jdk.javadoc.internal.doclets.toolkit.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.Name;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror;
@ -84,18 +83,27 @@ import static com.sun.source.doctree.DocTree.Kind.*;
* deletion without notice.</b>
*/
public class CommentHelper {
private final BaseConfiguration configuration;
public final TreePath path;
public final DocCommentTree dctree;
public final DocCommentTree dcTree;
public final Element element;
private Element overriddenElement;
public static final String SPACER = " ";
public CommentHelper(BaseConfiguration configuration, Element element, TreePath path, DocCommentTree dctree) {
//this.configuration = configuration;
/**
* Creates a utility class to encapsulate the contextual information for a doc comment tree.
*
* @param configuration the configuration
* @param element the element for which this is a doc comment
* @param path the path for the element
* @param dcTree the doc comment
*/
public CommentHelper(BaseConfiguration configuration, Element element, TreePath path, DocCommentTree dcTree) {
this.configuration = configuration;
this.element = element;
this.path = path;
this.dctree = dctree;
this.dcTree = dcTree;
}
public void setOverrideElement(Element ove) {
@ -144,17 +152,18 @@ public class CommentHelper {
}
}
Element getElement(BaseConfiguration c, ReferenceTree rtree) {
Element getElement(ReferenceTree rtree) {
Utils utils = configuration.utils;
// likely a synthesized tree
if (path == null) {
// NOTE: this code path only supports module/package/type signatures
// and not member signatures. For more complete support,
// set a suitable path and avoid this branch.
TypeMirror symbol = c.utils.getSymbol(rtree.getSignature());
TypeMirror symbol = utils.getSymbol(rtree.getSignature());
if (symbol == null) {
return null;
}
return c.docEnv.getTypeUtils().asElement(symbol);
return configuration.docEnv.getTypeUtils().asElement(symbol);
}
// case A: the element contains no comments associated and
// the comments need to be copied from ancestor
@ -162,37 +171,37 @@ public class CommentHelper {
// as appropriate has to be copied over.
// Case A.
if (dctree == null && overriddenElement != null) {
CommentHelper ovch = c.utils.getCommentHelper(overriddenElement);
return ovch.getElement(c, rtree);
if (dcTree == null && overriddenElement != null) {
CommentHelper ovch = utils.getCommentHelper(overriddenElement);
return ovch.getElement(rtree);
}
if (dctree == null) {
if (dcTree == null) {
return null;
}
DocTreePath docTreePath = DocTreePath.getPath(path, dctree, rtree);
DocTreePath docTreePath = DocTreePath.getPath(path, dcTree, rtree);
if (docTreePath == null) {
// Case B.
if (overriddenElement != null) {
CommentHelper ovch = c.utils.getCommentHelper(overriddenElement);
return ovch.getElement(c, rtree);
CommentHelper ovch = utils.getCommentHelper(overriddenElement);
return ovch.getElement(rtree);
}
return null;
}
DocTrees doctrees = c.docEnv.getDocTrees();
DocTrees doctrees = configuration.docEnv.getDocTrees();
return doctrees.getElement(docTreePath);
}
public Element getException(BaseConfiguration c, DocTree dtree) {
public Element getException(DocTree dtree) {
if (dtree.getKind() == THROWS || dtree.getKind() == EXCEPTION) {
ThrowsTree tt = (ThrowsTree)dtree;
ReferenceTree exceptionName = tt.getExceptionName();
return getElement(c, exceptionName);
return getElement(exceptionName);
}
return null;
}
public List<? extends DocTree> getDescription(BaseConfiguration c, DocTree dtree) {
return getTags(c, dtree);
public List<? extends DocTree> getDescription(DocTree dtree) {
return getTags(dtree);
}
public String getText(List<? extends DocTree> list) {
@ -224,16 +233,14 @@ public class CommentHelper {
quote = "\"";
break;
case SINGLE:
quote = "\'";
quote = "'";
break;
default:
quote = "";
break;
}
sb.append(quote);
node.getValue().stream().forEach((dt) -> {
dt.accept(this, null);
});
node.getValue().forEach(dt -> dt.accept(this, null));
sb.append(quote);
return null;
}
@ -259,9 +266,7 @@ public class CommentHelper {
}
node.getReference().accept(this, null);
node.getLabel().stream().forEach((dt) -> {
dt.accept(this, null);
});
node.getLabel().forEach(dt -> dt.accept(this, null) );
return null;
}
@ -285,17 +290,13 @@ public class CommentHelper {
@Override
public Void visitSee(SeeTree node, Void p) {
node.getReference().stream().forEach((dt) -> {
dt.accept(this, null);
});
node.getReference().forEach(dt -> dt.accept(this, null));
return null;
}
@Override
public Void visitSerial(SerialTree node, Void p) {
node.getDescription().stream().forEach((dt) -> {
dt.accept(this, null);
});
node.getDescription().forEach(dt -> dt.accept(this, null));
return null;
}
@ -303,9 +304,7 @@ public class CommentHelper {
public Void visitStartElement(StartElementTree node, Void p) {
sb.append("<");
sb.append(node.getName());
node.getAttributes().stream().forEach((dt) -> {
dt.accept(this, null);
});
node.getAttributes().forEach(dt -> dt.accept(this, null));
sb.append((node.isSelfClosing() ? "/>" : ">"));
return null;
}
@ -318,9 +317,7 @@ public class CommentHelper {
@Override
public Void visitUnknownBlockTag(UnknownBlockTagTree node, Void p) {
node.getContent().stream().forEach((dt) -> {
dt.accept(this, null);
});
node.getContent().forEach(dt -> dt.accept(this, null));
return null;
}
@ -338,24 +335,22 @@ public class CommentHelper {
return sb;
}
public String getLabel(BaseConfiguration c, DocTree dtree) {
public String getLabel(DocTree dtree) {
return new SimpleDocTreeVisitor<String, Void>() {
@Override
public String visitLink(LinkTree node, Void p) {
StringBuilder sb = new StringBuilder();
node.getLabel().stream().forEach((dt) -> {
sb.append(getText(dt));
});
return sb.toString();
return node.getLabel().stream()
.map(dt -> getText(dt))
.collect(Collectors.joining());
}
@Override
public String visitSee(SeeTree node, Void p) {
StringBuilder sb = new StringBuilder();
node.getReference().stream().filter((dt) -> (c.utils.isText(dt))).forEach((dt) -> {
sb.append(((TextTree)dt).getBody());
});
return sb.toString();
Utils utils = configuration.utils;
return node.getReference().stream()
.filter(utils::isText)
.map(dt -> ((TextTree) dt).getBody())
.collect(Collectors.joining());
}
@Override
@ -365,22 +360,24 @@ public class CommentHelper {
}.visit(dtree, null);
}
public TypeElement getReferencedClass(BaseConfiguration c, DocTree dtree) {
Element e = getReferencedElement(c, dtree);
public TypeElement getReferencedClass(DocTree dtree) {
Utils utils = configuration.utils;
Element e = getReferencedElement(dtree);
if (e == null) {
return null;
} else if (c.utils.isTypeElement(e)) {
} else if (utils.isTypeElement(e)) {
return (TypeElement) e;
} else if (!c.utils.isPackage(e)) {
return c.utils.getEnclosingTypeElement(e);
} else if (!utils.isPackage(e)) {
return utils.getEnclosingTypeElement(e);
}
return null;
}
public String getReferencedClassName(BaseConfiguration c, DocTree dtree) {
Element e = getReferencedClass(c, dtree);
public String getReferencedClassName(DocTree dtree) {
Utils utils = configuration.utils;
Element e = getReferencedClass(dtree);
if (e != null) {
return c.utils.isTypeElement(e) ? c.utils.getSimpleName(e) : null;
return utils.isTypeElement(e) ? utils.getSimpleName(e) : null;
}
String s = getReferencedSignature(dtree);
if (s == null) {
@ -390,12 +387,13 @@ public class CommentHelper {
return (n == -1) ? s : s.substring(0, n);
}
public Element getReferencedMember(BaseConfiguration c, DocTree dtree) {
Element e = getReferencedElement(c, dtree);
public Element getReferencedMember(DocTree dtree) {
Utils utils = configuration.utils;
Element e = getReferencedElement(dtree);
if (e == null) {
return null;
}
return (c.utils.isExecutableElement(e) || c.utils.isVariableElement(e)) ? e : null;
return (utils.isExecutableElement(e) || utils.isVariableElement(e)) ? e : null;
}
public String getReferencedMemberName(DocTree dtree) {
@ -407,33 +405,34 @@ public class CommentHelper {
return (n == -1) ? null : s.substring(n + 1);
}
public String getReferencedMemberName(BaseConfiguration c, Element e) {
public String getReferencedMemberName(Element e) {
if (e == null) {
return null;
}
return c.utils.isExecutableElement(e)
? c.utils.getSimpleName(e) + c.utils.makeSignature((ExecutableElement) e, true, true)
: c.utils.getSimpleName(e);
Utils utils = configuration.utils;
return utils.isExecutableElement(e)
? utils.getSimpleName(e) + utils.makeSignature((ExecutableElement) e, true, true)
: utils.getSimpleName(e);
}
public PackageElement getReferencedPackage(BaseConfiguration c, DocTree dtree) {
Element e = getReferencedElement(c, dtree);
public PackageElement getReferencedPackage(DocTree dtree) {
Element e = getReferencedElement(dtree);
if (e != null) {
return c.utils.containingPackage(e);
Utils utils = configuration.utils;
return utils.containingPackage(e);
}
return null;
}
public List<? extends DocTree> getFirstSentenceTrees(BaseConfiguration c, List<? extends DocTree> body) {
List<DocTree> firstSentence = c.docEnv.getDocTrees().getFirstSentence(body);
return firstSentence;
public List<? extends DocTree> getFirstSentenceTrees(List<? extends DocTree> body) {
return configuration.docEnv.getDocTrees().getFirstSentence(body);
}
public List<? extends DocTree> getFirstSentenceTrees(BaseConfiguration c, DocTree dtree) {
return getFirstSentenceTrees(c, getBody(c, dtree));
public List<? extends DocTree> getFirstSentenceTrees(DocTree dtree) {
return getFirstSentenceTrees(getBody(dtree));
}
private Element getReferencedElement(BaseConfiguration c, DocTree dtree) {
private Element getReferencedElement(DocTree dtree) {
return new SimpleDocTreeVisitor<Element, Void>() {
@Override
public Element visitSee(SeeTree node, Void p) {
@ -460,7 +459,7 @@ public class CommentHelper {
@Override
public Element visitReference(ReferenceTree node, Void p) {
return getElement(c, node);
return getElement(node);
}
@Override
@ -480,10 +479,11 @@ public class CommentHelper {
}.visit(dtree, null);
}
public TypeElement getServiceType(BaseConfiguration c, DocTree dtree) {
Element e = getReferencedElement(c, dtree);
public TypeElement getServiceType(DocTree dtree) {
Element e = getReferencedElement(dtree);
if (e != null) {
return c.utils.isTypeElement(e) ? (TypeElement) e : null;
Utils utils = configuration.utils;
return utils.isTypeElement(e) ? (TypeElement) e : null;
}
return null;
}
@ -546,11 +546,11 @@ public class CommentHelper {
}
}
public List<? extends DocTree> getTags(BaseConfiguration c, DocTree dtree) {
public List<? extends DocTree> getTags(DocTree dtree) {
return new SimpleDocTreeVisitor<List<? extends DocTree>, Void>() {
List<? extends DocTree> asList(String content) {
List<DocTree> out = new ArrayList<>();
out.add(c.cmtUtils.makeTextTree(content));
out.add(configuration.cmtUtils.makeTextTree(content));
return out;
}
@ -651,22 +651,22 @@ public class CommentHelper {
}.visit(dtree, null);
}
public List<? extends DocTree> getBody(BaseConfiguration c, DocTree dtree) {
return getTags(c, dtree);
public List<? extends DocTree> getBody(DocTree dtree) {
return getTags(dtree);
}
public ReferenceTree getType(DocTree dtree) {
if (dtree.getKind() == SERIAL_FIELD) {
return ((SerialFieldTree)dtree).getType();
return ((SerialFieldTree) dtree).getType();
} else {
return null;
}
}
public DocTreePath getDocTreePath(DocTree dtree) {
if (path == null || dctree == null || dtree == null)
if (path == null || dcTree == null || dtree == null)
return null;
return DocTreePath.getPath(path, dctree, dtree);
return DocTreePath.getPath(path, dcTree, dtree);
}
public Element getOverriddenElement() {
@ -680,7 +680,7 @@ public class CommentHelper {
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder("CommentHelper{" + "path=" + path + ", dctree=" + dctree);
StringBuilder sb = new StringBuilder("CommentHelper{" + "path=" + path + ", dcTree=" + dcTree);
sb.append(", element=");
sb.append(element.getEnclosingElement());
sb.append("::");

@ -3198,7 +3198,7 @@ public class Utils {
public DocCommentTree getDocCommentTree(Element element) {
CommentHelper ch = commentHelperCache.get(element);
if (ch != null) {
return ch.dctree;
return ch.dcTree;
}
DocCommentTree dcTree = getDocCommentTree0(element);
if (dcTree != null) {