Skip to content

Commit

Permalink
8220202: Simplify/standardize method naming for HtmlTree
Browse files Browse the repository at this point in the history
Reviewed-by: lucy
Backport-of: 1b9db9b
  • Loading branch information
Amos Shi committed Apr 25, 2024
1 parent decacb8 commit dabf4d1
Show file tree
Hide file tree
Showing 83 changed files with 1,219 additions and 1,223 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -78,8 +78,8 @@ public AbstractExecutableMemberWriter(SubWriterHolderWriter writer) {
protected void addTypeParameters(ExecutableElement member, Content htmltree) {
Content typeParameters = getTypeParameters(member);
if (!typeParameters.isEmpty()) {
htmltree.addContent(typeParameters);
htmltree.addContent(Contents.SPACE);
htmltree.add(typeParameters);
htmltree.add(Contents.SPACE);
}
}

Expand All @@ -100,16 +100,16 @@ protected Content getTypeParameters(ExecutableElement member) {
@Override
protected Content getDeprecatedLink(Element member) {
Content deprecatedLinkContent = new ContentBuilder();
deprecatedLinkContent.addContent(utils.getFullyQualifiedName(member));
deprecatedLinkContent.add(utils.getFullyQualifiedName(member));
if (!utils.isConstructor(member)) {
deprecatedLinkContent.addContent(".");
deprecatedLinkContent.addContent(member.getSimpleName());
deprecatedLinkContent.add(".");
deprecatedLinkContent.add(member.getSimpleName());
}
String signature = utils.flatSignature((ExecutableElement) member);
if (signature.length() > 2) {
deprecatedLinkContent.addContent(Contents.ZERO_WIDTH_SPACE);
deprecatedLinkContent.add(Contents.ZERO_WIDTH_SPACE);
}
deprecatedLinkContent.addContent(signature);
deprecatedLinkContent.add(signature);

return writer.getDocLink(MEMBER, utils.getEnclosingTypeElement(member), member, deprecatedLinkContent);
}
Expand All @@ -131,7 +131,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement te, Element
name(ee), false));
Content code = HtmlTree.CODE(memberLink);
addParameters(ee, false, code, name(ee).length() - 1);
tdSummary.addContent(code);
tdSummary.add(code);
}

/**
Expand All @@ -143,7 +143,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement te, Element
*/
@Override
protected void addInheritedSummaryLink(TypeElement te, Element member, Content linksTree) {
linksTree.addContent(writer.getDocLink(MEMBER, te, member, name(member), false));
linksTree.add(writer.getDocLink(MEMBER, te, member, name(member), false));
}

/**
Expand All @@ -158,10 +158,10 @@ 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);
tree.add(link);
if(name(param).length() > 0) {
tree.addContent(Contents.SPACE);
tree.addContent(name(param));
tree.add(Contents.SPACE);
tree.add(name(param));
}
}

Expand All @@ -176,12 +176,12 @@ protected void addParam(ExecutableElement member, VariableElement param,
protected void addReceiverAnnotations(ExecutableElement member, TypeMirror rcvrType,
List<? extends AnnotationMirror> annotationMirrors, Content tree) {
writer.addReceiverAnnotationInfo(member, rcvrType, annotationMirrors, tree);
tree.addContent(Contents.SPACE);
tree.addContent(utils.getTypeName(rcvrType, false));
tree.add(Contents.SPACE);
tree.add(utils.getTypeName(rcvrType, false));
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, RECEIVER_TYPE, rcvrType);
tree.addContent(writer.getTypeParameterLinks(linkInfo));
tree.addContent(Contents.SPACE);
tree.addContent("this");
tree.add(writer.getTypeParameterLinks(linkInfo));
tree.add(Contents.SPACE);
tree.add("this");
}


Expand Down Expand Up @@ -216,7 +216,7 @@ protected void addParameters(ExecutableElement member,
}
int paramstart;
for (paramstart = 0; paramstart < parameters.size(); paramstart++) {
paramTree.addContent(sep);
paramTree.add(sep);
VariableElement param = parameters.get(paramstart);

if (param.getKind() != ElementKind.INSTANCE_INIT) {
Expand All @@ -225,8 +225,8 @@ protected void addParameters(ExecutableElement member,
writer.addAnnotationInfo(indent.length(),
member, param, paramTree);
if (foundAnnotations) {
paramTree.addContent(DocletConstants.NL);
paramTree.addContent(indent);
paramTree.add(DocletConstants.NL);
paramTree.add(indent);
}
}
addParam(member, param,
Expand All @@ -236,28 +236,28 @@ protected void addParameters(ExecutableElement member,
}

for (int i = paramstart + 1; i < parameters.size(); i++) {
paramTree.addContent(",");
paramTree.addContent(DocletConstants.NL);
paramTree.addContent(indent);
paramTree.add(",");
paramTree.add(DocletConstants.NL);
paramTree.add(indent);
if (includeAnnotations) {
boolean foundAnnotations =
writer.addAnnotationInfo(indent.length(), member, parameters.get(i),
paramTree);
if (foundAnnotations) {
paramTree.addContent(DocletConstants.NL);
paramTree.addContent(indent);
paramTree.add(DocletConstants.NL);
paramTree.add(indent);
}
}
addParam(member, parameters.get(i), (i == parameters.size() - 1) && member.isVarArgs(),
paramTree);
}
if (paramTree.isEmpty()) {
htmltree.addContent("()");
htmltree.add("()");
} else {
htmltree.addContent(Contents.ZERO_WIDTH_SPACE);
htmltree.addContent("(");
htmltree.addContent(paramTree);
paramTree.addContent(")");
htmltree.add(Contents.ZERO_WIDTH_SPACE);
htmltree.add("(");
htmltree.add(paramTree);
paramTree.add(")");
}
}

Expand All @@ -271,19 +271,19 @@ protected void addExceptions(ExecutableElement member, Content htmltree, int ind
List<? extends TypeMirror> exceptions = member.getThrownTypes();
if (!exceptions.isEmpty()) {
CharSequence indent = makeSpace(indentSize + 1 - 7);
htmltree.addContent(DocletConstants.NL);
htmltree.addContent(indent);
htmltree.addContent("throws ");
htmltree.add(DocletConstants.NL);
htmltree.add(indent);
htmltree.add("throws ");
indent = makeSpace(indentSize + 1);
Content link = writer.getLink(new LinkInfoImpl(configuration, MEMBER, exceptions.get(0)));
htmltree.addContent(link);
htmltree.add(link);
for(int i = 1; i < exceptions.size(); i++) {
htmltree.addContent(",");
htmltree.addContent(DocletConstants.NL);
htmltree.addContent(indent);
htmltree.add(",");
htmltree.add(DocletConstants.NL);
htmltree.add(indent);
Content exceptionLink = writer.getLink(new LinkInfoImpl(configuration, MEMBER,
exceptions.get(i)));
htmltree.addContent(exceptionLink);
htmltree.add(exceptionLink);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected void addContents(Character uc, Collection<? extends Element> memberlis
for (Element element : memberlist) {
addDescription(dl, element);
}
contentTree.addContent(dl);
contentTree.add(dl);
}
}

Expand All @@ -122,7 +122,7 @@ protected void addSearchContents(Character uc, List<SearchIndexItem> searchList,
for (SearchIndexItem sii : searchList) {
addDescription(sii, dl);
}
contentTree.addContent(dl);
contentTree.add(dl);
}
}

Expand Down Expand Up @@ -163,16 +163,16 @@ protected void addContents(Character uc, List<? extends Element> memberlist,
i++;
}
}
contentTree.addContent(dl);
contentTree.add(dl);
}

protected void addHeading(Character uc, Content contentTree) {
String unicode = uc.toString();
contentTree.addContent(getMarkerAnchorForIndex(unicode));
contentTree.add(getMarkerAnchorForIndex(unicode));
Content headContent = new StringContent(unicode);
Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, false,
HtmlStyle.title, headContent);
contentTree.addContent(heading);
contentTree.add(heading);
}

protected void addDescription(Content dl, Element element) {
Expand Down Expand Up @@ -225,13 +225,13 @@ protected void addDescription(ModuleElement mdle, Content dlTree, SearchIndexIte
si.setLabel(moduleName);
si.setCategory(resources.getText("doclet.Modules"));
Content dt = HtmlTree.DT(link);
dt.addContent(" - ");
dt.addContent(contents.module_);
dt.addContent(" " + moduleName);
dlTree.addContent(dt);
dt.add(" - ");
dt.add(contents.module_);
dt.add(" " + moduleName);
dlTree.add(dt);
Content dd = new HtmlTree(HtmlTag.DD);
addSummaryComment(mdle, dd);
dlTree.addContent(dd);
dlTree.add(dd);
}

/**
Expand All @@ -249,13 +249,13 @@ protected void addDescription(PackageElement pkg, Content dlTree, SearchIndexIte
si.setLabel(utils.getPackageName(pkg));
si.setCategory(resources.getText("doclet.Packages"));
Content dt = HtmlTree.DT(link);
dt.addContent(" - ");
dt.addContent(contents.package_);
dt.addContent(" " + utils.getPackageName(pkg));
dlTree.addContent(dt);
dt.add(" - ");
dt.add(contents.package_);
dt.add(" " + utils.getPackageName(pkg));
dlTree.add(dt);
Content dd = new HtmlTree(HtmlTag.DD);
addSummaryComment(pkg, dd);
dlTree.addContent(dd);
dlTree.add(dd);
}

/**
Expand All @@ -272,12 +272,12 @@ protected void addDescription(TypeElement typeElement, Content dlTree, SearchInd
si.setLabel(utils.getSimpleName(typeElement));
si.setCategory(resources.getText("doclet.Types"));
Content dt = HtmlTree.DT(link);
dt.addContent(" - ");
dt.add(" - ");
addClassInfo(typeElement, dt);
dlTree.addContent(dt);
dlTree.add(dt);
Content dd = new HtmlTree(HtmlTag.DD);
addComment(typeElement, dd);
dlTree.addContent(dd);
dlTree.add(dd);
}

/**
Expand All @@ -288,7 +288,7 @@ protected void addDescription(TypeElement typeElement, Content dlTree, SearchInd
* @param contentTree the content tree to which the class info will be added
*/
protected void addClassInfo(TypeElement te, Content contentTree) {
contentTree.addContent(contents.getContent("doclet.in",
contentTree.add(contents.getContent("doclet.in",
utils.getTypeElementName(te, false),
getPackageLink(utils.containingPackage(te),
utils.getPackageName(utils.containingPackage(te)))
Expand Down Expand Up @@ -322,29 +322,29 @@ protected void addDescription(Element member, Content dlTree, SearchIndexItem si
Content span = HtmlTree.SPAN(HtmlStyle.memberNameLink,
getDocLink(LinkInfoImpl.Kind.INDEX, member, name));
Content dt = HtmlTree.DT(span);
dt.addContent(" - ");
dt.add(" - ");
addMemberDesc(member, dt);
dlTree.addContent(dt);
dlTree.add(dt);
Content dd = new HtmlTree(HtmlTag.DD);
addComment(member, dd);
dlTree.addContent(dd);
dlTree.add(dd);
}

protected void addDescription(SearchIndexItem sii, Content dlTree) {
String siiPath = pathToRoot.isEmpty() ? "" : pathToRoot.getPath() + "/";
siiPath += sii.getUrl();
HtmlTree labelLink = HtmlTree.A(siiPath, new StringContent(sii.getLabel()));
Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.searchTagLink, labelLink));
dt.addContent(" - ");
dt.addContent(contents.getContent("doclet.Search_tag_in", sii.getHolder()));
dlTree.addContent(dt);
dt.add(" - ");
dt.add(contents.getContent("doclet.Search_tag_in", sii.getHolder()));
dlTree.add(dt);
Content dd = new HtmlTree(HtmlTag.DD);
if (sii.getDescription().isEmpty()) {
dd.addContent(Contents.SPACE);
dd.add(Contents.SPACE);
} else {
dd.addContent(sii.getDescription());
dd.add(sii.getDescription());
}
dlTree.addContent(dd);
dlTree.add(dd);
}

/**
Expand All @@ -362,17 +362,17 @@ protected void addComment(Element element, Content contentTree) {
HtmlTree div = new HtmlTree(HtmlTag.DIV);
div.setStyle(HtmlStyle.deprecationBlock);
if (utils.isDeprecated(element)) {
div.addContent(span);
div.add(span);
tags = utils.getBlockTags(element, DocTree.Kind.DEPRECATED);
if (!tags.isEmpty())
addInlineDeprecatedComment(element, tags.get(0), div);
contentTree.addContent(div);
contentTree.add(div);
} else {
TypeElement encl = utils.getEnclosingTypeElement(element);
while (encl != null) {
if (utils.isDeprecated(encl)) {
div.addContent(span);
contentTree.addContent(div);
div.add(span);
contentTree.add(div);
break;
}
encl = utils.getEnclosingTypeElement(encl);
Expand All @@ -395,15 +395,15 @@ protected void addMemberDesc(Element member, Content contentTree) {
Content resource = contents.getContent(utils.isStatic(member)
? "doclet.Static_variable_in"
: "doclet.Variable_in", classdesc);
contentTree.addContent(resource);
contentTree.add(resource);
} else if (utils.isConstructor(member)) {
contentTree.addContent(
contentTree.add(
contents.getContent("doclet.Constructor_for", classdesc));
} else if (utils.isMethod(member)) {
Content resource = contents.getContent(utils.isStatic(member)
? "doclet.Static_method_in"
: "doclet.Method_in", classdesc);
contentTree.addContent(resource);
contentTree.add(resource);
}
addPreQualifiedClassLink(LinkInfoImpl.Kind.INDEX, containing,
false, contentTree);
Expand Down
Loading

1 comment on commit dabf4d1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.