Package com.google.dart.engine.element

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


    if (!accessorElement.isSynthetic()) {
      resolver.reportErrorForNode(CompileTimeErrorCode.INVALID_ANNOTATION, annotation);
      return;
    }
    // variable should be constant
    VariableElement variableElement = accessorElement.getVariable();
    if (!variableElement.isConst()) {
      resolver.reportErrorForNode(CompileTimeErrorCode.INVALID_ANNOTATION, annotation);
    }
    // OK
    return;
  }
View Full Code Here


   * @param potentialType the potential type of the elements
   * @param allowPrecisionLoss see @{code overrideVariable} docs
   */
  protected void overrideExpression(Expression expression, Type potentialType,
      boolean allowPrecisionLoss) {
    VariableElement element = getOverridableStaticElement(expression);
    if (element != null) {
      overrideVariable(element, potentialType, allowPrecisionLoss);
    }
    element = getOverridablePropagatedElement(expression);
    if (element != null) {
View Full Code Here

   * @param expression the expression used to access the static element whose types might be
   *          promoted
   * @param potentialType the potential type of the elements
   */
  private void promote(Expression expression, Type potentialType) {
    VariableElement element = getPromotionStaticElement(expression);
    if (element != null) {
      // may be mutated somewhere in closure
      if (((VariableElementImpl) element).isPotentiallyMutatedInClosure()) {
        return;
      }
View Full Code Here

    return null;
  }

  @Override
  public Void visitDeclaredIdentifier(DeclaredIdentifier node) {
    VariableElement element = node.getElement();
    if (element != null) {
      nameScope.define(element);
    }
    super.visitDeclaredIdentifier(node);
    return null;
View Full Code Here

  @Override
  public Void visitVariableDeclaration(VariableDeclaration node) {
    super.visitVariableDeclaration(node);
    if (!(node.getParent().getParent() instanceof TopLevelVariableDeclaration)
        && !(node.getParent().getParent() instanceof FieldDeclaration)) {
      VariableElement element = node.getElement();
      if (element != null) {
        nameScope.define(element);
      }
    }
    return null;
View Full Code Here

    } else if (element instanceof ExecutableElement) {
      staticType = ((ExecutableElement) element).getType();
    } else if (element instanceof TypeParameterElement) {
      staticType = typeProvider.getTypeType();
    } else if (element instanceof VariableElement) {
      VariableElement variable = (VariableElement) element;
      staticType = promoteManager.getStaticType(variable);
    } else if (element instanceof PrefixElement) {
      return null;
    } else {
      staticType = dynamicType;
View Full Code Here

    Expression initializer = node.getInitializer();
    if (initializer != null) {
      Type rightType = initializer.getBestType();
      SimpleIdentifier name = node.getName();
      recordPropagatedType(name, rightType);
      VariableElement element = (VariableElement) name.getStaticElement();
      if (element != null) {
        resolver.overrideVariable(element, rightType, true);
      }
    }
    return null;
View Full Code Here

      if (type != null) {
        // TODO(brianwilkerson) Figure out the conditions under which the type is null.
        return type.getReturnType();
      }
    } else if (element instanceof VariableElement) {
      VariableElement variable = (VariableElement) element;
      Type variableType = promoteManager.getStaticType(variable);
      if (variableType instanceof FunctionType) {
        return ((FunctionType) variableType).getReturnType();
      }
    }
View Full Code Here

    return super.visitTypeParameter(node);
  }

  @Override
  public Void visitVariableDeclaration(VariableDeclaration node) {
    VariableElement element = null;
    SimpleIdentifier variableName = node.getName();
    if (enclosingExecutable != null) {
      element = findIdentifier(enclosingExecutable.getLocalVariables(), variableName);
    }
    if (element == null && enclosingClass != null) {
      element = findIdentifier(enclosingClass.getFields(), variableName);
    }
    if (element == null && enclosingUnit != null) {
      element = findIdentifier(enclosingUnit.getTopLevelVariables(), variableName);
    }
    Expression initializer = node.getInitializer();
    if (initializer != null) {
      ExecutableElement outerExecutable = enclosingExecutable;
      try {
        if (element == null) {
          // TODO(brianwilkerson) Report this internal error.
        } else {
          enclosingExecutable = element.getInitializer();
        }
        return super.visitVariableDeclaration(node);
      } finally {
        enclosingExecutable = outerExecutable;
      }
View Full Code Here

TOP

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

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.