Package com.google.dart.engine.ast.visitor

Examples of com.google.dart.engine.ast.visitor.NodeLocator


    CompilationUnit unit = getUnit();
    if (unit == null) {
      return null;
    }
    int offset = getNameOffset();
    AstNode node = new NodeLocator(offset).searchWithin(unit);
    if (node == null) {
      return null;
    }
    return node.getAncestor(clazz);
  }
View Full Code Here


    }
    CompilationUnit unit = parseCompilationUnit(source);
    if (unit == null) {
      return null;
    }
    NodeLocator locator = new NodeLocator(element.getNameOffset());
    AstNode nameNode = locator.searchWithin(unit);
    while (nameNode != null) {
      if (nameNode instanceof AnnotatedNode) {
        Comment comment = ((AnnotatedNode) nameNode).getDocumentationComment();
        if (comment == null) {
          return null;
View Full Code Here

  /**
   * If the given {@link AstNode} has an {@link Element} at the given offset, then returns
   * {@link Reference} with this {@link Element}.
   */
  private Reference getReferenceAtNode(AstNode root, int offset) {
    AstNode node = new NodeLocator(offset).searchWithin(root);
    if (node != null) {
      Element element = ElementLocator.locate(node);
      return new Reference(element, node.getOffset(), node.getLength());
    }
    return null;
View Full Code Here

    return expression.getOffset();
  }

  @Override
  public Reference getReference(int offset) {
    AstNode node = new NodeLocator(offset).searchWithin(expression);
    if (node != null) {
      Element element = ElementLocator.locate(node);
      return new Reference(element, node.getOffset(), node.getLength());
    }
    return null;
View Full Code Here

   * Returns the {@link Expression} that is part of the given root {@link AstNode} and encloses the
   * given offset.
   */
  private static Expression getExpressionAt(AstNode root, int offset) {
    if (root.getOffset() <= offset && offset <= root.getEnd()) {
      AstNode dartNode = new NodeLocator(offset).searchWithin(root);
      if (dartNode instanceof Expression) {
        return (Expression) dartNode;
      }
    }
    return null;
View Full Code Here

    }
    //
    // 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();
View Full Code Here

TOP

Related Classes of com.google.dart.engine.ast.visitor.NodeLocator

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.