Java Code Examples for com.google.javascript.rhino.Node#putProp()
The following examples show how to use
com.google.javascript.rhino.Node#putProp() .
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_9_ProcessCommonJSModules_t.java From coming with MIT License | 6 votes |
@Override public void visit(NodeTraversal t, Node n, Node parent) { if (n.isName()) { String name = n.getString(); if (suffix.equals(name)) { return; } if (EXPORTS.equals(name)) { n.setString(suffix); n.putProp(Node.ORIGINALNAME_PROP, EXPORTS); } else { Scope.Var var = t.getScope().getVar(name); if (var != null && var.isGlobal()) { n.setString(name + "$$" + suffix); n.putProp(Node.ORIGINALNAME_PROP, name); } } } }
Example 2
Source File: Closure_26_ProcessCommonJSModules_s.java From coming with MIT License | 6 votes |
@Override public void visit(NodeTraversal t, Node n, Node parent) { if (n.isName()) { String name = n.getString(); if (suffix.equals(name)) { return; } if (EXPORTS.equals(name)) { n.setString(suffix); n.putProp(Node.ORIGINALNAME_PROP, EXPORTS); } else { Scope.Var var = t.getScope().getVar(name); if (var != null && var.isGlobal()) { n.setString(name + "$$" + suffix); n.putProp(Node.ORIGINALNAME_PROP, name); } } } }
Example 3
Source File: Closure_26_ProcessCommonJSModules_t.java From coming with MIT License | 5 votes |
/** * Rewrite module.exports to moduleName.module$exports. */ private void visitModuleExports(Node prop) { String moduleName = guessCJSModuleName(prop.getSourceFileName()); Node module = prop.getChildAtIndex(0); module.putProp(Node.ORIGINALNAME_PROP, "module"); module.setString(moduleName); Node exports = prop.getChildAtIndex(1); exports.putProp(Node.ORIGINALNAME_PROP, "exports"); exports.setString("module$exports"); modulesWithExports.add(moduleName); }
Example 4
Source File: SourceInformationAnnotatorTest.java From astor with GNU General Public License v2.0 | 5 votes |
public void testPreserveAnnotatedName() { Node root = new Node(Token.SCRIPT); Node name = Node.newString("foo"); name.putProp(Node.ORIGINALNAME_PROP, "bar"); root.addChildToBack(name); NodeTraversal.traverse(null, root, new SourceInformationAnnotator("", false)); assertEquals(name.getProp(Node.ORIGINALNAME_PROP), "bar"); }
Example 5
Source File: Closure_81_IRFactory_t.java From coming with MIT License | 4 votes |
@Override Node processParenthesizedExpression(ParenthesizedExpression exprNode) { Node node = transform(exprNode.getExpression()); node.putProp(Node.PARENTHESIZED_PROP, Boolean.TRUE); return node; }
Example 6
Source File: 1_JsDocInfoParser.java From SimFix with GNU General Public License v2.0 | 4 votes |
private Node createTemplateNode() { // The Node type choice is arbitrary. Node templateNode = new Node(Token.SCRIPT); templateNode.putProp(Node.SOURCENAME_PROP, sourceName); return templateNode; }
Example 7
Source File: Closure_81_IRFactory_t.java From coming with MIT License | 4 votes |
private Node createTemplateNode() { // The Node type choice is arbitrary. Node templateNode = new Node(Token.SCRIPT); templateNode.putProp(Node.SOURCENAME_PROP, sourceName); return templateNode; }
Example 8
Source File: Closure_84_IRFactory_s.java From coming with MIT License | 4 votes |
private Node createTemplateNode() { // The Node type choice is arbitrary. Node templateNode = new Node(Token.SCRIPT); templateNode.putProp(Node.SOURCENAME_PROP, sourceName); return templateNode; }
Example 9
Source File: Closure_68_JsDocInfoParser_s.java From coming with MIT License | 4 votes |
private Node createTemplateNode() { // The Node type choice is arbitrary. Node templateNode = new Node(Token.SCRIPT); templateNode.putProp(Node.SOURCENAME_PROP, sourceName); return templateNode; }
Example 10
Source File: 1_NodeUtil.java From SimFix with GNU General Public License v2.0 | 3 votes |
/** * Creates a new node representing an *existing* name, copying over the source * location information from the basis node and assigning the given original * name to the node. * * @param name The name for the new NAME node. * @param basisNode The node that represents the name as currently found in * the AST. * @param originalName The original name of the item being represented by the * NAME node. Used for debugging information. * * @return The node created. */ static Node newName( CodingConvention convention, String name, Node basisNode, String originalName) { Node nameNode = newName(convention, name, basisNode); nameNode.putProp(Node.ORIGINALNAME_PROP, originalName); return nameNode; }
Example 11
Source File: Cardumen_0087_s.java From coming with MIT License | 3 votes |
/** * Creates a new node representing an *existing* name, copying over the source * location information from the basis node and assigning the given original * name to the node. * * @param name The name for the new NAME node. * @param basisNode The node that represents the name as currently found in * the AST. * @param originalName The original name of the item being represented by the * NAME node. Used for debugging information. * * @return The node created. */ static Node newName( CodingConvention convention, String name, Node basisNode, String originalName) { Node nameNode = newName(convention, name, basisNode); nameNode.putProp(Node.ORIGINALNAME_PROP, originalName); return nameNode; }
Example 12
Source File: NodeUtil.java From astor with GNU General Public License v2.0 | 3 votes |
/** * Creates a new node representing an *existing* name, copying over the source * location information from the basis node and assigning the given original * name to the node. * * @param name The name for the new NAME node. * @param basisNode The node that represents the name as currently found in * the AST. * @param originalName The original name of the item being represented by the * NAME node. Used for debugging information. * * @return The node created. */ static Node newName( CodingConvention convention, String name, Node basisNode, String originalName) { Node nameNode = newName(convention, name, basisNode); nameNode.putProp(Node.ORIGINALNAME_PROP, originalName); return nameNode; }
Example 13
Source File: Cardumen_00149_s.java From coming with MIT License | 3 votes |
/** * Creates a new node representing an *existing* name, copying over the source * location information from the basis node and assigning the given original * name to the node. * * @param name The name for the new NAME node. * @param basisNode The node that represents the name as currently found in * the AST. * @param originalName The original name of the item being represented by the * NAME node. Used for debugging information. * * @return The node created. */ static Node newName( CodingConvention convention, String name, Node basisNode, String originalName) { Node nameNode = newName(convention, name, basisNode); nameNode.putProp(Node.ORIGINALNAME_PROP, originalName); return nameNode; }
Example 14
Source File: Cardumen_0014_t.java From coming with MIT License | 3 votes |
/** * Creates a new node representing an *existing* name, copying over the source * location information from the basis node and assigning the given original * name to the node. * * @param name The name for the new NAME node. * @param basisNode The node that represents the name as currently found in * the AST. * @param originalName The original name of the item being represented by the * NAME node. Used for debugging information. * * @return The node created. */ static Node newName( CodingConvention convention, String name, Node basisNode, String originalName) { Node nameNode = newName(convention, name, basisNode); nameNode.putProp(Node.ORIGINALNAME_PROP, originalName); return nameNode; }
Example 15
Source File: Closure_10_NodeUtil_t.java From coming with MIT License | 2 votes |
/** * Sets the debug information (source file info and original name) * on the given node. * * @param node The node on which to set the debug information. * @param basisNode The basis node from which to copy the source file info. * @param originalName The original name of the node. */ static void setDebugInformation(Node node, Node basisNode, String originalName) { node.copyInformationFromForTree(basisNode); node.putProp(Node.ORIGINALNAME_PROP, originalName); }
Example 16
Source File: Cardumen_0014_s.java From coming with MIT License | 2 votes |
/** * Sets the debug information (source file info and original name) * on the given node. * * @param node The node on which to set the debug information. * @param basisNode The basis node from which to copy the source file info. * @param originalName The original name of the node. */ static void setDebugInformation(Node node, Node basisNode, String originalName) { node.copyInformationFromForTree(basisNode); node.putProp(Node.ORIGINALNAME_PROP, originalName); }
Example 17
Source File: Closure_86_NodeUtil_s.java From coming with MIT License | 2 votes |
/** * Sets the debug information (source file info and orignal name) * on the given node. * * @param node The node on which to set the debug information. * @param basisNode The basis node from which to copy the source file info. * @param originalName The original name of the node. */ static void setDebugInformation(Node node, Node basisNode, String originalName) { node.copyInformationFromForTree(basisNode); node.putProp(Node.ORIGINALNAME_PROP, originalName); }
Example 18
Source File: Cardumen_00149_s.java From coming with MIT License | 2 votes |
/** * Sets the debug information (source file info and original name) * on the given node. * * @param node The node on which to set the debug information. * @param basisNode The basis node from which to copy the source file info. * @param originalName The original name of the node. */ static void setDebugInformation(Node node, Node basisNode, String originalName) { node.copyInformationFromForTree(basisNode); node.putProp(Node.ORIGINALNAME_PROP, originalName); }
Example 19
Source File: jKali_003_t.java From coming with MIT License | 2 votes |
/** * Sets the debug information (source file info and original name) * on the given node. * * @param node The node on which to set the debug information. * @param basisNode The basis node from which to copy the source file info. * @param originalName The original name of the node. */ static void setDebugInformation(Node node, Node basisNode, String originalName) { node.copyInformationFromForTree(basisNode); node.putProp(Node.ORIGINALNAME_PROP, originalName); }
Example 20
Source File: 1_NodeUtil.java From SimFix with GNU General Public License v2.0 | 2 votes |
/** * Sets the debug information (source file info and orignal name) * on the given node. * * @param node The node on which to set the debug information. * @param basisNode The basis node from which to copy the source file info. * @param originalName The original name of the node. */ static void setDebugInformation(Node node, Node basisNode, String originalName) { node.copyInformationFromForTree(basisNode); node.putProp(Node.ORIGINALNAME_PROP, originalName); }