本文整理汇总了Java中com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle类的典型用法代码示例。如果您正苦于以下问题:Java MinimizationStyle类的具体用法?Java MinimizationStyle怎么用?Java MinimizationStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MinimizationStyle类属于com.google.javascript.jscomp.MinimizedCondition包,在下文中一共展示了MinimizationStyle类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryMinimizeHook
import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //导入依赖的package包/类
/**
* Try flipping HOOKs that have negated conditions.
*
* Returns the replacement for n or the original if no replacement was
* necessary.
*/
private Node tryMinimizeHook(Node n) {
Node originalCond = n.getFirstChild();
MinimizedCondition minCond = MinimizedCondition.fromConditionNode(originalCond);
MeasuredNode mNode =
minCond.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT);
if (mNode.isNot()) {
// Swap the HOOK
Node thenBranch = n.getSecondChild();
replaceNode(originalCond, mNode.withoutNot());
n.removeChild(thenBranch);
n.addChildToBack(thenBranch);
compiler.reportChangeToEnclosingScope(n);
} else {
replaceNode(originalCond, mNode);
}
return n;
}
示例2: tryMinimizeExprResult
import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //导入依赖的package包/类
/**
* Try to remove leading NOTs from EXPR_RESULTS.
*
* Returns the replacement for n or the original if no replacement was
* necessary.
*/
private Node tryMinimizeExprResult(Node n) {
MinimizedCondition minCond =
MinimizedCondition.fromConditionNode(n.getFirstChild());
MinimizedCondition.MeasuredNode mNode =
minCond.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT);
Node placeholder = minCond.getPlaceholder();
if (mNode.getNode().isNot()) {
// Remove the leading NOT in the EXPR_RESULT.
n.replaceChild(placeholder, mNode.getNode().removeFirstChild());
reportCodeChange();
} else {
replaceNode(placeholder, mNode);
}
return n;
}
示例3: tryMinimizeHook
import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //导入依赖的package包/类
/**
* Try flipping HOOKs that have negated conditions.
*
* Returns the replacement for n or the original if no replacement was
* necessary.
*/
private Node tryMinimizeHook(Node n) {
MinimizedCondition minCond =
MinimizedCondition.fromConditionNode(n.getFirstChild());
MinimizedCondition.MeasuredNode mNode =
minCond.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT);
Node placeholder = minCond.getPlaceholder();
if (mNode.getNode().isNot()) {
// Swap the HOOK
Node thenBranch = n.getFirstChild().getNext();
n.replaceChild(placeholder, mNode.getNode().removeFirstChild());
n.removeChild(thenBranch);
n.addChildToBack(thenBranch);
reportCodeChange();
} else {
replaceNode(placeholder, mNode);
}
return n;
}
示例4: minCond
import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //导入依赖的package包/类
private static void minCond(String input, String positive, String negative) {
Node inputNode = parseExpr(input);
MinimizedCondition result = MinimizedCondition.fromConditionNode(inputNode);
Node positiveNode = parseExpr(positive);
Node negativeNode = parseExpr(negative);
// With counting the leading NOT node:
Node positiveResult =
result.getMinimized(MinimizationStyle.PREFER_UNNEGATED).getNode();
// Without counting the leading NOT node:
Node negativeResult =
result.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT).getNode();
if (!positiveResult.isEquivalentTo(positiveNode)) {
fail("Not equal:" +
"\nExpected: " + positive +
"\nBut was : " + (new Compiler()).toSource(positiveResult) +
"\nExpected tree:\n" + positiveNode.toStringTree() +
"\nActual tree:\n" + positiveResult.toStringTree());
}
if (!negativeResult.isEquivalentTo(negativeNode)) {
fail("Not equal:" +
"\nExpected: " + negative +
"\nBut was : " + (new Compiler()).toSource(negativeResult) +
"\nExpected tree:\n" + negativeNode.toStringTree() +
"\nActual tree:\n" + negativeResult.toStringTree());
}
}
示例5: minCond
import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //导入依赖的package包/类
private static void minCond(String input, String positive, String negative) {
Node inputNode = parseExpr(input);
MinimizedCondition result = MinimizedCondition.fromConditionNode(inputNode);
Node positiveNode = parseExpr(positive);
Node negativeNode = parseExpr(negative);
// With counting the leading NOT node:
Node positiveResult =
result.getMinimized(MinimizationStyle.PREFER_UNNEGATED).getNode();
// Without counting the leading NOT node:
Node negativeResult =
result.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT).getNode();
if (!positiveResult.isEquivalentTo(positiveNode)) {
fail("Not equal:\n" + positiveResult.toStringTree()
+ "and:\n" + positiveNode.toStringTree());
}
if (!negativeResult.isEquivalentTo(negativeNode)) {
fail("Not equal:\n" + negativeResult.toStringTree()
+ "and:\n" + negativeNode.toStringTree());
}
}
示例6: tryMinimizeExprResult
import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //导入依赖的package包/类
/**
* Try to remove leading NOTs from EXPR_RESULTS.
*
* Returns the replacement for n or the original if no replacement was
* necessary.
*/
private Node tryMinimizeExprResult(Node n) {
Node originalExpr = n.getFirstChild();
MinimizedCondition minCond = MinimizedCondition.fromConditionNode(originalExpr);
MeasuredNode mNode =
minCond.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT);
if (mNode.isNot()) {
// Remove the leading NOT in the EXPR_RESULT.
replaceNode(originalExpr, mNode.withoutNot());
} else {
replaceNode(originalExpr, mNode);
}
return n;
}
示例7: tryMinimizeCondition
import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //导入依赖的package包/类
/**
* Try to minimize condition expression, as there are additional
* assumptions that can be made when it is known that the final result
* is a boolean.
*
* @return The replacement for n, or the original if no change was made.
*/
private Node tryMinimizeCondition(Node n) {
n = performConditionSubstitutions(n);
MinimizedCondition minCond = MinimizedCondition.fromConditionNode(n);
return replaceNode(
n,
minCond.getMinimized(MinimizationStyle.PREFER_UNNEGATED));
}
示例8: minCond
import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //导入依赖的package包/类
private static void minCond(String input, String positive, String negative) {
Node inputNode = parseExpr(input);
MinimizedCondition result1 = MinimizedCondition.fromConditionNode(cloneAttachedTree(inputNode));
MinimizedCondition result2 = MinimizedCondition.fromConditionNode(cloneAttachedTree(inputNode));
Node positiveNode = parseExpr(positive);
Node negativeNode = parseExpr(negative);
// With counting the leading NOT node:
Node positiveResult =
result1.getMinimized(MinimizationStyle.PREFER_UNNEGATED).buildReplacement();
// Without counting the leading NOT node:
Node negativeResult =
result2.getMinimized(MinimizationStyle.ALLOW_LEADING_NOT).buildReplacement();
if (!positiveResult.isEquivalentTo(positiveNode)) {
fail("Not equal:" +
"\nExpected: " + positive +
"\nBut was : " + (new Compiler()).toSource(positiveResult) +
"\nExpected tree:\n" + positiveNode.toStringTree() +
"\nActual tree:\n" + positiveResult.toStringTree());
}
if (!negativeResult.isEquivalentTo(negativeNode)) {
fail("Not equal:" +
"\nExpected: " + negative +
"\nBut was : " + (new Compiler()).toSource(negativeResult) +
"\nExpected tree:\n" + negativeNode.toStringTree() +
"\nActual tree:\n" + negativeResult.toStringTree());
}
}
示例9: tryMinimizeCondition
import com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle; //导入依赖的package包/类
/**
* Try to minimize condition expression, as there are additional
* assumptions that can be made when it is known that the final result
* is a boolean.
*
* @return The replacement for n, or the original if no change was made.
*/
private Node tryMinimizeCondition(Node n) {
n = performConditionSubstitutions(n);
MinimizedCondition minCond = MinimizedCondition.fromConditionNode(n);
return replaceNode(
minCond.getPlaceholder(),
minCond.getMinimized(MinimizationStyle.PREFER_UNNEGATED));
}