List<PsiExpression> (PsiExpression construction) { List<PsiExpression> joinParts = new ArrayList<>(); PsiExpression expression = construction; PsiMethodCallExpression current = tryCast(construction, PsiMethodCallExpression.class); while(current != null) { if (APPEND.test(current)) { joinParts.add(current.getArgumentList().getExpressions()[0]); } else { return null; } expression = current.getMethodExpression().getQualifierExpression(); current = MethodCallUtils.getQualifierMethodCall(current); } PsiNewExpression newExpression = tryCast(PsiUtil.skipParenthesizedExprDown(expression), PsiNewExpression.class); if (newExpression == null) return null; final PsiJavaCodeReferenceElement classReference = newExpression.getClassReference(); if (classReference == null) return null; PsiClass aClass = tryCast(classReference.resolve(), PsiClass.class); if (aClass == null) return null; final String qualifiedName = aClass.getQualifiedName(); if (!CommonClassNames.JAVA_LANG_STRING_BUILDER.equals(qualifiedName) && !CommonClassNames.JAVA_LANG_STRING_BUFFER.equals(qualifiedName)) { return null; } final PsiExpressionList argumentList = newExpression.getArgumentList(); if (argumentList == null) return null; final PsiExpression[] arguments = argumentList.getExpressions(); if (arguments.length != 0) { if(arguments.length != 1) return null; final PsiExpression argument = arguments[0]; final PsiType argumentType = argument.getType(); if (!PsiTypes.intType().equals(argumentType)) { joinParts.add(argument); } } Collections.reverse(joinParts); return joinParts; }