@Test public void testFetchLinkTarget() { { DefaultJavadocScanner scanner = string("java.lang.String"); IrDocFragment target = JavadocBlockParserUtil.fetchLinkTarget(scanner, null); assertNotNull(target); assertEquals(IrDocElementKind.NAMED_TYPE, target.getKind()); IrDocNamedType elem = (IrDocNamedType) target; assertEquals("java.lang.String", elem.getName().asString()); assertSameLocation(0, "java.lang.String".length(), elem.getLocation()); assertEquals(EOF, scanner.lookahead(0).getKind()); } { DefaultJavadocScanner scanner = string("Math#PI{"); IrDocFragment target = JavadocBlockParserUtil.fetchLinkTarget(scanner, null); assertNotNull(target); assertEquals(IrDocElementKind.FIELD, target.getKind()); IrDocField elem = (IrDocField) target; assertEquals("Math", elem.getDeclaringType().getName().asString()); assertEquals("PI", elem.getName().getIdentifier()); assertSameLocation(0, "Math#PI".length(), elem.getLocation()); assertEquals(LEFT_BRACE, scanner.lookahead(0).getKind()); } { DefaultJavadocScanner scanner = string("Math#max(int a, int b)"); IrDocFragment target = JavadocBlockParserUtil.fetchLinkTarget(scanner, null); assertNotNull(target); assertEquals(IrDocElementKind.METHOD, target.getKind()); IrDocMethod elem = (IrDocMethod) target; assertEquals("Math", elem.getDeclaringType().getName().asString()); assertEquals("max", elem.getName().asString()); assertEquals(2, elem.getParameters().size()); { IrDocMethodParameter param = elem.getParameters().get(0); assertEquals(IrDocElementKind.BASIC_TYPE, param.getType().getKind()); assertEquals(IrBasicTypeKind.INT, ((IrDocBasicType) param.getType()).getTypeKind()); assertFalse(param.isVariableArity()); assertNotNull(param.getName()); assertEquals("a", param.getName().getIdentifier()); } { IrDocMethodParameter param = elem.getParameters().get(1); assertEquals(IrDocElementKind.BASIC_TYPE, param.getType().getKind()); assertEquals(IrBasicTypeKind.INT, ((IrDocBasicType) param.getType()).getTypeKind()); assertFalse(param.isVariableArity()); assertNotNull(param.getName()); assertEquals("b", param.getName().getIdentifier()); } assertEquals(EOF, scanner.lookahead(0).getKind()); } }
public static IrDocFragment fetchLinkTarget(JavadocScanner scanner, Set<JavadocTokenKind> follow) { IrDocMethod method = fetchMethod(scanner, follow); if (method != null) { return method; } IrDocField field = fetchField(scanner, follow); if (field != null) { return field; } IrDocNamedType type = fetchNamedType(scanner, follow); if (type != null) { return type; } return null; }
JavadocBlockParserUtil { public static IrDocFragment fetchLinkTarget(JavadocScanner scanner, Set<JavadocTokenKind> follow) { IrDocMethod method = fetchMethod(scanner, follow); if (method != null) { return method; } IrDocField field = fetchField(scanner, follow); if (field != null) { return field; } IrDocNamedType type = fetchNamedType(scanner, follow); if (type != null) { return type; } return null; } }
JavadocBlockParserUtil { public static IrDocFragment fetchLinkTarget(JavadocScanner scanner, Set<JavadocTokenKind> follow) { IrDocMethod method = fetchMethod(scanner, follow); if (method != null) { return method; } IrDocField field = fetchField(scanner, follow); if (field != null) { return field; } IrDocNamedType type = fetchNamedType(scanner, follow); if (type != null) { return type; } return null; } private  JavadocBlockParserUtil(); }
JavadocBlockParserUtil { public static IrDocFragment fetchLinkTarget(JavadocScanner scanner, Set<JavadocTokenKind> follow) { IrDocMethod method = fetchMethod(scanner, follow); if (method != null) { return method; } IrDocField field = fetchField(scanner, follow); if (field != null) { return field; } IrDocNamedType type = fetchNamedType(scanner, follow); if (type != null) { return type; } return null; } 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 IrDocFragment fetchLinkTarget(JavadocScanner scanner, Set<JavadocTokenKind> follow) { IrDocMethod method = fetchMethod(scanner, follow); if (method != null) { return method; } IrDocField field = fetchField(scanner, follow); if (field != null) { return field; } IrDocNamedType type = fetchNamedType(scanner, follow); if (type != null) { return type; } return null; } 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; }