mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 21:41:24 +07:00
IDEA-137719 Complete current statement doesn't insert a method body for static methods in interfaces, creates broken code
This commit is contained in:
@@ -67,7 +67,7 @@ public class MissingMethodBodyFixer implements Fixer {
|
||||
static boolean shouldHaveBody(PsiMethod method) {
|
||||
PsiClass containingClass = method.getContainingClass();
|
||||
if (containingClass == null) return false;
|
||||
if (containingClass.isInterface() && !method.hasModifierProperty(DEFAULT)) return false;
|
||||
if (containingClass.isInterface() && !method.hasModifierProperty(DEFAULT) && !method.hasModifierProperty(STATIC)) return false;
|
||||
if (method.hasModifierProperty(ABSTRACT)) return false;
|
||||
return !method.hasModifierProperty(NATIVE);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
public interface Foo {
|
||||
static void foo(<caret>)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
public interface Foo {
|
||||
static void foo() {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ package com.intellij.codeInsight;
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.testFramework.EditorActionTestCase;
|
||||
@@ -272,6 +271,7 @@ public class CompleteStatementTest extends EditorActionTestCase {
|
||||
public void testGenericMethodBody() throws Exception { doTest(); }
|
||||
|
||||
public void testDefaultMethodBody() { doTest(); }
|
||||
public void testStaticInterfaceMethodBody() { doTest(); }
|
||||
|
||||
public void testArrayInitializerRBracket() throws Exception { doTest(); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user