Package com.google.dart.engine.element

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


      return false;
    }
    // determine the display name, use the extended display name if the enclosing class of the
    // inherited member is in a different source
    String displayName;
    Element enclosingElement = inheritedMember.getEnclosingElement();
    if (enclosingElement.getSource().equals(enclosingClass.getSource())) {
      displayName = enclosingElement.getDisplayName();
    } else {
      displayName = enclosingElement.getExtendedDisplayName(null);
    }
    // report problem
    errorReporter.reportErrorForOffset(
        CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE,
        staticMember.getNameOffset(),
View Full Code Here


    if (!isInConstructorInitializer && !isInStaticMethod && !isInFactory
        && !isInInstanceVariableInitializer && !isInStaticVariableDeclaration) {
      return false;
    }
    // prepare element
    Element element = node.getStaticElement();
    if (!(element instanceof MethodElement || element instanceof PropertyAccessorElement)) {
      return false;
    }
    // static element
    ExecutableElement executableElement = (ExecutableElement) element;
    if (executableElement.isStatic()) {
      return false;
    }
    // not a class member
    Element enclosingElement = element.getEnclosingElement();
    if (!(enclosingElement instanceof ClassElement)) {
      return false;
    }
    // comment
    AstNode parent = node.getParent();
View Full Code Here

    // OK, target is a type
    if (typeReference != null) {
      return false;
    }
    // prepare member Element
    Element element = name.getStaticElement();
    if (!(element instanceof ExecutableElement)) {
      return false;
    }
    ExecutableElement executableElement = (ExecutableElement) element;
    // OK, top-level element
View Full Code Here

    Expression expression = statement.getExpression();
    Type expressionType = getStaticType(expression);
    if (expressionType == null) {
      return false;
    }
    Element expressionElement = expressionType.getElement();
    if (!(expressionElement instanceof ClassElement)) {
      return false;
    }
    ClassElement classElement = (ClassElement) expressionElement;
    if (!classElement.isEnum()) {
View Full Code Here

    ExecutableElement[] missingOverridesArray = missingOverrides.toArray(new ExecutableElement[missingOverridesSize]);
    ArrayList<String> stringMembersArrayListSet = new ArrayList<String>(
        missingOverridesArray.length);
    for (int i = 0; i < missingOverridesArray.length; i++) {
      String newStrMember;
      Element enclosingElement = missingOverridesArray[i].getEnclosingElement();
      String prefix = StringUtilities.EMPTY;
      if (missingOverridesArray[i] instanceof PropertyAccessorElement) {
        PropertyAccessorElement propertyAccessorElement = (PropertyAccessorElement) missingOverridesArray[i];
        if (propertyAccessorElement.isGetter()) {
          prefix = GETTER_SPACE; // "getter "
        } else {
          prefix = SETTER_SPACE; // "setter "
        }
      }
      if (enclosingElement != null) {
        newStrMember = prefix + "'" + enclosingElement.getDisplayName() + '.'
            + missingOverridesArray[i].getDisplayName() + "'";
      } else {
        newStrMember = prefix + "'" + missingOverridesArray[i].getDisplayName() + "'";
      }
      stringMembersArrayListSet.add(newStrMember);
View Full Code Here

    // OK, target is not a type
    if (typeReference == null) {
      return false;
    }
    // prepare member Element
    Element element = name.getStaticElement();
    if (!(element instanceof ExecutableElement)) {
      return false;
    }
    ExecutableElement memberElement = (ExecutableElement) element;
    // OK, static
View Full Code Here

    Type type = node.getType();
    if (type == null) {
      return false;
    }
    // prepare ClassElement
    Element element = type.getElement();
    if (!(element instanceof ClassElement)) {
      return false;
    }
    ClassElement classElement = (ClassElement) element;
    // prepare type parameters
View Full Code Here

   * @param name the name to be evaluated
   * @return {@code true} if and only if an error code is generated on the passed node
   * @see StaticTypeWarningCode#UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER
   */
  private boolean checkForUnqualifiedReferenceToNonLocalStaticMember(SimpleIdentifier name) {
    Element element = name.getStaticElement();
    if (element == null || element instanceof TypeParameterElement) {
      return false;
    }
    Element enclosingElement = element.getEnclosingElement();
    if (!(enclosingElement instanceof ClassElement)) {
      return false;
    }
    if ((element instanceof MethodElement && !((MethodElement) element).isStatic())
        || (element instanceof PropertyAccessorElement && !((PropertyAccessorElement) element).isStatic())) {
View Full Code Here

    final Set<Element> checked = new HashSet<Element>();
    final List<Element> toCheck = new ArrayList<Element>();
    toCheck.add(target);
    boolean firstIteration = true;
    while (true) {
      Element current;
      // get next element
      while (true) {
        // may be no more elements to check
        if (toCheck.isEmpty()) {
          return false;
        }
        // try to get next element
        current = toCheck.remove(toCheck.size() - 1);
        if (target.equals(current)) {
          if (firstIteration) {
            firstIteration = false;
            break;
          } else {
            return true;
          }
        }
        if (current != null && !checked.contains(current)) {
          break;
        }
      }
      // check current element
      current.accept(new GeneralizingElementVisitor<Void>() {
        private boolean inClass;

        @Override
        public Void visitClassElement(ClassElement element) {
          addTypeToCheck(element.getSupertype());
          for (InterfaceType mixin : element.getMixins()) {
            addTypeToCheck(mixin);
          }
          inClass = !element.isTypedef();
          try {
            return super.visitClassElement(element);
          } finally {
            inClass = false;
          }
        }

        @Override
        public Void visitExecutableElement(ExecutableElement element) {
          if (element.isSynthetic()) {
            return null;
          }
          addTypeToCheck(element.getReturnType());
          return super.visitExecutableElement(element);
        }

        @Override
        public Void visitFunctionTypeAliasElement(FunctionTypeAliasElement element) {
          addTypeToCheck(element.getReturnType());
          return super.visitFunctionTypeAliasElement(element);
        }

        @Override
        public Void visitParameterElement(ParameterElement element) {
          addTypeToCheck(element.getType());
          return super.visitParameterElement(element);
        }

        @Override
        public Void visitTypeParameterElement(TypeParameterElement element) {
          addTypeToCheck(element.getBound());
          return super.visitTypeParameterElement(element);
        }

        @Override
        public Void visitVariableElement(VariableElement element) {
          addTypeToCheck(element.getType());
          return super.visitVariableElement(element);
        }

        private void addTypeToCheck(Type type) {
          if (type == null) {
            return;
          }
          Element element = type.getElement();
          // it is OK to reference target from class
          if (inClass && target.equals(element)) {
            return;
          }
          // schedule for checking
View Full Code Here

   * @param expression the expression to evaluate
   * @return the element representing the class
   */
  public static ClassElementImpl getTypeReference(Expression expression) {
    if (expression instanceof Identifier) {
      Element staticElement = ((Identifier) expression).getStaticElement();
      if (staticElement instanceof ClassElementImpl) {
        return (ClassElementImpl) staticElement;
      }
    }
    return null;
View Full Code Here

TOP

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

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.