This commit is contained in:
Alexey Kudravtsev
2014-10-06 17:22:41 +04:00
parent cfcc46a9c0
commit b9a02c8cfc
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -31,7 +31,6 @@ import org.jetbrains.annotations.NotNull;
* @author ven
*/
public class AddOverrideAnnotationAction implements IntentionAction {
private static final String JAVA_LANG_OVERRIDE = "java.lang.Override";
@Override
@NotNull
@@ -51,11 +50,11 @@ public class AddOverrideAnnotationAction implements IntentionAction {
if (!file.getManager().isInProject(file)) return false;
PsiMethod method = findMethod(file, editor.getCaretModel().getOffset());
if (method == null) return false;
if (method.getModifierList().findAnnotation(JAVA_LANG_OVERRIDE) != null) return false;
if (method.getModifierList().findAnnotation(CommonClassNames.JAVA_LANG_OVERRIDE) != null) return false;
PsiMethod[] superMethods = method.findSuperMethods();
for (PsiMethod superMethod : superMethods) {
if (!superMethod.hasModifierProperty(PsiModifier.ABSTRACT)
&& new AddAnnotationFix(JAVA_LANG_OVERRIDE, method).isAvailable(project, editor, file)) {
&& new AddAnnotationFix(CommonClassNames.JAVA_LANG_OVERRIDE, method).isAvailable(project, editor, file)) {
return true;
}
}
@@ -67,7 +66,7 @@ public class AddOverrideAnnotationAction implements IntentionAction {
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
PsiMethod method = findMethod(file, editor.getCaretModel().getOffset());
if (method != null) {
new AddAnnotationFix(JAVA_LANG_OVERRIDE, method).invoke(project, editor, file);
new AddAnnotationFix(CommonClassNames.JAVA_LANG_OVERRIDE, method).invoke(project, editor, file);
}
}