Allow user to find usages of overriden methods
This commit is contained in:
@@ -265,3 +265,4 @@ choose.the.ones.you.want.to.be.deleted=Choose the ones you want to be deleted.
|
|||||||
method.column=Member
|
method.column=Member
|
||||||
delete.param.in.method.hierarchy={0} is a part of method hierarchy. Do you want to delete multiple parameters?
|
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 com.intellij.psi.PsiElement;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.psi.JetClass;
|
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.lang.psi.JetNamedFunction;
|
||||||
import org.jetbrains.jet.plugin.findUsages.handlers.KotlinFindClassUsagesHandler;
|
import org.jetbrains.jet.plugin.findUsages.handlers.KotlinFindClassUsagesHandler;
|
||||||
import org.jetbrains.jet.plugin.findUsages.handlers.KotlinFindFunctionUsagesHandler;
|
import org.jetbrains.jet.plugin.findUsages.handlers.KotlinFindFunctionUsagesHandler;
|
||||||
|
import org.jetbrains.jet.plugin.refactoring.JetRefactoringUtil;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
public class KotlinFindUsagesHandlerFactory extends FindUsagesHandlerFactory {
|
public class KotlinFindUsagesHandlerFactory extends FindUsagesHandlerFactory {
|
||||||
@Override
|
@Override
|
||||||
@@ -38,6 +41,16 @@ public class KotlinFindUsagesHandlerFactory extends FindUsagesHandlerFactory {
|
|||||||
return new KotlinFindClassUsagesHandler((JetClass) element, this);
|
return new KotlinFindClassUsagesHandler((JetClass) element, this);
|
||||||
}
|
}
|
||||||
if (element instanceof JetNamedFunction) {
|
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);
|
return new KotlinFindFunctionUsagesHandler((JetNamedFunction) element, this);
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("unexpected element type: " + element);
|
throw new IllegalArgumentException("unexpected element type: " + element);
|
||||||
|
|||||||
+10
@@ -20,7 +20,17 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||||
import org.jetbrains.jet.plugin.findUsages.KotlinFindUsagesHandlerFactory;
|
import org.jetbrains.jet.plugin.findUsages.KotlinFindUsagesHandlerFactory;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
public class KotlinFindFunctionUsagesHandler extends KotlinFindUsagesHandler<JetNamedFunction> {
|
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) {
|
public KotlinFindFunctionUsagesHandler(@NotNull JetNamedFunction function, @NotNull KotlinFindUsagesHandlerFactory factory) {
|
||||||
super(function, factory);
|
super(function, factory);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user