@Test public void testParse() throws Exception { JavadocParserBuilder builder = new JavadocParserBuilder(); 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(1, blocks.size()); } { DefaultJavadocScanner scanner = string( ""); IrDocComment doc = parser.parse(scanner); List<? extends IrDocBlock> blocks = doc.getBlocks(); assertEquals(2, blocks.size()); assertNull(blocks.get(0).getTag()); assertEquals("@tag", blocks.get(1).getTag()); } { DefaultJavadocScanner scanner = string( ""); IrDocComment doc = parser.parse(scanner); List<? extends IrDocBlock> blocks = doc.getBlocks(); assertEquals(3, blocks.size()); assertNull(blocks.get(0).getTag()); assertEquals("@tag1", blocks.get(1).getTag()); assertEquals("@tag2", blocks.get(2).getTag()); } { DefaultJavadocScanner scanner = string( ""); try { parser.parse(scanner); fail(); } catch (IllegalDocCommentFormatException e) { } } { DefaultJavadocScanner scanner = string( ""); try { parser.parse(scanner); fail(); } catch (IllegalDocCommentFormatException e) { } } { DefaultJavadocScanner scanner = string( ""); parser.parse(scanner); } }
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);  }