IPP: make method default cosmetics

This commit is contained in:
Bas Leijdekkers
2017-05-19 19:12:56 +02:00
parent 3592c743fb
commit 47158b16f5
5 changed files with 13 additions and 7 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2011 Bas Leijdekkers
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,10 +26,13 @@ import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
public class MakeMethodDefaultIntention extends BaseElementAtCaretIntentionAction {
private String text = "Make method default";
@NotNull
@Override
public String getText() {
return "Make method default";
return text;
}
@NotNull
@@ -44,7 +47,10 @@ public class MakeMethodDefaultIntention extends BaseElementAtCaretIntentionActio
if (psiMethod != null && PsiUtil.isLanguageLevel8OrHigher(psiMethod)) {
if (psiMethod.getBody() == null && !psiMethod.hasModifierProperty(PsiModifier.DEFAULT)) {
final PsiClass containingClass = psiMethod.getContainingClass();
return containingClass != null && containingClass.isInterface();
if (containingClass != null && containingClass.isInterface()) {
text = "Make '" + psiMethod.getName() + "()' default";
return true;
}
}
}
return false;
@@ -1,3 +1,3 @@
public interface X {
default void foo(){}
default void foo() {}
}
@@ -1,3 +1,3 @@
public interface X {
<spot>void foo()</spot>
<spot>void foo();</spot>
}
@@ -1,6 +1,6 @@
<html>
<body>
This intention adds default modifier and body to method in interface
Adds a default modifier and body to a method in an interface.
<!-- tooltip end -->
</body>
</html>
@@ -22,7 +22,7 @@ public class MakeMethodDefaultTest extends IPPTestCase {
@Override
protected String getIntentionName() {
return "Make method default";
return "Make 'foo()' default";
}
@Override