boolean (IntroduceVariableSettings settings) { String name = settings.getEnteredName(); PsiExpression[] occurrences = settings.getReplaceChoice().filter(myOccurenceManager); final PsiElement anchor = IntroduceVariableBase.getAnchor(occurrences); if (anchor == null) return true; final PsiElement scope = anchor.getParent(); if(scope == null) return true; final MultiMap<PsiElement, String> conflicts = new MultiMap<>(); final HashSet<PsiVariable> reportedVariables = new HashSet<>(); JavaUnresolvableLocalCollisionDetector.CollidingVariableVisitor visitor = new JavaUnresolvableLocalCollisionDetector.CollidingVariableVisitor() { @Override public void visitCollidingElement(PsiVariable collidingVariable) { if (!reportedVariables.contains(collidingVariable)) { reportedVariables.add(collidingVariable); String message = JavaRefactoringBundle.message("introduced.variable.will.conflict.with.0", RefactoringUIUtil.getDescription(collidingVariable, true)); conflicts.putValue(collidingVariable, message); } } }; JavaUnresolvableLocalCollisionDetector.visitLocalsCollisions(anchor, name, scope, anchor, visitor); for (PsiExpression occurence : occurrences) { IntroduceVariableBase.checkInLoopCondition(occurence, conflicts); } if (conflicts.size() > 0) { return myIntroduceVariableBase.reportConflicts(conflicts, myProject, settings); } else { return true; } }