@Test public void testFetchType() { { DefaultJavadocScanner scanner = string("double"); IrDocType type = JavadocBlockParserUtil.fetchType(scanner, null); assertNotNull(type); assertEquals(IrDocElementKind.BASIC_TYPE, type.getKind()); IrDocBasicType elem = (IrDocBasicType) type; assertEquals(IrBasicTypeKind.DOUBLE, elem.getTypeKind()); assertSameLocation(0, "double".length(), elem.getLocation()); assertEquals(EOF, scanner.lookahead(0).getKind()); } { DefaultJavadocScanner scanner = string("float[]"); IrDocType type = JavadocBlockParserUtil.fetchType(scanner, null); assertNotNull(type); assertEquals(IrDocElementKind.ARRAY_TYPE, type.getKind()); IrDocArrayType array = (IrDocArrayType) type; assertSameLocation(0, "float[]".length(), array.getLocation()); IrDocBasicType elem = (IrDocBasicType) array.getComponentType(); assertEquals(IrBasicTypeKind.FLOAT, elem.getTypeKind()); assertSameLocation(0, "float".length(), elem.getLocation()); assertEquals(EOF, scanner.lookahead(0).getKind()); } { DefaultJavadocScanner scanner = string("char[][]"); IrDocType type = JavadocBlockParserUtil.fetchType(scanner, null); assertNotNull(type); assertEquals(IrDocElementKind.ARRAY_TYPE, type.getKind()); IrDocArrayType array = (IrDocArrayType) type; assertSameLocation(0, "char[][]".length(), array.getLocation()); IrDocType component = array.getComponentType(); assertEquals(IrDocElementKind.ARRAY_TYPE, component.getKind()); IrDocArrayType array2 = (IrDocArrayType) component; assertSameLocation(0, "char[]".length(), array2.getLocation()); IrDocBasicType elem = (IrDocBasicType) array2.getComponentType(); assertEquals(IrBasicTypeKind.CHAR, elem.getTypeKind()); assertSameLocation(0, "char".length(), elem.getLocation()); assertEquals(EOF, scanner.lookahead(0).getKind()); } { DefaultJavadocScanner scanner = string("java.lang.String"); IrDocType type = JavadocBlockParserUtil.fetchType(scanner, null); assertNotNull(type); assertEquals(IrDocElementKind.NAMED_TYPE, type.getKind()); IrDocNamedType elem = (IrDocNamedType) type; assertEquals("java.lang.String", elem.getName().asString()); assertSameLocation(0, "java.lang.String".length(), elem.getLocation()); assertEquals(EOF, scanner.lookahead(0).getKind()); } { DefaultJavadocScanner scanner = string("java.lang.String[]"); IrDocType type = JavadocBlockParserUtil.fetchType(scanner, null); assertNotNull(type); assertEquals(IrDocElementKind.ARRAY_TYPE, type.getKind()); IrDocArrayType array = (IrDocArrayType) type; assertSameLocation(0, "java.lang.String[]".length(), array.getLocation()); IrDocNamedType elem = (IrDocNamedType) array.getComponentType(); assertEquals("java.lang.String", elem.getName().asString()); assertSameLocation(0, "java.lang.String".length(), elem.getLocation()); assertEquals(EOF, scanner.lookahead(0).getKind()); } }
public static IrDocType fetchType(JavadocScanner scanner, Set<JavadocTokenKind> follow) { JavadocTokenStream stream = new DefaultJavadocTokenStream(scanner); stream.mark(); IrDocType elem = fetchType(stream); if (!follows(stream, follow)) { stream.rewind(); return null; } else { stream.discard(); return elem; } }
JavadocBlockParserUtil { public static IrDocType fetchType(JavadocScanner scanner, Set<JavadocTokenKind> follow) { JavadocTokenStream stream = new DefaultJavadocTokenStream(scanner); stream.mark(); IrDocType elem = fetchType(stream); if (!follows(stream, follow)) { stream.rewind(); return null; } else { stream.discard(); return elem; } } }
JavadocBlockParserUtil { public static IrDocType fetchType(JavadocScanner scanner, Set<JavadocTokenKind> follow) { JavadocTokenStream stream = new DefaultJavadocTokenStream(scanner); stream.mark(); IrDocType elem = fetchType(stream); if (!follows(stream, follow)) { stream.rewind(); return null; } else { stream.discard(); return elem; } } private  JavadocBlockParserUtil(); }
JavadocBlockParserUtil { public static IrDocType fetchType(JavadocScanner scanner, Set<JavadocTokenKind> follow) { JavadocTokenStream stream = new DefaultJavadocTokenStream(scanner); stream.mark(); IrDocType elem = fetchType(stream); if (!follows(stream, follow)) { stream.rewind(); return null; } else { stream.discard(); return elem; } } private  JavadocBlockParserUtil(); static T setLocation(T elem, JavadocToken start, JavadocToken stop); static T setLocation(T elem, IrLocation start, IrLocation stop); static IrDocText fetchText(JavadocScanner scanner, boolean trimHead, boolean trimTail); static JavadocBlockInfo fetchBlockInfo(JavadocScanner scanner); static int countWhileTagName(JavadocScanner scanner, int start); static IrDocSimpleName fetchSimpleName(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocName fetchName(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocBasicType fetchBasicType(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocBasicType fetchPrimitiveType(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocNamedType fetchNamedType(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocType fetchType(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocField fetchField(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocMethod fetchMethod(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocFragment fetchLinkTarget(JavadocScanner scanner, Set<JavadocTokenKind> follow); static String buildString(List<? extends JavadocToken> tokens); }
JavadocBlockParserUtil { public static IrDocType fetchType(JavadocScanner scanner, Set<JavadocTokenKind> follow) { JavadocTokenStream stream = new DefaultJavadocTokenStream(scanner); stream.mark(); IrDocType elem = fetchType(stream); if (!follows(stream, follow)) { stream.rewind(); return null; } else { stream.discard(); return elem; } } private  JavadocBlockParserUtil(); static T setLocation(T elem, JavadocToken start, JavadocToken stop); static T setLocation(T elem, IrLocation start, IrLocation stop); static IrDocText fetchText(JavadocScanner scanner, boolean trimHead, boolean trimTail); static JavadocBlockInfo fetchBlockInfo(JavadocScanner scanner); static int countWhileTagName(JavadocScanner scanner, int start); static IrDocSimpleName fetchSimpleName(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocName fetchName(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocBasicType fetchBasicType(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocBasicType fetchPrimitiveType(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocNamedType fetchNamedType(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocType fetchType(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocField fetchField(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocMethod fetchMethod(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocFragment fetchLinkTarget(JavadocScanner scanner, Set<JavadocTokenKind> follow); static String buildString(List<? extends JavadocToken> tokens); static final Set<JavadocTokenKind> S_WHITE; }