Class RhinoJavaScriptAstParser


public class RhinoJavaScriptAstParser extends JavaScriptAstParser
Rhino specific JavaScriptAstParser. Reads the importPackage and importClass from the parsed document and adds to the RhinoJavaScriptTypesFactory.
  • Field Details

  • Constructor Details

  • Method Details

    • clearImportCache

      public void clearImportCache(SourceCompletionProvider provider)
      Clear the importPackage and importClass cache
      Parameters:
      provider - SourceCompletionProvider
    • convertAstNodeToCodeBlock

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

      private void mergeImportCache(HashSet<String> packages, HashSet<String> classes)
    • iterateNode

      protected void iterateNode(org.mozilla.javascript.ast.AstNode child, Set<org.fife.ui.autocomplete.Completion> set, String entered, CodeBlock block, int offset)
      Overridden iterateNode to intercept Token.EXPR_RESULT and check for importPackage and importClass named nodes If found, then process them and extract the imports and add them to RhinoJavaScriptTypesFactory then return otherwise call super.iterateNode()
      Overrides:
      iterateNode in class JavaScriptAstParser
    • processImportNode

      private boolean processImportNode(org.mozilla.javascript.ast.AstNode child, Set<org.fife.ui.autocomplete.Completion> set, String entered, CodeBlock block, int offset)
      Look for text importPackage and importClass and add to cache
      Parameters:
      child - AstNode to check. This will always be Token.EXPR_RESULT AstNode
      set - Set to add completions
      entered - text entered by user if applicable
      block - CodeBlock
      offset - position of AstNode within document
      Returns:
      true if either importPackage or importClass is found
    • removePackages

      public static String removePackages(String src)
    • extractNameFromSrc

      private String extractNameFromSrc(String src)
      Parameters:
      src - String to extract name
      Returns:
      import statement from withing the ( and ) e.g. importPackage(java.util) importClass(java.util.HashSet) returns java.util or java.util.HashSet respectively
    • processImportPackage

      private void processImportPackage(String src)
      Adds package name to RhinoJavaScriptTypesFactory
      Parameters:
      src - source text to extract the package
    • processImportClass

      private void processImportClass(String src)
      Adds class name to RhinoJavaScriptTypesFactory
      Parameters:
      src - source text to extract the class name