Search in sources :

Example 1 with RootDoc

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;
}
Also used : ListBuffer(com.sun.tools.javac.util.ListBuffer) ModifierFilter(com.sun.tools.javadoc.ModifierFilter) Method(java.lang.reflect.Method) RootDoc(com.sun.javadoc.RootDoc)

Example 2 with 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));
}
Also used : Context(com.sun.tools.javac.util.Context) ListBuffer(com.sun.tools.javac.util.ListBuffer) RootDoc(com.sun.javadoc.RootDoc) JavadocTool(com.sun.tools.javadoc.JavadocTool) Test(org.junit.Test)

Example 3 with 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));
}
Also used : Context(com.sun.tools.javac.util.Context) ListBuffer(com.sun.tools.javac.util.ListBuffer) RootDoc(com.sun.javadoc.RootDoc) JavadocTool(com.sun.tools.javadoc.JavadocTool) Test(org.junit.Test)

Example 4 with 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.
    }
}
Also used : Context(com.sun.tools.javac.util.Context) ListBuffer(com.sun.tools.javac.util.ListBuffer) RootDoc(com.sun.javadoc.RootDoc) JavadocTool(com.sun.tools.javadoc.JavadocTool) Test(org.junit.Test)

Aggregations

RootDoc (com.sun.javadoc.RootDoc)4 ListBuffer (com.sun.tools.javac.util.ListBuffer)4 Context (com.sun.tools.javac.util.Context)3 JavadocTool (com.sun.tools.javadoc.JavadocTool)3 Test (org.junit.Test)3 ModifierFilter (com.sun.tools.javadoc.ModifierFilter)1 Method (java.lang.reflect.Method)1