Class VariableResolver

java.lang.Object
org.fife.rsta.ac.js.ast.VariableResolver

public class VariableResolver extends 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
  • Field Details

  • Constructor Details

    • VariableResolver

      public VariableResolver()
  • Method Details

    • 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(String name)
      remove pre-processing variable from system variable cache
      Parameters:
      name - of the system variable to remove
    • removeSystemVariable

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

      public JavaScriptVariableDeclaration findDeclaration(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(String name, int dot, boolean local, boolean preProcessed, boolean system)
    • findNonLocalDeclaration

      public JavaScriptVariableDeclaration findNonLocalDeclaration(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(HashMap<String, JavaScriptVariableDeclaration> variables, 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(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(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
    • addLocalFunction

      public void addLocalFunction(JavaScriptFunctionDeclaration func)
    • findFunctionDeclaration

      public JavaScriptFunctionDeclaration findFunctionDeclaration(String name)
    • findFunctionDeclaration

      public JavaScriptFunctionDeclaration findFunctionDeclaration(String name, boolean local, boolean preProcessed)
    • findFunctionDeclarationByFunctionName

      public JavaScriptFunctionDeclaration findFunctionDeclarationByFunctionName(String name, boolean local, boolean preprocessed)
    • findFirstFunction

      private JavaScriptFunctionDeclaration findFirstFunction(String name, HashMap<String, JavaScriptFunctionDeclaration> functions)
    • addPreProcessingFunction

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