IDEA-97548 NPE while change signature of groovy constructor

This commit is contained in:
Max Medvedev
2012-12-14 16:25:51 +04:00
parent bd155e199c
commit fef0eeaf13
2 changed files with 8 additions and 4 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -100,6 +100,8 @@ public abstract class ChangeSignatureDialogBase<
private final Alarm myUpdateSignatureAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
protected VisibilityPanelBase<Visibility> myVisibilityPanel;
@Nullable
protected PsiCodeFragment myReturnTypeCodeFragment;
private DelegationPanel myDelegationPanel;
protected AnActionButton myPropagateParamChangesButton;
@@ -156,7 +156,9 @@ public class GrChangeSignatureDialog extends ChangeSignatureDialogBase<GrParamet
private CanonicalTypes.Type getReturnType() {
PsiType returnType = null;
try {
returnType = ((PsiTypeCodeFragment)myReturnTypeCodeFragment).getType();
if (myReturnTypeCodeFragment != null) {
returnType = ((PsiTypeCodeFragment)myReturnTypeCodeFragment).getType();
}
}
catch (PsiTypeCodeFragment.TypeSyntaxException ignored) {
}
@@ -211,7 +213,7 @@ public class GrChangeSignatureDialog extends ChangeSignatureDialogBase<GrParamet
return message("name.is.wrong", getMethodName());
}
if (!checkType((PsiTypeCodeFragment)myReturnTypeCodeFragment, true)) {
if (myReturnTypeCodeFragment != null && !checkType((PsiTypeCodeFragment)myReturnTypeCodeFragment, true)) {
return message("return.type.is.wrong");
}
@@ -296,7 +298,7 @@ public class GrChangeSignatureDialog extends ChangeSignatureDialogBase<GrParamet
@Override
protected String calculateSignature() {
String name = getMethodName();
String type = myReturnTypeCodeFragment.getText().trim();
String type = myReturnTypeCodeFragment != null ? myReturnTypeCodeFragment.getText().trim() : "";
StringBuilder builder = new StringBuilder();
builder.append(myVisibilityPanel.getVisibility()).append(' ');