Provides the functionality of resolving local references. This means, this class takes care to find out where a local variable was defined and it can be used to find all references of a variable inside a scope. "Local" in this context means that the variable must be localized with Module, Block, Table, Compile, etc..
This class is for instance used by {@link SymbolPsiReference} but to give an overview of a complete flow let meexplain this in more detail:
Let's assume you have "Preferences" -> "Editor" -> "Highlight usages of symbol under cursor" turned on and when you browse through the code and stop on a variable, the variable itself and all its usages are highlighted. The moment you move the cursor over the variable, IDEA calls {@link Symbol#getReference()} in order to find the place where thisvariable is defined. The {@link SymbolPsiReference} first finds the correct PsiElement for which the reference shouldbe searched. Usually, this is always the {@link Symbol} over which the cursor is.
Now {@link SymbolPsiReference#resolveInner()} searches clever for the place where the variable could be defined. Thisprocess depends on the language; in Mathematica, I use currently the following approach: I walk the parsing tree upwards and check every Module, Block, ... I find on my way. Checking means I look in the definition list whether my variable is defined there. If not, I go further upwards. This is why you find a {@link PsiTreeUtil#treeWalkUp(PsiScopeProcessor,PsiElement,PsiElement,ResolveState)} in this method. On every stepupwards the {@link #execute(PsiElement,ResolveState)} method is called and exactly here I extract all locallydefined variables I find and check whether any of it has the same name as my original variable whose definition I want to find.
If I find it in any of the localization constructs like Module, Block.. I stop and return the PsiElement which is the place of definition.
Finding all usages works btw the same way: First I find the definition of a variable and then I find all variables which resolve to the exact same place of definition.
@author patrick (5/22/13)