@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()); } }
@Override public IrDocBlock parse(String tag, JavadocScanner scanner) throws JavadocParseException { ArrayList<IrDocFragment> fragments = new ArrayList<>(); IrDocFragment first = fetchLinkTarget(scanner); if (first != null) { fragments.add(first); } fragments.addAll(fetchRestFragments(scanner)); fragments.trimToSize(); return newBlock(tag, fragments); }
FollowsReferenceBlockParser extends AcceptableJavadocBlockParser { @Override public IrDocBlock parse(String tag, JavadocScanner scanner) throws JavadocParseException { ArrayList<IrDocFragment> fragments = new ArrayList<>(); IrDocFragment first = fetchLinkTarget(scanner); if (first != null) { fragments.add(first); } fragments.addAll(fetchRestFragments(scanner)); fragments.trimToSize(); return newBlock(tag, fragments); } }
FollowsReferenceBlockParser extends AcceptableJavadocBlockParser { @Override public IrDocBlock parse(String tag, JavadocScanner scanner) throws JavadocParseException { ArrayList<IrDocFragment> fragments = new ArrayList<>(); IrDocFragment first = fetchLinkTarget(scanner); if (first != null) { fragments.add(first); } fragments.addAll(fetchRestFragments(scanner)); fragments.trimToSize(); return newBlock(tag, fragments); } FollowsReferenceBlockParser(String...tagNames); }
FollowsReferenceBlockParser extends AcceptableJavadocBlockParser { @Override public IrDocBlock parse(String tag, JavadocScanner scanner) throws JavadocParseException { ArrayList<IrDocFragment> fragments = new ArrayList<>(); IrDocFragment first = fetchLinkTarget(scanner); if (first != null) { fragments.add(first); } fragments.addAll(fetchRestFragments(scanner)); fragments.trimToSize(); return newBlock(tag, fragments); } FollowsReferenceBlockParser(String...tagNames); @Override IrDocBlock parse(String tag, JavadocScanner scanner); }
FollowsReferenceBlockParser extends AcceptableJavadocBlockParser { @Override public IrDocBlock parse(String tag, JavadocScanner scanner) throws JavadocParseException { ArrayList<IrDocFragment> fragments = new ArrayList<>(); IrDocFragment first = fetchLinkTarget(scanner); if (first != null) { fragments.add(first); } fragments.addAll(fetchRestFragments(scanner)); fragments.trimToSize(); return newBlock(tag, fragments); } FollowsReferenceBlockParser(String...tagNames); @Override IrDocBlock parse(String tag, JavadocScanner scanner);  }