Class JavaScriptOutlineTreeGenerator

java.lang.Object
org.fife.rsta.ac.js.tree.JavaScriptOutlineTreeGenerator
All Implemented Interfaces:
org.mozilla.javascript.ast.NodeVisitor

class JavaScriptOutlineTreeGenerator extends Object implements org.mozilla.javascript.ast.NodeVisitor
Generates the root node for a JavaScriptOutlineTree based on a Rhino AST of RSyntaxTextArea code.
Version:
1.0
  • Field Details

  • Constructor Details

    • JavaScriptOutlineTreeGenerator

      JavaScriptOutlineTreeGenerator(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea, org.mozilla.javascript.ast.AstRoot ast)
  • Method Details

    • addPrototypeAdditionsToRoot

      private void addPrototypeAdditionsToRoot()
      While parsing JS code, this class identifies members added to prototypes. After all parsing is done, this method is called to create tree nodes for those prototype members identified.
    • createTreeNode

      private JavaScriptTreeNode createTreeNode(org.mozilla.javascript.ast.AstNode node)
      Creates and returns a node for the outline tree that corresponds to a specific AST node.
      Parameters:
      node - The AST node.
      Returns:
      The outline tree node.
    • createTreeNode

      private JavaScriptTreeNode createTreeNode(List<org.mozilla.javascript.ast.AstNode> nodes)
      Creates and returns a node for the outline tree that corresponds to specific AST nodes.
      Parameters:
      nodes - The AST nodes.
      Returns:
      The outline tree node.
    • getChainedPropertyGetNodes

      private List<org.mozilla.javascript.ast.AstNode> getChainedPropertyGetNodes(org.mozilla.javascript.ast.PropertyGet pg)
    • getChainedPropertyGetNodesImpl

      private void getChainedPropertyGetNodesImpl(org.mozilla.javascript.ast.PropertyGet pg, List<org.mozilla.javascript.ast.AstNode> nodes)
    • getTreeRoot

      public JavaScriptTreeNode getTreeRoot()
    • visit

      public boolean visit(org.mozilla.javascript.ast.AstNode node)
      Specified by:
      visit in interface org.mozilla.javascript.ast.NodeVisitor
    • visitExpressionStatement

      private boolean visitExpressionStatement(org.mozilla.javascript.ast.ExpressionStatement exprStmt)
    • visitPropertyDescriptors

      private void visitPropertyDescriptors(org.mozilla.javascript.ast.ObjectLiteral descriptorObjLit, String clazz)
      It is assumed that descriptorObjectLit has been identified as an object literal containing property descriptors. Any property descriptors found as properties of that literal are parsed and tree nodes are created for them.
      Parameters:
      descriptorObjLit - The object literal containing property descriptors (for example, the object parameter to Object.create()).
      clazz - The class that the properties belong to.
    • visitPropertyDescriptor

      private void visitPropertyDescriptor(JavaScriptTreeNode tn, String clazz, String memberName, org.mozilla.javascript.ast.ObjectLiteral propDesc)
      Parses an AST node that represents a property descriptor.
      Parameters:
      tn - The tree node representing the property defined by the property descriptor. This is configured by this method, and added to the list of nodes to ultimately add to the tree.
      clazz - The class that the property belongs to.
      memberName - The name of the property.
      propDesc - The node representing the property descriptor.
    • visitPrototypeMembers

      private void visitPrototypeMembers(org.mozilla.javascript.ast.ObjectLiteral objLiteral, String clazz)
    • visitPrototypeMember

      private void visitPrototypeMember(JavaScriptTreeNode tn, String clazz, String memberName, org.mozilla.javascript.ast.AstNode memberValue)
      Visits a node representing a member being defined on a prototype.
      Parameters:
      tn - The tree node to extend, representing this member.
      clazz - The class that the property belongs to.
      memberName - The name of the member.
      memberValue - The AST node representing the value of the member.
    • visitFunction

      private boolean visitFunction(org.mozilla.javascript.ast.FunctionNode fn)
      Visits a function AST node. This will create a tree node for the function, and also visit the AST nodes in the function's body, to identify local variables, nested functions, etc.
      Parameters:
      fn - The function node.
      Returns:
      false always, as this method manually visits the function AST node's child nodes.
    • visitVariableDeclaration

      private boolean visitVariableDeclaration(org.mozilla.javascript.ast.VariableDeclaration varDec)
      Visits a variable AST node. This will create a tree node for the variable, and if it also has an initializer, it is parsed.
      Parameters:
      varDec - The variable declaration AST node.
      Returns:
      false always, as this method manually visits the variable AST node's child nodes.