Package org.fife.rsta.ac.js.ast
Class VariableResolver
java.lang.Object
org.fife.rsta.ac.js.ast.VariableResolver
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 Summary
FieldsModifier and TypeFieldDescriptionprivate HashMap<String, JavaScriptFunctionDeclaration> private HashMap<String, JavaScriptVariableDeclaration> private HashMap<String, JavaScriptFunctionDeclaration> private HashMap<String, JavaScriptVariableDeclaration> private HashMap<String, JavaScriptVariableDeclaration> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddLocalVariable(JavaScriptVariableDeclaration declaration) Add local scope variable to cache.voidAdd pre-processing scope function to cache.voidaddPreProcessingVariable(JavaScriptVariableDeclaration declaration) Add pre-processing scope variable to cache.voidaddSystemVariable(JavaScriptVariableDeclaration declaration) Add system scope variable to cachefindDeclaration(String name, int dot) Find JSVariableDeclaration for name against all variable types and check is in scope of caret positionfindDeclaration(String name, int dot, boolean local, boolean preProcessed, boolean system) private JavaScriptVariableDeclarationfindDeclaration(HashMap<String, JavaScriptVariableDeclaration> variables, String name, int dot) Find JSVariableDeclaration and check the scope of the caret positionprivate JavaScriptFunctionDeclarationfindFirstFunction(String name, HashMap<String, JavaScriptFunctionDeclaration> functions) findFunctionDeclaration(String name, boolean local, boolean preProcessed) findFunctionDeclarationByFunctionName(String name, boolean local, boolean preprocessed) findNonLocalDeclaration(String name, int dot) Find JSVariableDeclaration within pre-processed and system variable only.getTypeDeclarationForVariable(String name, int dot) Find theTypeDeclarationfor the variable and check the scope of the caret positionvoidremove pre-processing variable from system variable cachevoidremoveSystemVariable(String name) remove system variable from system variable cachevoidClear all local scope variablesvoidresetPreProcessingVariables(boolean clear) voidresolveType(String varName, int dot) Resolve the entered text by chopping up the text and working from left to right, resolving each type in turn
-
Field Details
-
localVariables
-
preProcessedVariables
-
systemVariables
-
localFunctions
-
preProcessedFunctions
-
-
Constructor Details
-
VariableResolver
public VariableResolver()
-
-
Method Details
-
addLocalVariable
Add local scope variable to cache.- Parameters:
declaration- variable to add
-
addPreProcessingVariable
Add pre-processing scope variable to cache.- Parameters:
declaration- variable to add
-
addSystemVariable
Add system scope variable to cache- Parameters:
declaration- variable to add
-
removePreProcessingVariable
remove pre-processing variable from system variable cache- Parameters:
name- of the system variable to remove
-
removeSystemVariable
remove system variable from system variable cache- Parameters:
name- of the system variable to remove
-
findDeclaration
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
Find JSVariableDeclaration within pre-processed and system variable only. Also check is in scope of caret position- Parameters:
name- of variable to resolvedot- 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
Find theTypeDeclarationfor the variable and check the scope of the caret position- Parameters:
name- name of variabledot- 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
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
-
findFunctionDeclaration
-
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
Add pre-processing scope function to cache.- Parameters:
func- variable to add
-