prevent possible NPE

This commit is contained in:
anna
2011-06-29 18:52:47 +04:00
parent 570b173341
commit 5510997e7f
2 changed files with 9 additions and 6 deletions
@@ -200,12 +200,13 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
}
@Override
protected void updateTitle(PsiVariable variable) {
protected void updateTitle(@Nullable PsiVariable variable) {
if (variable == null) return;
updateTitle(variable, variable.getName());
}
@Override
protected void updateTitle(PsiVariable variable, String value) {
protected void updateTitle(@Nullable PsiVariable variable, String value) {
final PsiElement declarationScope = variable != null ? ((PsiParameter)variable).getDeclarationScope() : null;
if (declarationScope instanceof PsiMethod) {
final PsiMethod psiMethod = (PsiMethod)declarationScope;
@@ -226,8 +227,8 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
myLabel.append(variable == parameter ? value : parameter.getName(), attr);
}
myLabel.append(")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
revalidate();
}
revalidate();
}
@Override
@@ -72,7 +72,7 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNameIdentifierOwner
protected String myConstantName;
public static final Key<AbstractInplaceIntroducer> ACTIVE_INTRODUCE = Key.create("ACTIVE_INTRODUCE");
protected SimpleColoredComponent myLabel = new SimpleColoredComponent();
protected final SimpleColoredComponent myLabel = new SimpleColoredComponent();
private DocumentAdapter myDocumentAdapter;
protected final JPanel myWholePanel;
@@ -190,13 +190,15 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNameIdentifierOwner
return result.get();
}
protected void updateTitle(V variable, String value) {
protected void updateTitle(@Nullable V variable, String value) {
if (variable == null) return;
myLabel.clear();
myLabel.append(variable.getText().replace(variable.getName(), value), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
revalidate();
}
protected void updateTitle(V variable) {
protected void updateTitle(@Nullable V variable) {
if (variable == null) return;
myLabel.clear();
myLabel.append(variable.getText(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
revalidate();