extract method: add default modifier when extracted into interface (java 8 only)

This commit is contained in:
anna
2012-12-17 20:19:27 +01:00
parent 746ed966f9
commit 3afa9c526d
4 changed files with 21 additions and 0 deletions

View File

@@ -1048,6 +1048,9 @@ public class ExtractMethodProcessor implements MatchProvider {
}
}
if (myTargetClass.isInterface() && PsiUtil.isLanguageLevel8OrHigher(myTargetClass)) {
PsiUtil.setModifierProperty(newMethod, PsiModifier.DEFAULT, true);
}
return (PsiMethod)myStyleManager.reformat(newMethod);
}

View File

@@ -0,0 +1,5 @@
interface I {
default void foo () {
<selection>System.out.println("hello");</selection>
}
}

View File

@@ -0,0 +1,9 @@
interface I {
default void foo () {
newMethod();
}
private default void newMethod() {
System.out.println("hello");
}
}

View File

@@ -550,6 +550,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
doTest();
}
public void testMethod2Interface() throws Exception {
doTest();
}
public void testParamDetection() throws Exception {
doTest();
}