Implement "Override hierarchy" view
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
<root>
|
||||||
|
<item name='com.intellij.ide.hierarchy.HierarchyBrowserBase myProject'>
|
||||||
|
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||||
|
</item>
|
||||||
|
<item name='com.intellij.ide.hierarchy.HierarchyBrowserBaseEx javax.swing.JTree createTree(boolean)'>
|
||||||
|
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||||
|
</item>
|
||||||
|
<item name='com.intellij.ide.hierarchy.HierarchyBrowserBaseEx myBuilders'>
|
||||||
|
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||||
|
</item>
|
||||||
|
<item name='com.intellij.ide.hierarchy.HierarchyBrowserBaseEx void createTrees(java.util.Map<java.lang.String,javax.swing.JTree>)'>
|
||||||
|
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
|
||||||
|
<val name="value" val=""fun createTrees(trees: MutableMap<String, JTree>): Unit""/>
|
||||||
|
</annotation>
|
||||||
|
</item>
|
||||||
|
<item name='com.intellij.ide.hierarchy.HierarchyBrowserBaseEx void prependActions(com.intellij.openapi.actionSystem.DefaultActionGroup)'>
|
||||||
|
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
|
||||||
|
<val name="value" val=""fun prependActions(actionGroup: DefaultActionGroup): Unit""/>
|
||||||
|
</annotation>
|
||||||
|
</item>
|
||||||
|
<item name='com.intellij.ide.hierarchy.HierarchyNodeDescriptor myHighlightedText'>
|
||||||
|
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||||
|
</item>
|
||||||
|
<item
|
||||||
|
name='com.intellij.ide.hierarchy.HierarchyProvider com.intellij.ide.hierarchy.HierarchyBrowser createHierarchyBrowser(com.intellij.psi.PsiElement)'>
|
||||||
|
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
|
||||||
|
<val name="value" val=""fun createHierarchyBrowser(target: PsiElement): HierarchyBrowser""/>
|
||||||
|
</annotation>
|
||||||
|
</item>
|
||||||
|
</root>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<root>
|
||||||
|
<item name='com.intellij.ide.hierarchy.method.MethodHierarchyNodeDescriptor com.intellij.psi.PsiClass getPsiClass()'>
|
||||||
|
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||||
|
</item>
|
||||||
|
</root>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<root>
|
||||||
|
<item
|
||||||
|
name='com.intellij.ide.hierarchy.type.TypeHierarchyBrowser void prependActions(com.intellij.openapi.actionSystem.DefaultActionGroup)'>
|
||||||
|
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
|
||||||
|
<val name="value" val=""fun prependActions(actionGroup: DefaultActionGroup): Unit""/>
|
||||||
|
</annotation>
|
||||||
|
</item>
|
||||||
|
</root>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<root>
|
||||||
|
<item name='com.intellij.ide.util.treeView.SmartElementDescriptor myElement'>
|
||||||
|
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||||
|
</item>
|
||||||
|
</root>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<root>
|
||||||
|
<item name='com.intellij.openapi.actionSystem.AnAction com.intellij.openapi.actionSystem.ShortcutSet getShortcutSet()'>
|
||||||
|
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||||
|
</item>
|
||||||
|
<item name='com.intellij.openapi.actionSystem.AnAction ourEmptyShortcutSet'>
|
||||||
|
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||||
|
</item>
|
||||||
|
</root>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<root>
|
||||||
|
<item
|
||||||
|
name='com.intellij.openapi.roots.ui.util.CompositeAppearance com.intellij.openapi.roots.ui.util.CompositeAppearance.DequeEnd getBeginning()'>
|
||||||
|
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||||
|
</item>
|
||||||
|
</root>
|
||||||
@@ -339,6 +339,7 @@ fun main(args: Array<String>) {
|
|||||||
model("hierarchy/class/sub", extension = null, recursive = false, testMethod = "doSubClassHierarchyTest")
|
model("hierarchy/class/sub", extension = null, recursive = false, testMethod = "doSubClassHierarchyTest")
|
||||||
model("hierarchy/calls/callers", extension = null, recursive = false, testMethod = "doCallerHierarchyTest")
|
model("hierarchy/calls/callers", extension = null, recursive = false, testMethod = "doCallerHierarchyTest")
|
||||||
model("hierarchy/calls/callees", extension = null, recursive = false, testMethod = "doCalleeHierarchyTest")
|
model("hierarchy/calls/callees", extension = null, recursive = false, testMethod = "doCalleeHierarchyTest")
|
||||||
|
model("hierarchy/overrides", extension = null, recursive = false, testMethod = "doOverrideHierarchyTest")
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass(javaClass<AbstractCodeMoverTest>()) {
|
testClass(javaClass<AbstractCodeMoverTest>()) {
|
||||||
|
|||||||
@@ -299,6 +299,9 @@
|
|||||||
language="JAVA"
|
language="JAVA"
|
||||||
implementationClass="org.jetbrains.jet.plugin.hierarchy.calls.KotlinCallHierarchyProvider"
|
implementationClass="org.jetbrains.jet.plugin.hierarchy.calls.KotlinCallHierarchyProvider"
|
||||||
order="first" />
|
order="first" />
|
||||||
|
<methodHierarchyProvider
|
||||||
|
language="jet"
|
||||||
|
implementationClass="org.jetbrains.jet.plugin.hierarchy.overrides.KotlinOverrideHierarchyProvider" />
|
||||||
|
|
||||||
<java.elementFinder implementation="org.jetbrains.jet.asJava.JavaElementFinder"/>
|
<java.elementFinder implementation="org.jetbrains.jet.asJava.JavaElementFinder"/>
|
||||||
<java.shortNamesCache implementation="org.jetbrains.jet.plugin.caches.JetShortNamesCache"/>
|
<java.shortNamesCache implementation="org.jetbrains.jet.plugin.caches.JetShortNamesCache"/>
|
||||||
|
|||||||
@@ -286,6 +286,10 @@ find.what.constructor.usages.checkbox=Usages of &constructor
|
|||||||
find.what.derived.traits.checkbox=&Derived traits
|
find.what.derived.traits.checkbox=&Derived traits
|
||||||
find.what.derived.classes.checkbox=&Derived classes
|
find.what.derived.classes.checkbox=&Derived classes
|
||||||
|
|
||||||
|
hierarchy.legend.member.is.defined.in.class=Member is defined in the class
|
||||||
|
hierarchy.legend.member.defined.in.superclass=Member is not defined in the class but defined in superclass
|
||||||
|
hierarchy.legend.member.should.be.defined=Member should be defined since the class is not abstract
|
||||||
|
|
||||||
convert.to.extension=Convert to extension
|
convert.to.extension=Convert to extension
|
||||||
replace.by.reconstructed.type.family.name=Replace by Reconstructed Type
|
replace.by.reconstructed.type.family.name=Replace by Reconstructed Type
|
||||||
replace.by.reconstructed.type=Replace by ''{0}''
|
replace.by.reconstructed.type=Replace by ''{0}''
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
package org.jetbrains.jet.plugin.hierarchy;
|
package org.jetbrains.jet.plugin.hierarchy;
|
||||||
|
|
||||||
import com.intellij.psi.PsiClass;
|
import com.intellij.codeInsight.TargetElementUtilBase;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||||
import com.intellij.psi.PsiMethod;
|
import com.intellij.openapi.actionSystem.DataContext;
|
||||||
|
import com.intellij.openapi.editor.Editor;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.psi.*;
|
||||||
import com.intellij.util.ArrayUtil;
|
import com.intellij.util.ArrayUtil;
|
||||||
import jet.Function1;
|
import jet.Function1;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.PsiUtilPackage;
|
import org.jetbrains.jet.lang.psi.psiUtil.PsiUtilPackage;
|
||||||
|
import org.jetbrains.jet.plugin.JetPluginUtil;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class HierarchyUtils {
|
public class HierarchyUtils {
|
||||||
public static final Function1<PsiElement, Boolean> IS_CALL_HIERARCHY_ELEMENT = new Function1<PsiElement, Boolean>() {
|
public static final Function1<PsiElement, Boolean> IS_CALL_HIERARCHY_ELEMENT = new Function1<PsiElement, Boolean>() {
|
||||||
@@ -23,8 +26,37 @@ public class HierarchyUtils {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static final Function1<PsiElement, Boolean> IS_OVERRIDE_HIERARCHY_ELEMENT = new Function1<PsiElement, Boolean>() {
|
||||||
|
@Override
|
||||||
|
public Boolean invoke(@Nullable PsiElement input) {
|
||||||
|
return input instanceof PsiMethod ||
|
||||||
|
input instanceof JetNamedFunction ||
|
||||||
|
input instanceof JetProperty;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static PsiElement getCurrentElement(DataContext dataContext, Project project) {
|
||||||
|
Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
|
||||||
|
if (editor != null) {
|
||||||
|
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
|
||||||
|
if (file == null) return null;
|
||||||
|
|
||||||
|
if (!JetPluginUtil.isInSource(file)) return null;
|
||||||
|
if (JetPluginUtil.isKtFileInGradleProjectInWrongFolder(file)) return null;
|
||||||
|
|
||||||
|
return TargetElementUtilBase.findTargetElement(editor, TargetElementUtilBase.getInstance().getAllAccepted());
|
||||||
|
}
|
||||||
|
|
||||||
|
return CommonDataKeys.PSI_ELEMENT.getData(dataContext);
|
||||||
|
}
|
||||||
|
|
||||||
public static PsiElement getCallHierarchyElement(PsiElement element) {
|
public static PsiElement getCallHierarchyElement(PsiElement element) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return PsiUtilPackage.getParentByTypesAndPredicate(element, false, ArrayUtil.EMPTY_CLASS_ARRAY, IS_CALL_HIERARCHY_ELEMENT);
|
return PsiUtilPackage.getParentByTypesAndPredicate(element, false, ArrayUtil.EMPTY_CLASS_ARRAY, IS_CALL_HIERARCHY_ELEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PsiElement getOverrideHierarchyElement(PsiElement element) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return PsiUtilPackage.getParentByTypesAndPredicate(element, false, ArrayUtil.EMPTY_CLASS_ARRAY, IS_OVERRIDE_HIERARCHY_ELEMENT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.jet.plugin.hierarchy.overrides
|
||||||
|
|
||||||
|
import com.intellij.ide.hierarchy.MethodHierarchyBrowserBase
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import javax.swing.JPanel
|
||||||
|
import com.intellij.ide.hierarchy.HierarchyTreeStructure
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
|
import org.jetbrains.jet.plugin.hierarchy.HierarchyUtils
|
||||||
|
import org.jetbrains.jet.plugin.JetBundle
|
||||||
|
import com.intellij.ide.hierarchy.method.MethodHierarchyBrowser
|
||||||
|
import org.jetbrains.jet.asJava.getRepresentativeLightMethod
|
||||||
|
import com.intellij.psi.PsiMethod
|
||||||
|
import java.text.MessageFormat
|
||||||
|
import com.intellij.psi.ElementDescriptionUtil
|
||||||
|
import com.intellij.refactoring.util.RefactoringDescriptionLocation
|
||||||
|
import org.jetbrains.jet.lang.psi.JetDeclaration
|
||||||
|
|
||||||
|
class KotlinOverrideHierarchyBrowser(
|
||||||
|
project: Project, baseElement: PsiElement
|
||||||
|
) : MethodHierarchyBrowser(project, baseElement.getRepresentativeLightMethod()) {
|
||||||
|
override fun createLegendPanel(): JPanel? =
|
||||||
|
MethodHierarchyBrowserBase.createStandardLegendPanel(
|
||||||
|
JetBundle.message("hierarchy.legend.member.is.defined.in.class"),
|
||||||
|
JetBundle.message("hierarchy.legend.member.defined.in.superclass"),
|
||||||
|
JetBundle.message("hierarchy.legend.member.should.be.defined")
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun isApplicableElement(psiElement: PsiElement): Boolean =
|
||||||
|
HierarchyUtils.IS_OVERRIDE_HIERARCHY_ELEMENT(psiElement)
|
||||||
|
|
||||||
|
[suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE")]
|
||||||
|
override fun createHierarchyTreeStructure(typeName: String, psiElement: PsiElement): HierarchyTreeStructure? =
|
||||||
|
if (typeName == MethodHierarchyBrowserBase.METHOD_TYPE) KotlinOverrideTreeStructure(myProject, psiElement) else null
|
||||||
|
|
||||||
|
override fun getBaseMethod(): PsiMethod? {
|
||||||
|
val builder = myBuilders.get(myCurrentViewType)
|
||||||
|
if (builder == null) return null
|
||||||
|
|
||||||
|
return (builder.getTreeStructure() as KotlinOverrideTreeStructure).javaTreeStructures.get(0).getBaseMethod()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getContentDisplayName(typeName: String, element: PsiElement): String? {
|
||||||
|
val targetElement = element.getNavigationElement()
|
||||||
|
if (targetElement is JetDeclaration) {
|
||||||
|
return ElementDescriptionUtil.getElementDescription(targetElement, RefactoringDescriptionLocation.WITHOUT_PARENT)
|
||||||
|
}
|
||||||
|
return super.getContentDisplayName(typeName, element)
|
||||||
|
}
|
||||||
|
}
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.jet.plugin.hierarchy.overrides
|
||||||
|
|
||||||
|
import com.intellij.ide.hierarchy.HierarchyProvider
|
||||||
|
import com.intellij.openapi.actionSystem.DataContext
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import com.intellij.ide.hierarchy.HierarchyBrowser
|
||||||
|
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||||
|
import org.jetbrains.jet.plugin.hierarchy.HierarchyUtils
|
||||||
|
import com.intellij.ide.hierarchy.MethodHierarchyBrowserBase
|
||||||
|
import com.intellij.ide.hierarchy.HierarchyBrowserBaseEx
|
||||||
|
|
||||||
|
public class KotlinOverrideHierarchyProvider: HierarchyProvider {
|
||||||
|
override fun getTarget(dataContext: DataContext): PsiElement? {
|
||||||
|
return CommonDataKeys.PROJECT.getData(dataContext)?.let { project ->
|
||||||
|
HierarchyUtils.getOverrideHierarchyElement(HierarchyUtils.getCurrentElement(dataContext, project))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createHierarchyBrowser(target: PsiElement): HierarchyBrowser =
|
||||||
|
KotlinOverrideHierarchyBrowser(target.getProject(), target)
|
||||||
|
|
||||||
|
override fun browserActivated(hierarchyBrowser: HierarchyBrowser) {
|
||||||
|
(hierarchyBrowser as HierarchyBrowserBaseEx).changeView(MethodHierarchyBrowserBase.METHOD_TYPE)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.jet.plugin.hierarchy.overrides
|
||||||
|
|
||||||
|
import com.intellij.ide.hierarchy.HierarchyTreeStructure
|
||||||
|
import com.intellij.ide.hierarchy.HierarchyNodeDescriptor
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.jet.lang.psi.JetElement
|
||||||
|
import com.intellij.ide.hierarchy.method.MethodHierarchyNodeDescriptor
|
||||||
|
import com.intellij.ide.hierarchy.method.MethodHierarchyTreeStructure
|
||||||
|
import com.intellij.psi.PsiMethod
|
||||||
|
import org.jetbrains.jet.asJava.LightClassUtil
|
||||||
|
import org.jetbrains.jet.lang.psi.JetNamedFunction
|
||||||
|
import org.jetbrains.jet.lang.psi.JetProperty
|
||||||
|
import org.jetbrains.jet.lang.psi.JetParameter
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.jetAsJava.KotlinLightMethod
|
||||||
|
import org.jetbrains.jet.plugin.search.declarationsSearch.HierarchySearchRequest
|
||||||
|
import com.intellij.psi.search.GlobalSearchScopes
|
||||||
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
|
import org.jetbrains.jet.plugin.search.declarationsSearch.searchOverriders
|
||||||
|
import org.jetbrains.jet.lang.psi.JetDeclaration
|
||||||
|
import com.intellij.util.ArrayUtil
|
||||||
|
import org.jetbrains.jet.lang.psi.JetClassOrObject
|
||||||
|
import com.intellij.psi.PsiClass
|
||||||
|
import java.util.Collections
|
||||||
|
import org.jetbrains.jet.lang.psi.JetPropertyAccessor
|
||||||
|
import org.jetbrains.jet.asJava.toLightMethods
|
||||||
|
import com.siyeh.ig.psiutils.CollectionUtils
|
||||||
|
import com.intellij.util.containers.ContainerUtil
|
||||||
|
import java.util.HashSet
|
||||||
|
|
||||||
|
class KotlinOverrideTreeStructure(project: Project, val element: PsiElement) : HierarchyTreeStructure(project, null) {
|
||||||
|
val javaTreeStructures = element.toLightMethods().map { method -> MethodHierarchyTreeStructure(project, method) };
|
||||||
|
|
||||||
|
{
|
||||||
|
setBaseElement(javaTreeStructures.first!!.getBaseDescriptor()!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun buildChildren(descriptor: HierarchyNodeDescriptor): Array<Any> {
|
||||||
|
fun buildChildrenByTreeStructure(javaTreeStructure: MethodHierarchyTreeStructure): Array<Any> {
|
||||||
|
return javaTreeStructure.getChildElements(descriptor as MethodHierarchyNodeDescriptor) ?: ArrayUtil.EMPTY_OBJECT_ARRAY
|
||||||
|
}
|
||||||
|
|
||||||
|
return javaTreeStructures
|
||||||
|
.iterator()
|
||||||
|
.map (::buildChildrenByTreeStructure)
|
||||||
|
.reduce { (a, b) -> ContainerUtil.union(a.toSet(), b.toSet()).copyToArray() }
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
<node text="A ()" base="true">
|
||||||
|
<node text="B ()"/>
|
||||||
|
<node text="T ()">
|
||||||
|
<node text="C ()"/>
|
||||||
|
<node text="Y ()"/>
|
||||||
|
</node>
|
||||||
|
<node text="X ()">
|
||||||
|
<node text="Z ()">
|
||||||
|
<node text="D ()"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
class A {
|
||||||
|
public void <caret>foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class B extends A {
|
||||||
|
@Override
|
||||||
|
public void foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class C implements T {
|
||||||
|
@Override
|
||||||
|
public void foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class D extends Z {
|
||||||
|
@Override
|
||||||
|
public void foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class S {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
trait T: A {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class X: A() {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Y: T {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Z: X() {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SS {
|
||||||
|
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
<node text="A ()" base="true">
|
||||||
|
<node text="B ()"/>
|
||||||
|
<node text="T ()">
|
||||||
|
<node text="C ()"/>
|
||||||
|
<node text="Y ()"/>
|
||||||
|
</node>
|
||||||
|
<node text="X ()">
|
||||||
|
<node text="Z ()">
|
||||||
|
<node text="D ()"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
interface A {
|
||||||
|
public void <caret>foo();
|
||||||
|
}
|
||||||
|
|
||||||
|
class B implements A {
|
||||||
|
@Override
|
||||||
|
public void foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class C implements T {
|
||||||
|
@Override
|
||||||
|
public void foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class D extends Z {
|
||||||
|
@Override
|
||||||
|
public void foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class S {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
trait T: A {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class X: A {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Y: T {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Z: X() {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SS {
|
||||||
|
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
<node text="T ()" base="true">
|
||||||
|
<node text="B ()"/>
|
||||||
|
<node text="X ()"/>
|
||||||
|
<node text="Y ()">
|
||||||
|
<node text="A ()">
|
||||||
|
<node text="C ()"/>
|
||||||
|
</node>
|
||||||
|
<node text="Z ()">
|
||||||
|
<node text="D ()"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
open class T {
|
||||||
|
open fun <caret>foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class X: T() {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open trait Y: T() {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Z: Y {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SS {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
interface A extends Y {
|
||||||
|
@Override
|
||||||
|
public void foo();
|
||||||
|
}
|
||||||
|
|
||||||
|
class B extends T {
|
||||||
|
@Override
|
||||||
|
public void foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class C implements A {
|
||||||
|
@Override
|
||||||
|
public void foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class D extends Z {
|
||||||
|
@Override
|
||||||
|
public void foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class S {
|
||||||
|
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
<node text="T ()" base="true">
|
||||||
|
<node text="A ()">
|
||||||
|
<node text="C ()"/>
|
||||||
|
</node>
|
||||||
|
<node text="B ()">
|
||||||
|
<node text="Y ()"/>
|
||||||
|
</node>
|
||||||
|
<node text="X ()">
|
||||||
|
<node text="Z ()">
|
||||||
|
<node text="D ()"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
trait T {
|
||||||
|
fun <caret>foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
open class X: T {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Y: B() {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Z: X() {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SS {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
interface A extends T {
|
||||||
|
@Override
|
||||||
|
public void foo();
|
||||||
|
}
|
||||||
|
|
||||||
|
class B implements T {
|
||||||
|
@Override
|
||||||
|
public void foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class C implements A {
|
||||||
|
@Override
|
||||||
|
public void foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class D extends Z {
|
||||||
|
@Override
|
||||||
|
public void foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class S {
|
||||||
|
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
<node text="T ()" base="true">
|
||||||
|
<node text="B ()"/>
|
||||||
|
<node text="Y ()">
|
||||||
|
<node text="Z ()">
|
||||||
|
<node text="D ()"/>
|
||||||
|
</node>
|
||||||
|
<node text="A ()">
|
||||||
|
<node text="C ()"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
<node text="X ()"/>
|
||||||
|
</node>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
open class T {
|
||||||
|
open var <caret>foo: String = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
open class X: T() {
|
||||||
|
override var foo: String
|
||||||
|
get() = ""
|
||||||
|
set(value: String) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
trait Y: T {
|
||||||
|
override var foo: String
|
||||||
|
get() = ""
|
||||||
|
set(value: String) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Z: Y {
|
||||||
|
override var foo: String
|
||||||
|
get() = ""
|
||||||
|
set(value: String) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SS {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
interface A extends Y {
|
||||||
|
@Override
|
||||||
|
public String getFoo();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFoo(String value);
|
||||||
|
}
|
||||||
|
|
||||||
|
class B extends T {
|
||||||
|
@Override
|
||||||
|
public String getFoo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFoo(String value) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class C implements A {
|
||||||
|
@Override
|
||||||
|
public String getFoo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFoo(String value) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class D extends Z {
|
||||||
|
@Override
|
||||||
|
public String getFoo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFoo(String value) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class S {
|
||||||
|
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
<node text="T ()" base="true">
|
||||||
|
<node text="Y ()">
|
||||||
|
<node text="Z ()">
|
||||||
|
<node text="D ()"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
<node text="B ()"/>
|
||||||
|
<node text="X ()"/>
|
||||||
|
<node text="A ()">
|
||||||
|
<node text="C ()"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
trait T {
|
||||||
|
open var <caret>foo: String
|
||||||
|
}
|
||||||
|
|
||||||
|
open class X: T {
|
||||||
|
override var <caret>foo: String
|
||||||
|
get() = ""
|
||||||
|
set(value: String) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
open trait Y: T {
|
||||||
|
override var <caret>foo: String
|
||||||
|
get() = ""
|
||||||
|
set(value: String) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Z: Y {
|
||||||
|
override var <caret>foo: String
|
||||||
|
get() = ""
|
||||||
|
set(value: String) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SS {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
interface A extends T {
|
||||||
|
@Override
|
||||||
|
public String getFoo();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFoo(String value);
|
||||||
|
}
|
||||||
|
|
||||||
|
class B implements T {
|
||||||
|
@Override
|
||||||
|
public String getFoo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFoo(String value) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class C implements A {
|
||||||
|
@Override
|
||||||
|
public String getFoo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFoo(String value) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class D extends Z {
|
||||||
|
@Override
|
||||||
|
public String getFoo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFoo(String value) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class S {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -38,6 +38,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||||
import org.jetbrains.jet.plugin.hierarchy.calls.KotlinCalleeMethodsTreeStructure;
|
import org.jetbrains.jet.plugin.hierarchy.calls.KotlinCalleeMethodsTreeStructure;
|
||||||
import org.jetbrains.jet.plugin.hierarchy.calls.KotlinCallerMethodsTreeStructure;
|
import org.jetbrains.jet.plugin.hierarchy.calls.KotlinCallerMethodsTreeStructure;
|
||||||
|
import org.jetbrains.jet.plugin.hierarchy.overrides.KotlinOverrideTreeStructure;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -78,6 +79,11 @@ public abstract class AbstractHierarchyTest extends HierarchyViewTestBase {
|
|||||||
doHierarchyTest(getCalleeHierarchyStructure(), getFilesToConfigure());
|
doHierarchyTest(getCalleeHierarchyStructure(), getFilesToConfigure());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void doOverrideHierarchyTest(@NotNull String folderName) throws Exception {
|
||||||
|
this.folderName = folderName;
|
||||||
|
doHierarchyTest(getOverrideHierarchyStructure(), getFilesToConfigure());
|
||||||
|
}
|
||||||
|
|
||||||
private Computable<HierarchyTreeStructure> getSuperTypesHierarchyStructure() {
|
private Computable<HierarchyTreeStructure> getSuperTypesHierarchyStructure() {
|
||||||
return new Computable<HierarchyTreeStructure>() {
|
return new Computable<HierarchyTreeStructure>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -142,6 +148,18 @@ public abstract class AbstractHierarchyTest extends HierarchyViewTestBase {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Computable<HierarchyTreeStructure> getOverrideHierarchyStructure() {
|
||||||
|
return new Computable<HierarchyTreeStructure>() {
|
||||||
|
@Override
|
||||||
|
public HierarchyTreeStructure compute() {
|
||||||
|
return new KotlinOverrideTreeStructure(
|
||||||
|
getProject(),
|
||||||
|
getElementAtCaret(LanguageCallHierarchy.INSTANCE.forLanguage(getLanguage()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private PsiElement getElementAtCaret(HierarchyProvider provider) {
|
private PsiElement getElementAtCaret(HierarchyProvider provider) {
|
||||||
PsiElement target = provider.getTarget(getDataContext());
|
PsiElement target = provider.getTarget(getDataContext());
|
||||||
assert target != null : "Cannot apply action for element at caret";
|
assert target != null : "Cannot apply action for element at caret";
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import org.jetbrains.jet.plugin.hierarchy.AbstractHierarchyTest;
|
|||||||
|
|
||||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
@InnerTestClasses({HierarchyTestGenerated.Type.class, HierarchyTestGenerated.Super.class, HierarchyTestGenerated.Sub.class, HierarchyTestGenerated.Callers.class, HierarchyTestGenerated.Callees.class})
|
@InnerTestClasses({HierarchyTestGenerated.Type.class, HierarchyTestGenerated.Super.class, HierarchyTestGenerated.Sub.class, HierarchyTestGenerated.Callers.class, HierarchyTestGenerated.Callees.class, HierarchyTestGenerated.Overrides.class})
|
||||||
public class HierarchyTestGenerated extends AbstractHierarchyTest {
|
public class HierarchyTestGenerated extends AbstractHierarchyTest {
|
||||||
@TestMetadata("idea/testData/hierarchy/class/type")
|
@TestMetadata("idea/testData/hierarchy/class/type")
|
||||||
public static class Type extends AbstractHierarchyTest {
|
public static class Type extends AbstractHierarchyTest {
|
||||||
@@ -367,6 +367,44 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("idea/testData/hierarchy/overrides")
|
||||||
|
public static class Overrides extends AbstractHierarchyTest {
|
||||||
|
public void testAllFilesPresentInOverrides() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/hierarchy/overrides"), Pattern.compile("^([^\\.]+)$"), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("javaMethodInClass")
|
||||||
|
public void testJavaMethodInClass() throws Exception {
|
||||||
|
doOverrideHierarchyTest("idea/testData/hierarchy/overrides/javaMethodInClass");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("javaMethodInInterface")
|
||||||
|
public void testJavaMethodInInterface() throws Exception {
|
||||||
|
doOverrideHierarchyTest("idea/testData/hierarchy/overrides/javaMethodInInterface");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kotlinFunctionInClass")
|
||||||
|
public void testKotlinFunctionInClass() throws Exception {
|
||||||
|
doOverrideHierarchyTest("idea/testData/hierarchy/overrides/kotlinFunctionInClass");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kotlinFunctionInTrait")
|
||||||
|
public void testKotlinFunctionInTrait() throws Exception {
|
||||||
|
doOverrideHierarchyTest("idea/testData/hierarchy/overrides/kotlinFunctionInTrait");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kotlinPropertyInClass")
|
||||||
|
public void testKotlinPropertyInClass() throws Exception {
|
||||||
|
doOverrideHierarchyTest("idea/testData/hierarchy/overrides/kotlinPropertyInClass");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kotlinPropertyInTrait")
|
||||||
|
public void testKotlinPropertyInTrait() throws Exception {
|
||||||
|
doOverrideHierarchyTest("idea/testData/hierarchy/overrides/kotlinPropertyInTrait");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite = new TestSuite("HierarchyTestGenerated");
|
TestSuite suite = new TestSuite("HierarchyTestGenerated");
|
||||||
suite.addTestSuite(Type.class);
|
suite.addTestSuite(Type.class);
|
||||||
@@ -374,6 +412,7 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
|
|||||||
suite.addTestSuite(Sub.class);
|
suite.addTestSuite(Sub.class);
|
||||||
suite.addTestSuite(Callers.class);
|
suite.addTestSuite(Callers.class);
|
||||||
suite.addTestSuite(Callees.class);
|
suite.addTestSuite(Callees.class);
|
||||||
|
suite.addTestSuite(Overrides.class);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user