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

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


        currentHolder.addMethod(element);
        methodName.setStaticElement(element);
      } else {
        SimpleIdentifier propertyNameNode = node.getName();
        String propertyName = propertyNameNode.getName();
        FieldElementImpl field = (FieldElementImpl) currentHolder.getField(propertyName);
        if (field == null) {
          field = new FieldElementImpl(node.getName().getName(), -1);
          field.setFinal(true);
          field.setStatic(isStatic);
          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


    boolean hasInitializer = node.getInitializer() != null;

    VariableElementImpl element;
    if (inFieldContext) {
      SimpleIdentifier fieldName = node.getName();
      FieldElementImpl field;
      if (isConst && hasInitializer) {
        field = new ConstFieldElementImpl(fieldName);
      } else {
        field = new FieldElementImpl(fieldName);
      }
      element = field;

      currentHolder.addField(field);
      fieldName.setStaticElement(field);
View Full Code Here

    ArrayList<FieldElement> fields = new ArrayList<FieldElement>();
    ArrayList<PropertyAccessorElement> getters = new ArrayList<PropertyAccessorElement>();
    InterfaceType intType = typeProvider.getIntType();

    String indexFieldName = "index";
    FieldElementImpl indexField = new FieldElementImpl(indexFieldName, -1);
    indexField.setFinal(true);
    indexField.setSynthetic(true);
    indexField.setType(intType);
    fields.add(indexField);
    getters.add(createGetter(indexField));

    FieldElementImpl valuesField = new FieldElementImpl("values", -1);
    valuesField.setStatic(true);
    valuesField.setConst(true);
    valuesField.setSynthetic(true);
    valuesField.setType(typeProvider.getListType().substitute(new Type[] {enumType}));
    fields.add(valuesField);
    getters.add(createGetter(valuesField));
    //
    // Build the enum constants.
    //
    NodeList<EnumConstantDeclaration> constants = node.getConstants();
    int constantCount = constants.size();
    for (int i = 0; i < constantCount; i++) {
      SimpleIdentifier constantName = constants.get(i).getName();
      FieldElementImpl constantField = new ConstFieldElementImpl(constantName);
      constantField.setStatic(true);
      constantField.setConst(true);
      constantField.setType(enumType);
      //
      // Create a value for the constant.
      //
      HashMap<String, DartObjectImpl> fieldMap = new HashMap<String, DartObjectImpl>();
      fieldMap.put(indexFieldName, new DartObjectImpl(intType, new IntState(BigInteger.valueOf(i))));
      DartObjectImpl value = new DartObjectImpl(enumType, new GenericState(fieldMap));
      constantField.setEvaluationResult(new ValidResult(value));
      fields.add(constantField);
      getters.add(createGetter(constantField));
      constantName.setStaticElement(constantField);
    }
    //
View Full Code Here

TOP

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

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.