Package com.google.javascript.jscomp
Class NodeUtil
- java.lang.Object
-
- com.google.javascript.jscomp.NodeUtil
-
public final class NodeUtil extends java.lang.ObjectNodeUtil contains generally useful AST utilities.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static JSDocInfogetFunctionJSDocInfo(Node n)Get the JSDocInfo for a function.static NodegetFunctionParameters(Node fnNode)static InputIdgetInputId(Node n)static java.lang.StringgetNearestFunctionName(Node n)Gets the function's name.static StaticSourceFilegetSourceFile(Node n)static java.lang.StringgetSourceName(Node n)static booleanisLValue(Node n)Determines whether this node is used as an L-value.static TernaryValueisStrWhiteSpaceChar(int c)Copied from Rhino's ScriptRuntimestatic booleanisValidQualifiedName(java.lang.String name)Determines whether the given name is a valid qualified name.static NodenewQualifiedNameNode(CodingConvention convention, java.lang.String name)Creates a node representing a qualified name.
-
-
-
Method Detail
-
isStrWhiteSpaceChar
public static TernaryValue isStrWhiteSpaceChar(int c)
Copied from Rhino's ScriptRuntime
-
getNearestFunctionName
public static java.lang.String getNearestFunctionName(Node n)
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
nullif it has no name
-
isLValue
public static boolean isLValue(Node n)
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
public static Node newQualifiedNameNode(CodingConvention convention, java.lang.String name)
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
public static boolean isValidQualifiedName(java.lang.String name)
Determines whether the given name is a valid qualified name.
-
getFunctionParameters
public static Node getFunctionParameters(Node fnNode)
- Parameters:
fnNode- The function.- Returns:
- The Node containing the Function parameters.
-
getFunctionJSDocInfo
public static JSDocInfo getFunctionJSDocInfo(Node n)
Get the JSDocInfo for a function.
-
getSourceName
public static java.lang.String getSourceName(Node n)
- Parameters:
n- The node.- Returns:
- The source name property on the node or its ancestors.
-
getSourceFile
public static StaticSourceFile getSourceFile(Node n)
- Parameters:
n- The node.- Returns:
- The source name property on the node or its ancestors.
-
-