ItemToReplaceDescriptor (@NotNull PsiDeclarationStatement declarationStatement) { List<AccessibleLocalVariable> variables = new ArrayList<>(); for (PsiElement element : declarationStatement.getDeclaredElements()) { if (!(element instanceof PsiLocalVariable variable)) { return null; } String name = variable.getName(); PsiType variableType = variable.getType(); if (!PsiReflectionAccessUtil.isAccessibleType(variableType)) { variables.add(new AccessibleLocalVariable(name, PsiReflectionAccessUtil.nearestAccessibleType(variableType), variable)); } } if (!variables.isEmpty()) { return new LocalVariableDeclarationDescriptor(variables, declarationStatement); } return null; }