当前位置: 首页>>代码示例>>Java>>正文


Java MinimizationStyle类代码示例

本文整理汇总了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;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:24,代码来源:PeepholeMinimizeConditions.java

示例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;
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:22,代码来源:PeepholeMinimizeConditions.java

示例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;
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:25,代码来源:PeepholeMinimizeConditions.java

示例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());
  }
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:27,代码来源:MinimizedConditionTest.java

示例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());
  }
}
 
开发者ID:Robbert,项目名称:closure-compiler-copy,代码行数:21,代码来源:MinimizedConditionTest.java

示例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;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:20,代码来源:PeepholeMinimizeConditions.java

示例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));
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:15,代码来源:PeepholeMinimizeConditions.java

示例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());
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:28,代码来源:MinimizedConditionTest.java

示例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));
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:15,代码来源:PeepholeMinimizeConditions.java


注:本文中的com.google.javascript.jscomp.MinimizedCondition.MinimizationStyle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。