diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 7162ef03526..1333dd4f8d5 100755 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -95,6 +95,7 @@ import org.jetbrains.kotlin.idea.kdoc.AbstractKDocTypingTest import org.jetbrains.kotlin.idea.maven.AbstractKotlinMavenInspectionTest import org.jetbrains.kotlin.idea.maven.configuration.AbstractMavenConfigureProjectByChangingFileTest import org.jetbrains.kotlin.idea.navigation.AbstractGotoSuperTest +import org.jetbrains.kotlin.idea.navigation.AbstractGotoTypeDeclarationTest import org.jetbrains.kotlin.idea.navigation.AbstractKotlinGotoImplementationTest import org.jetbrains.kotlin.idea.navigation.AbstractKotlinGotoTest import org.jetbrains.kotlin.idea.parameterInfo.AbstractParameterInfoTest @@ -147,6 +148,7 @@ import org.jetbrains.kotlin.shortenRefs.AbstractShortenRefsTest import org.jetbrains.kotlin.types.AbstractTypeBindingTest import org.jetbrains.kotlin.uast.AbstractKotlinLintTest import java.io.File +import java.lang.IllegalArgumentException import java.util.* import java.util.regex.Pattern @@ -447,6 +449,10 @@ fun main(args: Array) { model("navigation/gotoSuper", extension = "test") } + testClass() { + model("navigation/gotoTypeDeclaration", extension = "test") + } + testClass() { model("parameterInfo", recursive = true, excludeDirs = listOf("withLib/sharedLib")) } diff --git a/idea/testData/navigation/gotoTypeDeclaration/explicitParameterInLambda.test b/idea/testData/navigation/gotoTypeDeclaration/explicitParameterInLambda.test new file mode 100644 index 00000000000..ec072a8749c --- /dev/null +++ b/idea/testData/navigation/gotoTypeDeclaration/explicitParameterInLambda.test @@ -0,0 +1,23 @@ +// FILE: before.kt +class Foo + +fun some(a: T, f: (T) -> Unit) {} +fun foo(a: Any) {} + +fun baz() { + some(Foo()) { p -> + foo(p) + } +} + +// FILE: after.kt +class Foo + +fun some(a: T, f: (T) -> Unit) {} +fun foo(a: Any) {} + +fun baz() { + some(Foo()) { p -> + foo(p) + } +} \ No newline at end of file diff --git a/idea/testData/navigation/gotoTypeDeclaration/functionCall.test b/idea/testData/navigation/gotoTypeDeclaration/functionCall.test new file mode 100644 index 00000000000..25ba342cab1 --- /dev/null +++ b/idea/testData/navigation/gotoTypeDeclaration/functionCall.test @@ -0,0 +1,17 @@ +// FILE: before.kt +class Foo + +fun test(): Foo = Foo() + +fun void() { + test() +} + +// FILE: after.kt +class Foo + +fun test(): Foo = Foo() + +fun void() { + test() +} \ No newline at end of file diff --git a/idea/testData/navigation/gotoTypeDeclaration/variableType.test b/idea/testData/navigation/gotoTypeDeclaration/variableType.test new file mode 100644 index 00000000000..fa48acb6186 --- /dev/null +++ b/idea/testData/navigation/gotoTypeDeclaration/variableType.test @@ -0,0 +1,15 @@ +// FILE: before.kt +interface Some + +fun some() { + val a: Some = null!! + a +} + +// FILE: after.kt +interface Some + +fun some() { + val a: Some = null!! + a +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoSuperTest.java b/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoSuperTest.java index c4bdc9a1500..8e2199bcad5 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoSuperTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoSuperTest.java @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.navigation; import com.intellij.codeInsight.CodeInsightActionHandler; import com.intellij.openapi.actionSystem.ActionManager; +import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; import org.jetbrains.kotlin.idea.KotlinFileType; import org.jetbrains.kotlin.test.KotlinTestUtils; @@ -30,7 +31,8 @@ public abstract class AbstractGotoSuperTest extends LightCodeInsightFixtureTestC myFixture.configureByText(KotlinFileType.INSTANCE, parts.get(0)); - CodeInsightActionHandler gotoSuperAction = (CodeInsightActionHandler) ActionManager.getInstance().getAction("GotoSuperMethod"); + CodeInsightActionHandler gotoSuperAction = + (CodeInsightActionHandler) ActionManager.getInstance().getAction(IdeActions.ACTION_GOTO_SUPER); gotoSuperAction.invoke(getProject(), myFixture.getEditor(), myFixture.getFile()); myFixture.checkResult(parts.get(1)); diff --git a/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoTypeDeclarationTest.kt b/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoTypeDeclarationTest.kt new file mode 100644 index 00000000000..404a46b055d --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/navigation/AbstractGotoTypeDeclarationTest.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2016 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.kotlin.idea.navigation + +import com.intellij.codeInsight.CodeInsightActionHandler +import com.intellij.openapi.actionSystem.ActionManager +import com.intellij.openapi.actionSystem.IdeActions +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase +import org.jetbrains.kotlin.idea.KotlinFileType +import org.jetbrains.kotlin.test.KotlinTestUtils +import org.junit.Assert + +abstract class AbstractGotoTypeDeclarationTest : LightCodeInsightFixtureTestCase() { + protected fun doTest(testPath: String) { + val parts = KotlinTestUtils.loadBeforeAfterText(testPath) + + myFixture.configureByText(KotlinFileType.INSTANCE, parts[0]) + + val gotoSuperAction = ActionManager.getInstance().getAction(IdeActions.ACTION_GOTO_TYPE_DECLARATION) as CodeInsightActionHandler + gotoSuperAction.invoke(project, myFixture.editor, myFixture.file) + + + val afterText = StringBuilder(myFixture.getDocument(myFixture.file).text).insert(editor.caretModel.offset, "").toString() + + Assert.assertEquals(parts[1], afterText) + } +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/navigation/GotoTypeDeclarationTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/navigation/GotoTypeDeclarationTestGenerated.java new file mode 100644 index 00000000000..05d40222088 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/navigation/GotoTypeDeclarationTestGenerated.java @@ -0,0 +1,55 @@ +/* + * Copyright 2010-2016 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.kotlin.idea.navigation; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("idea/testData/navigation/gotoTypeDeclaration") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class GotoTypeDeclarationTestGenerated extends AbstractGotoTypeDeclarationTest { + public void testAllFilesPresentInGotoTypeDeclaration() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/navigation/gotoTypeDeclaration"), Pattern.compile("^(.+)\\.test$"), true); + } + + @TestMetadata("explicitParameterInLambda.test") + public void testExplicitParameterInLambda() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/navigation/gotoTypeDeclaration/explicitParameterInLambda.test"); + doTest(fileName); + } + + @TestMetadata("functionCall.test") + public void testFunctionCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/navigation/gotoTypeDeclaration/functionCall.test"); + doTest(fileName); + } + + @TestMetadata("variableType.test") + public void testVariableType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/navigation/gotoTypeDeclaration/variableType.test"); + doTest(fileName); + } +}