Package com.google.dart.engine.ast

Examples of com.google.dart.engine.ast.SimpleIdentifier


      // Extra work to map Constructor Declarations to their associated Constructor Elements
      if (parent instanceof ConstructorDeclaration) {
        ConstructorDeclaration decl = (ConstructorDeclaration) parent;
        Identifier returnType = decl.getReturnType();
        if (returnType == node) {
          SimpleIdentifier name = decl.getName();
          if (name != null) {
            return name.getBestElement();
          }
          Element element = node.getBestElement();
          if (element instanceof ClassElement) {
            return ((ClassElement) element).getUnnamedConstructor();
          }
View Full Code Here


            unusedImports.add(importDirective);
            //
            // Initialize prefixElementMap
            //
            if (importDirective.getAsToken() != null) {
              SimpleIdentifier prefixIdentifier = importDirective.getPrefix();
              if (prefixIdentifier != null) {
                Element element = prefixIdentifier.getStaticElement();
                if (element instanceof PrefixElement) {
                  PrefixElement prefixElementKey = (PrefixElement) element;
                  ArrayList<ImportDirective> list = prefixElementMap.get(prefixElementKey);
                  if (list == null) {
                    list = new ArrayList<ImportDirective>(1);
View Full Code Here

      return null;
    }
    // If the prefixed identifier references some A.B, where A is a library prefix, then we can
    // lookup the associated ImportDirective in prefixElementMap and remove it from the
    // unusedImports list.
    SimpleIdentifier prefixIdentifier = node.getPrefix();
    Element element = prefixIdentifier.getStaticElement();
    if (element instanceof PrefixElement) {
      ArrayList<ImportDirective> importDirectives = prefixElementMap.get(element);
      if (importDirectives != null) {
        for (ImportDirective importDirective : importDirectives) {
          unusedImports.remove(importDirective);
        }
      }
      return null;
    }
    // Otherwise, pass the prefixed identifier element and name onto visitIdentifier.
    return visitIdentifier(element, prefixIdentifier.getName());
  }
View Full Code Here

    if (expression == null || !(expression instanceof MethodInvocation)) {
      return false;
    }
    MethodInvocation methodInvocation = (MethodInvocation) expression;
    if (methodInvocation.getStaticType() == VoidTypeImpl.getInstance()) {
      SimpleIdentifier methodName = methodInvocation.getMethodName();
      errorReporter.reportErrorForNode(
          HintCode.USE_OF_VOID_RESULT,
          methodName,
          methodName.getName());
      return true;
    }
    return false;
  }
View Full Code Here

      }

      private boolean isContext(Expression target) {
        if (target instanceof PrefixedIdentifier) {
          PrefixedIdentifier prefixed = (PrefixedIdentifier) target;
          SimpleIdentifier prefix = prefixed.getPrefix();
          SimpleIdentifier identifier = prefixed.getIdentifier();
          return ObjectUtilities.equals(identifier.getName(), "context") && isScope(prefix);
        }
        return false;
      }

      private boolean isScope(Expression target) {
View Full Code Here

        views.add(new AngularViewElementImpl(templateUri, templateUriOffset));
      }

      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;
View Full Code Here

  }

  @Override
  public Void visitSwitchCase(SwitchCase node) {
    for (Label label : node.getLabels()) {
      SimpleIdentifier labelName = label.getLabel();
      LabelElementImpl element = new LabelElementImpl(labelName, false, true);

      currentHolder.addLabel(element);
      labelName.setStaticElement(element);
    }
    return super.visitSwitchCase(node);
  }
View Full Code Here

  }

  @Override
  public Void visitSwitchDefault(SwitchDefault node) {
    for (Label label : node.getLabels()) {
      SimpleIdentifier labelName = label.getLabel();
      LabelElementImpl element = new LabelElementImpl(labelName, false, true);

      currentHolder.addLabel(element);
      labelName.setStaticElement(element);
    }
    return super.visitSwitchDefault(node);
  }
View Full Code Here

    return super.visitSwitchDefault(node);
  }

  @Override
  public Void visitTypeParameter(TypeParameter node) {
    SimpleIdentifier parameterName = node.getName();
    TypeParameterElementImpl typeParameter = new TypeParameterElementImpl(parameterName);

    TypeParameterTypeImpl typeParameterType = new TypeParameterTypeImpl(typeParameter);
    typeParameter.setType(typeParameterType);

    currentHolder.addTypeParameter(typeParameter);
    parameterName.setStaticElement(typeParameter);
    return super.visitTypeParameter(node);
  }
View Full Code Here

    boolean isFinal = matches(keyword, Keyword.FINAL);
    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);
    } else if (inFunction) {
      SimpleIdentifier variableName = node.getName();
      LocalVariableElementImpl variable;
      if (isConst && hasInitializer) {
        variable = new ConstLocalVariableElementImpl(variableName);
      } else {
        variable = new LocalVariableElementImpl(variableName);
      }
      element = variable;
      Block enclosingBlock = node.getAncestor(Block.class);
      int functionEnd = node.getOffset() + node.getLength();
      int blockEnd = enclosingBlock.getOffset() + enclosingBlock.getLength();
      // TODO(brianwilkerson) This isn't right for variables declared in a for loop.
      variable.setVisibleRange(functionEnd, blockEnd - functionEnd - 1);

      currentHolder.addLocalVariable(variable);
      variableName.setStaticElement(element);
    } else {
      SimpleIdentifier variableName = node.getName();
      TopLevelVariableElementImpl variable;
      if (isConst && hasInitializer) {
        variable = new ConstTopLevelVariableElementImpl(variableName);
      } else {
        variable = new TopLevelVariableElementImpl(variableName);
      }
      element = variable;

      currentHolder.addTopLevelVariable(variable);
      variableName.setStaticElement(element);
    }

    element.setConst(isConst);
    element.setFinal(isFinal);
    if (hasInitializer) {
View Full Code Here

TOP

Related Classes of com.google.dart.engine.ast.SimpleIdentifier

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.