mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
replace underscore with type-based-name if parameter name is underscore (IDEA-165093)
This commit is contained in:
@@ -95,7 +95,7 @@ public class LambdaRefactoringUtil {
|
||||
baseName = nameInfo.names.length > 0 ? nameInfo.names[0] : parameter.getName();
|
||||
}
|
||||
else {
|
||||
final String initialName;
|
||||
String initialName;
|
||||
if (psiParameters != null) {
|
||||
final int idx = parameterIndex - (isReceiver ? 1 : 0);
|
||||
initialName = psiParameters.length > 0 ? psiParameters[idx < psiParameters.length ? idx : psiParameters.length - 1].getName()
|
||||
@@ -105,6 +105,12 @@ public class LambdaRefactoringUtil {
|
||||
initialName = parameter.getName();
|
||||
}
|
||||
LOG.assertTrue(initialName != null);
|
||||
if ("_".equals(initialName)) {
|
||||
SuggestedNameInfo nameInfo = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, null, null, psiSubstitutor.substitute(parameter.getType()));
|
||||
if (nameInfo.names.length > 0) {
|
||||
initialName = nameInfo.names[0];
|
||||
}
|
||||
}
|
||||
baseName = codeStyleManager.variableNameToPropertyName(initialName, VariableKind.PARAMETER);
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import java.util.function.IntConsumer;
|
||||
|
||||
public class Main {
|
||||
void test(int _) {};
|
||||
|
||||
IntConsumer c = i -> test(i);
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import java.util.function.IntConsumer;
|
||||
|
||||
public class Main {
|
||||
void test(int _) {};
|
||||
|
||||
IntConsumer c = this::te<caret>st;
|
||||
}
|
||||
+4
@@ -130,4 +130,8 @@ public class MethodRefCanBeReplacedWithLambdaFixTest extends IGQuickFixesTestCas
|
||||
public void testPreserveExpressionQualifier() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNoUnderscoreInLambdaParameterName() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user