Class RhinoUtil

java.lang.Object
org.fife.rsta.ac.js.util.RhinoUtil

public class RhinoUtil extends Object
Utility methods for walking ASTs from Rhino.
Version:
1.0
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Private constructor to prevent instantiation.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getFunctionArgsString(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 String
    getPropertyName(org.mozilla.javascript.ast.AstNode propKeyNode)
    Property keys in object literals can be identifiers or string literals.
    static String
    getPrototypeClazz(List<org.mozilla.javascript.ast.AstNode> nodes)
     
    static String
    getPrototypeClazz(List<org.mozilla.javascript.ast.AstNode> nodes, int depth)
     
    private static boolean
    isName(org.mozilla.javascript.ast.AstNode node, String value)
    Returns whether an AST node is a Name with the specified value.
    static boolean
    isPrototypeNameNode(org.mozilla.javascript.ast.AstNode node)
     
    static boolean
    isPrototypePropertyGet(org.mozilla.javascript.ast.PropertyGet pg)
     
    static boolean
    isSimplePropertyGet(org.mozilla.javascript.ast.PropertyGet pg, String expectedObj, String expectedField)
    Returns whether a PropertyGet is 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)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RhinoUtil

      private RhinoUtil()
      Private constructor to prevent instantiation.
  • Method Details

    • getFunctionArgsString

      public static String getFunctionArgsString(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.
      Parameters:
      fn - The function node.
      Returns:
      The string representation of the function's arguments.
    • getPropertyName

      public static String getPropertyName(org.mozilla.javascript.ast.AstNode propKeyNode)
      Property keys in object literals can be identifiers or string literals. This method takes an AST node that was the key of an ObjectProperty and 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

      public static String getPrototypeClazz(List<org.mozilla.javascript.ast.AstNode> nodes)
    • getPrototypeClazz

      public static String getPrototypeClazz(List<org.mozilla.javascript.ast.AstNode> nodes, int depth)
    • isName

      private static boolean isName(org.mozilla.javascript.ast.AstNode node, String value)
      Returns whether an AST node is a Name with the specified value.
      Parameters:
      node - The AST node.
      value - The expected value.
      Returns:
      Whether the AST node is a Name with 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 a PropertyGet is a simple one, referencing an object's value 1 level deep. For example, Object.create.
      Parameters:
      pg - The PropertyGet.
      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)