Java Code Examples for com.google.javascript.rhino.Node#getProp()
The following examples show how to use
com.google.javascript.rhino.Node#getProp() .
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: ExtractPrototypeMemberDeclarations.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Replaces a member declaration to an assignment to the temp prototype * object. */ private void replacePrototypeMemberDeclaration( PrototypeMemberDeclaration declar) { // x.prototype.y = ... -> t.y = ... Node assignment = declar.node.getFirstChild(); Node lhs = assignment.getFirstChild(); Node name = NodeUtil.newQualifiedNameNode( compiler.getCodingConvention(), prototypeAlias + "." + declar.memberName, declar.node, declar.memberName); // Save the full prototype path on the left hand side of the assignment // for debugging purposes. // declar.lhs = x.prototype.y so first child of the first child // is 'x'. Node accessNode = declar.lhs.getFirstChild().getFirstChild(); Object originalName = accessNode.getProp(Node.ORIGINALNAME_PROP); String className = "?"; if (originalName != null) { className = originalName.toString(); } NodeUtil.setDebugInformation(name.getFirstChild(), lhs, className + ".prototype"); assignment.replaceChild(lhs, name); }
Example 2
Source File: Closure_94_NodeUtil_s.java From coming with MIT License | 5 votes |
/** * @param n The node. * @return The source name property on the node or its ancestors. */ static String getSourceName(Node n) { String sourceName = null; while (sourceName == null && n != null) { sourceName = (String) n.getProp(Node.SOURCENAME_PROP); n = n.getParent(); } return sourceName; }
Example 3
Source File: Closure_94_NodeUtil_t.java From coming with MIT License | 5 votes |
/** * @param n The node. * @return The source name property on the node or its ancestors. */ static String getSourceName(Node n) { String sourceName = null; while (sourceName == null && n != null) { sourceName = (String) n.getProp(Node.SOURCENAME_PROP); n = n.getParent(); } return sourceName; }
Example 4
Source File: Closure_95_TypedScopeCreator_t.java From coming with MIT License | 5 votes |
@Override public final boolean shouldTraverse(NodeTraversal nodeTraversal, Node n, Node parent) { if (n.getType() == Token.FUNCTION || n.getType() == Token.SCRIPT) { sourceName = (String) n.getProp(Node.SOURCENAME_PROP); } // We do want to traverse the name of a named function, but we don't // want to traverse the arguments or body. return parent == null || parent.getType() != Token.FUNCTION || n == parent.getFirstChild() || parent == scope.getRootNode(); }
Example 5
Source File: Closure_95_TypedScopeCreator_s.java From coming with MIT License | 5 votes |
@Override public final boolean shouldTraverse(NodeTraversal nodeTraversal, Node n, Node parent) { if (n.getType() == Token.FUNCTION || n.getType() == Token.SCRIPT) { sourceName = (String) n.getProp(Node.SOURCENAME_PROP); } // We do want to traverse the name of a named function, but we don't // want to traverse the arguments or body. return parent == null || parent.getType() != Token.FUNCTION || n == parent.getFirstChild() || parent == scope.getRootNode(); }
Example 6
Source File: Closure_75_NodeUtil_s.java From coming with MIT License | 5 votes |
/** * @param n The node. * @return The source name property on the node or its ancestors. */ static String getSourceName(Node n) { String sourceName = null; while (sourceName == null && n != null) { sourceName = (String) n.getProp(Node.SOURCENAME_PROP); n = n.getParent(); } return sourceName; }
Example 7
Source File: Closure_61_NodeUtil_t.java From coming with MIT License | 5 votes |
/** * @param n The node. * @return The source name property on the node or its ancestors. */ public static String getSourceName(Node n) { String sourceName = null; while (sourceName == null && n != null) { sourceName = (String) n.getProp(Node.SOURCENAME_PROP); n = n.getParent(); } return sourceName; }
Example 8
Source File: SourceMap.java From astor with GNU General Public License v2.0 | 5 votes |
public void addMapping( Node node, FilePosition outputStartPosition, FilePosition outputEndPosition) { String sourceFile = node.getSourceFileName(); // If the node does not have an associated source file or // its line number is -1, then the node does not have sufficient // information for a mapping to be useful. if (sourceFile == null || node.getLineno() < 0) { return; } sourceFile = fixupSourceLocation(sourceFile); String originalName = (String) node.getProp(Node.ORIGINALNAME_PROP); // Strangely, Rhino source lines are one based but columns are // zero based. // We don't change this for the v1 or v2 source maps but for // v3 we make them both 0 based. int lineBaseOffset = 1; if (generator instanceof SourceMapGeneratorV1 || generator instanceof SourceMapGeneratorV2) { lineBaseOffset = 0; } generator.addMapping( sourceFile, originalName, new FilePosition(node.getLineno() - lineBaseOffset, node.getCharno()), outputStartPosition, outputEndPosition); }
Example 9
Source File: Closure_47_SourceMap_t.java From coming with MIT License | 5 votes |
public void addMapping( Node node, FilePosition outputStartPosition, FilePosition outputEndPosition) { String sourceFile = node.getSourceFileName(); // If the node does not have an associated source file or // its line number is -1, then the node does not have sufficient // information for a mapping to be useful. if (sourceFile == null || node.getLineno() < 0) { return; } sourceFile = fixupSourceLocation(sourceFile); String originalName = (String) node.getProp(Node.ORIGINALNAME_PROP); // Strangely, Rhino source lines are one based but columns are // zero based. // We don't change this for the v1 or v2 source maps but for // v3 we make them both 0 based. int lineBaseOffset = 1; if (generator instanceof SourceMapGeneratorV1 || generator instanceof SourceMapGeneratorV2) { lineBaseOffset = 0; } generator.addMapping( sourceFile, originalName, new FilePosition(node.getLineno() - lineBaseOffset, node.getCharno()), outputStartPosition, outputEndPosition); }
Example 10
Source File: Closure_80_NodeUtil_t.java From coming with MIT License | 5 votes |
/** * @param n The node. * @return The source name property on the node or its ancestors. */ static String getSourceName(Node n) { String sourceName = null; while (sourceName == null && n != null) { sourceName = (String) n.getProp(Node.SOURCENAME_PROP); n = n.getParent(); } return sourceName; }
Example 11
Source File: 1_NodeUtil.java From SimFix with GNU General Public License v2.0 | 5 votes |
static String arrayToString(Node literal) { Node first = literal.getFirstChild(); int[] skipIndexes = (int[]) literal.getProp(Node.SKIP_INDEXES_PROP); StringBuilder result = new StringBuilder(); int nextSlot = 0; int nextSkipSlot = 0; for (Node n = first; n != null; n = n.getNext()) { while (skipIndexes != null && nextSkipSlot < skipIndexes.length) { if (nextSlot == skipIndexes[nextSkipSlot]) { result.append(','); nextSlot++; nextSkipSlot++; } else { break; } } String childValue = getArrayElementStringValue(n); if (childValue == null) { return null; } if (n != first) { result.append(','); } result.append(childValue); nextSlot++; } return result.toString(); }
Example 12
Source File: Closure_80_NodeUtil_t.java From coming with MIT License | 5 votes |
static String arrayToString(Node literal) { Node first = literal.getFirstChild(); int[] skipIndexes = (int[]) literal.getProp(Node.SKIP_INDEXES_PROP); StringBuilder result = new StringBuilder(); int nextSlot = 0; int nextSkipSlot = 0; for (Node n = first; n != null; n = n.getNext()) { while (skipIndexes != null && nextSkipSlot < skipIndexes.length) { if (nextSlot == skipIndexes[nextSkipSlot]) { result.append(','); nextSlot++; nextSkipSlot++; } else { break; } } String childValue = getArrayElementStringValue(n); if (childValue == null) { return null; } if (n != first) { result.append(','); } result.append(childValue); nextSlot++; } return result.toString(); }
Example 13
Source File: Closure_80_NodeUtil_s.java From coming with MIT License | 5 votes |
/** * @param n The node. * @return The source name property on the node or its ancestors. */ static String getSourceName(Node n) { String sourceName = null; while (sourceName == null && n != null) { sourceName = (String) n.getProp(Node.SOURCENAME_PROP); n = n.getParent(); } return sourceName; }
Example 14
Source File: Closure_80_NodeUtil_s.java From coming with MIT License | 5 votes |
static String arrayToString(Node literal) { Node first = literal.getFirstChild(); int[] skipIndexes = (int[]) literal.getProp(Node.SKIP_INDEXES_PROP); StringBuilder result = new StringBuilder(); int nextSlot = 0; int nextSkipSlot = 0; for (Node n = first; n != null; n = n.getNext()) { while (skipIndexes != null && nextSkipSlot < skipIndexes.length) { if (nextSlot == skipIndexes[nextSkipSlot]) { result.append(','); nextSlot++; nextSkipSlot++; } else { break; } } String childValue = getArrayElementStringValue(n); if (childValue == null) { return null; } if (n != first) { result.append(','); } result.append(childValue); nextSlot++; } return result.toString(); }
Example 15
Source File: Closure_86_NodeUtil_s.java From coming with MIT License | 5 votes |
/** * @param n The node. * @return The source name property on the node or its ancestors. */ static String getSourceName(Node n) { String sourceName = null; while (sourceName == null && n != null) { sourceName = (String) n.getProp(Node.SOURCENAME_PROP); n = n.getParent(); } return sourceName; }
Example 16
Source File: Closure_86_NodeUtil_t.java From coming with MIT License | 5 votes |
/** * @param n The node. * @return The source name property on the node or its ancestors. */ static String getSourceName(Node n) { String sourceName = null; while (sourceName == null && n != null) { sourceName = (String) n.getProp(Node.SOURCENAME_PROP); n = n.getParent(); } return sourceName; }
Example 17
Source File: Closure_75_NodeUtil_t.java From coming with MIT License | 5 votes |
/** * @param n The node. * @return The source name property on the node or its ancestors. */ static String getSourceName(Node n) { String sourceName = null; while (sourceName == null && n != null) { sourceName = (String) n.getProp(Node.SOURCENAME_PROP); n = n.getParent(); } return sourceName; }
Example 18
Source File: 1_NodeUtil.java From SimFix with GNU General Public License v2.0 | 5 votes |
/** * @param n The node. * @return The source name property on the node or its ancestors. */ static String getSourceName(Node n) { String sourceName = null; while (sourceName == null && n != null) { sourceName = (String) n.getProp(Node.SOURCENAME_PROP); n = n.getParent(); } return sourceName; }
Example 19
Source File: Closure_80_NodeUtil_s.java From coming with MIT License | 4 votes |
/** * Is this an sparse ARRAYLIT node */ static boolean isSparseArray(Node node) { Preconditions.checkArgument(isArrayLiteral(node)); int[] skipList = (int[]) node.getProp(Node.SKIP_INDEXES_PROP); return skipList != null && skipList.length > 0; }
Example 20
Source File: 1_NodeUtil.java From SimFix with GNU General Public License v2.0 | 4 votes |
/** * Is this an sparse ARRAYLIT node */ static boolean isSparseArray(Node node) { Preconditions.checkArgument(isArrayLiteral(node)); int[] skipList = (int[]) node.getProp(Node.SKIP_INDEXES_PROP); return skipList != null && skipList.length > 0; }