suggest implements->extends for interfaces hierarchy (IDEA-89867)

This commit is contained in:
Anna Kozlova
2012-09-14 14:54:25 +04:00
parent fd644a7299
commit da098b2a31
3 changed files with 19 additions and 1 deletions
@@ -49,7 +49,11 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.jsp.jspJava.JspClass;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.util.*;
import com.intellij.refactoring.typeMigration.TypeMigrationLabeler;
import com.intellij.refactoring.typeMigration.TypeMigrationProcessor;
import com.intellij.refactoring.typeMigration.TypeMigrationRules;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -401,7 +405,13 @@ public class HighlightClassUtil {
if (aClass.isInterface()) {
boolean isImplements = list.equals(aClass.getImplementsList());
if (isImplements) {
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, list, JavaErrorMessages.message("implements.after.interface"));
final HighlightInfo highlightInfo =
HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, list, JavaErrorMessages.message("implements.after.interface"));
final PsiClassType[] referencedTypes = list.getReferencedTypes();
if (referencedTypes.length > 0) {
QuickFixAction.registerQuickFixAction(highlightInfo, new ChangeExtendsToImplementsFix(aClass, referencedTypes[0]));
}
return highlightInfo;
}
}
}
@@ -0,0 +1,4 @@
// "Change 'implements Runnable' to 'extends Runnable'" "true"
interface a extends Runnable {
}
@@ -0,0 +1,4 @@
// "Change 'implements Runnable' to 'extends Runnable'" "true"
interface a implements <caret>Runnable {
}