Package com.google.dart.engine.element

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


        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;
View Full Code Here


        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;
View Full Code Here

        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;
View Full Code Here

    if (parent == null) {
      throw new AnalysisException("Cannot create scope: node is not part of a CompilationUnit");
    }
    Scope scope = scopeForAstNode(parent);
    if (node instanceof ClassDeclaration) {
      ClassElement element = ((ClassDeclaration) node).getElement();
      if (element == null) {
        throw new AnalysisException("Cannot build a scope for an unresolved class");
      }
      scope = new ClassScope(new TypeParameterScope(scope, element), element);
    } else if (node instanceof ClassTypeAlias) {
      ClassElement element = ((ClassTypeAlias) node).getElement();
      if (element == null) {
        throw new AnalysisException("Cannot build a scope for an unresolved class type alias");
      }
      scope = new ClassScope(new TypeParameterScope(scope, element), element);
    } else if (node instanceof ConstructorDeclaration) {
View Full Code Here

      // so e.g. non-generic types are never raw. As pointed out by paulberry, it's not clear
      // whether a type like T<int, dynamic> should be considered raw or not. On the one hand, it
      // doesn't correspond to a "raw"-in-the-Java-sense occurrence of T, which would instead
      // be T<dynamic, dynamic>; on the other hand, it's treated differently by <: and << when
      // occurring on the left hand side.
      ClassElement element = getElement();
      InheritanceManager manager = new InheritanceManager(element.getLibrary());
      FunctionType callType = manager.lookupMemberType(this, "call");
      if (callType != null) {
        // A more literal reading of the spec would give something like
        //
        //  return callType.equals(type)
View Full Code Here

    }

    //
    // Covariance: T is of the form I<T1, ..., Tn> and S is of the form I<S1, ..., Sn> and Ti << Si, 1 <= i <= n.
    //
    ClassElement tElement = getElement();
    ClassElement sElement = s.getElement();
    if (tElement.equals(sElement)) {
      Type[] tArguments = getTypeArguments();
      Type[] sArguments = s.getTypeArguments();
      if (tArguments.length != sArguments.length) {
        return false;
      }
      for (int i = 0; i < tArguments.length; i++) {
        if (!((TypeImpl) tArguments[i]).isMoreSpecificThan(
            sArguments[i],
            withDynamic,
            visitedTypePairs)) {
          return false;
        }
      }
      return true;
    }

    //
    // Transitivity: T << U and U << S.
    //
    // First check for infinite loops
    ClassElement element = getElement();
    if (element == null || visitedClasses.contains(element)) {
      return false;
    }
    visitedClasses.add(element);
    // Iterate over all of the types U that are more specific than T because they are direct
View Full Code Here

  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.
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

  private ExecutableElement getOverriddenMember(ExecutableElement member) {
    LibraryElement library = member.getLibrary();
    if (library == null) {
      return null;
    }
    ClassElement classElement = member.getAncestor(ClassElement.class);
    if (classElement == null) {
      return null;
    }
    return manager.lookupInheritance(classElement, member.getName());
  }
View Full Code Here

  public TypeParameterElement[] getTypeParameters() {
    Element element = getElement();
    if (element instanceof FunctionTypeAliasElement) {
      return ((FunctionTypeAliasElement) element).getTypeParameters();
    }
    ClassElement definingClass = element.getAncestor(ClassElement.class);
    if (definingClass != null) {
      return definingClass.getTypeParameters();
    }
    return TypeParameterElementImpl.EMPTY_ARRAY;
  }
View Full Code Here

TOP

Related Classes of com.google.dart.engine.element.ClassElement

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.