void (PsiVariable variable, PsiElement block) { if (block == null) return; PsiExpression initializer = PsiUtil.skipParenthesizedExprDown(variable.getInitializer()); PsiIdentifier identifier = variable.getNameIdentifier(); if (identifier != null && isNewExpression(initializer)) { boolean exactType = PsiUtil.skipParenthesizedExprDown(initializer) instanceof PsiNewExpression; PsiType type = variable.getType(); if (!(type instanceof PsiClassType)) return; if (InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_COLLECTION) || InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP) || InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_ABSTRACT_STRING_BUILDER)) { // will be processed by other inspections return; } List<PsiReferenceExpression> references = VariableAccessUtils.getVariableReferences(variable, block); if (references.isEmpty()) return; for (PsiReferenceExpression ref : references) { if (!isWriteWithoutRead(ref, exactType)) { return; } } holder.registerProblem(identifier, InspectionGadgetsBundle.message("write.only.object.display.name")); } }