mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: Ignore bare method expression (without parentheses) when matching potential parameters of extracted method (IDEA-194264)
This commit is contained in:
@@ -126,6 +126,8 @@ public final class Match {
|
||||
final List<PsiElement> currentValue = myParameterValues.get(psiVariable);
|
||||
final boolean isVararg = psiVariable instanceof PsiParameter && ((PsiParameter)psiVariable).isVarArgs();
|
||||
if (!(value instanceof PsiExpression)) return false;
|
||||
final PsiElement parent = value.getParent();
|
||||
if (parent instanceof PsiMethodCallExpression && value == ((PsiMethodCallExpression)parent).getMethodExpression()) return false;
|
||||
final PsiType type = ((PsiExpression)value).getType();
|
||||
final PsiType parameterType = parameter.getType();
|
||||
if (type == null) return false;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import java.util.List;
|
||||
|
||||
class C {
|
||||
void m(List<String> list) {
|
||||
int i = 0;
|
||||
System.out.println(<selection>i</selection>);
|
||||
|
||||
if (list.size() > 0) {
|
||||
System.out.println(list.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import java.util.List;
|
||||
|
||||
class C {
|
||||
void m(List<String> list) {
|
||||
int i = 0;
|
||||
System.out.println(newMethod(i));
|
||||
|
||||
if (list.size() > 0) {
|
||||
System.out.println(list.size());
|
||||
}
|
||||
}
|
||||
|
||||
private int newMethod(int i) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
class Test {
|
||||
void t(java.util.Map<String, String> m) {
|
||||
String f = "";
|
||||
System.out.println("f = " + newMethod(f) + ", " + newMethod(newMethod(f)));
|
||||
System.out.println("f = " + newMethod(f) + ", " + m.get(newMethod(f)));
|
||||
}
|
||||
|
||||
private String newMethod(String f) {
|
||||
|
||||
@@ -1321,6 +1321,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doDuplicatesTest();
|
||||
}
|
||||
|
||||
public void testOneVariableExpression() throws Exception {
|
||||
doDuplicatesTest();
|
||||
}
|
||||
|
||||
public void testInterfaceMethodVisibility() throws Exception {
|
||||
final String doesNotExist = "foo.bar.baz.DoesNotExist";
|
||||
final NullableNotNullManager nullManager = NullableNotNullManager.getInstance(getProject());
|
||||
|
||||
Reference in New Issue
Block a user