From 0b97b146426e23d193c817f50eb9ffa962282b3c Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Wed, 15 Aug 2012 21:40:54 +0400 Subject: [PATCH] KT-1389 Ctrl-Alt-B on class declaration does not work #KT-1389 In Progress --- .../implementations/ClassNavigation.kt | 7 ++ .../navigation/JetGotoImplementationTest.java | 76 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 idea/testData/navigation/implementations/ClassNavigation.kt create mode 100644 idea/tests/org/jetbrains/jet/plugin/navigation/JetGotoImplementationTest.java diff --git a/idea/testData/navigation/implementations/ClassNavigation.kt b/idea/testData/navigation/implementations/ClassNavigation.kt new file mode 100644 index 00000000000..036eb0a1c0a --- /dev/null +++ b/idea/testData/navigation/implementations/ClassNavigation.kt @@ -0,0 +1,7 @@ +package testing + +open class Test + +class TestOther : Test() + +// REF: JetLightClass:testing.TestOther \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/navigation/JetGotoImplementationTest.java b/idea/tests/org/jetbrains/jet/plugin/navigation/JetGotoImplementationTest.java new file mode 100644 index 00000000000..59782996687 --- /dev/null +++ b/idea/tests/org/jetbrains/jet/plugin/navigation/JetGotoImplementationTest.java @@ -0,0 +1,76 @@ +/* + * Copyright 2010-2012 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.google.common.base.Function; +import com.google.common.collect.Lists; +import com.intellij.codeInsight.navigation.GotoImplementationHandler; +import com.intellij.codeInsight.navigation.GotoTargetHandler; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.psi.PsiElement; +import com.intellij.testFramework.LightCodeInsightTestCase; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.plugin.PluginTestCaseBase; +import org.jetbrains.jet.testing.InTextDirectivesUtils; + +import java.io.File; +import java.util.Arrays; +import java.util.List; + +/** + * @author Nikolay Krasko + */ +public class JetGotoImplementationTest extends LightCodeInsightTestCase { + public void testClassNavigation() { + doTest(); + } + + @Override + protected String getTestDataPath() { + return new File(PluginTestCaseBase.getTestDataPathBase(), "/navigation/implementations").getPath() + + File.separator; + } + + @Override + protected Sdk getProjectJDK() { + return PluginTestCaseBase.jdkFromIdeaHome(); + } + + protected void doTest() { + configureByFile(getTestName(false) + ".kt"); + + List expectedReferences = Arrays.asList( + InTextDirectivesUtils.findListWithPrefix("// REF:", getEditor().getDocument().getText())); + + GotoTargetHandler.GotoData elements = new GotoImplementationHandler().getSourceAndTargetElements(getEditor(), getFile()); + + if (elements != null) { + List psiElements = Lists.transform(Arrays.asList(elements.targets), new Function() { + @Override + public String apply(@Nullable PsiElement element) { + assertNotNull(element); + return element.toString(); + } + }); + + assertOrderedEquals(expectedReferences, psiElements); + } + else { + assertEmpty(expectedReferences); + } + } +}