Class SourceCompletionProvider

java.lang.Object
org.fife.ui.autocomplete.CompletionProviderBase
org.fife.ui.autocomplete.AbstractCompletionProvider
org.fife.ui.autocomplete.DefaultCompletionProvider
org.fife.rsta.ac.js.SourceCompletionProvider
All Implemented Interfaces:
org.fife.ui.autocomplete.CompletionProvider

public class SourceCompletionProvider extends org.fife.ui.autocomplete.DefaultCompletionProvider
Completion provider for JavaScript source code (not comments or strings).
Version:
1.0
  • Field Details

  • Constructor Details

    • SourceCompletionProvider

      public SourceCompletionProvider(boolean xmlSupported)
    • SourceCompletionProvider

      public SourceCompletionProvider(String javaScriptEngine, boolean xmlSupported)
  • Method Details

    • addShorthandCompletions

      private void addShorthandCompletions(Set<org.fife.ui.autocomplete.Completion> set)
      Adds simple shorthand completions relevant to JavaScript from the shorthand template.
      Parameters:
      set - The set to add to.
      See Also:
    • setShorthandCache

      public void setShorthandCache(ShorthandCompletionCache shorthandCache)
      Set template completion cache for source completion provider.
      Parameters:
      shorthandCache - The cache to use.
    • getCompletionsAt

      public List<org.fife.ui.autocomplete.Completion> getCompletionsAt(JTextComponent tc, Point p)
      Specified by:
      getCompletionsAt in interface org.fife.ui.autocomplete.CompletionProvider
      Overrides:
      getCompletionsAt in class org.fife.ui.autocomplete.DefaultCompletionProvider
    • getCompletionsImpl

      protected List<org.fife.ui.autocomplete.Completion> getCompletionsImpl(JTextComponent comp)
      Overrides:
      getCompletionsImpl in class org.fife.ui.autocomplete.AbstractCompletionProvider
    • handleNewFilter

      private List<org.fife.ui.autocomplete.Completion> handleNewFilter(Set<org.fife.ui.autocomplete.Completion> set, String text)
    • resolveCompletions

      private List<org.fife.ui.autocomplete.Completion> resolveCompletions(String text, Set<org.fife.ui.autocomplete.Completion> set)
    • loadECMAClasses

      private void loadECMAClasses(Set<org.fife.ui.autocomplete.Completion> set, String text)
      Load ECMA JavaScript class completions
      Parameters:
      set - completion set
      text -
    • getSelf

      public String getSelf()
      returns the Base class for the source completion provider. This is represented by a class name or ECMA lookup name e.g. set to 'Global' for server side or 'Window' for client JavaScript support
      Returns:
      base class for the completion provider
    • parseTextAndResolve

      private void parseTextAndResolve(Set<org.fife.ui.autocomplete.Completion> set, String text)
      Parse Text and add completions to set
    • populateCompletionsFromType

      private boolean populateCompletionsFromType(JavaScriptType type, Set<org.fife.ui.autocomplete.Completion> set)
      Populate Set of completions if JavaScriptType is not null and return true, otherwise return false
    • getAlreadyEnteredText

      public String getAlreadyEnteredText(JTextComponent comp)
      Specified by:
      getAlreadyEnteredText in interface org.fife.ui.autocomplete.CompletionProvider
      Overrides:
      getAlreadyEnteredText in class org.fife.ui.autocomplete.DefaultCompletionProvider
    • iterateAstRoot

      protected CodeBlock iterateAstRoot(org.mozilla.javascript.ast.AstRoot root, Set<org.fife.ui.autocomplete.Completion> set, String entered, int dot, TypeDeclarationOptions options)
      Iterates through AstRoot to extract all code blocks, functions, variables etc... e.g. functions, if statements, variables
      Parameters:
      root - AstRoot to iterate
      set - add add completions to set (functions only TODO remove this and do elsewhere)
      entered - already entered text
      dot - position in code
      options - Options for the parsing.
      Returns:
    • resolveTypeDeclation

      public TypeDeclaration resolveTypeDeclation(String name)
      Convenience method to call variable resolver
      Parameters:
      name -
      Returns:
    • findDeclaration

      public JavaScriptVariableDeclaration findDeclaration(String name)
      Convenience method to call variable resolver
      Parameters:
      name -
      Returns:
      JavaScript variable declaration
    • findNonLocalDeclaration

      public JavaScriptVariableDeclaration findNonLocalDeclaration(String name)
      Convenience method to call variable resolver for non-local variables i.e. does NOT try to resolve name to any local variables (just pre-processed or system)
      Parameters:
      name -
      Returns:
      JavaScript variable declaration
    • resolveTypeFromFunctionNode

      public TypeDeclaration resolveTypeFromFunctionNode(org.mozilla.javascript.ast.AstNode functionNode)
      Get the source of the node and try to resolve function node:
      Parameters:
      functionNode -
      Returns:
      a.toString().getCharAt(1); returns String TypeDeclaration
    • setParent

      void setParent(JavaScriptCompletionProvider parent)
    • setJavaScriptTypesFactory

      public void setJavaScriptTypesFactory(JavaScriptTypesFactory factory)
    • getJavaScriptTypesFactory

      public JavaScriptTypesFactory getJavaScriptTypesFactory()
    • recursivelyAddLocalVars

      protected void recursivelyAddLocalVars(Set<org.fife.ui.autocomplete.Completion> completions, CodeBlock block, int dot, String text, boolean findMatch, boolean isPreprocessing)
      Iterate though the CodeBlock and extract all variables within scope
      Parameters:
      completions -
      block -
      dot -
      text -
      findMatch -
    • isValidChar

      protected boolean isValidChar(char ch)
      Overrides:
      isValidChar in class org.fife.ui.autocomplete.DefaultCompletionProvider
    • setJarManager

      public void setJarManager(JarManager jarManager)
      The jar manager is used to parse the JS API for function completions
      Parameters:
      jarManager -
    • getJarManager

      public JarManager getJarManager()
    • getVariableResolver

      public VariableResolver getVariableResolver()
    • getLanguageSupport

      public JavaScriptLanguageSupport getLanguageSupport()
    • setPreProcessingScripts

      public void setPreProcessingScripts(PreProcessingScripts preProcessing)
    • getPreProcessingScripts

      public PreProcessingScripts getPreProcessingScripts()
    • supportsPreProcessingScripts

      private boolean supportsPreProcessingScripts()
    • getJavaScriptEngine

      public JavaScriptEngine getJavaScriptEngine()
    • setJavaScriptEngine

      public void setJavaScriptEngine(JavaScriptEngine engine)
    • getSourceLocForClass

      public SourceLocation getSourceLocForClass(String className)
    • isXMLSupported

      public boolean isXMLSupported()
    • setXMLSupported

      public void setXMLSupported(boolean xmlSupported)
    • setSelf

      public void setSelf(String self)
    • parseDocument

      public void parseDocument(int dot)
    • getTypesFactory

      public TypeDeclarationFactory getTypesFactory()
    • setTypeDeclationOptions

      public void setTypeDeclationOptions(TypeDeclarationOptions typeDeclarationOptions)
      Set type declaration options for parser
      Parameters:
      typeDeclarationOptions -
    • debugCodeBlock

      public void debugCodeBlock(CodeBlock block, int tab)