Package com.google.dart.engine.internal.element

Examples of com.google.dart.engine.internal.element.PropertyAccessorElementImpl


   *
   * @param field the field for which a getter is to be created
   * @return the getter that was created
   */
  private PropertyAccessorElement createGetter(FieldElementImpl field) {
    PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl(field);
    getter.setGetter(true);
    getter.setReturnType(field.getType());
    field.setGetter(getter);
    return getter;
  }
View Full Code Here


          variable.setSynthetic(true);

          currentHolder.addTopLevelVariable(variable);
        }
        if (matches(property, Keyword.GET)) {
          PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl(propertyNameNode);
          getter.setFunctions(holder.getFunctions());
          getter.setLabels(holder.getLabels());
          getter.setLocalVariables(holder.getLocalVariables());
          if (body.isAsynchronous()) {
            getter.setAsynchronous(true);
          }
          if (body.isGenerator()) {
            getter.setGenerator(true);
          }

          getter.setVariable(variable);
          getter.setGetter(true);
          getter.setStatic(true);
          variable.setGetter(getter);

          currentHolder.addAccessor(getter);
          expression.setElement(getter);
          propertyNameNode.setStaticElement(getter);
        } else {
          PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl(propertyNameNode);
          setter.setFunctions(holder.getFunctions());
          setter.setLabels(holder.getLabels());
          setter.setLocalVariables(holder.getLocalVariables());
          setter.setParameters(holder.getParameters());
          if (body.isAsynchronous()) {
            setter.setAsynchronous(true);
          }
          if (body.isGenerator()) {
            setter.setGenerator(true);
          }

          setter.setVariable(variable);
          setter.setSetter(true);
          setter.setStatic(true);
          variable.setSetter(setter);
          variable.setFinal(false);

          currentHolder.addAccessor(setter);
          expression.setElement(setter);
View Full Code Here

          field.setSynthetic(true);

          currentHolder.addField(field);
        }
        if (matches(property, Keyword.GET)) {
          PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl(propertyNameNode);
          getter.setFunctions(holder.getFunctions());
          getter.setLabels(holder.getLabels());
          getter.setLocalVariables(holder.getLocalVariables());
          if (body.isAsynchronous()) {
            getter.setAsynchronous(true);
          }
          if (body.isGenerator()) {
            getter.setGenerator(true);
          }

          getter.setVariable(field);
          getter.setAbstract(body instanceof EmptyFunctionBody && node.getExternalKeyword() == null);
          getter.setGetter(true);
          getter.setStatic(isStatic);
          field.setGetter(getter);

          currentHolder.addAccessor(getter);
          propertyNameNode.setStaticElement(getter);
        } else {
          PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl(propertyNameNode);
          setter.setFunctions(holder.getFunctions());
          setter.setLabels(holder.getLabels());
          setter.setLocalVariables(holder.getLocalVariables());
          setter.setParameters(holder.getParameters());
          if (body.isAsynchronous()) {
            setter.setAsynchronous(true);
          }
          if (body.isGenerator()) {
            setter.setGenerator(true);
          }

          setter.setVariable(field);
          setter.setAbstract(body instanceof EmptyFunctionBody
              && !matches(node.getExternalKeyword(), Keyword.EXTERNAL));
          setter.setSetter(true);
          setter.setStatic(isStatic);
          field.setSetter(setter);
          field.setFinal(false);

          currentHolder.addAccessor(setter);
          propertyNameNode.setStaticElement(setter);
View Full Code Here

        ((FieldElementImpl) variable).setStatic(matches(
            ((FieldDeclaration) node.getParent().getParent()).getStaticKeyword(),
            Keyword.STATIC));
      }

      PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl(variable);
      getter.setGetter(true);

      currentHolder.addAccessor(getter);
      variable.setGetter(getter);

      if (!isFinal) {
        PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl(variable);
        setter.setSetter(true);
        ParameterElementImpl parameter = new ParameterElementImpl(
            "_" + variable.getName(),
            variable.getNameOffset());
        parameter.setSynthetic(true);
        parameter.setParameterKind(ParameterKind.REQUIRED);
        setter.setParameters(new ParameterElement[] {parameter});

        currentHolder.addAccessor(setter);
        variable.setSetter(setter);
      }
    }
View Full Code Here

    Element element = node.getName().getStaticElement();
    if (element instanceof VariableElement) {
      ((VariableElementImpl) element).setType(declaredType);
      if (element instanceof PropertyInducingElement) {
        PropertyInducingElement variableElement = (PropertyInducingElement) element;
        PropertyAccessorElementImpl getter = (PropertyAccessorElementImpl) variableElement.getGetter();
        getter.setReturnType(declaredType);
        FunctionTypeImpl getterType = new FunctionTypeImpl(getter);
        ClassElement definingClass = element.getAncestor(ClassElement.class);
        if (definingClass != null) {
          getterType.setTypeArguments(definingClass.getType().getTypeArguments());
        }
        getter.setType(getterType);

        PropertyAccessorElementImpl setter = (PropertyAccessorElementImpl) variableElement.getSetter();
        if (setter != null) {
          ParameterElement[] parameters = setter.getParameters();
          if (parameters.length > 0) {
            ((ParameterElementImpl) parameters[0]).setType(declaredType);
          }
          setter.setReturnType(VoidTypeImpl.getInstance());
          FunctionTypeImpl setterType = new FunctionTypeImpl(setter);
          if (definingClass != null) {
            setterType.setTypeArguments(definingClass.getType().getTypeArguments());
          }
          setter.setType(setterType);
        }
      }
    } else {
      // TODO(brianwilkerson) Report the internal error.
    }
View Full Code Here

TOP

Related Classes of com.google.dart.engine.internal.element.PropertyAccessorElementImpl

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.