mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
extract method: add default modifier when extracted into interface (java 8 only)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
interface I {
|
||||
default void foo () {
|
||||
<selection>System.out.println("hello");</selection>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
interface I {
|
||||
default void foo () {
|
||||
newMethod();
|
||||
}
|
||||
|
||||
private default void newMethod() {
|
||||
System.out.println("hello");
|
||||
}
|
||||
}
|
||||
@@ -550,6 +550,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMethod2Interface() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testParamDetection() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user