mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
allow override method suggestions on method name only
This commit is contained in:
+13
-1
@@ -54,7 +54,9 @@ public class ImplementAbstractMethodAction extends BaseIntentionAction {
|
||||
|
||||
PsiClass containingClass = method.getContainingClass();
|
||||
if (containingClass == null) return false;
|
||||
if (method.hasModifierProperty(PsiModifier.ABSTRACT) || !method.hasModifierProperty(PsiModifier.PRIVATE)) {
|
||||
final boolean isAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT);
|
||||
if (isAbstract || !method.hasModifierProperty(PsiModifier.PRIVATE)) {
|
||||
if (!isAbstract && !isOnIdentifier(file, offset)) return false;
|
||||
MyElementProcessor processor = new MyElementProcessor(method);
|
||||
if (containingClass.isEnum()) {
|
||||
for (PsiField field : containingClass.getFields()) {
|
||||
@@ -78,6 +80,16 @@ public class ImplementAbstractMethodAction extends BaseIntentionAction {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isOnIdentifier(PsiFile file, int offset) {
|
||||
final PsiElement psiElement = file.findElementAt(offset);
|
||||
if (psiElement instanceof PsiIdentifier){
|
||||
if (psiElement.getParent() instanceof PsiMethod) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected String getIntentionName(final PsiMethod method) {
|
||||
return method.hasModifierProperty(PsiModifier.ABSTRACT) ?
|
||||
CodeInsightBundle.message("intention.implement.abstract.method.text", method.getName()) :
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Override method 'foo'" "false"
|
||||
class Test {
|
||||
protected void foo(){<caret>}
|
||||
}
|
||||
|
||||
class TImple extends Test {}
|
||||
Reference in New Issue
Block a user