NoStar.java revision 3233:b5d08bc0d224
1/*
2 * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24/*
25 * @test
26 * @bug 4587562
27 * @summary tool: Indentation messed up for javadoc comments omitting preceding *
28 * @author gafter
29 * @modules jdk.javadoc
30 * @run main NoStar
31 */
32
33import java.util.*;
34
35import javax.lang.model.SourceVersion;
36import javax.lang.model.element.TypeElement;
37
38import com.sun.source.doctree.DocCommentTree;
39import com.sun.source.util.DocTrees;
40import jdk.javadoc.doclet.Doclet;
41import jdk.javadoc.doclet.Reporter;
42import jdk.javadoc.doclet.DocletEnvironment;
43
44/** First sentence.
450
46 1
47  2
48   3
49    4
50     5
51*/
52public class NoStar implements Doclet
53{
54    public static void main(String[] args) {
55        String[] argarray = {
56            "-docletpath", System.getProperty("test.classes", "."),
57            "-doclet", "NoStar",
58            System.getProperty("test.src", ".") + java.io.File.separatorChar + "NoStar.java"
59        };
60        if (jdk.javadoc.internal.tool.Main.execute(argarray) != 0)
61            throw new Error();
62    }
63
64    public boolean run(DocletEnvironment root) {
65        Set<TypeElement> classes = root.getIncludedClasses();
66        if (classes.size() != 1)
67            throw new Error("1 " + Arrays.asList(classes));
68        TypeElement self = classes.iterator().next();
69        DocTrees trees = root.getDocTrees();
70        DocCommentTree docCommentTree = trees.getDocCommentTree(self);
71        String c = docCommentTree.getFullBody().toString();
72        System.out.println("\"" + c + "\"");
73        return c.equals("First sentence.\n0\n 1\n  2\n   3\n    4\n     5");
74    }
75
76    @Override
77    public String getName() {
78        return "Test";
79    }
80
81    @Override
82    public Set<Option> getSupportedOptions() {
83        return Collections.emptySet();
84    }
85
86    @Override
87    public SourceVersion getSupportedSourceVersion() {
88        return SourceVersion.latest();
89    }
90
91    @Override
92    public void init(Locale locale, Reporter reporter) {
93        return;
94    }
95}
96