From 55daee04cb7b41a33ba126a7da9ee4bc1651f1b3 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Sun, 1 Apr 2012 15:16:10 +0400 Subject: [PATCH] fixed PY-6102 Call to constructor of super is missed --- .../python/actions/AddCallSuperQuickFix.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/actions/AddCallSuperQuickFix.java b/python/src/com/jetbrains/python/actions/AddCallSuperQuickFix.java index 26dda42142dd..0abb903eecb7 100644 --- a/python/src/com/jetbrains/python/actions/AddCallSuperQuickFix.java +++ b/python/src/com/jetbrains/python/actions/AddCallSuperQuickFix.java @@ -130,7 +130,27 @@ public class AddCallSuperQuickFix implements LocalQuickFix { } superCall.append(")"); - newFunction.append("):\n\t").append(superCall).append("\n\t").append(problemFunction.getStatementList().getText()); + final PyStatementList statementList = problemFunction.getStatementList(); + PyExpression docstring = null; + final PyStatement[] statements = statementList.getStatements(); + if (statements.length != 0 && statements[0] instanceof PyExpressionStatement) { + PyExpressionStatement st = (PyExpressionStatement)statements[0]; + if (st.getExpression() instanceof PyStringLiteralExpression) + docstring = st.getExpression(); + } + + newFunction.append("):\n\t"); + if (docstring != null) + newFunction.append(docstring.getText()).append("\n\t"); + newFunction.append(superCall).append("\n\t"); + boolean first = true; + for (PyStatement statement : statements) { + if (first && docstring != null) { + first = false; + continue; + } + newFunction.append(statement.getText()).append("\n\t"); + } problemFunction.replace( PyElementGenerator.getInstance(project).createFromText(LanguageLevel.forElement(problemFunction), PyFunction.class,