8062647: Wrong indentation of arguments of annotated methods

Reviewed-by: jjg, bpatel
This commit is contained in:
Ivan Gerasimov 2015-07-31 01:36:56 +03:00
parent 3e9194a696
commit f04bff42c7
5 changed files with 55 additions and 4 deletions

View File

@ -135,6 +135,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
public Content getSignature(ConstructorDoc constructor) {
Content pre = new HtmlTree(HtmlTag.PRE);
writer.addAnnotationInfo(constructor, pre);
int annotationLength = pre.charCount();
addModifiers(constructor, pre);
if (configuration.linksource) {
Content constructorName = new StringContent(constructor.name());
@ -142,7 +143,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
} else {
addName(constructor.name(), pre);
}
int indent = pre.charCount();
int indent = pre.charCount() - annotationLength;
addParameters(constructor, pre, indent);
addExceptions(constructor, pre, indent);
return pre;

View File

@ -1936,7 +1936,9 @@ public class HtmlDocletWriter extends HtmlDocWriter {
for (Content annotation: annotations) {
htmltree.addContent(sep);
htmltree.addContent(annotation);
sep = " ";
if (!lineBreak) {
sep = " ";
}
}
return true;
}

View File

@ -128,6 +128,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
public Content getSignature(MethodDoc method) {
Content pre = new HtmlTree(HtmlTag.PRE);
writer.addAnnotationInfo(method, pre);
int annotationLength = pre.charCount();
addModifiers(method, pre);
addTypeParameters(method, pre);
addReturnType(method, pre);
@ -137,7 +138,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
} else {
addName(method.name(), pre);
}
int indent = pre.charCount();
int indent = pre.charCount() - annotationLength;
addParameters(method, pre, indent);
addExceptions(method, pre, indent);
return pre;

View File

@ -23,7 +23,7 @@
/*
* @test
* @bug 8011288
* @bug 8011288 8062647
* @summary Erratic/inconsistent indentation of signatures
* @library ../lib
* @modules jdk.javadoc
@ -51,5 +51,12 @@ public class TestIndentation extends JavadocTester {
+ " T t2)",
"\n"
+ " throws java.lang.Exception");
// Test indentation of annotations and annotated method arguments
checkOutput("p/IndentAnnot.html", false,
" @Deprecated",
" int b)",
" java.lang.Object... b)");
}
}

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2015, 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 p;
public class IndentAnnot {
public void f1(int a, int b) {}
public void f2(int a, Object... b) {}
@Deprecated
public void f3(int a, int b) {}
@SafeVarargs
public void f4(int a, Object... b) {}
@SafeVarargs
@Deprecated
public void f5(int a, Object... b) {}
}