make method static: add parameter when method was used in method reference (IDEA-93138)

This commit is contained in:
anna
2012-10-18 13:45:04 +02:00
parent 77d23ad47b
commit 9598ba568c
5 changed files with 64 additions and 15 deletions
@@ -0,0 +1,9 @@
class Test4 {
void test() {
Foo2<Test4> f = Test4::yyy;
}
static void yyy(Test4 anObject) {}
}
interface Foo2<T> {
void bar(T j);
}
@@ -0,0 +1,9 @@
class Test4 {
void test() {
Foo2<Test4> f = Test4::yyy;
}
void yy<caret>y() {}
}
interface Foo2<T> {
void bar(T j);
}
@@ -19,7 +19,6 @@ import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.TargetElementUtilBase;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiTypeParameterListOwner;
import com.intellij.refactoring.makeStatic.MakeMethodStaticProcessor;
import com.intellij.refactoring.makeStatic.MakeStaticUtil;
import com.intellij.refactoring.makeStatic.Settings;
@@ -186,13 +185,21 @@ public class MakeMethodStaticTest extends LightRefactoringTestCase {
assertFalse(MakeStaticUtil.isParameterNeeded((PsiMethod)element));
}
public void testMethodReference() throws Exception {
doTest(true);
}
public void testPreserveParametersAlignment() throws Exception {
doTest();
}
private void doTest() throws Exception {
doTest(false);
}
private void doTest(final boolean addClassParameter) throws Exception {
configureByFile("/refactoring/makeMethodStatic/before" + getTestName(false) + ".java");
perform(false);
perform(addClassParameter);
checkResultByFile("/refactoring/makeMethodStatic/after" + getTestName(false) + ".java");
}