String (@Nullable PsiMethod psiMethod, @NotNull PsiClass psiClass, @NotNull PsiType buildMethodReturnType, @NotNull String buildMethodPrepare, @NotNull String buildMethodParameters) { final String blockText; final String codeBlockFormat, callExpressionText; if (null == psiMethod || psiMethod.isConstructor()) { codeBlockFormat = "%s\n return new %s(%s);"; callExpressionText = buildMethodReturnType.getPresentableText(); } else { if (PsiTypes.voidType().equals(buildMethodReturnType)) { codeBlockFormat = "%s\n %s(%s);"; } else { codeBlockFormat = "%s\n return %s(%s);"; } callExpressionText = calculateCallExpressionForMethod(psiMethod, psiClass); } blockText = String.format(codeBlockFormat, buildMethodPrepare, callExpressionText, buildMethodParameters); return blockText; }