Java Code Examples for com.google.javascript.rhino.Node#srcrefTree()

The following examples show how to use com.google.javascript.rhino.Node#srcrefTree() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Cardumen_00200_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * @return An appropriate AST node for the double value.
 */
static Node numberNode(double value, Node srcref) {
  Node result;
  if (Double.isNaN(value)) {
    result = IR.name("NaN");
  } else if (value == Double.POSITIVE_INFINITY) {
    result = IR.name("Infinity");
  } else if (value == Double.NEGATIVE_INFINITY) {
    result = IR.neg(IR.name("Infinity"));
  } else {
    result = IR.number(value);
  }
  if (srcref != null) {
    result.srcrefTree(srcref);
  }
  return result;
}
 
Example 2
Source File: Cardumen_00200_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * @return An appropriate AST node for the double value.
 */
static Node numberNode(double value, Node srcref) {
  Node result;
  if (Double.isNaN(value)) {
    result = IR.name("NaN");
  } else if (value == Double.POSITIVE_INFINITY) {
    result = IR.name("Infinity");
  } else if (value == Double.NEGATIVE_INFINITY) {
    result = IR.neg(IR.name("Infinity"));
  } else {
    result = IR.number(value);
  }
  if (srcref != null) {
    result.srcrefTree(srcref);
  }
  return result;
}
 
Example 3
Source File: Cardumen_00149_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * @return An appropriate AST node for the double value.
 */
static Node numberNode(double value, Node srcref) {
  Node result;
  if (Double.isNaN(value)) {
    result = IR.name("NaN");
  } else if (value == Double.POSITIVE_INFINITY) {
    result = IR.name("Infinity");
  } else if (value == Double.NEGATIVE_INFINITY) {
    result = IR.neg(IR.name("Infinity"));
  } else {
    result = IR.number(value);
  }
  if (srcref != null) {
    result.srcrefTree(srcref);
  }
  return result;
}
 
Example 4
Source File: Cardumen_00149_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * @return An appropriate AST node for the double value.
 */
static Node numberNode(double value, Node srcref) {
  Node result;
  if (Double.isNaN(value)) {
    result = IR.name("NaN");
  } else if (value == Double.POSITIVE_INFINITY) {
    result = IR.name("Infinity");
  } else if (value == Double.NEGATIVE_INFINITY) {
    result = IR.neg(IR.name("Infinity"));
  } else {
    result = IR.number(value);
  }
  if (srcref != null) {
    result.srcrefTree(srcref);
  }
  return result;
}
 
Example 5
Source File: Cardumen_0014_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * @return An appropriate AST node for the double value.
 */
static Node numberNode(double value, Node srcref) {
  Node result;
  if (Double.isNaN(value)) {
    result = IR.name("NaN");
  } else if (value == Double.POSITIVE_INFINITY) {
    result = IR.name("Infinity");
  } else if (value == Double.NEGATIVE_INFINITY) {
    result = IR.neg(IR.name("Infinity"));
  } else {
    result = IR.number(value);
  }
  if (srcref != null) {
    result.srcrefTree(srcref);
  }
  return result;
}
 
Example 6
Source File: Cardumen_0014_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * @return An appropriate AST node for the double value.
 */
static Node numberNode(double value, Node srcref) {
  Node result;
  if (Double.isNaN(value)) {
    result = IR.name("NaN");
  } else if (value == Double.POSITIVE_INFINITY) {
    result = IR.name("Infinity");
  } else if (value == Double.NEGATIVE_INFINITY) {
    result = IR.neg(IR.name("Infinity"));
  } else {
    result = IR.number(value);
  }
  if (srcref != null) {
    result.srcrefTree(srcref);
  }
  return result;
}
 
Example 7
Source File: Cardumen_0087_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * @return An appropriate AST node for the double value.
 */
static Node numberNode(double value, Node srcref) {
  Node result;
  if (Double.isNaN(value)) {
    result = IR.name("NaN");
  } else if (value == Double.POSITIVE_INFINITY) {
    result = IR.name("Infinity");
  } else if (value == Double.NEGATIVE_INFINITY) {
    result = IR.neg(IR.name("Infinity"));
  } else {
    result = IR.number(value);
  }
  if (srcref != null) {
    result.srcrefTree(srcref);
  }
  return result;
}
 
Example 8
Source File: Cardumen_0087_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * @return An appropriate AST node for the double value.
 */
static Node numberNode(double value, Node srcref) {
  Node result;
  if (Double.isNaN(value)) {
    result = IR.name("NaN");
  } else if (value == Double.POSITIVE_INFINITY) {
    result = IR.name("Infinity");
  } else if (value == Double.NEGATIVE_INFINITY) {
    result = IR.neg(IR.name("Infinity"));
  } else {
    result = IR.number(value);
  }
  if (srcref != null) {
    result.srcrefTree(srcref);
  }
  return result;
}
 
Example 9
Source File: jKali_003_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * @return An appropriate AST node for the double value.
 */
static Node numberNode(double value, Node srcref) {
  Node result;
  if (Double.isNaN(value)) {
    result = IR.name("NaN");
  } else if (value == Double.POSITIVE_INFINITY) {
    result = IR.name("Infinity");
  } else if (value == Double.NEGATIVE_INFINITY) {
    result = IR.neg(IR.name("Infinity"));
  } else {
    result = IR.number(value);
  }
  if (srcref != null) {
    result.srcrefTree(srcref);
  }
  return result;
}
 
Example 10
Source File: jKali_003_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * @return An appropriate AST node for the double value.
 */
static Node numberNode(double value, Node srcref) {
  Node result;
  if (Double.isNaN(value)) {
    result = IR.name("NaN");
  } else if (value == Double.POSITIVE_INFINITY) {
    result = IR.name("Infinity");
  } else if (value == Double.NEGATIVE_INFINITY) {
    result = IR.neg(IR.name("Infinity"));
  } else {
    result = IR.number(value);
  }
  if (srcref != null) {
    result.srcrefTree(srcref);
  }
  return result;
}
 
Example 11
Source File: jMutRepair_003_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * @return An appropriate AST node for the double value.
 */
static Node numberNode(double value, Node srcref) {
  Node result;
  if (Double.isNaN(value)) {
    result = IR.name("NaN");
  } else if (value == Double.POSITIVE_INFINITY) {
    result = IR.name("Infinity");
  } else if (value == Double.NEGATIVE_INFINITY) {
    result = IR.neg(IR.name("Infinity"));
  } else {
    result = IR.number(value);
  }
  if (srcref != null) {
    result.srcrefTree(srcref);
  }
  return result;
}
 
Example 12
Source File: jMutRepair_003_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * @return An appropriate AST node for the double value.
 */
static Node numberNode(double value, Node srcref) {
  Node result;
  if (Double.isNaN(value)) {
    result = IR.name("NaN");
  } else if (value == Double.POSITIVE_INFINITY) {
    result = IR.name("Infinity");
  } else if (value == Double.NEGATIVE_INFINITY) {
    result = IR.neg(IR.name("Infinity"));
  } else {
    result = IR.number(value);
  }
  if (srcref != null) {
    result.srcrefTree(srcref);
  }
  return result;
}
 
Example 13
Source File: Closure_10_NodeUtil_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * @return An appropriate AST node for the double value.
 */
static Node numberNode(double value, Node srcref) {
  Node result;
  if (Double.isNaN(value)) {
    result = IR.name("NaN");
  } else if (value == Double.POSITIVE_INFINITY) {
    result = IR.name("Infinity");
  } else if (value == Double.NEGATIVE_INFINITY) {
    result = IR.neg(IR.name("Infinity"));
  } else {
    result = IR.number(value);
  }
  if (srcref != null) {
    result.srcrefTree(srcref);
  }
  return result;
}
 
Example 14
Source File: Closure_10_NodeUtil_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * @return An appropriate AST node for the double value.
 */
static Node numberNode(double value, Node srcref) {
  Node result;
  if (Double.isNaN(value)) {
    result = IR.name("NaN");
  } else if (value == Double.POSITIVE_INFINITY) {
    result = IR.name("Infinity");
  } else if (value == Double.NEGATIVE_INFINITY) {
    result = IR.neg(IR.name("Infinity"));
  } else {
    result = IR.number(value);
  }
  if (srcref != null) {
    result.srcrefTree(srcref);
  }
  return result;
}
 
Example 15
Source File: NodeUtil.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @return An appropriate AST node for the double value.
 */
static Node numberNode(double value, Node srcref) {
  Node result;
  if (Double.isNaN(value)) {
    result = IR.name("NaN");
  } else if (value == Double.POSITIVE_INFINITY) {
    result = IR.name("Infinity");
  } else if (value == Double.NEGATIVE_INFINITY) {
    result = IR.neg(IR.name("Infinity"));
  } else {
    result = IR.number(value);
  }
  if (srcref != null) {
    result.srcrefTree(srcref);
  }
  return result;
}
 
Example 16
Source File: NodeModulePass.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
private void visitScript(NodeTraversal t, Node script) {
  if (currentModule == null) {
    return;
  }

  // Remove any 'use strict' directives. The compiler adds these by default to
  // closure modules and will generate a warning if specified directly.
  // TODO: remove when https://github.com/google/closure-compiler/issues/1263 is fixed.
  Set<String> directives = script.getDirectives();
  if (directives != null && directives.contains("use strict")) {
    // Directives is likely an immutable collection, so we need to make a copy.
    Set<String> newDirectives = new HashSet<>(directives);
    newDirectives.remove("use strict");
    script.setDirectives(newDirectives);
  }

  processModuleExportRefs(t);

  Node moduleBody = createModuleBody();
  moduleBody.srcrefTree(script);
  if (script.getChildCount() > 0) {
    moduleBody.addChildrenToBack(script.removeChildren());
  }
  script.addChildToBack(moduleBody);
  script.putBooleanProp(Node.GOOG_MODULE, true);

  t.getInput().addProvide(currentModule);

  traverse(t.getCompiler(), script, new TypeCleanup());

  googRequireExpr.clear();
  currentModule = null;

  t.reportCodeChange();
}