Examples of TypeParameterElement


Examples of com.google.dart.engine.element.TypeParameterElement

    return super.visitTopLevelVariableDeclaration(node);
  }

  @Override
  public Void visitTypeParameter(TypeParameter node) {
    TypeParameterElement element = node.getElement();
    enterScope(element);
    try {
      return super.visitTypeParameter(node);
    } finally {
      exitScope();
View Full Code Here

Examples of com.google.dart.engine.element.TypeParameterElement

   * @param node the type parameter to evaluate
   * @return {@code true} if and only if an error code is generated on the passed node
   * @see StaticTypeWarningCode#TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND
   */
  private boolean checkForTypeParameterSupertypeOfItsBound(TypeParameter node) {
    TypeParameterElement element = node.getElement();
    // prepare bound
    Type bound = element.getBound();
    if (bound == null) {
      return false;
    }
    // OK, type parameter is not supertype of its bound
    if (!bound.isMoreSpecificThan(element.getType())) {
      return false;
    }
    // report problem
    errorReporter.reportErrorForNode(
        StaticTypeWarningCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND,
        node,
        element.getDisplayName());
    return true;
  }
View Full Code Here

Examples of com.google.dart.engine.element.TypeParameterElement

  }

  @Override
  public Void visitTypeParameter(TypeParameter node) {
    SimpleIdentifier parameterName = node.getName();
    TypeParameterElement element = null;
    if (enclosingClass != null) {
      element = findIdentifier(enclosingClass.getTypeParameters(), parameterName);
    } else if (enclosingAlias != null) {
      element = findIdentifier(enclosingAlias.getTypeParameters(), parameterName);
    }
View Full Code Here

Examples of com.google.dart.engine.element.TypeParameterElement

//      Type[] argumentTypes = interfaceTypeContext.getTypeArguments();
      TypeParameterElement[] typeParameterElements = interfaceTypeContext.getElement() != null
          ? interfaceTypeContext.getElement().getTypeParameters() : null;
      if (typeParameterElements != null) {
        for (int i = 0; i < typeParameterElements.length; i++) {
          TypeParameterElement typeParameterElement = typeParameterElements[i];
          if (returnType.getName().equals(typeParameterElement.getName())) {
            return interfaceTypeContext.getTypeArguments()[i];
          }
        }
        // TODO(jwren) troubleshoot why call to substitute doesn't work
//        Type[] parameterTypes = TypeParameterTypeImpl.getTypes(parameterElements);
View Full Code Here

Examples of javax.lang.model.element.TypeParameterElement

    @Test
    public void typeVariable() {
        start(new Callback() {
            @Override protected void test() {
                TypeElement map = elements.getTypeElement(Map.class.getName());
                TypeParameterElement k = map.getTypeParameters().get(0);
                assertThat(
                    target.convert(k.asType()),
                    is((Type) f.newNamedType(f.newSimpleName("K"))));

                TypeElement list = elements.getTypeElement(List.class.getName());
                TypeParameterElement e = list.getTypeParameters().get(0);
                assertThat(
                    target.convert(e.asType()),
                    is((Type) f.newNamedType(f.newSimpleName("E"))));
            }
        });
    }
View Full Code Here

Examples of javax.lang.model.element.TypeParameterElement

                                }
                                TypeElement te;
                                if (type.getKind() == TypeKind.DECLARED) {
                                    te = (TypeElement) types.asElement(type);
                                } else if (type.getKind() == TypeKind.TYPEVAR) {
                                    TypeParameterElement tpe = (TypeParameterElement) types.asElement(type);
                                    List<? extends TypeMirror> exts = tpe.getBounds();
                                    if (exts.size() == 1) {
                                        type = exts.get(0);
                                        if (type.getKind() == TypeKind.DECLARED) {
                                            te = (TypeElement) types.asElement(type);
                                        } else {
View Full Code Here

Examples of javax.lang.model.element.TypeParameterElement

    }
    @SupportedAnnotationTypes("*")
    @SupportedSourceVersion(SourceVersion.RELEASE_6)
    static class MyProcessor extends AbstractProcessor {
        void test(TypeElement element, boolean fbound) {
            TypeParameterElement tpe = element.getTypeParameters().iterator().next();
            tpe.getBounds().getClass();
            if (fbound) {
                DeclaredType type = (DeclaredType)tpe.getBounds().get(0);
                if (type.asElement() != element)
                    throw error("%s != %s", type.asElement(), element);
                TypeVariable tv = (TypeVariable)type.getTypeArguments().get(0);
                if (tv.asElement() != tpe)
                    throw error("%s != %s", tv.asElement(), tpe);
View Full Code Here

Examples of javax.lang.model.element.TypeParameterElement

                        return SpecificCompilerWorkarounds.isSubType( typeUtils, superBound, p ) ||
                            typeUtils.isSameType( p, superBound );

                    case TYPEVAR:

                        TypeParameterElement typeParameter = getTypeParamFromCandidate( superBound );
                        // for example method: <T extends String & Serializable> T method(? super T)
                        if ( !isWithinBounds( p, typeParameter ) ) {
                            // this checks the part? <T extends String & Serializable>
                            return Boolean.FALSE;
                        }
                        // now, it becomes a bit more hairy. We have the relation (? super T). From T we know that
                        // it is a subclass of String & Serializable. However, The Java Language Secification,
                        // Chapter 4.4, states that a bound is either: 'A type variable-', 'A class-' or 'An
                        // interface-' type followed by further interface types. So we must compare with the first
                        // argument in the Expression String & Serializable & ..., so, in this case String.
                        // to check super type, we can simply reverse the argument, but that would initially yield
                        // a result: <type, superType] (so type not included) so we need to check sameType also.
                        TypeMirror superBoundAsDeclared = typeParameter.getBounds().get( 0 );
                        return ( SpecificCompilerWorkarounds.isSubType( typeUtils, superBoundAsDeclared, p ) ||
                            typeUtils.isSameType( p, superBoundAsDeclared ) );
                    default:
                        // does this situation occur?
                        return Boolean.FALSE;
View Full Code Here

Examples of javax.lang.model.element.TypeParameterElement

        if (typeArg.getKind() == TypeKind.DECLARED) {
          TypeM typeArgElemTypeM = getTypeM(typeArg);
          result.withTypeParameter(typeArgElemTypeM);
        } else if (typeArg.getKind() == TypeKind.TYPEVAR) {
          TypeVariable typeVar = (TypeVariable) typeArg;
          TypeParameterElement typeParamElem = (TypeParameterElement) typeVar.asElement();
          TypeVariableM var = getTypeVariableM(typeParamElem);
          result.withTypeParameter(var);
        }
      }
    }
View Full Code Here

Examples of javax.lang.model.element.TypeParameterElement

    if (typeParams == null) {
      return new TypeM[0];
    }
    TypeM[] result = new TypeM[typeParams.size()];
    for (int i = 0; i < result.length; ++i) {
      TypeParameterElement typeParameterElement = typeParams.get(i);
      TypeVariableM var = getTypeVariableM(typeParameterElement);
      result[i] = var;
    }
    return result;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.