String (PyElementGenerator generator) { StringBuilder builder = new StringBuilder(); for (String decorator : myDecorators) { final StringBuilder decoratorAppender = builder.append('@' + decorator); if (myDecoratorValues.containsKey(decorator)) { final PyCallExpression fakeCall = generator.createCallExpression(LanguageLevel.forElement(mySettingAnchor), "fakeFunction"); fakeCall.getArgumentList().addArgument(generator.createStringLiteralFromString(myDecoratorValues.get(decorator))); decoratorAppender.append(fakeCall.getArgumentList().getText()); } decoratorAppender.append("\n"); } if (myAsync) { builder.append("async "); } builder.append("def "); builder.append(myName).append("("); builder.append(StringUtil.join(myParameters, ", ")); builder.append(")"); if (myAnnotation != null) { builder.append(myAnnotation); } builder.append(":"); List<String> statements = myStatements.isEmpty() ? Collections.singletonList(PyNames.PASS) : myStatements; final String indent = PyIndentUtil.getIndentFromSettings(mySettingAnchor.getContainingFile()); // There was original docstring or some parameters were added via parameterWithType() if (!myDocStringGenerator.isNewMode() || myDocStringGenerator.hasParametersToAdd()) { final String docstring = PyIndentUtil.changeIndent(myDocStringGenerator.buildDocString(), true, indent); builder.append('\n').append(indent).append(docstring); } for (String statement : statements) { builder.append('\n').append(indent).append(statement); } return builder.toString(); }