Package com.google.dart.engine.element

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


    }
  }

  private PropertyAccessorElement internalLookUpConcreteGetter(String getterName,
      LibraryElement library, boolean includeThisClass) {
    PropertyAccessorElement getter = internalLookUpGetter(getterName, library, includeThisClass);
    while (getter != null && getter.isAbstract()) {
      Element definingClass = getter.getEnclosingElement();
      if (!(definingClass instanceof ClassElementImpl)) {
        return null;
      }
      getter = ((ClassElementImpl) definingClass).internalLookUpGetter(getterName, library, false);
    }
View Full Code Here


    return method;
  }

  private PropertyAccessorElement internalLookUpConcreteSetter(String setterName,
      LibraryElement library, boolean includeThisClass) {
    PropertyAccessorElement setter = internalLookUpSetter(setterName, library, includeThisClass);
    while (setter != null && setter.isAbstract()) {
      Element definingClass = setter.getEnclosingElement();
      if (!(definingClass instanceof ClassElementImpl)) {
        return null;
      }
      setter = ((ClassElementImpl) definingClass).internalLookUpSetter(setterName, library, false);
    }
View Full Code Here

  private PropertyAccessorElement internalLookUpGetter(String getterName, LibraryElement library,
      boolean includeThisClass) {
    HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
    ClassElement currentElement = this;
    if (includeThisClass) {
      PropertyAccessorElement element = currentElement.getGetter(getterName);
      if (element != null && element.isAccessibleIn(library)) {
        return element;
      }
    }
    while (currentElement != null && visitedClasses.add(currentElement)) {
      for (InterfaceType mixin : currentElement.getMixins()) {
        ClassElement mixinElement = mixin.getElement();
        if (mixinElement != null) {
          PropertyAccessorElement element = mixinElement.getGetter(getterName);
          if (element != null && element.isAccessibleIn(library)) {
            return element;
          }
        }
      }
      InterfaceType supertype = currentElement.getSupertype();
      if (supertype == null) {
        return null;
      }
      currentElement = supertype.getElement();
      PropertyAccessorElement element = currentElement.getGetter(getterName);
      if (element != null && element.isAccessibleIn(library)) {
        return element;
      }
    }
    return null;
  }
View Full Code Here

  private PropertyAccessorElement internalLookUpSetter(String setterName, LibraryElement library,
      boolean includeThisClass) {
    HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
    ClassElement currentElement = this;
    if (includeThisClass) {
      PropertyAccessorElement element = currentElement.getSetter(setterName);
      if (element != null && element.isAccessibleIn(library)) {
        return element;
      }
    }
    while (currentElement != null && visitedClasses.add(currentElement)) {
      for (InterfaceType mixin : currentElement.getMixins()) {
        ClassElement mixinElement = mixin.getElement();
        if (mixinElement != null) {
          PropertyAccessorElement element = mixinElement.getSetter(setterName);
          if (element != null && element.isAccessibleIn(library)) {
            return element;
          }
        }
      }
      InterfaceType supertype = currentElement.getSupertype();
      if (supertype == null) {
        return null;
      }
      currentElement = supertype.getElement();
      PropertyAccessorElement element = currentElement.getSetter(setterName);
      if (element != null && element.isAccessibleIn(library)) {
        return element;
      }
    }
    return null;
  }
View Full Code Here

        continue;
      }
      String fieldName = spec.substring(fieldNameOffset);
      fieldNameOffset += specLiteral.getValueOffset();
      // prepare field
      PropertyAccessorElement setter = classElement.getType().lookUpSetter(
          fieldName,
          classElement.getLibrary());
      if (setter == null) {
        reportErrorForOffset(
            AngularCode.INVALID_PROPERTY_FIELD,
            fieldNameOffset,
            fieldName.length(),
            fieldName);
        continue;
      }
      FieldElement field = (FieldElement) setter.getVariable();
      // add property
      AngularPropertyElementImpl property = new AngularPropertyElementImpl(name, nameOffset);
      property.setField(field);
      property.setPropertyKind(kind);
      property.setFieldNameOffset(fieldNameOffset);
View Full Code Here

    if (classElement == null) {
      return false;
    }
    MethodElement equalsOperatorMethodElement = classElement.getMethod(TokenType.EQ_EQ.getLexeme());
    if (equalsOperatorMethodElement != null) {
      PropertyAccessorElement hashCodeElement = classElement.getGetter(HASHCODE_GETTER_NAME);
      if (hashCodeElement == null) {
        errorReporter.reportErrorForNode(
            HintCode.OVERRIDE_EQUALS_BUT_NOT_HASH_CODE,
            node.getName(),
            classElement.getDisplayName());
View Full Code Here

    } else if (expression instanceof PropertyAccess) {
      PropertyAccess propertyAccess = (PropertyAccess) expression;
      element = propertyAccess.getPropertyName().getStaticElement();
    }
    if (element instanceof PropertyAccessorElement) {
      PropertyAccessorElement pae = (PropertyAccessorElement) element;
      PropertyInducingElement variable = pae.getVariable();
      return variable != null && variable.isConst();
    }
    return false;
  }
View Full Code Here

    return getBaseElement().isSetter();
  }

  @Override
  public String toString() {
    PropertyAccessorElement baseElement = getBaseElement();
    ParameterElement[] parameters = getParameters();
    FunctionType type = getType();
    StringBuilder builder = new StringBuilder();
    if (isGetter()) {
      builder.append("get ");
    } else {
      builder.append("set ");
    }
    builder.append(baseElement.getEnclosingElement().getDisplayName());
    builder.append(".");
    builder.append(baseElement.getDisplayName());
    builder.append("(");
    int parameterCount = parameters.length;
    for (int i = 0; i < parameterCount; i++) {
      if (i > 0) {
        builder.append(", ");
View Full Code Here

  protected AnalysisError getErrorForDuplicate(Element existing, Element duplicate) {
    if (existing instanceof PrefixElement) {
      // TODO(scheglov) consider providing actual 'nameOffset' from the synthetic accessor
      int offset = duplicate.getNameOffset();
      if (duplicate instanceof PropertyAccessorElement) {
        PropertyAccessorElement accessor = (PropertyAccessorElement) duplicate;
        if (accessor.isSynthetic()) {
          offset = accessor.getVariable().getNameOffset();
        }
      }
      return new AnalysisError(
          duplicate.getSource(),
          offset,
View Full Code Here

        }
        int length = field.getName().length();
        Location location = new Location(property, offset, length);
        // getter reference
        if (property.getPropertyKind().callsGetter()) {
          PropertyAccessorElement getter = field.getGetter();
          if (getter != null) {
            store.recordRelationship(getter, IndexConstants.IS_REFERENCED_BY_QUALIFIED, location);
          }
        }
        // setter reference
        if (property.getPropertyKind().callsSetter()) {
          PropertyAccessorElement setter = field.getSetter();
          if (setter != null) {
            store.recordRelationship(setter, IndexConstants.IS_REFERENCED_BY_QUALIFIED, location);
          }
        }
      }
View Full Code Here

TOP

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

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.