예제 #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());
  }
예제 #3
0
  @Override
  public Void visitTypeAlias(TypeAlias node) {
    ElementHolder holder = new ElementHolder();
    visitChildren(holder, node);

    TypeAliasElementImpl element = new TypeAliasElementImpl(node.getName());
    if (holder.getParameters() != null) {
      element.setParameters(holder.getParameters());
    }
    element.setTypeVariables(holder.getTypeVariables());
    currentHolder.addTypeAlias(element);
    return null;
  }
 @Override
 public R visitTypeAlias(TypeAlias node) {
   node.visitChildren(this);
   return null;
 }