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

The following examples show how to use com.google.javascript.rhino.Node#removeProp() . 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: Closure_49_MakeDeclaredNamesUnique_t.java    From coming with MIT License 5 votes vote down vote up
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
  switch (n.getType()) {
    case Token.NAME:
      String newName = getReplacementName(n.getString());
      if (newName != null) {
        Renamer renamer = nameStack.peek();
        if (renamer.stripConstIfReplaced()) {
          // TODO(johnlenz): Do we need to do anything about the javadoc?
          n.removeProp(Node.IS_CONSTANT_NAME);
        }
        n.setString(newName);
        t.getCompiler().reportCodeChange();
      }
      break;

    case Token.FUNCTION:
      // Remove the function body scope
      nameStack.pop();
      // Remove function recursive name (if any).
      nameStack.pop();
      break;

    case Token.LP:
      // Note: The parameters and function body variables live in the
      // same scope, we introduce the scope when in the "shouldTraverse"
      // visit of LP, but remove it when when we exit the function above.
      break;

    case Token.CATCH:
      // Remove catch except name from the stack of names.
      nameStack.pop();
      break;
  }
}
 
Example 2
Source File: Closure_49_MakeDeclaredNamesUnique_s.java    From coming with MIT License 5 votes vote down vote up
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
  switch (n.getType()) {
    case Token.NAME:
      String newName = getReplacementName(n.getString());
      if (newName != null) {
        Renamer renamer = nameStack.peek();
        if (renamer.stripConstIfReplaced()) {
          // TODO(johnlenz): Do we need to do anything about the javadoc?
          n.removeProp(Node.IS_CONSTANT_NAME);
        }
        n.setString(newName);
        t.getCompiler().reportCodeChange();
      }
      break;

    case Token.FUNCTION:
      // Remove the function body scope
      // Remove function recursive name (if any).
      nameStack.pop();
      break;

      // Note: The parameters and function body variables live in the
      // same scope, we introduce the scope when in the "shouldTraverse"
      // visit of LP, but remove it when when we exit the function above.

    case Token.CATCH:
      // Remove catch except name from the stack of names.
      nameStack.pop();
      break;
  }
}
 
Example 3
Source File: MakeDeclaredNamesUnique.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
  switch (n.getType()) {
    case Token.NAME:
      String newName = getReplacementName(n.getString());
      if (newName != null) {
        Renamer renamer = nameStack.peek();
        if (renamer.stripConstIfReplaced()) {
          // TODO(johnlenz): Do we need to do anything about the Javadoc?
          n.removeProp(Node.IS_CONSTANT_NAME);
        }
        n.setString(newName);
        t.getCompiler().reportCodeChange();
      }
      break;

    case Token.FUNCTION:
      // Remove the function body scope
      nameStack.pop();
      // Remove function recursive name (if any).
      nameStack.pop();
      break;

    case Token.PARAM_LIST:
      // Note: The parameters and function body variables live in the
      // same scope, we introduce the scope when in the "shouldTraverse"
      // visit of LP, but remove it when when we exit the function above.
      break;

    case Token.CATCH:
      // Remove catch except name from the stack of names.
      nameStack.pop();
      break;
  }
}
 
Example 4
Source File: Denormalize.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visit(NodeTraversal t, Node node, Node parent) {
  if (node.isName() || node.isString() || node.isStringKey()) {
    node.removeProp(Node.IS_CONSTANT_NAME);
  }
}