mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
8129909: Add -Xdoclint/package: to javadoc
Adding -Xdoclint/package: command line option, similar to the javac -Xdoclint/package: option, to javadoc. Reviewed-by: darcy, jjg, ksrini
This commit is contained in:
parent
629ace2fd4
commit
85193a1a26
8 changed files with 125 additions and 40 deletions
|
@ -23,7 +23,7 @@
|
|||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8004834 8007610
|
||||
* @bug 8004834 8007610 8129909
|
||||
* @summary Add doclint support into javadoc
|
||||
* @modules jdk.compiler/com.sun.tools.javac.main
|
||||
*/
|
||||
|
@ -59,7 +59,7 @@ public class DocLintTest {
|
|||
|
||||
DocumentationTool javadoc;
|
||||
StandardJavaFileManager fm;
|
||||
JavaFileObject file;
|
||||
Iterable<? extends JavaFileObject> files;
|
||||
|
||||
final String code =
|
||||
/* 01 */ "/** Class comment. */\n" +
|
||||
|
@ -77,6 +77,20 @@ public class DocLintTest {
|
|||
/* 13 */ " public int emptyReturn() { return 0; }\n" +
|
||||
/* 14 */ "}\n";
|
||||
|
||||
final String p1Code =
|
||||
/* 01 */ "package p1;\n" +
|
||||
/* 02 */ "public class P1Test {\n" +
|
||||
/* 03 */ " /** Syntax < error. */\n" +
|
||||
/* 04 */ " public void method() { }\n" +
|
||||
/* 05 */ "}\n";
|
||||
|
||||
final String p2Code =
|
||||
/* 01 */ "package p2;\n" +
|
||||
/* 02 */ "public class P2Test {\n" +
|
||||
/* 03 */ " /** Syntax < error. */\n" +
|
||||
/* 04 */ " public void method() { }\n" +
|
||||
/* 05 */ "}\n";
|
||||
|
||||
private final String rawDiags = "-XDrawDiagnostics";
|
||||
|
||||
private enum Message {
|
||||
|
@ -85,6 +99,9 @@ public class DocLintTest {
|
|||
DL_ERR9(ERROR, "Test.java:9:14: compiler.err.proc.messager: reference not found"),
|
||||
DL_WRN12(WARNING, "Test.java:12:9: compiler.warn.proc.messager: no description for @return"),
|
||||
|
||||
DL_ERR_P1TEST(ERROR, "P1Test.java:3:16: compiler.err.proc.messager: malformed HTML"),
|
||||
DL_ERR_P2TEST(ERROR, "P2Test.java:3:16: compiler.err.proc.messager: malformed HTML"),
|
||||
|
||||
// doclint messages when -XDrawDiagnostics is not in effect
|
||||
DL_ERR9A(ERROR, "Test.java:9: error: reference not found"),
|
||||
DL_WRN12A(WARNING, "Test.java:12: warning: no description for @return"),
|
||||
|
@ -95,7 +112,8 @@ public class DocLintTest {
|
|||
|
||||
// javadoc messages for bad options
|
||||
OPT_BADARG(ERROR, "javadoc: error - Invalid argument for -Xdoclint option"),
|
||||
OPT_BADQUAL(ERROR, "javadoc: error - Access qualifiers not permitted for -Xdoclint arguments");
|
||||
OPT_BADQUAL(ERROR, "javadoc: error - Access qualifiers not permitted for -Xdoclint arguments"),
|
||||
OPT_BADPACKAGEARG(ERROR, "javadoc: error - Invalid argument for -Xdoclint/package option");
|
||||
|
||||
final Diagnostic.Kind kind;
|
||||
final String text;
|
||||
|
@ -124,12 +142,7 @@ public class DocLintTest {
|
|||
fm = javadoc.getStandardFileManager(null, null, null);
|
||||
try {
|
||||
fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
|
||||
file = new SimpleJavaFileObject(URI.create("Test.java"), JavaFileObject.Kind.SOURCE) {
|
||||
@Override
|
||||
public CharSequence getCharContent(boolean ignoreEncoding) {
|
||||
return code;
|
||||
}
|
||||
};
|
||||
files = Arrays.asList(new TestJFO("Test.java", code));
|
||||
|
||||
test(Collections.<String>emptyList(),
|
||||
Main.Result.ERROR,
|
||||
|
@ -175,6 +188,21 @@ public class DocLintTest {
|
|||
Main.Result.ERROR,
|
||||
EnumSet.of(Message.OPT_BADARG));
|
||||
|
||||
files = Arrays.asList(new TestJFO("p1/P1Test.java", p1Code),
|
||||
new TestJFO("p2/P2Test.java", p2Code));
|
||||
|
||||
test(Arrays.asList(rawDiags),
|
||||
Main.Result.ERROR,
|
||||
EnumSet.of(Message.DL_ERR_P1TEST, Message.DL_ERR_P2TEST));
|
||||
|
||||
test(Arrays.asList(rawDiags, "-Xdoclint/package:p1"),
|
||||
Main.Result.ERROR,
|
||||
EnumSet.of(Message.DL_ERR_P1TEST));
|
||||
|
||||
test(Arrays.asList(rawDiags, "-Xdoclint/package:*p"),
|
||||
Main.Result.ERROR,
|
||||
EnumSet.of(Message.OPT_BADPACKAGEARG));
|
||||
|
||||
if (errors > 0)
|
||||
throw new Exception(errors + " errors occurred");
|
||||
} finally {
|
||||
|
@ -186,7 +214,6 @@ public class DocLintTest {
|
|||
System.err.println("test: " + opts);
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
List<JavaFileObject> files = Arrays.asList(file);
|
||||
try {
|
||||
DocumentationTask t = javadoc.getTask(pw, fm, null, null, opts, files);
|
||||
boolean ok = t.call();
|
||||
|
@ -257,4 +284,19 @@ public class DocLintTest {
|
|||
}
|
||||
|
||||
int errors;
|
||||
|
||||
class TestJFO extends SimpleJavaFileObject {
|
||||
|
||||
private final String content;
|
||||
|
||||
public TestJFO(String fileName, String content) {
|
||||
super(URI.create(fileName), JavaFileObject.Kind.SOURCE);
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getCharContent(boolean ignoreEncoding) {
|
||||
return content;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue