8303123: Add line break opportunity to single type parameters
Reviewed-by: jjg
This commit is contained in:
parent
094e03de6a
commit
2e91585ac9
@ -202,8 +202,9 @@ public abstract class AbstractMemberWriter implements MemberSummaryWriter, Membe
|
||||
if (list != null && !list.isEmpty()) {
|
||||
Content typeParameters = ((AbstractExecutableMemberWriter) this)
|
||||
.getTypeParameters((ExecutableElement)member);
|
||||
code.add(typeParameters);
|
||||
//Code to avoid ugly wrapping in member summary table.
|
||||
code.add(typeParameters);
|
||||
// Add explicit line break between method type parameters and
|
||||
// return type in member summary table to avoid random wrapping.
|
||||
if (typeParameters.charCount() > 10) {
|
||||
code.add(new HtmlTree(TagName.BR));
|
||||
} else {
|
||||
@ -212,7 +213,8 @@ public abstract class AbstractMemberWriter implements MemberSummaryWriter, Membe
|
||||
}
|
||||
code.add(
|
||||
writer.getLink(new HtmlLinkInfo(configuration,
|
||||
HtmlLinkInfo.Kind.LINK_TYPE_PARAMS, type)));
|
||||
HtmlLinkInfo.Kind.LINK_TYPE_PARAMS, type)
|
||||
.addLineBreakOpportunitiesInTypeParameters(true)));
|
||||
}
|
||||
target.add(code);
|
||||
}
|
||||
|
@ -327,6 +327,9 @@ public class HtmlLinkFactory {
|
||||
return links;
|
||||
}
|
||||
if (!vars.isEmpty()) {
|
||||
if (linkInfo.addLineBreakOpportunitiesInTypeParameters()) {
|
||||
links.add(new HtmlTree(TagName.WBR));
|
||||
}
|
||||
links.add("<");
|
||||
boolean many = false;
|
||||
for (TypeMirror t : vars) {
|
||||
|
@ -122,9 +122,12 @@ public class HtmlLinkInfo {
|
||||
// True iff the preview flags should be skipped for this link.
|
||||
private boolean skipPreview;
|
||||
|
||||
// True if type parameters should be separated by line breaks.
|
||||
// True if type parameters should be separated by hard line breaks.
|
||||
private boolean addLineBreaksInTypeParameters = false;
|
||||
|
||||
// True if additional <wbr> tags should be added to type parameters
|
||||
private boolean addLineBreakOpportunitiesInTypeParameters = false;
|
||||
|
||||
// True if annotations on type parameters should be shown.
|
||||
private boolean showTypeParameterAnnotations = false;
|
||||
|
||||
@ -311,6 +314,23 @@ public class HtmlLinkInfo {
|
||||
return addLineBreaksInTypeParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the addLineBreakOpportunitiesInTypeParameters flag for this link.
|
||||
* @param addLineBreakOpportunities the new value
|
||||
* @return this object
|
||||
*/
|
||||
public HtmlLinkInfo addLineBreakOpportunitiesInTypeParameters(boolean addLineBreakOpportunities) {
|
||||
this.addLineBreakOpportunitiesInTypeParameters = addLineBreakOpportunities;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return true if line break opportunities should be added to type parameters}
|
||||
*/
|
||||
public boolean addLineBreakOpportunitiesInTypeParameters() {
|
||||
return addLineBreakOpportunitiesInTypeParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the linkToSelf flag for this link.
|
||||
* @param linkToSelf the new value
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2023, 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
|
||||
@ -369,16 +369,16 @@ public class TestJavaFX extends JavadocTester {
|
||||
<div class="col-last odd-row-color method-summary-table method-summary-table-tab\
|
||||
2 method-summary-table-tab4"> </div>
|
||||
<div class="col-first even-row-color method-summary-table method-summary-table-t\
|
||||
ab2 method-summary-table-tab4"><code>final java.util.List<java.util.Set<? \
|
||||
super java.lang.Object>></code></div>
|
||||
ab2 method-summary-table-tab4"><code>final java.util.List<wbr><java.util.Set&\
|
||||
lt;? super java.lang.Object>></code></div>
|
||||
<div class="col-second even-row-color method-summary-table method-summary-table-\
|
||||
tab2 method-summary-table-tab4"><code><a href="#deltaProperty()" class="member-n\
|
||||
ame-link">deltaProperty</a>()</code></div>
|
||||
<div class="col-last even-row-color method-summary-table method-summary-table-ta\
|
||||
b2 method-summary-table-tab4"> </div>
|
||||
<div class="col-first odd-row-color method-summary-table method-summary-table-ta\
|
||||
b2 method-summary-table-tab4"><code>final java.util.List<java.lang.String>\
|
||||
</code></div>
|
||||
b2 method-summary-table-tab4"><code>final java.util.List<wbr><java.lang.Strin\
|
||||
g></code></div>
|
||||
<div class="col-second odd-row-color method-summary-table method-summary-table-t\
|
||||
ab2 method-summary-table-tab4"><code><a href="#gammaProperty()" class="member-na\
|
||||
me-link">gammaProperty</a>()</code></div>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2023, 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
|
||||
@ -272,7 +272,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
|
||||
></span></div>""",
|
||||
"""
|
||||
<div class="col-first even-row-color"><code><a href="../ParamTest.html" title="class\
|
||||
in pkg2">ParamTest</a><<a href="../Foo.html" title="class in pkg2">Foo</a>&g\
|
||||
in pkg2">ParamTest</a><wbr><<a href="../Foo.html" title="class in pkg2">Foo</a>&g\
|
||||
t;</code></div>"""
|
||||
);
|
||||
|
||||
@ -283,7 +283,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
|
||||
pan></div>""",
|
||||
"""
|
||||
<div class="col-first even-row-color"><code><a href="../ParamTest.html" title="class\
|
||||
in pkg2">ParamTest</a><<a href="../Foo.html" title="class in pkg2">Foo</a>&\
|
||||
in pkg2">ParamTest</a><wbr><<a href="../Foo.html" title="class in pkg2">Foo</a>&\
|
||||
gt;</code></div>"""
|
||||
);
|
||||
|
||||
@ -331,9 +331,9 @@ public class TestNewLanguageFeatures extends JavadocTester {
|
||||
declared as <a href="../ParamTest.html" title="class in pkg2">ParamTest</a></s\
|
||||
pan></div>""",
|
||||
"""
|
||||
<div class="col-first even-row-color"><code><a href="../ParamTest.html" title="class\
|
||||
in pkg2">ParamTest</a><<a href="../Foo.html" title="class in pkg2">Foo</a>&\
|
||||
gt;</code></div>""",
|
||||
<div class="col-first even-row-color"><code><a href="../ParamTest.html" title="\
|
||||
class in pkg2">ParamTest</a><wbr><<a href="../Foo.html" title="class in pkg2\
|
||||
">Foo</a>></code></div>""",
|
||||
"""
|
||||
<div class="caption"><span>Methods in <a href="../package-summary.html">pkg2</a\
|
||||
> with type parameters of type <a href="../ParamTest.html" title="class in pkg2\
|
||||
@ -342,8 +342,8 @@ public class TestNewLanguageFeatures extends JavadocTester {
|
||||
<div class="col-first even-row-color"><code><T extends <a href="../ParamTest.html\
|
||||
" title="class in pkg2">ParamTest</a><<a href="../Foo3.html" title="class in\
|
||||
pkg2">Foo3</a>>><br><a href="../ParamTest.html" title="class in pkg2">Pa\
|
||||
ramTest</a><<a href="../Foo3.html" title="class in pkg2">Foo3</a>></code>\
|
||||
</div>"""
|
||||
ramTest</a><wbr><<a href="../Foo3.html" title="class in pkg2">Foo3</a>></\
|
||||
code></div>"""
|
||||
);
|
||||
|
||||
checkOutput("pkg2/class-use/Foo3.html", true,
|
||||
@ -372,8 +372,8 @@ public class TestNewLanguageFeatures extends JavadocTester {
|
||||
<div class="col-first even-row-color"><code><T extends <a href="../ParamTest.html\
|
||||
" title="class in pkg2">ParamTest</a><<a href="../Foo3.html" title="class in\
|
||||
pkg2">Foo3</a>>><br><a href="../ParamTest.html" title="class in pkg2">Pa\
|
||||
ramTest</a><<a href="../Foo3.html" title="class in pkg2">Foo3</a>></code>\
|
||||
</div>"""
|
||||
ramTest</a><wbr><<a href="../Foo3.html" title="class in pkg2">Foo3</a>></\
|
||||
code></div>"""
|
||||
);
|
||||
|
||||
// ClassUseTest3: <T extends ParamTest2<List<? extends Foo4>>>
|
||||
@ -400,8 +400,8 @@ public class TestNewLanguageFeatures extends JavadocTester {
|
||||
<div class="col-first even-row-color"><code><T extends <a href="../ParamTest2.htm\
|
||||
l" title="class in pkg2">ParamTest2</a><java.util.List<? extends <a href=\
|
||||
"../Foo4.html" title="class in pkg2">Foo4</a>>>><br><a href="../ParamT\
|
||||
est2.html" title="class in pkg2">ParamTest2</a><java.util.List<? extends\
|
||||
<a href="../Foo4.html" title="class in pkg2">Foo4</a>>></code></div>"""
|
||||
est2.html" title="class in pkg2">ParamTest2</a><wbr><java.util.List<? ext\
|
||||
ends <a href="../Foo4.html" title="class in pkg2">Foo4</a>>></code></div>"""
|
||||
);
|
||||
|
||||
checkOutput("pkg2/class-use/Foo4.html", true,
|
||||
@ -431,8 +431,8 @@ public class TestNewLanguageFeatures extends JavadocTester {
|
||||
<div class="col-first even-row-color"><code><T extends <a href="../ParamTest2\
|
||||
.html" title="class in pkg2">ParamTest2</a><java.util.List<? extends <a hr\
|
||||
ef="../Foo4.html" title="class in pkg2">Foo4</a>>>><br><a href="../Para\
|
||||
mTest2.html" title="class in pkg2">ParamTest2</a><java.util.List<? extends\
|
||||
<a href="../Foo4.html" title="class in pkg2">Foo4</a>>></code></div>"""
|
||||
mTest2.html" title="class in pkg2">ParamTest2</a><wbr><java.util.List<? ex\
|
||||
tends <a href="../Foo4.html" title="class in pkg2">Foo4</a>>></code></div>"""
|
||||
);
|
||||
|
||||
// Type parameters in constructor and method args
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2023, 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
|
||||
@ -89,8 +89,8 @@ public class TestProperty extends JavadocTester {
|
||||
// no tab classes should be used in the property table
|
||||
"""
|
||||
<div class="col-first even-row-color"><code>final <a href="ObjectProperty.html" \
|
||||
title="class in pkg">ObjectProperty</a><<a href="MyObj.html" title="class in \
|
||||
pkg">MyObj</a>[]></code></div>
|
||||
title="class in pkg">ObjectProperty</a><wbr><<a href="MyObj.html" title="clas\
|
||||
s in pkg">MyObj</a>[]></code></div>
|
||||
<div class="col-second even-row-color"><code><a href="#badProperty" class="membe\
|
||||
r-name-link">bad</a></code></div>
|
||||
<div class="col-last even-row-color">""",
|
||||
@ -99,8 +99,8 @@ public class TestProperty extends JavadocTester {
|
||||
"""
|
||||
<div class="col-first even-row-color method-summary-table method-summary-table-t\
|
||||
ab2 method-summary-table-tab4"><code>final <a href="ObjectProperty.html" title="\
|
||||
class in pkg">ObjectProperty</a><<a href="MyObj.html" title="class in pkg">My\
|
||||
Obj</a>[]></code></div>
|
||||
class in pkg">ObjectProperty</a><wbr><<a href="MyObj.html" title="class in pk\
|
||||
g">MyObj</a>[]></code></div>
|
||||
<div class="col-second even-row-color method-summary-table method-summary-table-\
|
||||
tab2 method-summary-table-tab4"><code><a href="#badProperty()" class="member-nam\
|
||||
e-link">badProperty</a>()</code></div>"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user