mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
java 8: suggest to add method body for default methods in interface
This commit is contained in:
@@ -874,6 +874,7 @@ public class HighlightMethodUtil {
|
||||
if (hasNoBody) {
|
||||
if (isExtension) {
|
||||
description = JavaErrorMessages.message("extension.method.should.have.a.body");
|
||||
additionalFixes.add(new AddMethodBodyFix(method));
|
||||
}
|
||||
else if (isInterface && isStatic) {
|
||||
description = "Static methods in interfaces should have a body";
|
||||
|
||||
@@ -134,7 +134,7 @@ public class CreateFromUsageUtils {
|
||||
|
||||
JVMElementFactory factory = JVMElementFactories.getFactory(aClass.getLanguage(), aClass.getProject());
|
||||
|
||||
LOG.assertTrue(!aClass.isInterface(), "Interface bodies should be already set up");
|
||||
LOG.assertTrue(!aClass.isInterface() || method.hasModifierProperty(PsiModifier.DEFAULT), "Interface bodies should be already set up");
|
||||
|
||||
FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(template.getExtension());
|
||||
Properties properties = new Properties();
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Add Method Body" "true"
|
||||
interface a {
|
||||
default String f() {
|
||||
<selection>return null;</selection>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// "Add Method Body" "true"
|
||||
interface a {
|
||||
default <caret>String f();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user