Class VariableResolver


  • public class VariableResolver
    extends java.lang.Object
    Cache Local and System scope variables Local scope variables are cleared each time the SourceCompletionProvider finishes parsing the script System scope variables will not be cleared
    • Constructor Detail

      • VariableResolver

        public VariableResolver()
    • Method Detail

      • addLocalVariable

        public void addLocalVariable​(JavaScriptVariableDeclaration declaration)
        Add local scope variable to cache.
        Parameters:
        declaration - variable to add
      • addPreProcessingVariable

        public void addPreProcessingVariable​(JavaScriptVariableDeclaration declaration)
        Add pre-processing scope variable to cache.
        Parameters:
        declaration - variable to add
      • addSystemVariable

        public void addSystemVariable​(JavaScriptVariableDeclaration declaration)
        Add system scope variable to cache
        Parameters:
        declaration - variable to add
      • removePreProcessingVariable

        public void removePreProcessingVariable​(java.lang.String name)
        remove pre-processing variable from system variable cache
        Parameters:
        name - of the system variable to remove
      • removeSystemVariable

        public void removeSystemVariable​(java.lang.String name)
        remove system variable from system variable cache
        Parameters:
        name - of the system variable to remove
      • findDeclaration

        public JavaScriptVariableDeclaration findDeclaration​(java.lang.String name,
                                                             int dot)
        Find JSVariableDeclaration for name against all variable types and check is in scope of caret position
        Parameters:
        name -
        dot -
        Returns:
        JSVariableDeclaration from the name
      • findDeclaration

        public JavaScriptVariableDeclaration findDeclaration​(java.lang.String name,
                                                             int dot,
                                                             boolean local,
                                                             boolean preProcessed,
                                                             boolean system)
      • findNonLocalDeclaration

        public JavaScriptVariableDeclaration findNonLocalDeclaration​(java.lang.String name,
                                                                     int dot)
        Find JSVariableDeclaration within pre-processed and system variable only. Also check is in scope of caret position
        Parameters:
        name - of variable to resolve
        dot - position in text document
        Returns:
        JSVariableDeclaration from the name
      • findDeclaration

        private JavaScriptVariableDeclaration findDeclaration​(java.util.HashMap<java.lang.String,​JavaScriptVariableDeclaration> variables,
                                                              java.lang.String name,
                                                              int dot)
        Find JSVariableDeclaration and check the scope of the caret position
        Parameters:
        name -
        dot -
        Returns:
        JSVariableDeclaration from the name
      • getTypeDeclarationForVariable

        public TypeDeclaration getTypeDeclarationForVariable​(java.lang.String name,
                                                             int dot)
        Find the TypeDeclaration for the variable and check the scope of the caret position
        Parameters:
        name - name of variable
        dot - position
        Returns:
        TypeDeclaration from the name
      • resetLocalVariables

        public void resetLocalVariables()
        Clear all local scope variables
      • resetPreProcessingVariables

        public void resetPreProcessingVariables​(boolean clear)
      • resetSystemVariables

        public void resetSystemVariables()
      • resolveType

        public TypeDeclaration resolveType​(java.lang.String varName,
                                           int dot)
        Resolve the entered text by chopping up the text and working from left to right, resolving each type in turn
        Parameters:
        varName -
        dot -
        Returns:
        TypeDeclaration for variable name
      • findFunctionDeclaration

        public JavaScriptFunctionDeclaration findFunctionDeclaration​(java.lang.String name,
                                                                     boolean local,
                                                                     boolean preProcessed)
      • findFunctionDeclarationByFunctionName

        public JavaScriptFunctionDeclaration findFunctionDeclarationByFunctionName​(java.lang.String name,
                                                                                   boolean local,
                                                                                   boolean preprocessed)
      • addPreProcessingFunction

        public void addPreProcessingFunction​(JavaScriptFunctionDeclaration func)
        Add pre-processing scope function to cache.
        Parameters:
        func - variable to add