mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
change signature: setup default type value as default type; setup selection
This commit is contained in:
+6
-6
@@ -28,10 +28,7 @@ import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.scope.processor.VariablesProcessor;
|
||||
import com.intellij.psi.scope.util.PsiScopesUtil;
|
||||
import com.intellij.psi.util.MethodSignatureUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.rename.RenameUtil;
|
||||
import com.intellij.refactoring.util.*;
|
||||
@@ -542,7 +539,9 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
if (usageInfo instanceof MethodCallUsageInfo) {
|
||||
MethodCallUsageInfo methodCallUsageInfo = (MethodCallUsageInfo)usageInfo;
|
||||
if (methodCallUsageInfo.isToChangeArguments()){
|
||||
final boolean needDefaultValue = needDefaultValue(changeInfo, RefactoringUtil.getEnclosingMethod(methodCallUsageInfo.getElement()));
|
||||
final PsiElement element = methodCallUsageInfo.getElement();
|
||||
if (element == null) continue;
|
||||
final boolean needDefaultValue = needDefaultValue(changeInfo, RefactoringUtil.getEnclosingMethod(element));
|
||||
if (needDefaultValue) {
|
||||
final ParameterInfo[] parameters = changeInfo.getNewParameters();
|
||||
for (ParameterInfo parameter : parameters) {
|
||||
@@ -550,7 +549,8 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
if (defaultValue == null && parameter.getOldIndex() == -1) {
|
||||
((ParameterInfoImpl)parameter).setDefaultValue("");
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
final DefaultValueChooser chooser = new DefaultValueChooser(project, parameter.getName());
|
||||
final PsiType type = ((ParameterInfoImpl)parameter).getTypeWrapper().getType(element, element.getManager());
|
||||
final DefaultValueChooser chooser = new DefaultValueChooser(project, parameter.getName(), PsiTypesUtil.getDefaultValueOfType(type));
|
||||
chooser.show();
|
||||
if (chooser.isOK()) {
|
||||
if (chooser.feelLucky()) {
|
||||
|
||||
+4
-2
@@ -2,7 +2,7 @@
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.refactoring.changeSignature.DefaultValueChooser">
|
||||
<grid id="27dc6" binding="myWholePanel" layout-manager="GridBagLayout">
|
||||
<constraints>
|
||||
<xy x="8" y="296" width="898" height="428"/>
|
||||
<xy x="258" y="615" width="592" height="231"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -72,7 +72,9 @@
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag top="0" left="20" bottom="0" right="0" weightx="1.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<properties>
|
||||
<minimumSize width="10" height="24"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
|
||||
+6
-1
@@ -38,13 +38,17 @@ public class DefaultValueChooser extends DialogWrapper{
|
||||
private JPanel myWholePanel;
|
||||
private JLabel myBlankDescription;
|
||||
|
||||
public DefaultValueChooser(Project project, String name) {
|
||||
public DefaultValueChooser(Project project, String name, String defaultValue) {
|
||||
super(project);
|
||||
new RadioUpDownListener(myLeaveBlankRadioButton, myFeelLuckyRadioButton, myUseValueRadioButton);
|
||||
final ActionListener actionListener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
myValueEditor.setEnabled(myUseValueRadioButton.isSelected());
|
||||
if (myUseValueRadioButton.isSelected()) {
|
||||
myValueEditor.selectAll();
|
||||
myValueEditor.requestFocus();
|
||||
}
|
||||
}
|
||||
};
|
||||
myLeaveBlankRadioButton.addActionListener(actionListener);
|
||||
@@ -58,6 +62,7 @@ public class DefaultValueChooser extends DialogWrapper{
|
||||
"Blank place would be used otherwise");
|
||||
myFeelLuckyDescription.setUI(new MultiLineLabelUI());
|
||||
myBlankDescription.setUI(new MultiLineLabelUI());
|
||||
myValueEditor.setText(defaultValue);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user