Package com.google.dart.engine.type

Examples of com.google.dart.engine.type.InterfaceType


  }

  @Override
  public InterfaceType getSuperclass() {
    ClassElement classElement = getElement();
    InterfaceType supertype = classElement.getSupertype();
    if (supertype == null) {
      return null;
    }
    Type[] typeParameters = classElement.getType().getTypeArguments();
    if (typeArguments.length == 0 || typeArguments.length != typeParameters.length) {
      return supertype;
    }
    return supertype.substitute(typeArguments, typeParameters);
  }
View Full Code Here


    return element.getName().equals("Function") && element.getLibrary().isDartCore();
  }

  @Override
  public boolean isDirectSupertypeOf(InterfaceType type) {
    InterfaceType i = this;
    InterfaceType j = type;
    ClassElement jElement = j.getElement();
    InterfaceType supertype = jElement.getSupertype();
    //
    // If J has no direct supertype then it is Object, and Object has no direct supertypes.
    //
    if (supertype == null) {
      return false;
    }
    //
    // I is listed in the extends clause of J.
    //
    Type[] jArgs = j.getTypeArguments();
    Type[] jVars = jElement.getType().getTypeArguments();
    supertype = supertype.substitute(jArgs, jVars);
    if (supertype.equals(i)) {
      return true;
    }
    //
    // I is listed in the implements clause of J.
    //
View Full Code Here

      if (element != null && element.isAccessibleIn(library)) {
        return element;
      }
    }
    HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
    InterfaceType supertype = getSuperclass();
    ClassElement supertypeElement = supertype == null ? null : supertype.getElement();
    while (supertype != null && !visitedClasses.contains(supertypeElement)) {
      visitedClasses.add(supertypeElement);
      PropertyAccessorElement element = supertype.getGetter(getterName);
      if (element != null && element.isAccessibleIn(library)) {
        return element;
      }
      for (InterfaceType mixin : supertype.getMixins()) {
        element = mixin.getGetter(getterName);
        if (element != null && element.isAccessibleIn(library)) {
          return element;
        }
      }
      supertype = supertype.getSuperclass();
      supertypeElement = supertype == null ? null : supertype.getElement();
    }
    return null;
  }
View Full Code Here

      if (element != null && element.isAccessibleIn(library)) {
        return element;
      }
    }
    HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
    InterfaceType supertype = getSuperclass();
    ClassElement supertypeElement = supertype == null ? null : supertype.getElement();
    while (supertype != null && !visitedClasses.contains(supertypeElement)) {
      visitedClasses.add(supertypeElement);
      MethodElement element = supertype.getMethod(methodName);
      if (element != null && element.isAccessibleIn(library)) {
        return element;
      }
      for (InterfaceType mixin : supertype.getMixins()) {
        element = mixin.getMethod(methodName);
        if (element != null && element.isAccessibleIn(library)) {
          return element;
        }
      }
      supertype = supertype.getSuperclass();
      supertypeElement = supertype == null ? null : supertype.getElement();
    }
    return null;
  }
View Full Code Here

   * Defines variable for the given {@link AngularElement} with type of the enclosing
   * {@link ClassElement}.
   */
  private void defineTopVariable_forClassElement(AngularElement element) {
    ClassElement classElement = (ClassElement) element.getEnclosingElement();
    InterfaceType type = classElement.getType();
    LocalVariableElementImpl variable = createLocalVariableWithName(type, element.getName());
    defineTopVariable(variable);
    variable.setToolkitObjects(new AngularElement[] {element});
  }
View Full Code Here

      if (element != null && element.isAccessibleIn(library)) {
        return element;
      }
    }
    HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
    InterfaceType supertype = getSuperclass();
    ClassElement supertypeElement = supertype == null ? null : supertype.getElement();
    while (supertype != null && !visitedClasses.contains(supertypeElement)) {
      visitedClasses.add(supertypeElement);
      PropertyAccessorElement element = supertype.getSetter(setterName);
      if (element != null && element.isAccessibleIn(library)) {
        return element;
      }
      for (InterfaceType mixin : supertype.getMixins()) {
        element = mixin.getSetter(setterName);
        if (element != null && element.isAccessibleIn(library)) {
          return element;
        }
      }
      supertype = supertype.getSuperclass();
      supertypeElement = supertype == null ? null : supertype.getElement();
    }
    return null;
  }
View Full Code Here

      return false;
    }
    visitedClasses.add(element);
    // Iterate over all of the types U that are more specific than T because they are direct
    // supertypes of T and return true if any of them are more specific than S.
    InterfaceType supertype = getSuperclass();
    if (supertype != null
        && ((InterfaceTypeImpl) supertype).isMoreSpecificThan(
            s,
            visitedClasses,
            withDynamic,
View Full Code Here

    return false;
  }

  private boolean isSubtypeOf(InterfaceType type, HashSet<ClassElement> visitedClasses,
      Set<TypePair> visitedTypePairs) {
    InterfaceType typeT = this;
    InterfaceType typeS = type;
    ClassElement elementT = getElement();
    if (elementT == null || visitedClasses.contains(elementT)) {
      return false;
    }
    visitedClasses.add(elementT);

    if (typeT.equals(typeS)) {
      return true;
    } else if (ObjectUtilities.equals(elementT, typeS.getElement())) {
      // For each of the type arguments return true if all type args from T is a subtype of all
      // types from S.
      Type[] typeTArgs = typeT.getTypeArguments();
      Type[] typeSArgs = typeS.getTypeArguments();
      if (typeTArgs.length != typeSArgs.length) {
        // This case covers the case where two objects are being compared that have a different
        // number of parameterized types.
        return false;
      }
      for (int i = 0; i < typeTArgs.length; i++) {
        // Recursively call isSubtypeOf the type arguments and return false if the T argument is not
        // a subtype of the S argument.
        if (!((TypeImpl) typeTArgs[i]).isSubtypeOf(typeSArgs[i], visitedTypePairs)) {
          return false;
        }
      }
      return true;
    } else if (typeS.isDartCoreFunction() && elementT.getMethod("call") != null) {
      return true;
    }

    InterfaceType supertype = getSuperclass();
    // The type is Object, return false.
    if (supertype != null
        && ((InterfaceTypeImpl) supertype).isSubtypeOf(typeS, visitedClasses, visitedTypePairs)) {
      return true;
    }
View Full Code Here

    if (!(expression instanceof SimpleIdentifier)) {
      return;
    }
    SimpleIdentifier identifier = (SimpleIdentifier) expression;
    // define variable Element
    InterfaceType type = resolver.getTypeProvider().getStringType();
    LocalVariableElementImpl element = resolver.createLocalVariableFromIdentifier(type, identifier);
    resolver.defineTopVariable(element);
    // remember expression
    identifier.setStaticElement(element);
    identifier.setStaticType(type);
View Full Code Here

    if (validResult.isTrue()) {
      return thenResult;
    } else if (validResult.isFalse()) {
      return elseResult;
    }
    InterfaceType thenType = ((ValidResult) thenResult).getValue().getType();
    InterfaceType elseType = ((ValidResult) elseResult).getValue().getType();
    return validWithUnknownValue((InterfaceType) thenType.getLeastUpperBound(elseType));
  }
View Full Code Here

TOP

Related Classes of com.google.dart.engine.type.InterfaceType

Copyright © 2018 www.massapicom. 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.