@Override
    public PsiVariable getUsedVariable(@NotNull PsiReferenceExpression refExpr) {
      if (refExpr.isQualified()) return null;

      PsiElement refElement = refExpr.resolve();
      if ((refElement instanceof PsiLocalVariable || refElement instanceof PsiParameter) &&
          !PsiTreeUtil.isAncestor(myElement, refElement, true)) {
        return (PsiVariable) refElement;
      }

      return null;
    }
@Override
    public PsiVariable getUsedVariable(@NotNull PsiReferenceExpression refExpr)