do not insert initial method comments in delegate with default param value (IDEA-81106)

This commit is contained in:
anna
2012-02-09 18:51:11 +01:00
parent 45654bcffd
commit b13cd651dc
3 changed files with 27 additions and 7 deletions
@@ -65,16 +65,14 @@ public class DelegateWithDefaultParamValueIntentionAction extends PsiElementBase
private static PsiMethod generateMethodPrototype(PsiMethod method, PsiParameter param) {
final PsiMethod prototype = (PsiMethod)method.copy();
PsiCodeBlock body = prototype.getBody();
final PsiCodeBlock body = prototype.getBody();
final PsiCodeBlock emptyBody = JavaPsiFacade.getElementFactory(method.getProject()).createMethodFromText("void foo(){}", prototype).getBody();
assert emptyBody != null;
if (body != null) {
for (PsiStatement psiStatement : body.getStatements()) {
psiStatement.delete();
}
body.replace(emptyBody);
} else {
prototype.getModifierList().setModifierProperty(PsiModifier.ABSTRACT, false);
body =
(PsiCodeBlock)prototype
.addBefore(JavaPsiFacade.getElementFactory(method.getProject()).createMethodFromText("void foo(){}", prototype).getBody(), null);
prototype.addBefore(emptyBody, null);
}
final int parameterIndex = method.getParameterList().getParameterIndex(param);
prototype.getParameterList().getParameters()[parameterIndex].delete();