Package com.google.dart.engine.element

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


  private void validateInitializerExpression(final ParameterElement[] parameterElements,
      Expression expression) {
    EvaluationResultImpl result = expression.accept(new ConstantVisitor(typeProvider) {
      @Override
      public EvaluationResultImpl visitSimpleIdentifier(SimpleIdentifier node) {
        Element element = node.getStaticElement();
        for (ParameterElement parameterElement : parameterElements) {
          if (parameterElement == element && parameterElement != null) {
            Type type = parameterElement.getType();
            if (type != null) {
              if (type.isDynamic()) {
View Full Code Here


   * @param expression the expression whose element is to be returned
   * @return the variable element represented by the expression
   */
  public static VariableElement getVariableElement(Expression expression) {
    if (expression instanceof Identifier) {
      Element element = ((Identifier) expression).getStaticElement();
      if (element instanceof VariableElement) {
        return (VariableElement) element;
      }
    }
    return null;
View Full Code Here

  @Override
  public Void visitBreakStatement(BreakStatement node) {
    SimpleIdentifier labelNode = node.getLabel();
    if (labelNode != null) {
      Element labelElement = labelNode.getStaticElement();
      if (labelElement instanceof LabelElementImpl
          && ((LabelElementImpl) labelElement).isOnSwitchMember()) {
        errorReporter.reportErrorForNode(ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER, labelNode);
      }
    }
View Full Code Here

  @Override
  public Void visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
    isInConstructorInitializer = true;
    try {
      SimpleIdentifier fieldName = node.getFieldName();
      Element staticElement = fieldName.getStaticElement();
      checkForInvalidField(node, fieldName, staticElement);
      checkForFieldInitializerNotAssignable(node, staticElement);
      return super.visitConstructorFieldInitializer(node);
    } finally {
      isInConstructorInitializer = false;
View Full Code Here

  @Override
  public Void visitContinueStatement(ContinueStatement node) {
    SimpleIdentifier labelNode = node.getLabel();
    if (labelNode != null) {
      Element labelElement = labelNode.getStaticElement();
      if (labelElement instanceof LabelElementImpl
          && ((LabelElementImpl) labelElement).isOnSwitchStatement()) {
        errorReporter.reportErrorForNode(ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH, labelNode);
      }
    }
View Full Code Here

        return false;
      }
      if (constructorInitializer instanceof ConstructorFieldInitializer) {
        ConstructorFieldInitializer constructorFieldInitializer = (ConstructorFieldInitializer) constructorInitializer;
        SimpleIdentifier fieldName = constructorFieldInitializer.getFieldName();
        Element element = fieldName.getStaticElement();
        if (element instanceof FieldElement) {
          FieldElement fieldElement = (FieldElement) element;
          INIT_STATE state = fieldElementsMap.get(fieldElement);
          if (state == INIT_STATE.NOT_INIT) {
            fieldElementsMap.put(fieldElement, INIT_STATE.INIT_IN_INITIALIZERS);
View Full Code Here

    // check exported names
    Namespace namespace = new NamespaceBuilder().createExportNamespaceForDirective(exportElement);
    Map<String, Element> definedNames = namespace.getDefinedNames();
    for (Entry<String, Element> definedEntry : definedNames.entrySet()) {
      String name = definedEntry.getKey();
      Element element = definedEntry.getValue();
      Element prevElement = exportedElements.get(name);
      if (element != null && prevElement != null && !prevElement.equals(element)) {
        errorReporter.reportErrorForNode(
            CompileTimeErrorCode.AMBIGUOUS_EXPORT,
            node,
            name,
            prevElement.getLibrary().getDefiningCompilationUnit().getDisplayName(),
            element.getLibrary().getDefiningCompilationUnit().getDisplayName());
        return true;
      } else {
        exportedElements.put(name, element);
      }
View Full Code Here

   * @see StaticWarningCode#ASSIGNMENT_TO_FINAL
   * @see StaticWarningCode#ASSIGNMENT_TO_METHOD
   */
  private boolean checkForAssignmentToFinal(Expression expression) {
    // prepare element
    Element element = null;
    AstNode highlightedNode = expression;
    if (expression instanceof Identifier) {
      element = ((Identifier) expression).getStaticElement();
      if (expression instanceof PrefixedIdentifier) {
        highlightedNode = ((PrefixedIdentifier) expression).getIdentifier();
View Full Code Here

        // Do lookups in the enclosing class (and the inherited member) if the member is a method or
        // a setter for StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER warning.
        if (isMethod) {
          String setterName = name.getName() + "=";
          Element enclosingElementOfSetter = null;
          ClassMember conflictingSetter = memberHashMap.get(setterName);
          if (conflictingSetter != null) {
            enclosingElementOfSetter = conflictingSetter.getElement().getEnclosingElement();
          } else {
            ExecutableElement elementFromInheritance = inheritanceManager.lookupInheritance(
                enclosingClass,
                setterName);
            if (elementFromInheritance != null) {
              enclosingElementOfSetter = elementFromInheritance.getEnclosingElement();
            }
          }
          if (enclosingElementOfSetter != null) {
            // report problem
            errorReporter.reportErrorForNode(
                StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER,
                name,
                enclosingClass.getDisplayName(),
                name.getName(),
                enclosingElementOfSetter.getDisplayName());
            foundError |= true;
            addThisMemberToTheMap = false;
          }
        } else if (isSetter) {
          String methodName = name.getName();
View Full Code Here

        Directive directive = directives.get(i);
        if (directive instanceof ImportDirective) {
          ImportDirective importDirective = (ImportDirective) directive;
          SimpleIdentifier prefix = importDirective.getPrefix();
          if (prefix != null) {
            Element element = prefix.getStaticElement();
            if (element instanceof PrefixElement) {
              PrefixElement prefixElement = (PrefixElement) element;
              ArrayList<ImportDirective> elements = prefixToDirectivesMap.get(prefixElement);
              if (elements == null) {
                elements = new ArrayList<ImportDirective>();
View Full Code Here

TOP

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

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.