Package com.google.dart.engine.ast

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


   *
   * @param node the node being tested
   * @return {@code true} if the given node is not a type literal
   */
  private boolean isNotTypeLiteral(Identifier node) {
    AstNode parent = node.getParent();
    return parent instanceof TypeName
        || (parent instanceof PrefixedIdentifier && (parent.getParent() instanceof TypeName || ((PrefixedIdentifier) parent).getPrefix() == node))
        || (parent instanceof PropertyAccess && ((PropertyAccess) parent).getTarget() == node)
        || (parent instanceof MethodInvocation && node == ((MethodInvocation) parent).getTarget());
  }
View Full Code Here


      PrintStringWriter writer = new PrintStringWriter();
      writer.println("Invalid state found in the Analysis Engine:");
      writer.println("DeclarationResolver.getElementForParameter() is visiting a parameter that "
          + "does not appear to be in a method or function.");
      writer.println("Ancestors:");
      AstNode parent = node.getParent();
      while (parent != null) {
        writer.println(parent.getClass().getName());
        writer.println("---------");
        parent = parent.getParent();
      }
      AnalysisEngine.getInstance().getLogger().logError(writer.toString(), new AnalysisException());
    }
    return element;
  }
View Full Code Here

   */
  public static SourceRange rangeNodes(List<? extends AstNode> nodes) {
    if (nodes.isEmpty()) {
      return rangeStartLength(0, 0);
    }
    AstNode first = nodes.get(0);
    AstNode last = nodes.get(nodes.size() - 1);
    return rangeStartEnd(first, last);
  }
View Full Code Here

  }

  @Override
  public Void visitNode(AstNode node) {
    immediateChild = node;
    AstNode parent = node.getParent();
    if (parent != null) {
      parent.accept(this);
    }
    return null;
  }
View Full Code Here

   * @param originalEnd the offset in the original source of the last character that was modified
   */
  @SuppressWarnings("unchecked")
  public <E extends AstNode> E reparse(E originalStructure, Token leftToken, Token rightToken,
      int originalStart, int originalEnd) {
    AstNode oldNode = null;
    AstNode newNode = null;
    //
    // Find the first token that needs to be re-parsed.
    //
    Token firstToken = leftToken.getNext();
    if (firstToken == rightToken) {
      // If there are no new tokens, then we need to include at least one copied node in the range.
      firstToken = leftToken;
    }
    //
    // Find the smallest AST node that encompasses the range of re-scanned tokens.
    //
    if (originalEnd < originalStart) {
      oldNode = new NodeLocator(originalStart).searchWithin(originalStructure);
    } else {
      oldNode = new NodeLocator(originalStart, originalEnd).searchWithin(originalStructure);
    }
    //
    // Find the token at which parsing is to begin.
    //
    int originalOffset = oldNode.getOffset();
    Token parseToken = findTokenAt(firstToken, originalOffset);
    if (parseToken == null) {
      return null;
    }
    //
    // Parse the appropriate AST structure starting at the appropriate place.
    //
    Parser parser = new Parser(source, errorListener);
    parser.setCurrentToken(parseToken);
    while (newNode == null) {
      AstNode parent = oldNode.getParent();
      if (parent == null) {
        parseToken = findFirstToken(parseToken);
        parser.setCurrentToken(parseToken);
        return (E) parser.parseCompilationUnit();
      }
      boolean advanceToParent = false;
      try {
        IncrementalParseDispatcher dispatcher = new IncrementalParseDispatcher(parser, oldNode);
        newNode = parent.accept(dispatcher);
        //
        // Validate that the new node can replace the old node.
        //
        Token mappedToken = tokenMap.get(oldNode.getEndToken().getNext());
        if (mappedToken == null
View Full Code Here

TOP

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

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.