Path: blob/master/test/langtools/jdk/javadoc/tool/NoStar.java
40957 views
/*1* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 458756226* @summary tool: Indentation messed up for javadoc comments omitting preceding *27* @modules jdk.javadoc/jdk.javadoc.internal.tool28* @run main NoStar29*/3031import java.util.*;3233import javax.lang.model.SourceVersion;34import javax.lang.model.element.TypeElement;35import javax.lang.model.util.ElementFilter;3637import com.sun.source.doctree.DocCommentTree;38import com.sun.source.util.DocTrees;39import jdk.javadoc.doclet.Doclet;40import jdk.javadoc.doclet.Reporter;41import jdk.javadoc.doclet.DocletEnvironment;4243/** First sentence.44045146247348449550*/51public class NoStar implements Doclet52{53public static void main(String[] args) {54String[] argarray = {55"-docletpath", System.getProperty("test.classes", "."),56"-doclet", "NoStar",57System.getProperty("test.src", ".") + java.io.File.separatorChar + "NoStar.java"58};59if (jdk.javadoc.internal.tool.Main.execute(argarray) != 0)60throw new Error();61}6263public boolean run(DocletEnvironment root) {64Set<TypeElement> classes = ElementFilter.typesIn(root.getIncludedElements());65if (classes.size() != 1)66throw new Error("1 " + Arrays.asList(classes));67TypeElement self = classes.iterator().next();68DocTrees trees = root.getDocTrees();69DocCommentTree docCommentTree = trees.getDocCommentTree(self);70String c = docCommentTree.getFullBody().toString();71System.out.println("\"" + c + "\"");72return c.equals("""73First sentence.740751762773784795""");80}8182@Override83public String getName() {84return "Test";85}8687@Override88public Set<Option> getSupportedOptions() {89return Collections.emptySet();90}9192@Override93public SourceVersion getSupportedSourceVersion() {94return SourceVersion.latest();95}9697@Override98public void init(Locale locale, Reporter reporter) {99return;100}101}102103104