From bc0654e29891fa5e93b8d122518179779aae7e6a Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 27 May 2015 19:26:13 +0200 Subject: allow to explicitly specify the type of root for every input path --- src/Analysis/AnalysisEnvironment.kt | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/Analysis/AnalysisEnvironment.kt') diff --git a/src/Analysis/AnalysisEnvironment.kt b/src/Analysis/AnalysisEnvironment.kt index 1d0631bb..164f76f5 100644 --- a/src/Analysis/AnalysisEnvironment.kt +++ b/src/Analysis/AnalysisEnvironment.kt @@ -16,10 +16,7 @@ import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment -import org.jetbrains.kotlin.cli.jvm.config.addJavaSourceRoot -import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoot -import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoots -import org.jetbrains.kotlin.cli.jvm.config.jvmClasspathRoots +import org.jetbrains.kotlin.cli.jvm.config.* import org.jetbrains.kotlin.config.* import org.jetbrains.kotlin.idea.caches.resolve.KotlinCacheService import org.jetbrains.kotlin.idea.caches.resolve.LibraryModificationTracker @@ -106,19 +103,23 @@ public class AnalysisEnvironment(val messageCollector: MessageCollector, body: A */ public fun addSources(list: List) { list.forEach { - val file = File(it) - if (file.extension == "java") { - configuration.addJavaSourceRoot(file) - } else { - configuration.addKotlinSourceRoot(it) - } + configuration.add(CommonConfigurationKeys.CONTENT_ROOTS, contentRootFromPath(it)) } } + public fun addRoots(list: List) { + configuration.addAll(CommonConfigurationKeys.CONTENT_ROOTS, list) + } + /** * Disposes the environment and frees all associated resources. */ public override fun dispose() { Disposer.dispose(this) } -} \ No newline at end of file +} + +public fun contentRootFromPath(path: String): ContentRoot { + val file = File(path) + return if (file.extension == "java") JavaSourceRoot(file) else KotlinSourceRoot(path) +} -- cgit