Call Hierarchy: Forbid interfaces
#EA-64406 Fixed
This commit is contained in:
@@ -38,7 +38,8 @@ public class HierarchyUtils {
|
||||
input instanceof JetFile ||
|
||||
input instanceof JetNamedFunction ||
|
||||
input instanceof JetSecondaryConstructor ||
|
||||
input instanceof JetClassOrObject ||
|
||||
input instanceof JetObjectDeclaration ||
|
||||
(input instanceof JetClass && !((JetClass) input).isInterface()) ||
|
||||
input instanceof JetProperty;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.idea.hierarchy.HierarchyUtils;
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil;
|
||||
import org.jetbrains.kotlin.psi.JetFile;
|
||||
|
||||
public class KotlinCallHierarchyProvider implements HierarchyProvider {
|
||||
@Override
|
||||
@@ -40,7 +41,10 @@ public class KotlinCallHierarchyProvider implements HierarchyProvider {
|
||||
PsiElement element = getCurrentElement(dataContext, project);
|
||||
if (element == null) return null;
|
||||
|
||||
return HierarchyUtils.getCallHierarchyElement(element);
|
||||
element = HierarchyUtils.getCallHierarchyElement(element);
|
||||
if (element instanceof JetFile) return null;
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
private static PsiElement getCurrentElement(DataContext dataContext, Project project) {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
interface <caret>T
|
||||
|
||||
class A : T {
|
||||
val t: T? = null
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Cannot apply action for element at caret
|
||||
@@ -0,0 +1,5 @@
|
||||
interface <caret>T
|
||||
|
||||
class A : T {
|
||||
val t: T? = null
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Cannot apply action for element at caret
|
||||
@@ -316,6 +316,12 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
|
||||
doCallerHierarchyTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinInterface")
|
||||
public void testKotlinInterface() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callers/kotlinInterface/");
|
||||
doCallerHierarchyTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinLocalClass")
|
||||
public void testKotlinLocalClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callers/kotlinLocalClass/");
|
||||
@@ -457,6 +463,12 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
|
||||
doCalleeHierarchyTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinInterface")
|
||||
public void testKotlinInterface() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callees/kotlinInterface/");
|
||||
doCalleeHierarchyTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinLocalClass")
|
||||
public void testKotlinLocalClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callees/kotlinLocalClass/");
|
||||
|
||||
Reference in New Issue
Block a user