fixed PY-2518 Join 2 ifs: merge comments if both presented

This commit is contained in:
Ekaterina Tuzova
2010-12-17 11:39:29 +03:00
parent 07764c98cb
commit cd1889b6ba
2 changed files with 2 additions and 3 deletions
@@ -59,8 +59,6 @@ public class PyConvertLambdaToFunctionIntention extends BaseIntentionAction {
functionBuilder.statement("return " + body.getText());
PyFunction function = functionBuilder.buildFunction(project);
PyFunction parentFunction = PsiTreeUtil.getTopmostParentOfType(lambdaExpression, PyFunction.class);
if (parentFunction != null ) {
PyClass parentClass = PsiTreeUtil.getTopmostParentOfType(parentFunction, PyClass.class);
@@ -75,12 +75,13 @@ public class PyJoinIfIntention extends BaseIntentionAction {
List<PsiComment> comments = PsiTreeUtil.getChildrenOfTypeAsList(ifStatement.getIfPart(), PsiComment.class);
comments.addAll(PsiTreeUtil.getChildrenOfTypeAsList(((PyIfStatement)firstStatement).getIfPart(), PsiComment.class));
comments.addAll(PsiTreeUtil.getChildrenOfTypeAsList(ifStatementList, PsiComment.class));
comments.addAll(PsiTreeUtil.getChildrenOfTypeAsList(stList, PsiComment.class));
for (PsiElement comm : comments) {
ifStatement.getIfPart().addBefore(comm, ifStatementList);
comm.delete();
}
ifStatementList.replace(stList);
}
}