boolean (PsiExpression expression) { PsiElement parent = expression.getParent(); if (!(parent instanceof PsiExpressionList)) { return false; } parent = parent.getParent(); if (!(parent instanceof PsiMethodCallExpression methodCall)) { return false; } final PsiReferenceExpression methodExpression = methodCall.getMethodExpression(); final PsiType type = methodExpression.getType(); if (type == null) { return false; } final String className = type.getCanonicalText(); if (!CommonClassNames.JAVA_LANG_STRING_BUFFER.equals(className) && !CommonClassNames.JAVA_LANG_STRING_BUILDER.equals(className)) { return false; } @NonNls final String methodName = methodExpression.getReferenceName(); return "append".equals(methodName); }