@Override public void visitLocalVariable(@NotNull PsiLocalVariable variable) { super.visitLocalVariable(variable); final PsiCodeBlock codeBlock = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class); if (!shouldCheckVariable(variable, codeBlock)) { return; } final ArrayReadWriteVisitor visitor = new ArrayReadWriteVisitor(variable, !isSimpleArrayExpression(variable.getInitializer())); codeBlock.accept(visitor); final boolean written = visitor.isWritten(); if (!visitor.isReferenced() || written == visitor.isRead()) { return; } registerVariableError(variable, Boolean.valueOf(written)); }
@Override public void visitField(@NotNull PsiField field) { super.visitField(field); if (!field.hasModifierProperty(PsiModifier.PRIVATE)) { return; } if (HighlightUtil.isSerializationImplicitlyUsedField(field)) { return; } final PsiClass containingClass = PsiUtil.getTopLevelClass(field); if (!shouldCheckVariable(field, containingClass)) { return; } final ArrayReadWriteVisitor visitor = new ArrayReadWriteVisitor(field, !isSimpleArrayExpression(field.getInitializer())); containingClass.accept(visitor); final boolean written = visitor.isWritten(); if (!visitor.isReferenced() || written == visitor.isRead()) { return; } registerFieldError(field, Boolean.valueOf(written)); }