@Test public void testParseDetails() throws Exception { JavadocParserBuilder builder = new JavadocParserBuilder(); builder.addSpecialStandAloneBlockParser(new ParamBlockParser()); builder.addSpecialStandAloneBlockParser(new FollowsNamedTypeBlockParser("throws")); builder.addSpecialInlineBlockParser(new FollowsReferenceBlockParser("link")); JavadocParser parser = builder.build(); { DefaultJavadocScanner scanner = string( ""); IrDocComment doc = parser.parse(scanner); List<? extends IrDocBlock> blocks = doc.getBlocks(); assertEquals(0, blocks.size()); } { DefaultJavadocScanner scanner = string( ""); 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); } } }
public IrDocComment parse(JavadocScanner scanner) throws JavadocParseException { if (scanner == null) { throw new IllegalArgumentException("scanner"); } int index = scanner.getIndex(); try { JavadocInfo info = fetchJavadocInfo(scanner); List<IrDocBlock> blocks = new ArrayList<>(info.getBlocks().size()); for (JavadocBlockInfo b: info.getBlocks()) { IrDocBlock block = parseBlock(b); blocks.add(block); } IrDocComment elem = new IrDocComment(); elem.setBlocks(blocks); elem.setLocation(info.getLocation()); return elem; } catch (JavadocParseException e) { scanner.seek(index); throw e; } }
JavadocParser extends JavadocBaseParser { public IrDocComment parse(JavadocScanner scanner) throws JavadocParseException { if (scanner == null) { throw new IllegalArgumentException("scanner"); } int index = scanner.getIndex(); try { JavadocInfo info = fetchJavadocInfo(scanner); List<IrDocBlock> blocks = new ArrayList<>(info.getBlocks().size()); for (JavadocBlockInfo b: info.getBlocks()) { IrDocBlock block = parseBlock(b); blocks.add(block); } IrDocComment elem = new IrDocComment(); elem.setBlocks(blocks); elem.setLocation(info.getLocation()); return elem; } catch (JavadocParseException e) { scanner.seek(index); throw e; } } }
JavadocParser extends JavadocBaseParser { public IrDocComment parse(JavadocScanner scanner) throws JavadocParseException { if (scanner == null) { throw new IllegalArgumentException("scanner"); } int index = scanner.getIndex(); try { JavadocInfo info = fetchJavadocInfo(scanner); List<IrDocBlock> blocks = new ArrayList<>(info.getBlocks().size()); for (JavadocBlockInfo b: info.getBlocks()) { IrDocBlock block = parseBlock(b); blocks.add(block); } IrDocComment elem = new IrDocComment(); elem.setBlocks(blocks); elem.setLocation(info.getLocation()); return elem; } catch (JavadocParseException e) { scanner.seek(index); throw e; } } JavadocParser(List<? extends JavadocBlockParser> blockParsers); }
JavadocParser extends JavadocBaseParser { public IrDocComment parse(JavadocScanner scanner) throws JavadocParseException { if (scanner == null) { throw new IllegalArgumentException("scanner"); } int index = scanner.getIndex(); try { JavadocInfo info = fetchJavadocInfo(scanner); List<IrDocBlock> blocks = new ArrayList<>(info.getBlocks().size()); for (JavadocBlockInfo b: info.getBlocks()) { IrDocBlock block = parseBlock(b); blocks.add(block); } IrDocComment elem = new IrDocComment(); elem.setBlocks(blocks); elem.setLocation(info.getLocation()); return elem; } catch (JavadocParseException e) { scanner.seek(index); throw e; } } JavadocParser(List<? extends JavadocBlockParser> blockParsers); IrDocComment parse(JavadocScanner scanner); IrDocBlock parseBlock(JavadocScanner scanner); }
JavadocParser extends JavadocBaseParser { public IrDocComment parse(JavadocScanner scanner) throws JavadocParseException { if (scanner == null) { throw new IllegalArgumentException("scanner"); } int index = scanner.getIndex(); try { JavadocInfo info = fetchJavadocInfo(scanner); List<IrDocBlock> blocks = new ArrayList<>(info.getBlocks().size()); for (JavadocBlockInfo b: info.getBlocks()) { IrDocBlock block = parseBlock(b); blocks.add(block); } IrDocComment elem = new IrDocComment(); elem.setBlocks(blocks); elem.setLocation(info.getLocation()); return elem; } catch (JavadocParseException e) { scanner.seek(index); throw e; } } JavadocParser(List<? extends JavadocBlockParser> blockParsers); IrDocComment parse(JavadocScanner scanner); IrDocBlock parseBlock(JavadocScanner scanner);  }