/**
   * Test method for {@link JavadocBlockParserUtil#fetchLinkTarget(JavadocScanner, java.util.Set)}.
   */
  @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());
    }
  }
 /** Test method for {@link JavadocBlockParserUtil#fetchMethod(JavadocScanner, java.util.Set)}. */
 @Test
 public void testFetchMethod() {
   {
     DefaultJavadocScanner scanner = string("String#length(){");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNotNull(elem);
     assertEquals("String", elem.getDeclaringType().getName().asString());
     assertEquals("length", elem.getName().asString());
     assertEquals(0, elem.getParameters().size());
     assertEquals(LEFT_BRACE, scanner.lookahead(0).getKind());
   }
   {
     DefaultJavadocScanner scanner = string("#length(){");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNotNull(elem);
     assertNull(elem.getDeclaringType());
     assertEquals("length", elem.getName().asString());
     assertEquals(0, elem.getParameters().size());
     assertEquals(LEFT_BRACE, scanner.lookahead(0).getKind());
   }
   {
     DefaultJavadocScanner scanner = string("Math#abs(int)");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNotNull(elem);
     assertEquals("Math", elem.getDeclaringType().getName().asString());
     assertEquals("abs", elem.getName().asString());
     assertEquals(1, elem.getParameters().size());
     {
       IrDocMethodParameter param = elem.getParameters().get(0);
       assertEquals(IrDocElementKind.BASIC_TYPE, param.getType().getKind());
       assertEquals(IrBasicTypeKind.INT, ((IrDocBasicType) param.getType()).getTypeKind());
       assertNull(param.getName());
     }
     assertEquals(EOF, scanner.lookahead(0).getKind());
   }
   {
     DefaultJavadocScanner scanner = string("Math#abs(int number)");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNotNull(elem);
     assertEquals("Math", elem.getDeclaringType().getName().asString());
     assertEquals("abs", elem.getName().asString());
     assertEquals(1, 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("number", param.getName().getIdentifier());
     }
     assertEquals(EOF, scanner.lookahead(0).getKind());
   }
   {
     DefaultJavadocScanner scanner = string("Arrays#asList(Object...)");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNotNull(elem);
     assertEquals("Arrays", elem.getDeclaringType().getName().asString());
     assertEquals("asList", elem.getName().asString());
     assertEquals(1, elem.getParameters().size());
     {
       IrDocMethodParameter param = elem.getParameters().get(0);
       assertEquals(IrDocElementKind.NAMED_TYPE, param.getType().getKind());
       assertEquals("Object", ((IrDocNamedType) param.getType()).getName().asString());
       assertTrue(param.isVariableArity());
       assertNull(param.getName());
     }
     assertEquals(EOF, scanner.lookahead(0).getKind());
   }
   {
     DefaultJavadocScanner scanner = string("Arrays#asList(Object...elems)");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNotNull(elem);
     assertEquals("Arrays", elem.getDeclaringType().getName().asString());
     assertEquals("asList", elem.getName().asString());
     assertEquals(1, elem.getParameters().size());
     {
       IrDocMethodParameter param = elem.getParameters().get(0);
       assertEquals(IrDocElementKind.NAMED_TYPE, param.getType().getKind());
       assertEquals("Object", ((IrDocNamedType) param.getType()).getName().asString());
       assertTrue(param.isVariableArity());
       assertNotNull(param.getName());
       assertEquals("elems", param.getName().getIdentifier());
     }
     assertEquals(EOF, scanner.lookahead(0).getKind());
   }
   {
     DefaultJavadocScanner scanner = string("Math#max(int, int)");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNotNull(elem);
     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());
       assertNull(param.getName());
     }
     {
       IrDocMethodParameter param = elem.getParameters().get(1);
       assertEquals(IrDocElementKind.BASIC_TYPE, param.getType().getKind());
       assertEquals(IrBasicTypeKind.INT, ((IrDocBasicType) param.getType()).getTypeKind());
       assertFalse(param.isVariableArity());
       assertNull(param.getName());
     }
     assertEquals(EOF, scanner.lookahead(0).getKind());
   }
   {
     DefaultJavadocScanner scanner = string("Math#max(int a, int b)");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNotNull(elem);
     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());
   }
   {
     DefaultJavadocScanner scanner = string("/Math#max(int a, int b)");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNull(elem);
     assertEquals(0, scanner.getIndex());
   }
   {
     DefaultJavadocScanner scanner = string("Math+#max(int a, int b)");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNull(elem);
     assertEquals(0, scanner.getIndex());
   }
   {
     DefaultJavadocScanner scanner = string("Math#+max(int a, int b)");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNull(elem);
     assertEquals(0, scanner.getIndex());
   }
   {
     DefaultJavadocScanner scanner = string("Math#max+(int a, int b)");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNull(elem);
     assertEquals(0, scanner.getIndex());
   }
   {
     DefaultJavadocScanner scanner = string("Math#max(+int a, int b)");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNull(elem);
     assertEquals(0, scanner.getIndex());
   }
   {
     DefaultJavadocScanner scanner = string("Math#max(int *a, int b)");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNull(elem);
     assertEquals(0, scanner.getIndex());
   }
   {
     DefaultJavadocScanner scanner = string("Math#max(int a+, int b)");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNull(elem);
     assertEquals(0, scanner.getIndex());
   }
   {
     DefaultJavadocScanner scanner = string("Math#max(int a int b)");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNull(elem);
     assertEquals(0, scanner.getIndex());
   }
   {
     DefaultJavadocScanner scanner = string("Math#max(int a, int b");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, null);
     assertNull(elem);
     assertEquals(0, scanner.getIndex());
   }
   {
     DefaultJavadocScanner scanner = string("String#length(){");
     IrDocMethod elem = JavadocBlockParserUtil.fetchMethod(scanner, EnumSet.of(WHITE_SPACES));
     assertNull(elem);
     assertEquals(0, scanner.getIndex());
   }
 }