本文整理汇总了Java中com.google.javascript.rhino.Node.removeChildAfter方法的典型用法代码示例。如果您正苦于以下问题:Java Node.removeChildAfter方法的具体用法?Java Node.removeChildAfter怎么用?Java Node.removeChildAfter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.rhino.Node
的用法示例。
在下文中一共展示了Node.removeChildAfter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: split
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private void split(Node n) {
Node c = n.getFirstChild();
Node before = null;
while (c != null) {
Node next = c.getNext();
if (shouldSplit.apply(c)) {
Node placeHolder = placeHolderProvider.get();
if (before == null) {
forest.add(n.removeFirstChild());
n.addChildToFront(placeHolder);
} else {
n.addChildAfter(placeHolder, c);
n.removeChildAfter(before);
forest.add(c);
}
recordSplitPoint(placeHolder, before, c);
before = placeHolder;
} else {
split(c);
before = c;
}
c = next;
}
}
示例2: moveNamedFunctions
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
* Move all the functions that are valid at the execution of the first
* statement of the function to the beginning of the function definition.
*/
private void moveNamedFunctions(Node functionBody) {
Preconditions.checkState(
functionBody.getParent().getType() == Token.FUNCTION);
Node previous = null;
Node current = functionBody.getFirstChild();
// Skip any declarations at the beginning of the function body, they
// are already in the right place.
while (current != null && NodeUtil.isFunctionDeclaration(current)) {
previous = current;
current = current.getNext();
}
// Find any remaining declarations and move them.
Node insertAfter = previous;
while (current != null) {
// Save off the next node as the current node maybe removed.
Node next = current.getNext();
if (NodeUtil.isFunctionDeclaration(current)) {
// Remove the declaration from the body.
Preconditions.checkNotNull(previous);
functionBody.removeChildAfter(previous);
// Readd the function at the top of the function body (after any
// previous declarations).
insertAfter = addToFront(functionBody, current, insertAfter);
reportCodeChange("Move function declaration not at top of function");
} else {
// Update the previous only if the current node hasn't been moved.
previous = current;
}
current = next;
}
}