Package org.fife.rsta.ac.js.util
Class RhinoUtil
java.lang.Object
org.fife.rsta.ac.js.util.RhinoUtil
Utility methods for walking ASTs from Rhino.
- Version:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetFunctionArgsString(org.mozilla.javascript.ast.FunctionNode fn) Iterates through a function's parameters and returns a string representation of them, suitable for presentation as part of the method's signature.static StringgetPropertyName(org.mozilla.javascript.ast.AstNode propKeyNode) Property keys in object literals can be identifiers or string literals.static StringgetPrototypeClazz(List<org.mozilla.javascript.ast.AstNode> nodes) static StringgetPrototypeClazz(List<org.mozilla.javascript.ast.AstNode> nodes, int depth) private static booleanReturns whether an AST node is aNamewith the specified value.static booleanisPrototypeNameNode(org.mozilla.javascript.ast.AstNode node) static booleanisPrototypePropertyGet(org.mozilla.javascript.ast.PropertyGet pg) static booleanisSimplePropertyGet(org.mozilla.javascript.ast.PropertyGet pg, String expectedObj, String expectedField) Returns whether aPropertyGetis a simple one, referencing an object's value 1 level deep.static List<org.mozilla.javascript.ast.AstNode> toList(org.mozilla.javascript.ast.AstNode... nodes)
-
Constructor Details
-
RhinoUtil
private RhinoUtil()Private constructor to prevent instantiation.
-
-
Method Details
-
getFunctionArgsString
Iterates through a function's parameters and returns a string representation of them, suitable for presentation as part of the method's signature.- Parameters:
fn- The function node.- Returns:
- The string representation of the function's arguments.
-
getPropertyName
Property keys in object literals can be identifiers or string literals. This method takes an AST node that was the key of anObjectPropertyand returns its value, no matter what the concrete AST node's type.- Parameters:
propKeyNode- The AST node for the property key.- Returns:
- The property key's value.
-
getPrototypeClazz
-
getPrototypeClazz
-
isName
Returns whether an AST node is aNamewith the specified value.- Parameters:
node- The AST node.value- The expected value.- Returns:
- Whether the AST node is a
Namewith the specified value.
-
isPrototypeNameNode
public static boolean isPrototypeNameNode(org.mozilla.javascript.ast.AstNode node) -
isPrototypePropertyGet
public static boolean isPrototypePropertyGet(org.mozilla.javascript.ast.PropertyGet pg) -
isSimplePropertyGet
public static boolean isSimplePropertyGet(org.mozilla.javascript.ast.PropertyGet pg, String expectedObj, String expectedField) Returns whether aPropertyGetis a simple one, referencing an object's value 1 level deep. For example,Object.create.- Parameters:
pg- ThePropertyGet.expectedObj- The expected object value.expectedField- The expected string value.- Returns:
- Whether the object is what was expected.
-
toList
public static List<org.mozilla.javascript.ast.AstNode> toList(org.mozilla.javascript.ast.AstNode... nodes)
-