Allow user to find usages of overriden methods

This commit is contained in:
Alexey Sedunov
2013-08-05 16:16:00 +04:00
parent 76d8e8b95d
commit 64a7e93900
3 changed files with 26 additions and 2 deletions
@@ -264,4 +264,5 @@ there.are.unused.methods.that.override.methods.you.delete=There are unused membe
choose.the.ones.you.want.to.be.deleted=Choose the ones you want to be deleted.
method.column=Member
delete.param.in.method.hierarchy={0} is a part of method hierarchy. Do you want to delete multiple parameters?
super.methods.delete.with.usage.search=delete (with usage search)
super.methods.delete.with.usage.search=delete (with usage search)
super.methods.action.key.find.usages=find usages of
@@ -21,10 +21,13 @@ import com.intellij.find.findUsages.FindUsagesHandlerFactory;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetClass;
import org.jetbrains.jet.lang.psi.JetFunction;
import org.jetbrains.jet.lang.psi.JetDeclaration;
import org.jetbrains.jet.lang.psi.JetNamedFunction;
import org.jetbrains.jet.plugin.findUsages.handlers.KotlinFindClassUsagesHandler;
import org.jetbrains.jet.plugin.findUsages.handlers.KotlinFindFunctionUsagesHandler;
import org.jetbrains.jet.plugin.refactoring.JetRefactoringUtil;
import java.util.Collection;
public class KotlinFindUsagesHandlerFactory extends FindUsagesHandlerFactory {
@Override
@@ -38,6 +41,16 @@ public class KotlinFindUsagesHandlerFactory extends FindUsagesHandlerFactory {
return new KotlinFindClassUsagesHandler((JetClass) element, this);
}
if (element instanceof JetNamedFunction) {
if (!forHighlightUsages) {
Collection<? extends PsiElement> methods =
JetRefactoringUtil.checkSuperMethods((JetDeclaration) element, null, "super.methods.action.key.find.usages");
if (methods == null || methods.isEmpty()) return FindUsagesHandler.NULL_HANDLER;
if (methods.size() > 1) {
return new KotlinFindFunctionUsagesHandler((JetNamedFunction) element, methods, this);
}
}
return new KotlinFindFunctionUsagesHandler((JetNamedFunction) element, this);
}
throw new IllegalArgumentException("unexpected element type: " + element);
@@ -20,7 +20,17 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetNamedFunction;
import org.jetbrains.jet.plugin.findUsages.KotlinFindUsagesHandlerFactory;
import java.util.Collection;
public class KotlinFindFunctionUsagesHandler extends KotlinFindUsagesHandler<JetNamedFunction> {
public KotlinFindFunctionUsagesHandler(
@NotNull JetNamedFunction function,
@NotNull Collection<? extends PsiElement> elementsToSearch,
@NotNull KotlinFindUsagesHandlerFactory factory
) {
super(function, elementsToSearch, factory);
}
public KotlinFindFunctionUsagesHandler(@NotNull JetNamedFunction function, @NotNull KotlinFindUsagesHandlerFactory factory) {
super(function, factory);
}