diff --git a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java index 15be16c3bc8..9e5468b3c6a 100644 --- a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java +++ b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java @@ -43,6 +43,7 @@ import org.jetbrains.jet.plugin.codeInsight.surroundWith.AbstractSurroundWithTes import org.jetbrains.jet.plugin.folding.AbstractKotlinFoldingTest; import org.jetbrains.jet.plugin.hierarchy.AbstractHierarchyTest; import org.jetbrains.jet.plugin.highlighter.AbstractDeprecatedHighlightingTest; +import org.jetbrains.jet.plugin.navigation.JetAbstractGotoSuperTest; import org.jetbrains.jet.plugin.quickfix.AbstractQuickFixMultiFileTest; import org.jetbrains.jet.plugin.quickfix.AbstractQuickFixTest; import org.jetbrains.jet.resolve.AbstractResolveTest; @@ -282,6 +283,12 @@ public class GenerateTests { AbstractJavaWithLibCompletionTest.class, testModel("idea/testData/completion/basic/custom", false, "doTestWithJar")); + generateTest( + "idea/tests", + "JetGotoSuperTestGenerated", + JetAbstractGotoSuperTest.class, + testModel("idea/testData/navigation/gotoSuper", false, "test", "doTest")); + generateTest( "idea/tests/", "QuickFixMultiFileTestGenerated", diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/GotoSuperActionHandler.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/GotoSuperActionHandler.java index bd7ef16d1cc..da4bc244c1a 100644 --- a/idea/src/org/jetbrains/jet/plugin/codeInsight/GotoSuperActionHandler.java +++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/GotoSuperActionHandler.java @@ -51,14 +51,17 @@ public class GotoSuperActionHandler implements CodeInsightActionHandler { PsiElement element = file.findElementAt(editor.getCaretModel().getOffset()); if (element == null) return; - @SuppressWarnings("unchecked") JetNamedDeclaration funOrClass = - PsiTreeUtil.getParentOfType(element, JetNamedFunction.class, JetClass.class, JetProperty.class); - if (funOrClass == null) return; + @SuppressWarnings("unchecked") JetDeclaration declaration = + PsiTreeUtil.getParentOfType(element, + JetNamedFunction.class, + JetClass.class, + JetProperty.class, + JetObjectDeclaration.class); + if (declaration == null) return; final BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile((JetFile) file).getBindingContext(); - DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, funOrClass); - + DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration); Collection superDescriptors; String message; diff --git a/idea/testData/navigation/gotoSuper/ClassSimple.test b/idea/testData/navigation/gotoSuper/ClassSimple.test new file mode 100644 index 00000000000..ce53dfcb7c5 --- /dev/null +++ b/idea/testData/navigation/gotoSuper/ClassSimple.test @@ -0,0 +1,6 @@ +// FILE: before.kt +trait Some +class SomeObject: Some +// FILE: after.kt +trait Some +class SomeObject: Some \ No newline at end of file diff --git a/idea/testData/navigation/gotoSuper/FunctionSimple.test b/idea/testData/navigation/gotoSuper/FunctionSimple.test new file mode 100644 index 00000000000..d363f865f80 --- /dev/null +++ b/idea/testData/navigation/gotoSuper/FunctionSimple.test @@ -0,0 +1,18 @@ +// FILE: before.kt +trait Some { + fun test() +} +class SomeObject: Some { + override fun test() { + + } +} +// FILE: after.kt +trait Some { + fun test() +} +class SomeObject: Some { + override fun test() { + + } +} \ No newline at end of file diff --git a/idea/testData/navigation/gotoSuper/ObjectSimple.test b/idea/testData/navigation/gotoSuper/ObjectSimple.test new file mode 100644 index 00000000000..b21ccc71077 --- /dev/null +++ b/idea/testData/navigation/gotoSuper/ObjectSimple.test @@ -0,0 +1,6 @@ +// FILE: b.kt +trait Some +object SomeObject: Some +// FILE: a.kt +trait Some +object SomeObject: Some \ No newline at end of file diff --git a/idea/testData/navigation/gotoSuper/PropertySimple.test b/idea/testData/navigation/gotoSuper/PropertySimple.test new file mode 100644 index 00000000000..0282d13c6d4 --- /dev/null +++ b/idea/testData/navigation/gotoSuper/PropertySimple.test @@ -0,0 +1,14 @@ +// FILE: b.kt +trait Some { + val test: Int +} +class SomeObject: Some { + override val test: Int = 1 +} +// FILE: a.kt +trait Some { + val test: Int +} +class SomeObject: Some { + override val test: Int = 1 +} \ No newline at end of file diff --git a/idea/testData/navigation/gotoSuper/TraitSimple.test b/idea/testData/navigation/gotoSuper/TraitSimple.test new file mode 100644 index 00000000000..65c9f2ce61d --- /dev/null +++ b/idea/testData/navigation/gotoSuper/TraitSimple.test @@ -0,0 +1,6 @@ +// FILE: a.kt +open class First +trait Second: First +// FILE: b.kt +open class First +trait Second: First \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/navigation/JetAbstractGotoSuperTest.java b/idea/tests/org/jetbrains/jet/plugin/navigation/JetAbstractGotoSuperTest.java new file mode 100644 index 00000000000..b3ef210ddc7 --- /dev/null +++ b/idea/tests/org/jetbrains/jet/plugin/navigation/JetAbstractGotoSuperTest.java @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2013 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.navigation; + +import com.intellij.codeInsight.CodeInsightActionHandler; +import com.intellij.openapi.actionSystem.ActionManager; +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.plugin.JetFileType; +import org.jetbrains.jet.plugin.PluginTestCaseBase; + +import java.io.File; +import java.util.List; + +public abstract class JetAbstractGotoSuperTest extends LightCodeInsightFixtureTestCase { + protected void doTest(String testPath) { + List parts = JetTestUtils.loadBeforeAfterText(testPath); + + myFixture.configureByText(JetFileType.INSTANCE, parts.get(0)); + + CodeInsightActionHandler gotoSuperAction = (CodeInsightActionHandler) ActionManager.getInstance().getAction("GotoSuperMethod"); + gotoSuperAction.invoke(getProject(), myFixture.getEditor(), myFixture.getFile()); + + myFixture.checkResult(parts.get(1)); + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/navigation/JetGotoSuperTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/navigation/JetGotoSuperTestGenerated.java new file mode 100644 index 00000000000..f02b35b2d66 --- /dev/null +++ b/idea/tests/org/jetbrains/jet/plugin/navigation/JetGotoSuperTestGenerated.java @@ -0,0 +1,64 @@ +/* + * Copyright 2010-2013 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.navigation; + +import junit.framework.Assert; +import junit.framework.Test; +import junit.framework.TestSuite; + +import java.io.File; +import java.util.regex.Pattern; +import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.test.InnerTestClasses; +import org.jetbrains.jet.test.TestMetadata; + +import org.jetbrains.jet.plugin.navigation.JetAbstractGotoSuperTest; + +/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("idea/testData/navigation/gotoSuper") +public class JetGotoSuperTestGenerated extends JetAbstractGotoSuperTest { + public void testAllFilesPresentInGotoSuper() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/navigation/gotoSuper"), Pattern.compile("^(.+)\\.test$"), false); + } + + @TestMetadata("ClassSimple.test") + public void testClassSimple() throws Exception { + doTest("idea/testData/navigation/gotoSuper/ClassSimple.test"); + } + + @TestMetadata("FunctionSimple.test") + public void testFunctionSimple() throws Exception { + doTest("idea/testData/navigation/gotoSuper/FunctionSimple.test"); + } + + @TestMetadata("ObjectSimple.test") + public void testObjectSimple() throws Exception { + doTest("idea/testData/navigation/gotoSuper/ObjectSimple.test"); + } + + @TestMetadata("PropertySimple.test") + public void testPropertySimple() throws Exception { + doTest("idea/testData/navigation/gotoSuper/PropertySimple.test"); + } + + @TestMetadata("TraitSimple.test") + public void testTraitSimple() throws Exception { + doTest("idea/testData/navigation/gotoSuper/TraitSimple.test"); + } + +}