void (final @NotNull PsiFile file, final PsiElement element, final String prefix, final PsiType itemType, final Consumer<? super LookupElement> result, @Nullable final PsiElement qualifier, final PsiType expectedType) { final PsiType componentType = PsiUtil.extractIterableTypeParameter(itemType, true); if (componentType == null || !(expectedType instanceof PsiArrayType type)) return; if (!type.getComponentType().isAssignableFrom(componentType) || componentType instanceof PsiClassType && ((PsiClassType) componentType).hasParameters()) { return; } final String bracketSpace = getSpace(CodeStyle.getLanguageSettings(file).SPACE_WITHIN_BRACKETS); boolean hasEmptyArrayField = false; final PsiClass psiClass = PsiUtil.resolveClassInType(type); if (psiClass != null) { for (final PsiField field : psiClass.getAllFields()) { if (field.hasModifierProperty(PsiModifier.STATIC) && field.hasModifierProperty(PsiModifier.FINAL) && JavaPsiFacade.getInstance(field.getProject()).getResolveHelper().isAccessible(field, element, null) && type.isAssignableFrom(field.getType()) && ConstructionUtils.isEmptyArrayInitializer(field.getInitializer())) { boolean needQualify; try { needQualify = !field.isEquivalentTo(((PsiReferenceExpression)createExpression(field.getName(), element)).resolve()); } catch (IncorrectOperationException e) { continue; } PsiClass containingClass = field.getContainingClass(); if (containingClass == null) continue; addToArrayConversion(file, element, prefix, (needQualify ? containingClass.getQualifiedName() + "." : "") + field.getName(), (needQualify ? containingClass.getName() + "." : "") + field.getName(), result, qualifier); hasEmptyArrayField = true; } } } if (!hasEmptyArrayField) { addToArrayConversion(file, element, prefix, "new " + componentType.getCanonicalText() + "[" + bracketSpace + "0" + bracketSpace + "]", "new " + componentType.getPresentableText() + "[0]", result, qualifier); } }