boolean (PsiExpression expression) { if (expression == null) { return false; } if (ExpressionUtils.isVoidContext(expression)) { return true; } final PsiElement parent = expression.getParent(); if (parent instanceof PsiReferenceExpression) { final PsiElement grandParent = parent.getParent(); if (grandParent instanceof PsiMethodCallExpression) { final String methodName = ((PsiReferenceExpression)parent).getReferenceName(); if ("toString".equals(methodName)) { return true; } else if ("append".equals(methodName) || "appendCodePoint".equals(methodName) || "insert".equals(methodName)) { return isSafeStringBufferUsage((PsiExpression)grandParent); } } } return false; }