本文整理汇总了Java中com.google.javascript.rhino.Node.isEquivalentTo方法的典型用法代码示例。如果您正苦于以下问题:Java Node.isEquivalentTo方法的具体用法?Java Node.isEquivalentTo怎么用?Java Node.isEquivalentTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.rhino.Node
的用法示例。
在下文中一共展示了Node.isEquivalentTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkNodesMatch
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
* Check that the two nodes have the same relative position in the tree.
*/
private boolean checkNodesMatch(Node nodeA, Node nodeB) {
Node currentA = nodeA;
Node currentB = nodeB;
while (currentA != null && currentB != null) {
if (currentA.getType() != currentB.getType() ||
!currentA.isEquivalentTo(currentB)) {
return false;
}
currentA = currentA.getParent();
currentB = currentB.getParent();
}
return currentA == null && currentB == null;
}
示例2: overrideDefines
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private void overrideDefines(Map<String, DefineInfo> allDefines) {
boolean changed = false;
for (Map.Entry<String, DefineInfo> def : allDefines.entrySet()) {
String defineName = def.getKey();
DefineInfo info = def.getValue();
Node inputValue = dominantReplacements.get(defineName);
Node finalValue = inputValue != null ?
inputValue : info.getLastValue();
if (finalValue != info.initialValue) {
info.initialValueParent.replaceChild(
info.initialValue, finalValue.cloneTree());
compiler.addToDebugLog("Overriding @define variable " + defineName);
changed = changed ||
finalValue.getType() != info.initialValue.getType() ||
!finalValue.isEquivalentTo(info.initialValue);
}
}
if (changed) {
compiler.reportCodeChange();
}
Set<String> unusedReplacements = dominantReplacements.keySet();
unusedReplacements.removeAll(allDefines.keySet());
unusedReplacements.removeAll(KNOWN_DEFINES);
for (String unknownDefine : unusedReplacements) {
compiler.report(JSError.make(UNKNOWN_DEFINE_WARNING, unknownDefine));
}
}
示例3: maybeReplaceChildWithNumber
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
* Replaces a node with a number node if the new number node is not equivalent
* to the current node.
*/
private void maybeReplaceChildWithNumber(NodeTraversal t, Node n, Node parent,
int num) {
Node newNode = Node.newNumber(num);
if(!newNode.isEquivalentTo(n)) {
parent.replaceChild(n, newNode);
t.getCompiler().reportCodeChange();
}
}