@Test public void testParse() throws Exception { MockJavadocBlockParser i1 = new MockJavadocBlockParser(); i1.setIdentifier("i1"); i1.setAcceptable(Pattern.compile("a")); DefaultJavadocBlockParser parser = new DefaultJavadocBlockParser(Arrays.asList(i1)); { IrDocBlock block = parser.parse(null, string(" Hello, world!")); assertNull(block.getTag()); List<? extends IrDocFragment> fragments = block.getFragments(); assertKinds(fragments, TEXT); } { IrDocBlock block = parser.parse(null, string("{@a sample}")); assertNull(block.getTag()); List<? extends IrDocFragment> fragments = block.getFragments(); assertKinds(fragments, BLOCK); assertMockBlockEquals(i1, "@a", fragments.get(0)); } { IrDocBlock block = parser.parse(null, string("Hello, {@a THIS} world!")); assertNull(block.getTag()); List<? extends IrDocFragment> fragments = block.getFragments(); assertKinds(fragments, TEXT, BLOCK, TEXT); assertTextEquals("Hello, ", fragments.get(0)); assertMockBlockEquals(i1, "@a", fragments.get(1)); assertTextEquals(" world!", fragments.get(2)); } { try { parser.parse(null, string("Hello, {@b THIS} world!")); fail(); } catch (MissingJavadocBlockParserException e) { assertEquals("b", e.getTagName()); } } }
@Override public IrDocBlock parse(String tag, JavadocScanner scanner) throws JavadocParseException { List<IrDocFragment> fragments = fetchRestFragments(scanner); return newBlock(tag, fragments); }
DefaultJavadocBlockParser extends JavadocBlockParser { @Override public IrDocBlock parse(String tag, JavadocScanner scanner) throws JavadocParseException { List<IrDocFragment> fragments = fetchRestFragments(scanner); return newBlock(tag, fragments); } }
DefaultJavadocBlockParser extends JavadocBlockParser { @Override public IrDocBlock parse(String tag, JavadocScanner scanner) throws JavadocParseException { List<IrDocFragment> fragments = fetchRestFragments(scanner); return newBlock(tag, fragments); } DefaultJavadocBlockParser();  DefaultJavadocBlockParser(List<? extends JavadocBlockParser> blockParsers); }
DefaultJavadocBlockParser extends JavadocBlockParser { @Override public IrDocBlock parse(String tag, JavadocScanner scanner) throws JavadocParseException { List<IrDocFragment> fragments = fetchRestFragments(scanner); return newBlock(tag, fragments); } DefaultJavadocBlockParser();  DefaultJavadocBlockParser(List<? extends JavadocBlockParser> blockParsers); @Override boolean canAccept(String tag); @Override IrDocBlock parse(String tag, JavadocScanner scanner); }
DefaultJavadocBlockParser extends JavadocBlockParser { @Override public IrDocBlock parse(String tag, JavadocScanner scanner) throws JavadocParseException { List<IrDocFragment> fragments = fetchRestFragments(scanner); return newBlock(tag, fragments); } DefaultJavadocBlockParser();  DefaultJavadocBlockParser(List<? extends JavadocBlockParser> blockParsers); @Override boolean canAccept(String tag); @Override IrDocBlock parse(String tag, JavadocScanner scanner);  }