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

The following examples show how to use com.google.javascript.rhino.Node#srcref() . 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: RescopeGlobalSymbols.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
private void replaceSymbol(Node node, String name) {
  Node parent = node.getParent();
  Node replacement = IR.getprop(
      IR.name(globalSymbolNamespace).srcref(node),
      IR.string(name).srcref(node));
  replacement.srcref(node);
  if (node.hasChildren()) {
    // var declaration list: var a = 1, b = 2;
    Node assign = IR.assign(replacement,
        node.removeFirstChild());
    parent.replaceChild(node, assign);
  } else {
    parent.replaceChild(node, replacement);
  }
  compiler.reportCodeChange();
}
 
Example 2
Source File: Cardumen_00200_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Create a VAR node containing the given name and initial value expression.
 */
static Node newVarNode(String name, Node value) {
  Node nodeName = IR.name(name);
  if (value != null) {
    Preconditions.checkState(value.getNext() == null);
    nodeName.addChildToBack(value);
    nodeName.srcref(value);
  }
  Node var = IR.var(nodeName).srcref(nodeName);

  return var;
}
 
Example 3
Source File: NodeUtil.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a VAR node containing the given name and initial value expression.
 */
static Node newVarNode(String name, Node value) {
  Node nodeName = IR.name(name);
  if (value != null) {
    Preconditions.checkState(value.getNext() == null);
    nodeName.addChildToBack(value);
    nodeName.srcref(value);
  }
  Node var = IR.var(nodeName).srcref(nodeName);

  return var;
}
 
Example 4
Source File: Closure_10_NodeUtil_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Create a VAR node containing the given name and initial value expression.
 */
static Node newVarNode(String name, Node value) {
  Node nodeName = IR.name(name);
  if (value != null) {
    Preconditions.checkState(value.getNext() == null);
    nodeName.addChildToBack(value);
    nodeName.srcref(value);
  }
  Node var = IR.var(nodeName).srcref(nodeName);

  return var;
}
 
Example 5
Source File: Closure_10_NodeUtil_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Create a VAR node containing the given name and initial value expression.
 */
static Node newVarNode(String name, Node value) {
  Node nodeName = IR.name(name);
  if (value != null) {
    Preconditions.checkState(value.getNext() == null);
    nodeName.addChildToBack(value);
    nodeName.srcref(value);
  }
  Node var = IR.var(nodeName).srcref(nodeName);

  return var;
}
 
Example 6
Source File: jMutRepair_003_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Create a VAR node containing the given name and initial value expression.
 */
static Node newVarNode(String name, Node value) {
  Node nodeName = IR.name(name);
  if (value != null) {
    Preconditions.checkState(value.getNext() == null);
    nodeName.addChildToBack(value);
    nodeName.srcref(value);
  }
  Node var = IR.var(nodeName).srcref(nodeName);

  return var;
}
 
Example 7
Source File: jMutRepair_003_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Create a VAR node containing the given name and initial value expression.
 */
static Node newVarNode(String name, Node value) {
  Node nodeName = IR.name(name);
  if (value != null) {
    Preconditions.checkState(value.getNext() == null);
    nodeName.addChildToBack(value);
    nodeName.srcref(value);
  }
  Node var = IR.var(nodeName).srcref(nodeName);

  return var;
}
 
Example 8
Source File: jKali_003_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Create a VAR node containing the given name and initial value expression.
 */
static Node newVarNode(String name, Node value) {
  Node nodeName = IR.name(name);
  if (value != null) {
    Preconditions.checkState(value.getNext() == null);
    nodeName.addChildToBack(value);
    nodeName.srcref(value);
  }
  Node var = IR.var(nodeName).srcref(nodeName);

  return var;
}
 
Example 9
Source File: jKali_003_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Create a VAR node containing the given name and initial value expression.
 */
static Node newVarNode(String name, Node value) {
  Node nodeName = IR.name(name);
  if (value != null) {
    Preconditions.checkState(value.getNext() == null);
    nodeName.addChildToBack(value);
    nodeName.srcref(value);
  }
  Node var = IR.var(nodeName).srcref(nodeName);

  return var;
}
 
Example 10
Source File: Cardumen_0087_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Create a VAR node containing the given name and initial value expression.
 */
static Node newVarNode(String name, Node value) {
  Node nodeName = IR.name(name);
  if (value != null) {
    Preconditions.checkState(value.getNext() == null);
    nodeName.addChildToBack(value);
    nodeName.srcref(value);
  }
  Node var = IR.var(nodeName).srcref(nodeName);

  return var;
}
 
Example 11
Source File: Cardumen_0087_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Create a VAR node containing the given name and initial value expression.
 */
static Node newVarNode(String name, Node value) {
  Node nodeName = IR.name(name);
  if (value != null) {
    Preconditions.checkState(value.getNext() == null);
    nodeName.addChildToBack(value);
    nodeName.srcref(value);
  }
  Node var = IR.var(nodeName).srcref(nodeName);

  return var;
}
 
Example 12
Source File: Cardumen_0014_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Create a VAR node containing the given name and initial value expression.
 */
static Node newVarNode(String name, Node value) {
  Node nodeName = IR.name(name);
  if (value != null) {
    Preconditions.checkState(value.getNext() == null);
    nodeName.addChildToBack(value);
    nodeName.srcref(value);
  }
  Node var = IR.var(nodeName).srcref(nodeName);

  return var;
}
 
Example 13
Source File: Cardumen_0014_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Create a VAR node containing the given name and initial value expression.
 */
static Node newVarNode(String name, Node value) {
  Node nodeName = IR.name(name);
  if (value != null) {
    Preconditions.checkState(value.getNext() == null);
    nodeName.addChildToBack(value);
    nodeName.srcref(value);
  }
  Node var = IR.var(nodeName).srcref(nodeName);

  return var;
}
 
Example 14
Source File: Cardumen_00149_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Create a VAR node containing the given name and initial value expression.
 */
static Node newVarNode(String name, Node value) {
  Node nodeName = IR.name(name);
  if (value != null) {
    Preconditions.checkState(value.getNext() == null);
    nodeName.addChildToBack(value);
    nodeName.srcref(value);
  }
  Node var = IR.var(nodeName).srcref(nodeName);

  return var;
}
 
Example 15
Source File: Cardumen_00149_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Create a VAR node containing the given name and initial value expression.
 */
static Node newVarNode(String name, Node value) {
  Node nodeName = IR.name(name);
  if (value != null) {
    Preconditions.checkState(value.getNext() == null);
    nodeName.addChildToBack(value);
    nodeName.srcref(value);
  }
  Node var = IR.var(nodeName).srcref(nodeName);

  return var;
}
 
Example 16
Source File: Cardumen_00200_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Create a VAR node containing the given name and initial value expression.
 */
static Node newVarNode(String name, Node value) {
  Node nodeName = IR.name(name);
  if (value != null) {
    Preconditions.checkState(value.getNext() == null);
    nodeName.addChildToBack(value);
    nodeName.srcref(value);
  }
  Node var = IR.var(nodeName).srcref(nodeName);

  return var;
}
 
Example 17
Source File: ClosureRewriteClass.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private Node fixupSrcref(Node node) {
  node.srcref(node.getFirstChild());
  return node;
}