Java Code Examples for com.google.javascript.rhino.Node#setWasEmptyNode()

The following examples show how to use com.google.javascript.rhino.Node#setWasEmptyNode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Closure_122_IRFactory_t.java    From coming with MIT License 6 votes vote down vote up
private Node transformBlock(AstNode node) {
  Node irNode = transform(node);
  if (!irNode.isBlock()) {
    if (irNode.isEmpty()) {
      irNode.setType(Token.BLOCK);
      irNode.setWasEmptyNode(true);
    } else {
      Node newBlock = newNode(Token.BLOCK, irNode);
      newBlock.setLineno(irNode.getLineno());
      newBlock.setCharno(irNode.getCharno());
      maybeSetLengthFrom(newBlock, node);
      irNode = newBlock;
    }
  }
  return irNode;
}
 
Example 2
Source File: Closure_122_IRFactory_s.java    From coming with MIT License 6 votes vote down vote up
private Node transformBlock(AstNode node) {
  Node irNode = transform(node);
  if (!irNode.isBlock()) {
    if (irNode.isEmpty()) {
      irNode.setType(Token.BLOCK);
      irNode.setWasEmptyNode(true);
    } else {
      Node newBlock = newNode(Token.BLOCK, irNode);
      newBlock.setLineno(irNode.getLineno());
      newBlock.setCharno(irNode.getCharno());
      maybeSetLengthFrom(newBlock, node);
      irNode = newBlock;
    }
  }
  return irNode;
}
 
Example 3
Source File: Closure_129_PrepareAst_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Add blocks to IF, WHILE, DO, etc.
 */
private void normalizeBlocks(Node n) {
  if (NodeUtil.isControlStructure(n)
      && !n.isLabel()
      && !n.isSwitch()) {
    for (Node c = n.getFirstChild(); c != null; c = c.getNext()) {
      if (NodeUtil.isControlStructureCodeBlock(n,c) &&
          !c.isBlock()) {
        Node newBlock = IR.block().srcref(n);
        n.replaceChild(c, newBlock);
        if (!c.isEmpty()) {
          newBlock.addChildrenToFront(c);
        } else {
          newBlock.setWasEmptyNode(true);
        }
        c = newBlock;
        reportChange();
      }
    }
  }
}
 
Example 4
Source File: Closure_129_PrepareAst_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Add blocks to IF, WHILE, DO, etc.
 */
private void normalizeBlocks(Node n) {
  if (NodeUtil.isControlStructure(n)
      && !n.isLabel()
      && !n.isSwitch()) {
    for (Node c = n.getFirstChild(); c != null; c = c.getNext()) {
      if (NodeUtil.isControlStructureCodeBlock(n,c) &&
          !c.isBlock()) {
        Node newBlock = IR.block().srcref(n);
        n.replaceChild(c, newBlock);
        if (!c.isEmpty()) {
          newBlock.addChildrenToFront(c);
        } else {
          newBlock.setWasEmptyNode(true);
        }
        c = newBlock;
        reportChange();
      }
    }
  }
}
 
Example 5
Source File: Closure_37_IRFactory_t.java    From coming with MIT License 6 votes vote down vote up
private Node transformBlock(AstNode node) {
  Node irNode = transform(node);
  if (!irNode.isBlock()) {
    if (irNode.isEmpty()) {
      irNode.setType(Token.BLOCK);
      irNode.setWasEmptyNode(true);
    } else {
      Node newBlock = newNode(Token.BLOCK, irNode);
      newBlock.setLineno(irNode.getLineno());
      newBlock.setCharno(irNode.getCharno());
      maybeSetLengthFrom(newBlock, node);
      irNode = newBlock;
    }
  }
  return irNode;
}
 
Example 6
Source File: Closure_37_IRFactory_s.java    From coming with MIT License 6 votes vote down vote up
private Node transformBlock(AstNode node) {
  Node irNode = transform(node);
  if (!irNode.isBlock()) {
    if (irNode.isEmpty()) {
      irNode.setType(Token.BLOCK);
      irNode.setWasEmptyNode(true);
    } else {
      Node newBlock = newNode(Token.BLOCK, irNode);
      newBlock.setLineno(irNode.getLineno());
      newBlock.setCharno(irNode.getCharno());
      maybeSetLengthFrom(newBlock, node);
      irNode = newBlock;
    }
  }
  return irNode;
}
 
Example 7
Source File: Closure_42_IRFactory_t.java    From coming with MIT License 6 votes vote down vote up
private Node transformBlock(AstNode node) {
  Node irNode = transform(node);
  if (!irNode.isBlock()) {
    if (irNode.isEmpty()) {
      irNode.setType(Token.BLOCK);
      irNode.setWasEmptyNode(true);
    } else {
      Node newBlock = newNode(Token.BLOCK, irNode);
      newBlock.setLineno(irNode.getLineno());
      newBlock.setCharno(irNode.getCharno());
      maybeSetLengthFrom(newBlock, node);
      irNode = newBlock;
    }
  }
  return irNode;
}
 
Example 8
Source File: Closure_42_IRFactory_s.java    From coming with MIT License 6 votes vote down vote up
private Node transformBlock(AstNode node) {
  Node irNode = transform(node);
  if (!irNode.isBlock()) {
    if (irNode.isEmpty()) {
      irNode.setType(Token.BLOCK);
      irNode.setWasEmptyNode(true);
    } else {
      Node newBlock = newNode(Token.BLOCK, irNode);
      newBlock.setLineno(irNode.getLineno());
      newBlock.setCharno(irNode.getCharno());
      maybeSetLengthFrom(newBlock, node);
      irNode = newBlock;
    }
  }
  return irNode;
}
 
Example 9
Source File: PrepareAst.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Add blocks to IF, WHILE, DO, etc.
 */
private void normalizeBlocks(Node n) {
  if (NodeUtil.isControlStructure(n)
      && !n.isLabel()
      && !n.isSwitch()) {
    for (Node c = n.getFirstChild(); c != null; c = c.getNext()) {
      if (NodeUtil.isControlStructureCodeBlock(n,c) &&
          !c.isBlock()) {
        Node newBlock = IR.block().srcref(n);
        n.replaceChild(c, newBlock);
        if (!c.isEmpty()) {
          newBlock.addChildrenToFront(c);
        } else {
          newBlock.setWasEmptyNode(true);
        }
        c = newBlock;
        reportChange();
      }
    }
  }
}
 
Example 10
Source File: IRFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
private Node transformBlock(AstNode node) {
  Node irNode = transform(node);
  if (!irNode.isBlock()) {
    if (irNode.isEmpty()) {
      irNode.setType(Token.BLOCK);
      irNode.setWasEmptyNode(true);
    } else {
      Node newBlock = newNode(Token.BLOCK, irNode);
      newBlock.setLineno(irNode.getLineno());
      newBlock.setCharno(irNode.getCharno());
      maybeSetLengthFrom(newBlock, node);
      irNode = newBlock;
    }
  }
  return irNode;
}
 
Example 11
Source File: Closure_81_IRFactory_t.java    From coming with MIT License 5 votes vote down vote up
private Node transformBlock(AstNode node) {
  Node irNode = transform(node);
  if (irNode.getType() != Token.BLOCK) {
    if (irNode.getType() == Token.EMPTY) {
      irNode.setType(Token.BLOCK);
      irNode.setWasEmptyNode(true);
    } else {
      Node newBlock = newNode(Token.BLOCK, irNode);
      newBlock.setLineno(irNode.getLineno());
      newBlock.setCharno(irNode.getCharno());
      irNode = newBlock;
    }
  }
  return irNode;
}
 
Example 12
Source File: Closure_81_IRFactory_s.java    From coming with MIT License 5 votes vote down vote up
private Node transformBlock(AstNode node) {
  Node irNode = transform(node);
  if (irNode.getType() != Token.BLOCK) {
    if (irNode.getType() == Token.EMPTY) {
      irNode.setType(Token.BLOCK);
      irNode.setWasEmptyNode(true);
    } else {
      Node newBlock = newNode(Token.BLOCK, irNode);
      newBlock.setLineno(irNode.getLineno());
      newBlock.setCharno(irNode.getCharno());
      irNode = newBlock;
    }
  }
  return irNode;
}
 
Example 13
Source File: Closure_84_IRFactory_t.java    From coming with MIT License 5 votes vote down vote up
private Node transformBlock(AstNode node) {
  Node irNode = transform(node);
  if (irNode.getType() != Token.BLOCK) {
    if (irNode.getType() == Token.EMPTY) {
      irNode.setType(Token.BLOCK);
      irNode.setWasEmptyNode(true);
    } else {
      Node newBlock = newNode(Token.BLOCK, irNode);
      newBlock.setLineno(irNode.getLineno());
      newBlock.setCharno(irNode.getCharno());
      irNode = newBlock;
    }
  }
  return irNode;
}
 
Example 14
Source File: Closure_84_IRFactory_s.java    From coming with MIT License 5 votes vote down vote up
private Node transformBlock(AstNode node) {
  Node irNode = transform(node);
  if (irNode.getType() != Token.BLOCK) {
    if (irNode.getType() == Token.EMPTY) {
      irNode.setType(Token.BLOCK);
      irNode.setWasEmptyNode(true);
    } else {
      Node newBlock = newNode(Token.BLOCK, irNode);
      newBlock.setLineno(irNode.getLineno());
      newBlock.setCharno(irNode.getCharno());
      irNode = newBlock;
    }
  }
  return irNode;
}