Navigate to super for objects
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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<? extends DeclarationDescriptor> superDescriptors;
|
||||
String message;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// FILE: before.kt
|
||||
trait Some
|
||||
class <caret>SomeObject: Some
|
||||
// FILE: after.kt
|
||||
trait <caret>Some
|
||||
class SomeObject: Some
|
||||
@@ -0,0 +1,18 @@
|
||||
// FILE: before.kt
|
||||
trait Some {
|
||||
fun test()
|
||||
}
|
||||
class SomeObject: Some {
|
||||
override fun <caret>test() {
|
||||
|
||||
}
|
||||
}
|
||||
// FILE: after.kt
|
||||
trait Some {
|
||||
fun <caret>test()
|
||||
}
|
||||
class SomeObject: Some {
|
||||
override fun test() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// FILE: b.kt
|
||||
trait Some
|
||||
object <caret>SomeObject: Some
|
||||
// FILE: a.kt
|
||||
trait <caret>Some
|
||||
object SomeObject: Some
|
||||
@@ -0,0 +1,14 @@
|
||||
// FILE: b.kt
|
||||
trait Some {
|
||||
val test: Int
|
||||
}
|
||||
class SomeObject: Some {
|
||||
override val <caret>test: Int = 1
|
||||
}
|
||||
// FILE: a.kt
|
||||
trait Some {
|
||||
val <caret>test: Int
|
||||
}
|
||||
class SomeObject: Some {
|
||||
override val test: Int = 1
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// FILE: a.kt
|
||||
open class First
|
||||
trait <caret>Second: First
|
||||
// FILE: b.kt
|
||||
open class <caret>First
|
||||
trait Second: First
|
||||
@@ -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<String> 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));
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user