mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extract method: do not suggest primitive type when 'return null;' should be inserted
This commit is contained in:
@@ -31,6 +31,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.ui.*;
|
||||
import com.intellij.refactoring.util.ConflictsUtil;
|
||||
@@ -241,6 +242,9 @@ public class ExtractMethodDialog extends DialogWrapper implements AbstractExtrac
|
||||
|
||||
@Nullable
|
||||
private JPanel createReturnTypePanel() {
|
||||
if (TypeConversionUtil.isPrimitiveWrapper(myReturnType) && myNullness == Nullness.NULLABLE) {
|
||||
return null;
|
||||
}
|
||||
mySelector = new TypeSelectorManagerImpl(myProject, myReturnType, findOccurrences(), areTypesDirected()).getTypeSelector();
|
||||
final JComponent component = mySelector.getComponent();
|
||||
if (component instanceof JComboBox) {
|
||||
@@ -532,7 +536,7 @@ public class ExtractMethodDialog extends DialogWrapper implements AbstractExtrac
|
||||
buffer.append(myTargetClass.getName());
|
||||
}
|
||||
else {
|
||||
buffer.append(PsiFormatUtil.formatType(mySelector.getSelectedType(), 0, PsiSubstitutor.EMPTY));
|
||||
buffer.append(PsiFormatUtil.formatType(mySelector != null ? mySelector.getSelectedType() : myReturnType, 0, PsiSubstitutor.EMPTY));
|
||||
buffer.append(" ");
|
||||
buffer.append(myNameField.getText());
|
||||
}
|
||||
@@ -602,6 +606,6 @@ public class ExtractMethodDialog extends DialogWrapper implements AbstractExtrac
|
||||
}
|
||||
|
||||
public PsiType getReturnType() {
|
||||
return mySelector.getSelectedType();
|
||||
return mySelector != null ? mySelector.getSelectedType() : myReturnType;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user