public final class NodeUtil extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
NodeUtil.Visitor
Interface for use with the visit method.
|
Modifier and Type | Method and Description |
---|---|
static JSDocInfo |
getBestJSDocInfo(Node n)
Find the best JSDoc for the given node.
|
static JSDocInfo |
getFunctionJSDocInfo(Node n)
Get the JSDocInfo for a function.
|
static Node |
getFunctionParameters(Node fnNode) |
static InputId |
getInputId(Node n) |
static String |
getNearestFunctionName(Node n)
Gets the function's name.
|
static StaticSourceFile |
getSourceFile(Node n) |
static String |
getSourceName(Node n) |
static boolean |
isLValue(Node n)
Determines whether this node is used as an L-value.
|
static TernaryValue |
isStrWhiteSpaceChar(int c)
Copied from Rhino's ScriptRuntime
|
static boolean |
isValidQualifiedName(String name)
Determines whether the given name is a valid qualified name.
|
static Map<Node,Node> |
mapMainToClone(Node main,
Node clone)
Given an AST and its copy, map the root node of each scope of main to the
corresponding root node of clone
|
static Node |
newQName(AbstractCompiler compiler,
String name)
Creates a node representing a qualified name.
|
static Node |
newQNameDeclaration(AbstractCompiler compiler,
String name,
Node value,
JSDocInfo info)
Creates a node representing a qualified name.
|
static void |
verifyScopeChanges(Map<Node,Node> map,
Node main,
boolean verifyUnchangedNodes,
AbstractCompiler compiler)
Checks that the scope roots marked as changed have indeed changed
|
static void |
visitPreOrder(Node node,
NodeUtil.Visitor visitor,
com.google.common.base.Predicate<Node> traverseChildrenPred)
A pre-order traversal, calling Visitor.visit for each child matching
the predicate.
|
public static TernaryValue isStrWhiteSpaceChar(int c)
public static String getNearestFunctionName(Node n)
{'name': function() ...}
{name: function() ...}
function name() ...
var name = function() ...
qualified.name = function() ...
var name2 = function name1() ...
qualified.name2 = function name1() ...
n
- a node whose type is Token.FUNCTION
null
if it has no namepublic static boolean isLValue(Node n)
We treat "var x;" as a pseudo-L-value, which kind of makes sense if you treat it as "assignment to 'undefined' at the top of the scope". But if we're honest with ourselves, it doesn't make sense, and we only do this because it makes sense to treat this as syntactically similar to "var x = 0;".
n
- The nodepublic static Node newQName(AbstractCompiler compiler, String name)
name
- A qualified name (e.g. "foo" or "foo.bar.baz")public static Node newQNameDeclaration(AbstractCompiler compiler, String name, Node value, JSDocInfo info)
name
- A qualified name (e.g. "foo" or "foo.bar.baz")public static boolean isValidQualifiedName(String name)
public static void visitPreOrder(Node node, NodeUtil.Visitor visitor, com.google.common.base.Predicate<Node> traverseChildrenPred)
public static Node getFunctionParameters(Node fnNode)
fnNode
- The function.public static JSDocInfo getFunctionJSDocInfo(Node n)
public static String getSourceName(Node n)
n
- The node.public static StaticSourceFile getSourceFile(Node n)
n
- The node.public static InputId getInputId(Node n)
n
- The node.public static JSDocInfo getBestJSDocInfo(Node n)
public static Map<Node,Node> mapMainToClone(Node main, Node clone)
public static void verifyScopeChanges(Map<Node,Node> map, Node main, boolean verifyUnchangedNodes, AbstractCompiler compiler)
Copyright © 2009-2014 Google. All Rights Reserved.