Package com.asakusafw.utils.java.internal.parser.javadoc.ir

Examples of com.asakusafw.utils.java.internal.parser.javadoc.ir.IrDocBlock


     * @throws Exception If occurred
     */
    @Test
    public void testParseJust() throws Exception {
        FollowsNamedTypeBlockParser parser = new FollowsNamedTypeBlockParser("throws");
        IrDocBlock block = parser.parse("throws", string("IllegalArgumentException"));
        assertEquals("@throws", block.getTag());
        List<? extends IrDocFragment> fragments = block.getFragments();
        assertKinds(fragments, NAMED_TYPE);
        assertEquals("IllegalArgumentException", ((IrDocNamedType) fragments.get(0)).getName().asString());
    }
View Full Code Here


     * @throws Exception If occurred
     */
    @Test
    public void testParseTrails() throws Exception {
        FollowsNamedTypeBlockParser parser = new FollowsNamedTypeBlockParser("throws");
        IrDocBlock block = parser.parse("throws", string(" IllegalArgumentException nullpo"));
        assertEquals("@throws", block.getTag());
        List<? extends IrDocFragment> fragments = block.getFragments();
        assertKinds(fragments, NAMED_TYPE, TEXT);
        assertEquals("IllegalArgumentException", ((IrDocNamedType) fragments.get(0)).getName().asString());
        assertTextEquals(" nullpo", fragments.get(1));
    }
View Full Code Here

     * @throws Exception If occurred
     */
    @Test
    public void testParseMissing() throws Exception {
        FollowsNamedTypeBlockParser parser = new FollowsNamedTypeBlockParser("throws");
        IrDocBlock block = parser.parse("throws", string(" /IllegalArgumentException"));
        assertEquals("@throws", block.getTag());
        List<? extends IrDocFragment> fragments = block.getFragments();
        assertKinds(fragments, TEXT);
        assertTextEquals(" /IllegalArgumentException", fragments.get(0));
    }
View Full Code Here

                + " */");
            IrDocComment doc = parser.parse(scanner);
            List<? extends IrDocBlock> blocks = doc.getBlocks();
            assertEquals(3, blocks.size());
            {
                IrDocBlock b = blocks.get(0);
                assertNull(b.getTag());
                List<? extends IrDocFragment> fragments = b.getFragments();
                assertKinds(fragments, TEXT, BLOCK, TEXT, TEXT);
            }
            {
                IrDocBlock b = blocks.get(1);
                assertEquals("@param", b.getTag());
                List<? extends IrDocFragment> fragments = b.getFragments();
                assertKinds(fragments, SIMPLE_NAME, TEXT, BLOCK);
                IrDocBlock inner = (IrDocBlock) fragments.get(2);
                assertKinds(inner.getFragments(), NAMED_TYPE);
            }
            {
                IrDocBlock b = blocks.get(2);
                assertEquals("@throws", b.getTag());
                List<? extends IrDocFragment> fragments = b.getFragments();
                assertKinds(fragments, NAMED_TYPE, TEXT);
            }
        }
    }
View Full Code Here

    @Test
    public void testParse() throws Exception {
        SerialFieldBlockParser parser = new SerialFieldBlockParser();
        {
            DefaultJavadocScanner scanner = string("field int");
            IrDocBlock block = parser.parse("serialField", scanner);
            List<? extends IrDocFragment> fragments = block.getFragments();
            assertKinds(fragments, SIMPLE_NAME, BASIC_TYPE);
            assertEquals("field", ((IrDocSimpleName) fragments.get(0)).asString());
        }
        {
            DefaultJavadocScanner scanner = string("field java.lang.String");
            IrDocBlock block = parser.parse("serialField", scanner);
            List<? extends IrDocFragment> fragments = block.getFragments();
            assertKinds(fragments, SIMPLE_NAME, NAMED_TYPE);
            assertEquals("field", ((IrDocSimpleName) fragments.get(0)).asString());
            assertEquals("java.lang.String", ((IrDocNamedType) fragments.get(1)).getName().asString());
        }
        {
            DefaultJavadocScanner scanner = string("field java.lang.String Hello, world!");
            IrDocBlock block = parser.parse("serialField", scanner);
            List<? extends IrDocFragment> fragments = block.getFragments();
            assertKinds(fragments, SIMPLE_NAME, NAMED_TYPE, TEXT);
            assertEquals("field", ((IrDocSimpleName) fragments.get(0)).asString());
            assertEquals("java.lang.String", ((IrDocNamedType) fragments.get(1)).getName().asString());
            assertTextEquals(" Hello, world!", fragments.get(2));
        }
        {
            DefaultJavadocScanner scanner = string("java.lang.String Hello, world!");
            IrDocBlock block = parser.parse("serialField", scanner);
            List<? extends IrDocFragment> fragments = block.getFragments();
            assertKinds(fragments, TEXT);
            assertTextEquals("java.lang.String Hello, world!", fragments.get(0));
        }
    }
View Full Code Here

    @Test
    public void testParseType() throws Exception {
        {
            FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
            DefaultJavadocScanner scanner = string("A");
            IrDocBlock block = parser.parse(null, scanner);
            List<? extends IrDocFragment> fragments = block.getFragments();
            assertKinds(fragments, NAMED_TYPE);
            assertEquals("A", ((IrDocNamedType) fragments.get(0)).getName().asString());
        }
        {
            FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
            DefaultJavadocScanner scanner = string("hoge.foo.Bar");
            IrDocBlock block = parser.parse(null, scanner);
            List<? extends IrDocFragment> fragments = block.getFragments();
            assertKinds(fragments, NAMED_TYPE);
            assertEquals("hoge.foo.Bar", ((IrDocNamedType) fragments.get(0)).getName().asString());
        }
        {
            FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
            DefaultJavadocScanner scanner = string(
                "\n"
                + "    * hoge.foo.Bar");
            IrDocBlock block = parser.parse(null, scanner);
            List<? extends IrDocFragment> fragments = block.getFragments();
            assertKinds(fragments, NAMED_TYPE);
            assertEquals("hoge.foo.Bar", ((IrDocNamedType) fragments.get(0)).getName().asString());
        }
        {
            FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
            DefaultJavadocScanner scanner = string(
                "\n"
                + "    * hoge.foo.Bar?");
            IrDocBlock block = parser.parse(null, scanner);
            List<? extends IrDocFragment> fragments = block.getFragments();
            assertKinds(fragments, TEXT);
            assertTextEquals("hoge.foo.Bar?", fragments.get(0));
        }
        {
            FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
            DefaultJavadocScanner scanner = string(
                " hoge.foo.Bar This is a pen.");
            IrDocBlock block = parser.parse(null, scanner);
            List<? extends IrDocFragment> fragments = block.getFragments();
            assertKinds(fragments, NAMED_TYPE, TEXT);
            assertEquals("hoge.foo.Bar", ((IrDocNamedType) fragments.get(0)).getName().asString());
            assertTextEquals(" This is a pen.", fragments.get(1));
        }
    }
View Full Code Here

    @Test
    public void testParseField() throws Exception {
        {
            FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
            DefaultJavadocScanner scanner = string("#field");
            IrDocBlock block = parser.parse(null, scanner);
            List<? extends IrDocFragment> fragments = block.getFragments();
            assertKinds(fragments, FIELD);
            IrDocField field = (IrDocField) fragments.get(0);
            assertNull(field.getDeclaringType());
            assertEquals("field", field.getName().getIdentifier());
        }
        {
            FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
            DefaultJavadocScanner scanner = string("A#field");
            IrDocBlock block = parser.parse(null, scanner);
            List<? extends IrDocFragment> fragments = block.getFragments();
            assertKinds(fragments, FIELD);
            IrDocField field = (IrDocField) fragments.get(0);
            assertEquals("A", field.getDeclaringType().getName().asString());
            assertEquals("field", field.getName().getIdentifier());
        }
        {
            FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
            DefaultJavadocScanner scanner = string("hoge.foo.Bar#CONST");
            IrDocBlock block = parser.parse(null, scanner);
            List<? extends IrDocFragment> fragments = block.getFragments();
            assertKinds(fragments, FIELD);
            IrDocField field = (IrDocField) fragments.get(0);
            assertEquals("hoge.foo.Bar", field.getDeclaringType().getName().asString());
            assertEquals("CONST", field.getName().getIdentifier());
        }
        {
            FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
            DefaultJavadocScanner scanner = string("\n  * hoge.foo.Bar#CONST");
            IrDocBlock block = parser.parse(null, scanner);
            List<? extends IrDocFragment> fragments = block.getFragments();
            assertKinds(fragments, FIELD);
            IrDocField field = (IrDocField) fragments.get(0);
            assertEquals("hoge.foo.Bar", field.getDeclaringType().getName().asString());
            assertEquals("CONST", field.getName().getIdentifier());
        }
View Full Code Here

    @Test
    public void testParseMethod() throws Exception {
        {
            FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
            DefaultJavadocScanner scanner = string("#method()");
            IrDocBlock block = parser.parse(null, scanner);
            List<? extends IrDocFragment> fragments = block.getFragments();
            assertKinds(fragments, METHOD);
            IrDocMethod method = (IrDocMethod) fragments.get(0);
            assertNull(method.getDeclaringType());
            assertEquals("method", method.getName().getIdentifier());
            assertEquals(0, method.getParameters().size());
        }
        {
            FollowsReferenceBlockParser parser = new FollowsReferenceBlockParser();
            DefaultJavadocScanner scanner = string("#method(int)");
            IrDocBlock block = parser.parse(null, scanner);
            List<? extends IrDocFragment> fragments = block.getFragments();
            assertKinds(fragments, METHOD);
            IrDocMethod method = (IrDocMethod) fragments.get(0);
            assertNull(method.getDeclaringType());
            assertEquals("method", method.getName().getIdentifier());
            assertEquals(1, method.getParameters().size());
View Full Code Here

        return this.identifier;
    }

    @Override
    public IrDocBlock parse(String tag, JavadocScanner scanner) {
        IrDocBlock block = new IrDocBlock();
        block.setTag(tag);
        block.setFragments(Arrays.asList(new IrDocText(identifier)));
        return block;
    }
View Full Code Here

     * @param tag タグ名
     * @param fragment 対象の断片
     */
    public static void assertMockBlockEquals(MockJavadocBlockParser parser, String tag, IrDocFragment fragment) {
        assertEquals(BLOCK, fragment.getKind());
        IrDocBlock block = (IrDocBlock) fragment;
        assertEquals(tag, block.getTag());
        List<? extends IrDocFragment> inlines = block.getFragments();
        assertKinds(inlines, TEXT);
        assertEquals(parser.getIdentifier(), ((IrDocText) inlines.get(0)).getContent());
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.utils.java.internal.parser.javadoc.ir.IrDocBlock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.