From d4275e1110bc152b3f37504b40120f9a1c27af03 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 24 Oct 2014 17:10:11 +0400 Subject: [PATCH] Added test for KT-6132 --- .../jet/generators/tests/GenerateTests.kt | 12 ++-- .../JavaStaticMethodArgument/JavaClass.java | 3 + .../JavaStaticMethodArgument.kt | 7 +++ ...stractMultiFileJvmBasicCompletionTest.java | 56 ------------------- ...AbstractMultiFileJvmBasicCompletionTest.kt | 44 +++++++++++++++ .../AbstractMultiFileSmartCompletionTest.kt | 45 +++++++++++++++ ...MultiFileSmartCompletionTestGenerated.java | 43 ++++++++++++++ 7 files changed, 150 insertions(+), 60 deletions(-) create mode 100644 idea/testData/completion/smartMultiFile/JavaStaticMethodArgument/JavaClass.java create mode 100644 idea/testData/completion/smartMultiFile/JavaStaticMethodArgument/JavaStaticMethodArgument.kt delete mode 100644 idea/tests/org/jetbrains/jet/completion/AbstractMultiFileJvmBasicCompletionTest.java create mode 100644 idea/tests/org/jetbrains/jet/completion/AbstractMultiFileJvmBasicCompletionTest.kt create mode 100644 idea/tests/org/jetbrains/jet/completion/AbstractMultiFileSmartCompletionTest.kt create mode 100644 idea/tests/org/jetbrains/jet/completion/MultiFileSmartCompletionTestGenerated.java diff --git a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt index 7d05c55ea03..d2efff9a915 100644 --- a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt @@ -129,6 +129,7 @@ import org.jetbrains.k2js.test.semantics.AbstractBridgeTest import org.jetbrains.jet.j2k.test.AbstractJavaToKotlinConverterMultiFileTest import org.jetbrains.jet.j2k.test.AbstractJavaToKotlinConverterForWebDemoTest import org.jetbrains.jet.plugin.decompiler.textBuilder.AbstractDecompiledTextTest +import org.jetbrains.jet.completion.AbstractMultiFileSmartCompletionTest fun main(args: Array) { System.setProperty("java.awt.headless", "true") @@ -361,6 +362,13 @@ fun main(args: Array) { model("completion/basic/codeFragments", extension = "kt") } + testClass(javaClass()) { + model("completion/basic/multifile", extension = null, recursive = false) + } + testClass(javaClass()) { + model("completion/smartMultiFile", extension = null, recursive = false) + } + testClass(javaClass()) { model("navigation/gotoSuper", extension = "test") } @@ -605,10 +613,6 @@ fun main(args: Array) { model("stubs", extension = "kt") } - testClass(javaClass()) { - model("completion/basic/multifile", extension = null, recursive = false) - } - testClass(javaClass()) { model("multiFileHighlighting", recursive = false) } diff --git a/idea/testData/completion/smartMultiFile/JavaStaticMethodArgument/JavaClass.java b/idea/testData/completion/smartMultiFile/JavaStaticMethodArgument/JavaClass.java new file mode 100644 index 00000000000..67c0cc8d604 --- /dev/null +++ b/idea/testData/completion/smartMultiFile/JavaStaticMethodArgument/JavaClass.java @@ -0,0 +1,3 @@ +class JavaClass { + public static void search(X x) { } +} diff --git a/idea/testData/completion/smartMultiFile/JavaStaticMethodArgument/JavaStaticMethodArgument.kt b/idea/testData/completion/smartMultiFile/JavaStaticMethodArgument/JavaStaticMethodArgument.kt new file mode 100644 index 00000000000..79e1bdc1c52 --- /dev/null +++ b/idea/testData/completion/smartMultiFile/JavaStaticMethodArgument/JavaStaticMethodArgument.kt @@ -0,0 +1,7 @@ +trait X + +fun foo(x: X) { + JavaClass.search() +} + +// EXIST: x diff --git a/idea/tests/org/jetbrains/jet/completion/AbstractMultiFileJvmBasicCompletionTest.java b/idea/tests/org/jetbrains/jet/completion/AbstractMultiFileJvmBasicCompletionTest.java deleted file mode 100644 index 66aea1c6921..00000000000 --- a/idea/tests/org/jetbrains/jet/completion/AbstractMultiFileJvmBasicCompletionTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.completion; - -import com.intellij.codeInsight.lookup.LookupElement; -import kotlin.Function0; -import kotlin.Function1; -import kotlin.Unit; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.completion.util.UtilPackage; -import org.jetbrains.jet.plugin.KotlinCompletionTestCase; -import org.jetbrains.jet.plugin.PluginTestCaseBase; -import org.jetbrains.jet.plugin.project.TargetPlatform; -import org.jetbrains.jet.plugin.stubs.AstAccessControl; - -public abstract class AbstractMultiFileJvmBasicCompletionTest extends KotlinCompletionTestCase { - protected void doTest(@NotNull String testPath) throws Exception { - configureByFile(getTestName(false) + ".kt", ""); - boolean shouldFail = testPath.contains("NoSpecifiedType"); - AstAccessControl.INSTANCE$.testWithControlledAccessToAst( - shouldFail, getFile().getVirtualFile(), getProject(), getTestRootDisposable(), - new Function0() { - @Override - public Unit invoke() { - UtilPackage.testCompletion(getFile().getText(), TargetPlatform.JVM, new Function1() { - @Override - public LookupElement[] invoke(Integer invocationCount) { - complete(invocationCount); - return myItems; - } - }, 0); - return Unit.INSTANCE$; - } - } - ); - } - - @Override - protected String getTestDataPath() { - return PluginTestCaseBase.getTestDataPathBase() + "/completion/basic/multifile/" + getTestName(false) + "/"; - } -} diff --git a/idea/tests/org/jetbrains/jet/completion/AbstractMultiFileJvmBasicCompletionTest.kt b/idea/tests/org/jetbrains/jet/completion/AbstractMultiFileJvmBasicCompletionTest.kt new file mode 100644 index 00000000000..91ac7f0734e --- /dev/null +++ b/idea/tests/org/jetbrains/jet/completion/AbstractMultiFileJvmBasicCompletionTest.kt @@ -0,0 +1,44 @@ +/* + * 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.completion + +import com.intellij.codeInsight.lookup.LookupElement +import kotlin.Function0 +import kotlin.Function1 +import kotlin.Unit +import org.jetbrains.jet.completion.util.* +import org.jetbrains.jet.plugin.KotlinCompletionTestCase +import org.jetbrains.jet.plugin.PluginTestCaseBase +import org.jetbrains.jet.plugin.project.TargetPlatform +import org.jetbrains.jet.plugin.stubs.AstAccessControl + +public abstract class AbstractMultiFileJvmBasicCompletionTest : KotlinCompletionTestCase() { + protected fun doTest(testPath: String) { + configureByFile(getTestName(false) + ".kt", "") + val shouldFail = testPath.contains("NoSpecifiedType") + AstAccessControl.testWithControlledAccessToAst(shouldFail, getFile().getVirtualFile(), getProject(), getTestRootDisposable(), { + testCompletion(getFile().getText(), TargetPlatform.JVM, { invocationCount -> + complete(invocationCount) + myItems + }, 0) + }) + } + + override fun getTestDataPath(): String { + return PluginTestCaseBase.getTestDataPathBase() + "/completion/basic/multifile/" + getTestName(false) + "/" + } +} diff --git a/idea/tests/org/jetbrains/jet/completion/AbstractMultiFileSmartCompletionTest.kt b/idea/tests/org/jetbrains/jet/completion/AbstractMultiFileSmartCompletionTest.kt new file mode 100644 index 00000000000..6778ce7e45a --- /dev/null +++ b/idea/tests/org/jetbrains/jet/completion/AbstractMultiFileSmartCompletionTest.kt @@ -0,0 +1,45 @@ +/* + * 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.completion + +import org.jetbrains.jet.completion.util.* +import org.jetbrains.jet.plugin.KotlinCompletionTestCase +import org.jetbrains.jet.plugin.PluginTestCaseBase +import org.jetbrains.jet.plugin.project.TargetPlatform +import org.jetbrains.jet.plugin.stubs.AstAccessControl +import com.intellij.codeInsight.completion.CompletionType + +public abstract class AbstractMultiFileSmartCompletionTest : KotlinCompletionTestCase() { + override fun setUp() { + super.setUp() + setType(CompletionType.SMART) + } + + protected fun doTest(testPath: String) { + configureByFile(getTestName(false) + ".kt", "") + AstAccessControl.testWithControlledAccessToAst(false, getFile().getVirtualFile(), getProject(), getTestRootDisposable(), { + testCompletion(getFile().getText(), TargetPlatform.JVM, { invocationCount -> + complete(invocationCount) + myItems + }, 1) + }) + } + + override fun getTestDataPath(): String { + return PluginTestCaseBase.getTestDataPathBase() + "/completion/smartMultiFile/" + getTestName(false) + "/" + } +} diff --git a/idea/tests/org/jetbrains/jet/completion/MultiFileSmartCompletionTestGenerated.java b/idea/tests/org/jetbrains/jet/completion/MultiFileSmartCompletionTestGenerated.java new file mode 100644 index 00000000000..b2f88308c1e --- /dev/null +++ b/idea/tests/org/jetbrains/jet/completion/MultiFileSmartCompletionTestGenerated.java @@ -0,0 +1,43 @@ +/* + * 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.completion; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.jet.JUnit3RunnerWithInners; +import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("idea/testData/completion/smartMultiFile") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class MultiFileSmartCompletionTestGenerated extends AbstractMultiFileSmartCompletionTest { + public void testAllFilesPresentInSmartMultiFile() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/completion/smartMultiFile"), Pattern.compile("^([^\\.]+)$"), false); + } + + @TestMetadata("JavaStaticMethodArgument") + public void testJavaStaticMethodArgument() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/smartMultiFile/JavaStaticMethodArgument/"); + doTest(fileName); + } +}