Class JavaScriptAstParser

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void addCodeBlock​(org.mozilla.javascript.Node parent, java.util.Set<org.fife.ui.autocomplete.Completion> set, java.lang.String entered, CodeBlock codeBlock, int offset)
      for each child of parent AstNode add a new code block and add completions for each block of code
      private void addVariableToResolver​(org.mozilla.javascript.ast.AstNode name, org.mozilla.javascript.ast.AstNode target, CodeBlock block, int offset)  
      private boolean canAddVariable​(CodeBlock block)  
      private boolean canProcessNode​(org.mozilla.javascript.ast.AstNode node)  
      CodeBlock convertAstNodeToCodeBlock​(org.mozilla.javascript.ast.AstRoot root, java.util.Set<org.fife.ui.autocomplete.Completion> set, java.lang.String entered)
      Converts AstRoot to CodeBlock
      private JavaScriptFunctionDeclaration createJavaScriptFunction​(java.lang.String lookupName, int offset, CodeBlock block, TypeDeclaration returnType, org.mozilla.javascript.ast.FunctionNode fn)  
      private void extractVariableForForEach​(org.mozilla.javascript.ast.VariableInitializer initializer, CodeBlock block, int offset, org.mozilla.javascript.ast.AstNode iteratedObject)
      Extract variable for each in loop.
      private void extractVariableForForIn​(org.mozilla.javascript.ast.VariableInitializer initializer, CodeBlock block, int offset, org.mozilla.javascript.ast.AstNode iteratedObject)
      Extract variable for in loop.
      private JavaScriptVariableDeclaration extractVariableFromNode​(org.mozilla.javascript.ast.AstNode node, CodeBlock block, int offset)
      Extract the variable from the Rhino node and add to the CodeBlock
      private JavaScriptVariableDeclaration extractVariableFromNode​(org.mozilla.javascript.ast.AstNode node, CodeBlock block, int offset, org.mozilla.javascript.ast.AstNode initializer)
      Extract the variable from the Rhino node and add to the CodeBlock
      private void extractVariableFromNode​(org.mozilla.javascript.ast.VariableInitializer initializer, CodeBlock block, int offset)
      Extract the variable from the Variable initializer and set the Type
      int getDot()  
      private TypeDeclaration getFunctionType​(org.mozilla.javascript.ast.FunctionNode fn)  
      SourceCompletionProvider getProvider()  
      protected void iterateNode​(org.mozilla.javascript.ast.AstNode child, java.util.Set<org.fife.ui.autocomplete.Completion> set, java.lang.String entered, CodeBlock block, int offset)  
      private void processCaseNode​(org.mozilla.javascript.Node child, CodeBlock block, java.util.Set<org.fife.ui.autocomplete.Completion> set, java.lang.String entered, int offset)  
      private void processDoNode​(org.mozilla.javascript.Node child, CodeBlock block, java.util.Set<org.fife.ui.autocomplete.Completion> set, java.lang.String entered, int offset)
      Extract while loop from node and add new code block
      private void processExpressionNode​(org.mozilla.javascript.Node child, CodeBlock block, java.util.Set<org.fife.ui.autocomplete.Completion> set, java.lang.String entered, int offset)
      Extract completions from expression node
      private void processExpressionStatement​(org.mozilla.javascript.Node child, CodeBlock block, java.util.Set<org.fife.ui.autocomplete.Completion> set, java.lang.String entered, int offset)  
      private void processForNode​(org.mozilla.javascript.Node child, CodeBlock block, java.util.Set<org.fife.ui.autocomplete.Completion> set, java.lang.String entered, int offset)
      Extract code from Token.FOR and add completions, then parse body of for-loop.
      private void processFunctionNode​(org.mozilla.javascript.Node child, CodeBlock block, java.util.Set<org.fife.ui.autocomplete.Completion> set, java.lang.String entered, int offset)
      Add function to completions set and extract local variables to add to code block TODO: functions can have local scope, so add function to it's own codeblock when applicable
      private void processIfThenElse​(org.mozilla.javascript.Node child, CodeBlock block, java.util.Set<org.fife.ui.autocomplete.Completion> set, java.lang.String entered, int offset)
      Extract variables from if/else node(s)
      private void processInfix​(org.mozilla.javascript.Node child, CodeBlock block, java.util.Set<org.fife.ui.autocomplete.Completion> set, java.lang.String entered, int offset)
      Extract variable from binary operator e.g.
      private void processSwitchNode​(org.mozilla.javascript.Node child, CodeBlock block, java.util.Set<org.fife.ui.autocomplete.Completion> set, java.lang.String entered, int offset)
      Extract local variables from switch node*
      private void processTryCatchNode​(org.mozilla.javascript.Node child, CodeBlock block, java.util.Set<org.fife.ui.autocomplete.Completion> set, java.lang.String entered, int offset)
      Extract variables from try/catch node(s)
      private void processVariableNode​(org.mozilla.javascript.Node child, CodeBlock block, java.util.Set<org.fife.ui.autocomplete.Completion> set, java.lang.String entered, int offset)
      Extract variable from node and add to code block
      private void processWhileNode​(org.mozilla.javascript.Node child, CodeBlock block, java.util.Set<org.fife.ui.autocomplete.Completion> set, java.lang.String entered, int offset)
      Extract while loop from node and add new code block
      private void reassignVariable​(org.mozilla.javascript.ast.AstNode assign, CodeBlock block, int locationOffSet)  
      private void setFunctionValues()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • convertAstNodeToCodeBlock

        public CodeBlock convertAstNodeToCodeBlock​(org.mozilla.javascript.ast.AstRoot root,
                                                   java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                                   java.lang.String entered)
        Description copied from class: JavaScriptParser
        Converts AstRoot to CodeBlock
        Specified by:
        convertAstNodeToCodeBlock in class JavaScriptParser
        Parameters:
        root - AstRoot to iterate
        set - completions set
        entered - text entered by user
        Returns:
        CodeBlock tree
      • setFunctionValues

        private void setFunctionValues()
      • addCodeBlock

        private void addCodeBlock​(org.mozilla.javascript.Node parent,
                                  java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                  java.lang.String entered,
                                  CodeBlock codeBlock,
                                  int offset)
        for each child of parent AstNode add a new code block and add completions for each block of code
        Parameters:
        parent - AstNode to iterate children
        set - completions set to add to
        entered - Text entered
        codeBlock - parent CodeBlock
        offset - codeblock offset
      • iterateNode

        protected void iterateNode​(org.mozilla.javascript.ast.AstNode child,
                                   java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                   java.lang.String entered,
                                   CodeBlock block,
                                   int offset)
      • processExpressionStatement

        private void processExpressionStatement​(org.mozilla.javascript.Node child,
                                                CodeBlock block,
                                                java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                                java.lang.String entered,
                                                int offset)
      • reassignVariable

        private void reassignVariable​(org.mozilla.javascript.ast.AstNode assign,
                                      CodeBlock block,
                                      int locationOffSet)
      • addVariableToResolver

        private void addVariableToResolver​(org.mozilla.javascript.ast.AstNode name,
                                           org.mozilla.javascript.ast.AstNode target,
                                           CodeBlock block,
                                           int offset)
      • processCaseNode

        private void processCaseNode​(org.mozilla.javascript.Node child,
                                     CodeBlock block,
                                     java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                     java.lang.String entered,
                                     int offset)
      • processSwitchNode

        private void processSwitchNode​(org.mozilla.javascript.Node child,
                                       CodeBlock block,
                                       java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                       java.lang.String entered,
                                       int offset)
        Extract local variables from switch node*
      • processTryCatchNode

        private void processTryCatchNode​(org.mozilla.javascript.Node child,
                                         CodeBlock block,
                                         java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                         java.lang.String entered,
                                         int offset)
        Extract variables from try/catch node(s)
      • processIfThenElse

        private void processIfThenElse​(org.mozilla.javascript.Node child,
                                       CodeBlock block,
                                       java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                       java.lang.String entered,
                                       int offset)
        Extract variables from if/else node(s)
      • processExpressionNode

        private void processExpressionNode​(org.mozilla.javascript.Node child,
                                           CodeBlock block,
                                           java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                           java.lang.String entered,
                                           int offset)
        Extract completions from expression node
      • processWhileNode

        private void processWhileNode​(org.mozilla.javascript.Node child,
                                      CodeBlock block,
                                      java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                      java.lang.String entered,
                                      int offset)
        Extract while loop from node and add new code block
      • processDoNode

        private void processDoNode​(org.mozilla.javascript.Node child,
                                   CodeBlock block,
                                   java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                   java.lang.String entered,
                                   int offset)
        Extract while loop from node and add new code block
      • processInfix

        private void processInfix​(org.mozilla.javascript.Node child,
                                  CodeBlock block,
                                  java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                  java.lang.String entered,
                                  int offset)
        Extract variable from binary operator e.g. <, >, = etc..
      • processFunctionNode

        private void processFunctionNode​(org.mozilla.javascript.Node child,
                                         CodeBlock block,
                                         java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                         java.lang.String entered,
                                         int offset)
        Add function to completions set and extract local variables to add to code block TODO: functions can have local scope, so add function to it's own codeblock when applicable
      • canProcessNode

        private boolean canProcessNode​(org.mozilla.javascript.ast.AstNode node)
      • getFunctionType

        private TypeDeclaration getFunctionType​(org.mozilla.javascript.ast.FunctionNode fn)
      • processVariableNode

        private void processVariableNode​(org.mozilla.javascript.Node child,
                                         CodeBlock block,
                                         java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                         java.lang.String entered,
                                         int offset)
        Extract variable from node and add to code block
      • processForNode

        private void processForNode​(org.mozilla.javascript.Node child,
                                    CodeBlock block,
                                    java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                    java.lang.String entered,
                                    int offset)
        Extract code from Token.FOR and add completions, then parse body of for-loop.
      • extractVariableFromNode

        private void extractVariableFromNode​(org.mozilla.javascript.ast.VariableInitializer initializer,
                                             CodeBlock block,
                                             int offset)
        Extract the variable from the Variable initializer and set the Type
        Parameters:
        initializer - AstNode from which to extract the variable
        block - code block to add the variable too
        offset - position of the variable in code
      • extractVariableForForEach

        private void extractVariableForForEach​(org.mozilla.javascript.ast.VariableInitializer initializer,
                                               CodeBlock block,
                                               int offset,
                                               org.mozilla.javascript.ast.AstNode iteratedObject)
        Extract variable for each in loop. If the iteratedObject is an Array, then resolve the variable to the array type otherwise set to iterator object type
        Parameters:
        initializer -
        block -
        offset -
        iteratedObject -
      • extractVariableForForIn

        private void extractVariableForForIn​(org.mozilla.javascript.ast.VariableInitializer initializer,
                                             CodeBlock block,
                                             int offset,
                                             org.mozilla.javascript.ast.AstNode iteratedObject)
        Extract variable for in loop. If the iteratedObject is an Array, then assume the variable to be a number otherwise do not attempt to resolve
        Parameters:
        initializer -
        block -
        offset -
        iteratedObject -
      • canAddVariable

        private boolean canAddVariable​(CodeBlock block)
      • extractVariableFromNode

        private JavaScriptVariableDeclaration extractVariableFromNode​(org.mozilla.javascript.ast.AstNode node,
                                                                      CodeBlock block,
                                                                      int offset)
        Extract the variable from the Rhino node and add to the CodeBlock
        Parameters:
        node - AstNode node from which to extract the variable
        block - code block to add the variable too
        offset - position of the variable in code
      • extractVariableFromNode

        private JavaScriptVariableDeclaration extractVariableFromNode​(org.mozilla.javascript.ast.AstNode node,
                                                                      CodeBlock block,
                                                                      int offset,
                                                                      org.mozilla.javascript.ast.AstNode initializer)
        Extract the variable from the Rhino node and add to the CodeBlock
        Parameters:
        node - AstNode node from which to extract the variable
        block - code block to add the variable too
        offset - position of the variable in code
        initializer - node associated with variable
      • getDot

        public int getDot()