boolean (PsiExpression location) { // conservative check to see if the result value of the postfix // expression is used later in the same expression statement. // Applying the quick fix in such a case would break the code // because the explicit unboxing code would split the expression in // multiple statements. final PsiElement parent = PsiUtil.skipParenthesizedExprUp(location.getParent()); if (!(parent instanceof PsiPostfixExpression)) { return true; } final PsiReferenceExpression reference; if (location instanceof PsiReferenceExpression) { reference = (PsiReferenceExpression)location; } else if (location instanceof PsiArrayAccessExpression arrayAccessExpression) { final PsiExpression expression = arrayAccessExpression.getArrayExpression(); if (!(expression instanceof PsiReferenceExpression)) { return true; } reference = (PsiReferenceExpression)expression; } else { return true; } final PsiElement element = reference.resolve(); if (element == null) { return true; } final PsiStatement statement = PsiTreeUtil.getParentOfType(parent, PsiStatement.class); assert statement != null; final LocalSearchScope scope = new LocalSearchScope(statement); final Query<PsiReference> query = ReferencesSearch.search(element, scope); final Collection<PsiReference> references = query.findAll(); return references.size() <= 1; }