Allow configuring kotlin.test in KotlinLightCodeInsightFixtureTestCase
This commit is contained in:
+11
-9
@@ -27,24 +27,26 @@ import com.intellij.openapi.vfs.VfsUtil
|
|||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
open class KotlinJdkAndLibraryProjectDescriptor(private val libraryFile: File) : KotlinLightProjectDescriptor() {
|
open class KotlinJdkAndLibraryProjectDescriptor(private val libraryFiles: List<File>) : KotlinLightProjectDescriptor() {
|
||||||
|
|
||||||
|
constructor(libraryFile: File) : this(listOf(libraryFile))
|
||||||
|
|
||||||
init {
|
init {
|
||||||
assert(libraryFile.exists()) { "Library file doesn't exist: " + libraryFile.absolutePath }
|
for (libraryFile in libraryFiles) {
|
||||||
|
assert(libraryFile.exists()) { "Library file doesn't exist: " + libraryFile.absolutePath }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getModuleType(): ModuleType<*> {
|
override fun getModuleType(): ModuleType<*> = StdModuleTypes.JAVA
|
||||||
return StdModuleTypes.JAVA
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getSdk(): Sdk? {
|
override fun getSdk(): Sdk? = PluginTestCaseBase.mockJdk()
|
||||||
return PluginTestCaseBase.mockJdk()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun configureModule(module: Module, model: ModifiableRootModel) {
|
override fun configureModule(module: Module, model: ModifiableRootModel) {
|
||||||
val editor = NewLibraryEditor()
|
val editor = NewLibraryEditor()
|
||||||
editor.name = LIBRARY_NAME
|
editor.name = LIBRARY_NAME
|
||||||
editor.addRoot(VfsUtil.getUrlForLibraryRoot(libraryFile), OrderRootType.CLASSES)
|
for (libraryFile in libraryFiles) {
|
||||||
|
editor.addRoot(VfsUtil.getUrlForLibraryRoot(libraryFile), OrderRootType.CLASSES)
|
||||||
|
}
|
||||||
|
|
||||||
ConfigLibraryUtil.addLibrary(editor, model)
|
ConfigLibraryUtil.addLibrary(editor, model)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -115,6 +115,9 @@ abstract class KotlinLightCodeInsightFixtureTestCase : KotlinLightCodeInsightFix
|
|||||||
else if (InTextDirectivesUtils.isDirectiveDefined(fileText, "RUNTIME_WITH_SOURCES")) {
|
else if (InTextDirectivesUtils.isDirectiveDefined(fileText, "RUNTIME_WITH_SOURCES")) {
|
||||||
return ProjectDescriptorWithStdlibSources.INSTANCE
|
return ProjectDescriptorWithStdlibSources.INSTANCE
|
||||||
}
|
}
|
||||||
|
else if (InTextDirectivesUtils.isDirectiveDefined(fileText, "RUNTIME_WITH_KOTLIN_TEST")) {
|
||||||
|
return KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE_WITH_KOTLIN_TEST
|
||||||
|
}
|
||||||
else if (InTextDirectivesUtils.isDirectiveDefined(fileText, "RUNTIME") ||
|
else if (InTextDirectivesUtils.isDirectiveDefined(fileText, "RUNTIME") ||
|
||||||
InTextDirectivesUtils.isDirectiveDefined(fileText, "WITH_RUNTIME")) {
|
InTextDirectivesUtils.isDirectiveDefined(fileText, "WITH_RUNTIME")) {
|
||||||
return KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
return KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||||
|
|||||||
+14
@@ -17,14 +17,28 @@
|
|||||||
package org.jetbrains.kotlin.idea.test;
|
package org.jetbrains.kotlin.idea.test;
|
||||||
|
|
||||||
import com.intellij.openapi.projectRoots.Sdk;
|
import com.intellij.openapi.projectRoots.Sdk;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
|
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
|
||||||
|
import org.jetbrains.kotlin.utils.PathUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class KotlinWithJdkAndRuntimeLightProjectDescriptor extends KotlinJdkAndLibraryProjectDescriptor {
|
public class KotlinWithJdkAndRuntimeLightProjectDescriptor extends KotlinJdkAndLibraryProjectDescriptor {
|
||||||
protected KotlinWithJdkAndRuntimeLightProjectDescriptor() {
|
protected KotlinWithJdkAndRuntimeLightProjectDescriptor() {
|
||||||
super(ForTestCompileRuntime.runtimeJarForTests());
|
super(ForTestCompileRuntime.runtimeJarForTests());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected KotlinWithJdkAndRuntimeLightProjectDescriptor(@NotNull List<? extends File> libraryFiles) {
|
||||||
|
super(libraryFiles);
|
||||||
|
}
|
||||||
|
|
||||||
public static final KotlinWithJdkAndRuntimeLightProjectDescriptor INSTANCE = new KotlinWithJdkAndRuntimeLightProjectDescriptor();
|
public static final KotlinWithJdkAndRuntimeLightProjectDescriptor INSTANCE = new KotlinWithJdkAndRuntimeLightProjectDescriptor();
|
||||||
|
public static final KotlinWithJdkAndRuntimeLightProjectDescriptor INSTANCE_WITH_KOTLIN_TEST = new KotlinWithJdkAndRuntimeLightProjectDescriptor(
|
||||||
|
Arrays.asList(ForTestCompileRuntime.runtimeJarForTests(),
|
||||||
|
PathUtil.getKotlinPathsForDistDirectory().getKotlinTestPath())
|
||||||
|
);
|
||||||
public static final KotlinWithJdkAndRuntimeLightProjectDescriptor INSTANCE_FULL_JDK = new KotlinWithJdkAndRuntimeLightProjectDescriptor() {
|
public static final KotlinWithJdkAndRuntimeLightProjectDescriptor INSTANCE_FULL_JDK = new KotlinWithJdkAndRuntimeLightProjectDescriptor() {
|
||||||
@Override
|
@Override
|
||||||
public Sdk getSdk() {
|
public Sdk getSdk() {
|
||||||
|
|||||||
Reference in New Issue
Block a user