diff --git a/idea/testData/completion/basic/custom/TopLevelNonImportedExtFun.jar b/idea/testData/completion/basic/custom/TopLevelNonImportedExtFun.jar index 87a2f061f6d..c188655e547 100644 Binary files a/idea/testData/completion/basic/custom/TopLevelNonImportedExtFun.jar and b/idea/testData/completion/basic/custom/TopLevelNonImportedExtFun.jar differ diff --git a/idea/testData/completion/basic/custom/TopLevelNonImportedExtFunSrc/abc.kt b/idea/testData/completion/basic/custom/TopLevelNonImportedExtFunSrc/abc.kt new file mode 100644 index 00000000000..cd2a1b8f239 --- /dev/null +++ b/idea/testData/completion/basic/custom/TopLevelNonImportedExtFunSrc/abc.kt @@ -0,0 +1,9 @@ +package abc + +public fun abcdAAA1(): Unit {} + +public fun abcdBBB2(i: Int) {} + +public fun Int.abcdCCC3() {} + +public fun Int.abcdDDD4(i: Int) {} \ No newline at end of file diff --git a/idea/testData/completion/basic/custom/TopLevelNonImportedFun.jar b/idea/testData/completion/basic/custom/TopLevelNonImportedFun.jar index 87a2f061f6d..5c5910a1aa1 100644 Binary files a/idea/testData/completion/basic/custom/TopLevelNonImportedFun.jar and b/idea/testData/completion/basic/custom/TopLevelNonImportedFun.jar differ diff --git a/idea/testData/completion/basic/custom/TopLevelNonImportedFunSrc/abc.kt b/idea/testData/completion/basic/custom/TopLevelNonImportedFunSrc/abc.kt new file mode 100644 index 00000000000..cd2a1b8f239 --- /dev/null +++ b/idea/testData/completion/basic/custom/TopLevelNonImportedFunSrc/abc.kt @@ -0,0 +1,9 @@ +package abc + +public fun abcdAAA1(): Unit {} + +public fun abcdBBB2(i: Int) {} + +public fun Int.abcdCCC3() {} + +public fun Int.abcdDDD4(i: Int) {} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/completion/AbstractJavaWithLibCompletionTest.java b/idea/tests/org/jetbrains/jet/completion/AbstractJavaWithLibCompletionTest.java index daca77cdc8f..62f6691c2ea 100644 --- a/idea/tests/org/jetbrains/jet/completion/AbstractJavaWithLibCompletionTest.java +++ b/idea/tests/org/jetbrains/jet/completion/AbstractJavaWithLibCompletionTest.java @@ -27,30 +27,31 @@ import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEdito import com.intellij.openapi.vfs.VfsUtil; import com.intellij.testFramework.LightProjectDescriptor; import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl; +import junit.framework.Assert; import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.cli.common.ExitCode; +import org.jetbrains.jet.cli.jvm.K2JVMCompiler; +import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime; +import org.jetbrains.jet.codegen.forTestCompile.ForTestPackJdkAnnotations; import org.jetbrains.jet.plugin.PluginTestCaseBase; import org.jetbrains.jet.plugin.project.TargetPlatform; import org.jetbrains.jet.testing.ConfigLibraryUtil; import java.io.File; +import java.io.IOException; public abstract class AbstractJavaWithLibCompletionTest extends JetFixtureCompletionBaseTestCase { - public void doTestWithJar(String testPath) { + public void doTestWithJar(String testPath) throws IOException { + + File jarDependency = getOrCompileJarDependency(testPath); + assert jarDependency.exists() : "Library file should exist: " + jarDependency.getAbsolutePath(); NewLibraryEditor editor = new NewLibraryEditor(); editor.setName("doTestWithJarLib"); - - File fullDirectoryPath = new File(testPath).getParentFile(); - String jarLibName = getTestName(false) + ".jar"; - - File jarFile = new File(fullDirectoryPath, jarLibName); - assert jarFile.exists() : "Library file should exist: " + jarFile.getAbsolutePath(); - - editor.addRoot(VfsUtil.getUrlForLibraryRoot(jarFile), OrderRootType.CLASSES); + editor.addRoot(VfsUtil.getUrlForLibraryRoot(jarDependency), OrderRootType.CLASSES); try { ConfigLibraryUtil.configureLibrary(myModule, getProjectDescriptor().getSdk(), editor); CodeInsightTestFixtureImpl.ensureIndexesUpToDate(getProject()); - doTest(testPath); } finally { @@ -83,4 +84,30 @@ public abstract class AbstractJavaWithLibCompletionTest extends JetFixtureComple public TargetPlatform getPlatform() { return TargetPlatform.JVM; } + + //NOTE: you can just delete existing jar to recompile data for tests that have kotlin dependency + @NotNull + private File getOrCompileJarDependency(@NotNull String testPath) throws IOException { + File fullDirectoryPath = new File(testPath).getParentFile(); + String jarLibName = getTestName(false) + ".jar"; + File jarFile = new File(fullDirectoryPath, jarLibName); + if (!jarFile.exists()) { + compileDependencySources(jarFile, fullDirectoryPath); + } + return jarFile; + } + + private void compileDependencySources(@NotNull File outputFile, @NotNull File fullDirectoryPath) { + File sourcesDir = new File(fullDirectoryPath, getTestName(true) + "Src"); + File stdlib = ForTestCompileRuntime.runtimeJarForTests(); + File jdkAnnotations = ForTestPackJdkAnnotations.jdkAnnotationsForTests(); + ExitCode rv = new K2JVMCompiler().exec(System.out, + "-src", sourcesDir.getAbsolutePath(), + "-jar", outputFile.getAbsolutePath(), + "-noStdlib", + "-classpath", stdlib.getAbsolutePath(), + "-noJdkAnnotations", + "-annotations", jdkAnnotations.getAbsolutePath()); + Assert.assertEquals("compilation completed with non-zero code: " + rv.getCode(), ExitCode.OK, rv); + } }