Examples of VariableElement


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

      private boolean isViewFactory(Expression target) {
        if (target instanceof SimpleIdentifier) {
          SimpleIdentifier identifier = (SimpleIdentifier) target;
          Element element = identifier.getStaticElement();
          if (element instanceof VariableElement) {
            VariableElement variable = (VariableElement) element;
            Type type = variable.getType();
            if (type instanceof InterfaceType) {
              InterfaceType interfaceType = (InterfaceType) type;
              return interfaceType.getName().equals("ViewFactory");
            }
          }
View Full Code Here

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

   */
  private boolean checkForInvalidAssignment(Expression lhs, Expression rhs) {
    if (lhs == null || rhs == null) {
      return false;
    }
    VariableElement leftVariableElement = ErrorVerifier.getVariableElement(lhs);
    Type leftType = (leftVariableElement == null) ? ErrorVerifier.getStaticType(lhs)
        : leftVariableElement.getType();
    Type staticRightType = ErrorVerifier.getStaticType(rhs);
    if (!staticRightType.isAssignableTo(leftType)) {
      // The warning was generated on this rhs
      return false;
    }
View Full Code Here

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

    }
  }

  @Override
  public Void visitVariableDeclaration(VariableDeclaration node) {
    VariableElement element = node.getElement();
    // record declaration
    {
      SimpleIdentifier name = node.getName();
      Location location = createLocationFromNode(name);
      location = getLocationWithExpressionType(location, node.getInitializer());
View Full Code Here

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

    Element element = node.getStaticElement();
    if (element instanceof PropertyAccessorElement) {
      element = ((PropertyAccessorElement) element).getVariable();
    }
    if (element instanceof VariableElement) {
      VariableElement variable = (VariableElement) element;
      if (variable.isConst()) {
        VariableDeclaration variableDeclaration = variableDeclarationMap.get(variable);
        // The declaration will be null when the variable is not defined in the compilation units
        // that were used to produce the variableDeclarationMap.  In such cases, the variable should
        // already have a value associated with it, but we don't bother to check because there's
        // nothing we can do about it at this point.
View Full Code Here

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

  @Override
  public Void visitVariableDeclaration(VariableDeclaration node) {
    super.visitVariableDeclaration(node);
    Expression initializer = node.getInitializer();
    if (initializer != null && node.isConst()) {
      VariableElement element = node.getElement();
      if (element != null) {
        variableMap.put(element, node);
      }
    }
    return null;
View Full Code Here

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

    if (element instanceof PropertyAccessorElement) {
      PropertyAccessorElement accessor = (PropertyAccessorElement) element;
      element = accessor.getVariable();
    }
    if (element instanceof VariableElement) {
      VariableElement variable = (VariableElement) element;
      if (variable.isConst()) {
        errorReporter.reportErrorForNode(StaticWarningCode.ASSIGNMENT_TO_CONST, expression);
        return true;
      }
      if (variable.isFinal()) {
        if (variable instanceof FieldElementImpl
            && ((FieldElementImpl) variable).getSetter() == null && variable.isSynthetic()) {
          errorReporter.reportErrorForNode(
              StaticWarningCode.ASSIGNMENT_TO_FINAL_NO_SETTER,
              highlightedNode,
              variable.getName(),
              variable.getEnclosingElement().getDisplayName());
          return true;
        }
        errorReporter.reportErrorForNode(
            StaticWarningCode.ASSIGNMENT_TO_FINAL,
            highlightedNode,
            variable.getName());
        return true;
      }
      return false;
    }
    if (element instanceof FunctionElement) {
View Full Code Here

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

   */
  private boolean checkForInvalidAssignment(Expression lhs, Expression rhs) {
    if (lhs == null || rhs == null) {
      return false;
    }
    VariableElement leftVariableElement = getVariableElement(lhs);
    Type leftType = (leftVariableElement == null) ? getStaticType(lhs)
        : leftVariableElement.getType();
    Type staticRightType = getStaticType(rhs);
    if (!staticRightType.isAssignableTo(leftType)) {
      errorReporter.reportTypeErrorForNode(
          StaticTypeWarningCode.INVALID_ASSIGNMENT,
          rhs,
View Full Code Here

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

  private boolean checkForInvalidCompoundAssignment(AssignmentExpression node, Expression lhs,
      Expression rhs) {
    if (lhs == null) {
      return false;
    }
    VariableElement leftVariableElement = getVariableElement(lhs);
    Type leftType = (leftVariableElement == null) ? getStaticType(lhs)
        : leftVariableElement.getType();
    MethodElement invokedMethod = node.getStaticElement();
    if (invokedMethod == null) {
      return false;
    }
    Type rightType = invokedMethod.getType().getReturnType();
View Full Code Here

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

    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();
        }
        processElement(element);
        processElement(enclosingExecutable);
        return super.visitVariableDeclaration(node);
      } finally {
View Full Code Here

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

        }
      }
    } else if (element instanceof ExecutableElement) {
      return resolveArgumentsToFunction(false, argumentList, (ExecutableElement) element);
    } else if (element instanceof VariableElement) {
      VariableElement variable = (VariableElement) element;
      Type type = promoteManager.getStaticType(variable);
      if (type instanceof FunctionType) {
        FunctionType functionType = (FunctionType) type;
        ParameterElement[] parameters = functionType.getParameters();
        return resolveArgumentsToParameters(false, argumentList, parameters);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.