private static boolean hasNameCollision(PsiElement declaration, PsiElement context) {
    if (declaration instanceof PsiDeclarationStatement) {
      PsiResolveHelper helper = JavaPsiFacade.getInstance(context.getProject()).getResolveHelper();
      return StreamEx.of(((PsiDeclarationStatement)declaration).getDeclaredElements())
        .select(PsiLocalVariable.class)
        .map(PsiLocalVariable::getName)
        .nonNull()
        .anyMatch(name -> helper.resolveAccessibleReferencedVariable(name, context) != null);
    }
    return false;
  }
private static boolean hasNameCollision(PsiElement declaration, PsiElement context)