java 8: suggest to add method body for default methods in interface

This commit is contained in:
Anna Kozlova
2013-06-25 21:03:07 +04:00
parent a00aac060c
commit e9924f79c4
4 changed files with 14 additions and 1 deletions

View File

@@ -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";

View File

@@ -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();

View File

@@ -0,0 +1,7 @@
// "Add Method Body" "true"
interface a {
default String f() {
<selection>return null;</selection>
}
}

View File

@@ -0,0 +1,5 @@
// "Add Method Body" "true"
interface a {
default <caret>String f();
}