本文整理汇总了Java中com.google.javascript.rhino.Node.isSyntheticBlock方法的典型用法代码示例。如果您正苦于以下问题:Java Node.isSyntheticBlock方法的具体用法?Java Node.isSyntheticBlock怎么用?Java Node.isSyntheticBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.rhino.Node
的用法示例。
在下文中一共展示了Node.isSyntheticBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryFoldBlock
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
* Try removing unneeded block nodes and their useless children
*/
void tryFoldBlock(NodeTraversal t, Node n, Node parent) {
// Remove any useless children
for (Node c = n.getFirstChild(); c != null; ) {
Node next = c.getNext(); // save c.next, since 'c' may be removed
if (!NodeUtil.mayHaveSideEffects(c)) {
n.removeChild(c); // lazy kids
t.getCompiler().reportCodeChange();
}
c = next;
}
if (n.isSyntheticBlock() || parent == null) {
return;
}
// Try to remove the block.
if (NodeUtil.tryMergeBlock(n)) {
t.getCompiler().reportCodeChange();
}
}
示例2: handleStmtList
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private void handleStmtList(Node node) {
Node parent = node.getParent();
// Special case, don't add a block of empty CATCH block to the graph.
if (node.getType() == Token.BLOCK && parent != null &&
parent.getType() == Token.TRY &&
NodeUtil.getCatchBlock(parent) == node &&
!NodeUtil.hasCatchHandler(node)) {
return;
}
// A block transfer control to its first child if it is not empty.
Node child = node.getFirstChild();
// Function declarations are skipped since control doesn't go into that
// function (unless it is called)
while (child != null && child.getType() == Token.FUNCTION) {
child = child.getNext();
}
if (child != null) {
createEdge(node, Branch.UNCOND, computeFallThrough(child));
} else {
createEdge(node, Branch.UNCOND, computeFollowNode(node));
}
// Synthetic blocks
if (parent != null) {
switch (parent.getType()) {
case Token.DEFAULT:
case Token.CASE:
case Token.TRY:
break;
default:
if (node.getType() == Token.BLOCK && node.isSyntheticBlock()) {
Node next = node.getLastChild();
if (next != null) {
createEdge(node, Branch.SYN_BLOCK, computeFallThrough(next));
}
}
break;
}
}
}