use of com.sun.javadoc.RootDoc in project checkstyle by checkstyle.
the class TokenTypesDocletTest method getRootDoc.
private static RootDoc getRootDoc(JavadocTool javadocTool, ListBuffer<String[]> options, ListBuffer<String> names) throws Exception {
final Method getRootDocImpl = getMethodGetRootDocImplByReflection();
final RootDoc rootDoc;
if (System.getProperty("java.version").startsWith("1.7.")) {
rootDoc = (RootDoc) getRootDocImpl.invoke(javadocTool, "", "UTF-8", new ModifierFilter(ModifierFilter.ALL_ACCESS), names.toList(), options.toList(), false, new ListBuffer<String>().toList(), new ListBuffer<String>().toList(), false, false, false);
} else {
rootDoc = (RootDoc) getRootDocImpl.invoke(javadocTool, "", "UTF-8", new ModifierFilter(ModifierFilter.ALL_ACCESS), names.toList(), options.toList(), new ListBuffer<JavaFileObject>().toList(), false, new ListBuffer<String>().toList(), new ListBuffer<String>().toList(), false, false, false);
}
return rootDoc;
}
use of com.sun.javadoc.RootDoc in project checkstyle by checkstyle.
the class TokenTypesDocletTest method testNotConstants.
@Test
public void testNotConstants() throws Exception {
// Token types must be public int constants, which means that they must have
// modifiers public, static, final and type int, because they are referenced statically in
// a lot of different places, must not be changed and an int value is used to encrypt
// a token type.
final ListBuffer<String[]> options = new ListBuffer<>();
options.add(new String[] { "-doclet", "TokenTypesDoclet" });
options.add(new String[] { "-destfile", "target/tokentypes.properties" });
final ListBuffer<String> names = new ListBuffer<>();
names.add(getPath("InputTokenTypesDocletNotConstants.java"));
final Context context = new Context();
new TestMessager(context);
final JavadocTool javadocTool = JavadocTool.make0(context);
final RootDoc rootDoc = getRootDoc(javadocTool, options, names);
assertTrue(TokenTypesDoclet.start(rootDoc));
}
use of com.sun.javadoc.RootDoc in project checkstyle by checkstyle.
the class TokenTypesDocletTest method testCorrect.
@Test
public void testCorrect() throws Exception {
final ListBuffer<String[]> options = new ListBuffer<>();
options.add(new String[] { "-destfile", "target/tokentypes.properties" });
final ListBuffer<String> names = new ListBuffer<>();
names.add(getPath("InputTokenTypesDocletCorrect.java"));
final Context context = new Context();
new TestMessager(context);
final JavadocTool javadocTool = JavadocTool.make0(context);
final RootDoc rootDoc = getRootDoc(javadocTool, options, names);
assertTrue(TokenTypesDoclet.start(rootDoc));
}
use of com.sun.javadoc.RootDoc in project checkstyle by checkstyle.
the class TokenTypesDocletTest method testEmptyJavadoc.
@Test
public void testEmptyJavadoc() throws Exception {
final ListBuffer<String[]> options = new ListBuffer<>();
options.add(new String[] { "-destfile", "target/tokentypes.properties" });
final ListBuffer<String> names = new ListBuffer<>();
names.add(getPath("InputTokenTypesDocletEmptyJavadoc.java"));
final Context context = new Context();
new TestMessager(context);
final JavadocTool javadocTool = JavadocTool.make0(context);
final RootDoc rootDoc = getRootDoc(javadocTool, options, names);
try {
TokenTypesDoclet.start(rootDoc);
fail("IllegalArgumentException is expected");
} catch (IllegalArgumentException expected) {
// Token types must have first sentence of Javadoc summary
// so that a brief description could be provided. Otherwise,
// an IllegalArgumentException is thrown.
}
}
Aggregations