public void fix() throws IncorrectOperationException {
   if (myField == null) return;
   final PsiManager manager = myScope.getManager();
   for (PsiReferenceExpression referenceExpression : myReferenceExpressions) {
     if (!referenceExpression.isValid()) continue;
     final PsiElement newlyResolved = referenceExpression.resolve();
     if (!manager.areElementsEquivalent(newlyResolved, myField)) {
       qualifyReference(referenceExpression, myField, myQualifyingClass);
     }
   }
 }
  public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
    if (!(file instanceof PsiJavaFile)) return false;
    if (myUnresolvedReference.isQualified()) return false;
    final String referenceName = myUnresolvedReference.getReferenceName();
    if (referenceName == null) return false;

    PsiManager manager = file.getManager();
    if (!myUnresolvedReference.isValid() || !manager.isInProject(myUnresolvedReference))
      return false;

    PsiElement container =
        PsiTreeUtil.getParentOfType(myUnresolvedReference, PsiCodeBlock.class, PsiClass.class);
    if (!(container instanceof PsiCodeBlock)) return false;

    myOutOfScopeVariable = null;
    while (container.getParent() instanceof PsiStatement
        || container.getParent() instanceof PsiCatchSection) container = container.getParent();
    container.accept(
        new JavaRecursiveElementWalkingVisitor() {
          @Override
          public void visitReferenceExpression(PsiReferenceExpression expression) {}

          @Override
          public void visitExpression(PsiExpression expression) {
            // Don't look inside expressions
          }

          @Override
          public void visitLocalVariable(PsiLocalVariable variable) {
            if (referenceName.equals(variable.getName())) {
              if (myOutOfScopeVariable == null) {
                myOutOfScopeVariable = variable;
              } else {
                myOutOfScopeVariable = null; // 2 conflict variables
              }
            }
          }
        });

    return myOutOfScopeVariable != null;
  }