This commit is contained in:
Alexey Kudravtsev
2011-03-25 11:09:56 +03:00
parent af572b3a95
commit 97a99dbbc6
2 changed files with 8 additions and 5 deletions
@@ -139,7 +139,10 @@ public class CreateConstructorParameterFromFieldFix implements IntentionAction {
// do not introduce assignment in chanined constructor
if (HighlightControlFlowUtil.getChainedConstructors(constructor) == null) {
AssignFieldFromParameterAction.addFieldAssignmentStatement(project, getField(), parameter, editor);
PsiField field = getField();
if (field != null) {
AssignFieldFromParameterAction.addFieldAssignmentStatement(project, field, parameter, editor);
}
}
return true;
}
@@ -87,10 +87,10 @@ public class AssignFieldFromParameterAction extends BaseIntentionAction {
}
}
public static void addFieldAssignmentStatement(final Project project,
final PsiField field,
final PsiParameter parameter,
final Editor editor) throws IncorrectOperationException {
public static void addFieldAssignmentStatement(@NotNull Project project,
@NotNull PsiField field,
@NotNull PsiParameter parameter,
@NotNull Editor editor) throws IncorrectOperationException {
final PsiMethod method = (PsiMethod)parameter.getDeclarationScope();
PsiCodeBlock methodBody = method.getBody();
if (methodBody == null) return;