Package com.google.dart.engine.type

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


   * @return {@code true} if the given type represents the class {@code Future} from the
   *         {@code dart:async} library
   */
  private boolean isFuture(Type type) {
    if (type instanceof InterfaceType) {
      InterfaceType interfaceType = (InterfaceType) type;
      if (interfaceType.getName().equals("Future")) {
        ClassElement element = interfaceType.getElement();
        if (element != null) {
          LibraryElement library = element.getLibrary();
          if (library.getName().equals("dart.async")) {
            return true;
          }
View Full Code Here


    if (path.indexOf(classElt) > 0) {
      return false;
    }
    path.add(classElt);
    // n-case
    InterfaceType supertype = classElt.getSupertype();
    if (supertype != null
        && safeCheckForRecursiveInterfaceInheritance(supertype.getElement(), path)) {
      return true;
    }
    InterfaceType[] interfaceTypes = classElt.getInterfaces();
    for (InterfaceType interfaceType : interfaceTypes) {
      if (safeCheckForRecursiveInterfaceInheritance(interfaceType.getElement(), path)) {
View Full Code Here

    try {
      ConstructorName constructorName = node.getConstructorName();
      TypeName typeName = constructorName.getType();
      Type type = typeName.getType();
      if (type instanceof InterfaceType) {
        InterfaceType interfaceType = (InterfaceType) type;
        checkForConstOrNewWithAbstractClass(node, typeName, interfaceType);
        checkForConstOrNewWithEnum(node, typeName, interfaceType);
        if (isInConstInstanceCreation) {
          checkForConstWithNonConst(node);
          checkForConstWithUndefinedConstructor(node, constructorName, typeName);
View Full Code Here

    }
    String executableElementName = executableElement.getName();

    FunctionType overridingFT = executableElement.getType();
    FunctionType overriddenFT = overriddenExecutable.getType();
    InterfaceType enclosingType = enclosingClass.getType();
    overriddenFT = inheritanceManager.substituteTypeArgumentsInMemberFromInheritance(
        overriddenFT,
        executableElementName,
        enclosingType);
View Full Code Here

   */
  private boolean checkForConflictingInstanceGetterAndSuperclassMember() {
    if (enclosingClass == null) {
      return false;
    }
    InterfaceType enclosingType = enclosingClass.getType();
    // check every accessor
    boolean hasProblem = false;
    for (PropertyAccessorElement accessor : enclosingClass.getAccessors()) {
      // we analyze instance accessors here
      if (accessor.isStatic()) {
        continue;
      }
      // prepare accessor properties
      String name = accessor.getDisplayName();
      boolean getter = accessor.isGetter();
      // if non-final variable, ignore setter - we alreay reported problem for getter
      if (accessor.isSetter() && accessor.isSynthetic()) {
        continue;
      }
      // try to find super element
      ExecutableElement superElement;
      superElement = enclosingType.lookUpGetterInSuperclass(name, currentLibrary);
      if (superElement == null) {
        superElement = enclosingType.lookUpSetterInSuperclass(name, currentLibrary);
      }
      if (superElement == null) {
        superElement = enclosingType.lookUpMethodInSuperclass(name, currentLibrary);
      }
      if (superElement == null) {
        continue;
      }
      // OK, not static
      if (!superElement.isStatic()) {
        continue;
      }
      // prepare "super" type to report its name
      ClassElement superElementClass = (ClassElement) superElement.getEnclosingElement();
      InterfaceType superElementType = superElementClass.getType();
      // report problem
      hasProblem = true;
      if (getter) {
        errorReporter.reportErrorForElement(
            StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER,
            accessor,
            superElementType.getDisplayName());
      } else {
        errorReporter.reportErrorForElement(
            StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER,
            accessor,
            superElementType.getDisplayName());
      }
    }
    // done
    return hasProblem;
  }
View Full Code Here

    String name = nameNode.getName();
    // prepare enclosing type
    if (enclosingClass == null) {
      return false;
    }
    InterfaceType enclosingType = enclosingClass.getType();
    // try to find setter
    ExecutableElement setter = enclosingType.lookUpSetter(name, currentLibrary);
    if (setter == null) {
      return false;
    }
    // OK, also static
    if (setter.isStatic()) {
      return false;
    }
    // prepare "setter" type to report its name
    ClassElement setterClass = (ClassElement) setter.getEnclosingElement();
    InterfaceType setterType = setterClass.getType();
    // report problem
    errorReporter.reportErrorForNode(
        StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER,
        nameNode,
        setterType.getDisplayName());
    return true;
  }
View Full Code Here

    String name = nameNode.getName();
    // prepare enclosing type
    if (enclosingClass == null) {
      return false;
    }
    InterfaceType enclosingType = enclosingClass.getType();
    // try to find member
    ExecutableElement member;
    member = enclosingType.lookUpMethod(name, currentLibrary);
    if (member == null) {
      member = enclosingType.lookUpGetter(name, currentLibrary);
    }
    if (member == null) {
      member = enclosingType.lookUpSetter(name, currentLibrary);
    }
    if (member == null) {
      return false;
    }
    // OK, also static
    if (member.isStatic()) {
      return false;
    }
    // prepare "member" type to report its name
    ClassElement memberClass = (ClassElement) member.getEnclosingElement();
    InterfaceType memberType = memberClass.getType();
    // report problem
    errorReporter.reportErrorForNode(
        StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER,
        nameNode,
        memberType.getDisplayName());
    return true;
  }
View Full Code Here

            element.getEnclosingElement().getDisplayName());
        return true;
      }
    }
    // no explicit super constructor invocation, check default constructor
    InterfaceType supertype = enclosingClass.getSupertype();
    if (supertype == null) {
      return false;
    }
    if (supertype.isObject()) {
      return false;
    }
    ConstructorElement unnamedConstructor = supertype.getElement().getUnnamedConstructor();
    if (unnamedConstructor == null) {
      return false;
    }
    if (unnamedConstructor.isConst()) {
      return false;
    }
    // default constructor is not 'const', report problem
    errorReporter.reportErrorForNode(
        CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER,
        node.getReturnType(),
        supertype.getDisplayName());
    return true;
  }
View Full Code Here

          visitedInterfaces);
      if (getter != null) {
        return getter;
      }
    }
    InterfaceType superclass = targetType.getSuperclass();
    if (superclass == null) {
      return null;
    }
    return lookUpGetterInInterfaces(superclass, true, getterName, visitedInterfaces);
  }
View Full Code Here

   * @return the element representing the method or getter that was found
   */
  private ExecutableElement lookupGetterOrMethod(Type type, String memberName) {
    type = resolveTypeParameter(type);
    if (type instanceof InterfaceType) {
      InterfaceType interfaceType = (InterfaceType) type;
      ExecutableElement member = interfaceType.lookUpMethod(memberName, definingLibrary);
      if (member != null) {
        return member;
      }
      member = interfaceType.lookUpGetter(memberName, definingLibrary);
      if (member != null) {
        return member;
      }
      return lookUpGetterOrMethodInInterfaces(
          interfaceType,
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.