示例#1
0
  public void test_visitTypeAlias_withTypeParameters() {
    ElementHolder holder = new ElementHolder();
    ElementBuilder builder = new ElementBuilder(holder);
    String aliasName = "F";
    String firstTypeParameterName = "A";
    String secondTypeParameterName = "B";
    TypeAlias typeAlias =
        typeAlias(
            null,
            aliasName,
            typeParameterList(firstTypeParameterName, secondTypeParameterName),
            formalParameterList());
    typeAlias.accept(builder);
    TypeAliasElement[] aliases = holder.getTypeAliases();
    assertLength(1, aliases);

    TypeAliasElement alias = aliases[0];
    assertNotNull(alias);
    assertEquals(aliasName, alias.getName());
    assertFalse(alias.isSynthetic());
    VariableElement[] parameters = alias.getParameters();
    assertNotNull(parameters);
    assertLength(0, parameters);
    TypeVariableElement[] typeVariables = alias.getTypeVariables();
    assertLength(2, typeVariables);
    assertEquals(firstTypeParameterName, typeVariables[0].getName());
    assertEquals(secondTypeParameterName, typeVariables[1].getName());
  }
示例#2
0
  public void test_visitTypeAlias_minimal() {
    ElementHolder holder = new ElementHolder();
    ElementBuilder builder = new ElementBuilder(holder);
    String aliasName = "F";
    TypeAlias typeAlias = typeAlias(null, aliasName, null, null);
    typeAlias.accept(builder);
    TypeAliasElement[] aliases = holder.getTypeAliases();
    assertLength(1, aliases);

    TypeAliasElement alias = aliases[0];
    assertNotNull(alias);
    assertEquals(aliasName, alias.getName());
    assertFalse(alias.isSynthetic());
  }