Package com.google.javascript.jscomp.NodeIterators

Examples of com.google.javascript.jscomp.NodeIterators.FunctionlessLocalScope


    Node root = (new Compiler()).parseTestCode(";" + code);
    for (Node n = root; n != null; n = n.getFirstChild()) {
      ancestors.add(0, n);
    }

    FunctionlessLocalScope searchIt = new FunctionlessLocalScope(
        ancestors.toArray(new Node[ancestors.size()]));

    boolean found = false;
    while (searchIt.hasNext()) {
      Node n = searchIt.next();
      if (n.isName() &&
          searchIt.currentParent().isVar() &&
          n.getString().equals("X")) {
        found = true;
        break;
      }
    }

    assertTrue("Variable X not found! " + root.toStringTree(), found);

    List<Node> currentAncestors = searchIt.currentAncestors();
    assert(currentAncestors.size() >= 3);
    Iterator<Node> moveIt = LocalVarMotion.forVar(
        currentAncestors.get(0),
        currentAncestors.get(1),
        currentAncestors.get(2));
View Full Code Here


    Node root = (new Compiler()).parseTestCode(";" + code);
    for (Node n = root; n != null; n = n.getFirstChild()) {
      ancestors.add(0, n);
    }

    FunctionlessLocalScope searchIt = new FunctionlessLocalScope(
        ancestors.toArray(new Node[ancestors.size()]));

    boolean found = false;
    while (searchIt.hasNext()) {
      Node n = searchIt.next();
      if (n.getType() == Token.NAME &&
          searchIt.currentParent().getType() == Token.VAR &&
          n.getString().equals("X")) {
        found = true;
        break;
      }
    }

    assertTrue("Variable X not found! " + root.toStringTree(), found);

    List<Node> currentAncestors = searchIt.currentAncestors();
    assert(currentAncestors.size() >= 3);
    Iterator<Node> moveIt = LocalVarMotion.forVar(
        currentAncestors.get(0),
        currentAncestors.get(1),
        currentAncestors.get(2));
View Full Code Here

TOP

Related Classes of com.google.javascript.jscomp.NodeIterators.FunctionlessLocalScope

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.