private static String @Nullable [] getNamesForIdentifier(Project project, PsiIdentifier identifier){
     if (identifier.getParent() instanceof PsiVariable var && identifier.equals(var.getNameIdentifier())) {
       JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project);
       VariableKind variableKind = codeStyleManager.getVariableKind(var);
       PsiExpression initializer = var.getInitializer();
       if (var instanceof PsiParameter parameter && parameter.getDeclarationScope() instanceof PsiForeachStatement foreachStatement) {
         //synthesize initializer
         final PsiExpression iteratedValue = foreachStatement.getIteratedValue();
         if (iteratedValue != null) {
           try {
             final PsiArrayAccessExpression expr =
               (PsiArrayAccessExpression)JavaPsiFacade.getElementFactory(iteratedValue.getProject()).createExpressionFromText("a[0]", var);
             expr.getArrayExpression().replace(iteratedValue);
             initializer = expr; //note: non physical with no parent
           }
           catch (IncorrectOperationException e) {
             //do nothing
           }
         }
       }
       PsiExpression finalInitializer = initializer;
       SuggestedNameInfo suggestedInfo =
         DumbService.getInstance(project)
           .withAlternativeResolveEnabled(() -> codeStyleManager.suggestVariableName(variableKind, null, finalInitializer, var.getType()));
       return suggestedInfo.names;
     }
     return null;
   }
private static String @Nullable [] getNamesForIdentifier(Project project, PsiIdentifier identifier)