public static void findCollisions(final PsiElement element, final String newName, final List<? super UsageInfo> result) {
    if (!PsiUtil.isJvmLocalVariable(element)) {
      return;
    }

    PsiVariable variable = (PsiVariable)element;
    PsiElement scope;
    if (variable instanceof PsiLocalVariable local) {
      scope = CommonJavaRefactoringUtil.getVariableScope(local);
    }
    else {
      // element is a PsiParameter
      scope = ((PsiParameter)element).getDeclarationScope();
    }
    String oldName = variable.getName();
    LOG.assertTrue(scope != null, element.getClass().getName());
    boolean methodParameter = element instanceof PsiParameter parameter && parameter.getDeclarationScope() instanceof PsiMethod;
    
    PsiResolveHelper helper = PsiResolveHelper.getInstance(element.getProject());
    final CollidingVariableVisitor collidingNameVisitor = new CollidingVariableVisitor() {
      @Override
      public void visitCollidingElement(PsiVariable collidingVariable) {
        if (collidingVariable.equals(element)) return;
        if (collidingVariable.isUnnamed()) return;
        if (!methodParameter &&
            helper.resolveAccessibleReferencedVariable(newName, element) != collidingVariable &&
            helper.resolveAccessibleReferencedVariable(oldName, collidingVariable) != element) return;
        LocalHidesRenamedLocalUsageInfo collision = new LocalHidesRenamedLocalUsageInfo(collidingVariable, element);
        result.add(collision);
      }
    };

    visitLocalsCollisions(element, newName, scope, null, collidingNameVisitor);
  }
public static void findCollisions(final PsiElement element, final String newName, final List<? super UsageInfo> result)