@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)); } }
@Override public IrDocBlock parse(String tag, JavadocScanner scanner) throws JavadocParseException { ArrayList<IrDocFragment> fragments = new ArrayList<>(); IrDocSimpleName name = fetchSimpleName(scanner); if (name != null) { fragments.add(name); IrDocType type = fetchType(scanner); if (type != null) { fragments.add(type); } } fragments.addAll(fetchRestFragments(scanner)); fragments.trimToSize(); return newBlock(tag, fragments); }
SerialFieldBlockParser extends AcceptableJavadocBlockParser { @Override public IrDocBlock parse(String tag, JavadocScanner scanner) throws JavadocParseException { ArrayList<IrDocFragment> fragments = new ArrayList<>(); IrDocSimpleName name = fetchSimpleName(scanner); if (name != null) { fragments.add(name); IrDocType type = fetchType(scanner); if (type != null) { fragments.add(type); } } fragments.addAll(fetchRestFragments(scanner)); fragments.trimToSize(); return newBlock(tag, fragments); } }
SerialFieldBlockParser extends AcceptableJavadocBlockParser { @Override public IrDocBlock parse(String tag, JavadocScanner scanner) throws JavadocParseException { ArrayList<IrDocFragment> fragments = new ArrayList<>(); IrDocSimpleName name = fetchSimpleName(scanner); if (name != null) { fragments.add(name); IrDocType type = fetchType(scanner); if (type != null) { fragments.add(type); } } fragments.addAll(fetchRestFragments(scanner)); fragments.trimToSize(); return newBlock(tag, fragments); } SerialFieldBlockParser();  SerialFieldBlockParser(String tagName, String... tagNames); }
SerialFieldBlockParser extends AcceptableJavadocBlockParser { @Override public IrDocBlock parse(String tag, JavadocScanner scanner) throws JavadocParseException { ArrayList<IrDocFragment> fragments = new ArrayList<>(); IrDocSimpleName name = fetchSimpleName(scanner); if (name != null) { fragments.add(name); IrDocType type = fetchType(scanner); if (type != null) { fragments.add(type); } } fragments.addAll(fetchRestFragments(scanner)); fragments.trimToSize(); return newBlock(tag, fragments); } SerialFieldBlockParser();  SerialFieldBlockParser(String tagName, String... tagNames); @Override IrDocBlock parse(String tag, JavadocScanner scanner); }
SerialFieldBlockParser extends AcceptableJavadocBlockParser { @Override public IrDocBlock parse(String tag, JavadocScanner scanner) throws JavadocParseException { ArrayList<IrDocFragment> fragments = new ArrayList<>(); IrDocSimpleName name = fetchSimpleName(scanner); if (name != null) { fragments.add(name); IrDocType type = fetchType(scanner); if (type != null) { fragments.add(type); } } fragments.addAll(fetchRestFragments(scanner)); fragments.trimToSize(); return newBlock(tag, fragments); } SerialFieldBlockParser();  SerialFieldBlockParser(String tagName, String... tagNames); @Override IrDocBlock parse(String tag, JavadocScanner scanner);  }