Class 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
    • Constructor Detail

      • SourceCompletionProvider

        public SourceCompletionProvider​(boolean xmlSupported)
      • SourceCompletionProvider

        public SourceCompletionProvider​(java.lang.String javaScriptEngine,
                                        boolean xmlSupported)
    • Method Detail

      • addShorthandCompletions

        private void addShorthandCompletions​(java.util.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:
        ShorthandCompletionCache
      • setShorthandCache

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

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

        protected java.util.List<org.fife.ui.autocomplete.Completion> getCompletionsImpl​(javax.swing.text.JTextComponent comp)
        Overrides:
        getCompletionsImpl in class org.fife.ui.autocomplete.AbstractCompletionProvider
      • handleNewFilter

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

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

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

        public java.lang.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​(java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                         java.lang.String text)
        Parse Text and add completions to set
      • populateCompletionsFromType

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

        public java.lang.String getAlreadyEnteredText​(javax.swing.text.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,
                                           java.util.Set<org.fife.ui.autocomplete.Completion> set,
                                           java.lang.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​(java.lang.String name)
        Convenience method to call variable resolver
        Parameters:
        name -
        Returns:
      • findDeclaration

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

        public JavaScriptVariableDeclaration findNonLocalDeclaration​(java.lang.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
      • recursivelyAddLocalVars

        protected void recursivelyAddLocalVars​(java.util.Set<org.fife.ui.autocomplete.Completion> completions,
                                               CodeBlock block,
                                               int dot,
                                               java.lang.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()
      • setPreProcessingScripts

        public void setPreProcessingScripts​(PreProcessingScripts preProcessing)
      • supportsPreProcessingScripts

        private boolean supportsPreProcessingScripts()
      • setJavaScriptEngine

        public void setJavaScriptEngine​(JavaScriptEngine engine)
      • getSourceLocForClass

        public SourceLocation getSourceLocForClass​(java.lang.String className)
      • isXMLSupported

        public boolean isXMLSupported()
      • setXMLSupported

        public void setXMLSupported​(boolean xmlSupported)
      • setSelf

        public void setSelf​(java.lang.String self)
      • parseDocument

        public void parseDocument​(int dot)
      • setTypeDeclationOptions

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

        public void debugCodeBlock​(CodeBlock block,
                                   int tab)