boolean (@NotNull final PsiVariable variable, @Nullable final PsiElement scope) { if (scope == null) { return false; } final Collection<PsiReference> references = ReferencesSearch.search(variable, new LocalSearchScope(scope)).findAll(); boolean foundOnce = (variable instanceof PsiParameter) || (variable.getInitializer() != null); for (PsiReference reference : references) { if (reference instanceof PsiReferenceExpression) { if (PsiUtil.isAccessedForWriting((PsiReferenceExpression) reference)) { if (foundOnce) { return false; } foundOnce = true; } } } return true; }