Package com.google.javascript.jscomp
Class NodeUtil
java.lang.Object
com.google.javascript.jscomp.NodeUtil
NodeUtil contains generally useful AST utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic JSDocInfo
Get the JSDocInfo for a function.static Node
getFunctionParameters
(Node fnNode) static InputId
getInputId
(Node n) static String
Gets the function's name.static StaticSourceFile
static String
static boolean
Determines whether this node is used as an L-value.static TernaryValue
isStrWhiteSpaceChar
(int c) Copied from Rhino's ScriptRuntimestatic boolean
isValidQualifiedName
(String name) Determines whether the given name is a valid qualified name.static Node
newQualifiedNameNode
(CodingConvention convention, String name) Creates a node representing a qualified name.
-
Method Details
-
isStrWhiteSpaceChar
Copied from Rhino's ScriptRuntime -
getNearestFunctionName
Gets the function's name. This method recognizes the forms:{'name': function() ...}
{name: function() ...}
function name() ...
var name = function() ...
qualified.name = function() ...
var name2 = function name1() ...
qualified.name2 = function name1() ...
- Parameters:
n
- a node whose type isToken.FUNCTION
- Returns:
- the function's name, or
null
if it has no name
-
isLValue
Determines whether this node is used as an L-value. Notice that sometimes names are used as both L-values and R-values. 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;".- Parameters:
n
- The node- Returns:
- True if n is an L-value.
-
newQualifiedNameNode
Creates a node representing a qualified name.- Parameters:
name
- A qualified name (e.g. "foo" or "foo.bar.baz")- Returns:
- A NAME or GETPROP node
-
isValidQualifiedName
Determines whether the given name is a valid qualified name. -
getFunctionParameters
- Parameters:
fnNode
- The function.- Returns:
- The Node containing the Function parameters.
-
getFunctionJSDocInfo
Get the JSDocInfo for a function. -
getSourceName
- Parameters:
n
- The node.- Returns:
- The source name property on the node or its ancestors.
-
getSourceFile
- Parameters:
n
- The node.- Returns:
- The source name property on the node or its ancestors.
-
getInputId
- Parameters:
n
- The node.- Returns:
- The InputId property on the node or its ancestors.
-