boolean (@NotNull List<PsiElement> refs, @NotNull Set<PsiMethodCallExpression> allowedReferencePlaces) { return StreamEx.of(refs).select(PsiExpression.class).allMatch(expression -> { PsiMethodCallExpression usage = ExpressionUtils.getCallForQualifier(expression); if (usage != null) { if (allowedReferencePlaces.contains(usage)) return true; PsiExpression[] usageArgs = usage.getArgumentList().getExpressions(); String name = usage.getMethodExpression().getReferenceName(); if (usageArgs.length == 0 && ("toString".equals(name) || "length".equals(name))) return true; } PsiElement parent = PsiUtil.skipParenthesizedExprUp(expression.getParent()); if (parent instanceof PsiPolyadicExpression && ((PsiPolyadicExpression)parent).getOperationTokenType().equals(JavaTokenType.PLUS)) { return true; } if (parent instanceof PsiAssignmentExpression && ((PsiAssignmentExpression)parent).getOperationTokenType().equals(JavaTokenType.PLUSEQ)) { return true; } return false; }); }