8176231: javadoc -javafx creates bad link when Property is an array of objects

Reviewed-by: ksrini
This commit is contained in:
Jonathan Gibbons 2017-03-20 15:32:39 -07:00
parent 7feb5d6fb7
commit 07e7ae5ceb
8 changed files with 289 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2017, 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
@ -32,6 +32,12 @@ import javax.lang.model.element.Element;
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.ExecutableType;
import javax.lang.model.type.PrimitiveType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.SimpleTypeVisitor9;
import com.sun.source.doctree.DocTree;
import com.sun.source.doctree.DocTree.Kind;
@ -440,16 +446,10 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
if (null != setter) {
VariableElement param = setter.getParameters().get(0);
String typeName = utils.getTypeName(param.asType(), false);
// Removal of type parameters and package information.
typeName = typeName.split("<")[0];
if (typeName.contains(".")) {
typeName = typeName.substring(typeName.lastIndexOf(".") + 1);
}
StringBuilder sb = new StringBuilder("#");
sb.append(utils.getSimpleName(setter));
if (!utils.isTypeVariable(param.asType())) {
sb.append("(").append(typeName).append(")");
sb.append("(").append(utils.getTypeSignature(param.asType(), false, true)).append(")");
}
blockTags.add(cmtutils.makeSeeTree(sb.toString(), setter));
}

View File

@ -725,7 +725,7 @@ public class Utils {
return result.toString();
}
private String getTypeSignature(TypeMirror t, boolean qualifiedName, boolean noTypeParameters) {
public String getTypeSignature(TypeMirror t, boolean qualifiedName, boolean noTypeParameters) {
return new SimpleTypeVisitor9<StringBuilder, Void>() {
final StringBuilder sb = new StringBuilder();

View File

@ -0,0 +1,95 @@
/*
* Copyright (c) 2017, 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.
*
* 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.
*/
/*
* @test
* @bug 8176231
* @summary Test JavaFX property.
* @library ../lib/
* @modules jdk.javadoc/jdk.javadoc.internal.tool
* @build JavadocTester TestProperty
* @run main TestProperty
*/
public class TestProperty extends JavadocTester {
public static void main(String... args) throws Exception {
TestProperty tester = new TestProperty();
tester.runTests();
}
@Test
void testArrays() {
javadoc("-d", "out",
"-javafx",
"-sourcepath", testSrc,
"pkg");
checkExit(Exit.OK);
checkOutput("pkg/MyClass.html", true,
"<pre>public final&nbsp;<a href=\"../pkg/ObjectProperty.html\" "
+ "title=\"class in pkg\">ObjectProperty</a>"
+ "&lt;<a href=\"../pkg/MyObj.html\" "
+ "title=\"class in pkg\">MyObj</a>&gt; goodProperty</pre>\n"
+ "<div class=\"block\">This is an Object property where the "
+ "Object is a single Object.</div>\n"
+ "<dl>\n"
+ "<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
+ "<dd><a href=\"../pkg/MyClass.html#getGood--\"><code>getGood()</code></a>, \n"
+ "<a href=\"../pkg/MyClass.html#setGood-pkg.MyObj-\">"
+ "<code>setGood(MyObj)</code></a></dd>\n"
+ "</dl>",
"<pre>public final&nbsp;<a href=\"../pkg/ObjectProperty.html\" "
+ "title=\"class in pkg\">ObjectProperty</a>"
+ "&lt;<a href=\"../pkg/MyObj.html\" "
+ "title=\"class in pkg\">MyObj</a>[]&gt; badProperty</pre>\n"
+ "<div class=\"block\">This is an Object property where the "
+ "Object is an array.</div>\n"
+ "<dl>\n"
+ "<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
+ "<dd><a href=\"../pkg/MyClass.html#getBad--\"><code>getBad()</code></a>, \n"
+ "<a href=\"../pkg/MyClass.html#setBad-pkg.MyObj:A-\">"
+ "<code>setBad(MyObj[])</code></a></dd>\n"
+ "</dl>"
);
checkOutput("pkg/MyClassT.html", true,
"<pre>public final&nbsp;<a href=\"../pkg/ObjectProperty.html\" "
+ "title=\"class in pkg\">ObjectProperty</a>"
+ "&lt;java.util.List&lt;<a href=\"../pkg/MyClassT.html\" "
+ "title=\"type parameter in MyClassT\">T</a>&gt;&gt; "
+ "listProperty</pre>\n"
+ "<div class=\"block\">This is an Object property where the "
+ "Object is a single <code>List&lt;T&gt;</code>.</div>\n"
+ "<dl>\n"
+ "<dt><span class=\"seeLabel\">See Also:</span></dt>\n"
+ "<dd><a href=\"../pkg/MyClassT.html#getList--\">"
+ "<code>getList()</code></a>, \n"
+ "<a href=\"../pkg/MyClassT.html#setList-java.util.List-\">"
+ "<code>setList(List)</code></a></dd>\n"
+ "</dl>"
);
}
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2017, 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.
*
* 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 pkg;
/**
* Test program for javadoc properties.
*/
public class MyClass {
private SimpleObjectProperty<MyObj> good
= new SimpleObjectProperty<MyObj>();
/**
* This is an Object property where the Object is a single Object.
*
* @return the good
*/
public final ObjectProperty<MyObj> goodProperty() {
return good;
}
public final void setGood(MyObj good) {
}
public final MyObj getGood() {
return good.get();
}
private SimpleObjectProperty<MyObj[]> bad
= new SimpleObjectProperty<MyObj[]>();
/**
* This is an Object property where the Object is an array.
*
* @return the bad
*/
public final ObjectProperty<MyObj[]> badProperty() {
return bad;
}
public final void setBad(MyObj[] bad) {
}
public final MyObj[] getBad() {
return bad.get();
}
}

View File

@ -0,0 +1,32 @@
package pkg;
import java.util.List;
//import javafx.beans.property.*;
/**
* Test program for javadoc properties.
*/
public class MyClassT<T> {
private SimpleObjectProperty<List<T>> list
= new SimpleObjectProperty<List<T>>();
/**
* This is an Object property where the Object is a single {@code List<T>}.
*
* @return the list
*/
public final ObjectProperty<List<T>> listProperty() {
return list;
}
public final void setList(List<T> list) {
}
public final List<T> getList() {
return list.get();
}
}

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2017, 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.
*
* 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 pkg;
public class MyObj {
}

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2017, 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.
*
* 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 pkg;
public class ObjectProperty<T> { }

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2017, 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.
*
* 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 pkg;
public class SimpleObjectProperty<T> { }