Move some configuration keys to JVM or to CommonConfigurationKeys

Move CONTENT_ROOTS and SCRIPT_DEFINITIONS_KEY to JVMConfigurationKeys because
they are only used on JVM, rename the latter to SCRIPT_DEFINITIONS.

Move MODULE_NAME to CommonConfigurationKeys to be combined with MODULE_ID in
JSConfigurationKeys in the future
This commit is contained in:
Alexander Udalov
2016-05-25 20:55:15 +03:00
parent 6674412079
commit 05f8836f46
14 changed files with 51 additions and 51 deletions
@@ -0,0 +1,31 @@
/*
* Copyright 2010-2015 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.config
interface ContentRoot
data class KotlinSourceRoot(val path: String): ContentRoot
fun CompilerConfiguration.addKotlinSourceRoot(source: String) {
add(JVMConfigurationKeys.CONTENT_ROOTS, KotlinSourceRoot(source))
}
fun CompilerConfiguration.addKotlinSourceRoots(sources: List<String>): Unit =
sources.forEach { addKotlinSourceRoot(it) }
val CompilerConfiguration.kotlinSourceRoots: List<String>
get() = get(JVMConfigurationKeys.CONTENT_ROOTS)?.filterIsInstance<KotlinSourceRoot>()?.map { it.path }.orEmpty()
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.config;
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents;
import org.jetbrains.kotlin.modules.Module;
import org.jetbrains.kotlin.script.KotlinScriptDefinition;
import java.io.File;
import java.util.List;
@@ -26,6 +27,10 @@ public class JVMConfigurationKeys {
private JVMConfigurationKeys() {
}
// roots, including dependencies and own source
public static final CompilerConfigurationKey<List<ContentRoot>> CONTENT_ROOTS =
CompilerConfigurationKey.create("content roots");
public static final CompilerConfigurationKey<File> OUTPUT_DIRECTORY =
CompilerConfigurationKey.create("output directory");
public static final CompilerConfigurationKey<File> OUTPUT_JAR =
@@ -33,6 +38,9 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<Boolean> INCLUDE_RUNTIME =
CompilerConfigurationKey.create("include runtime to the resulting .jar");
public static final CompilerConfigurationKey<List<KotlinScriptDefinition>> SCRIPT_DEFINITIONS =
CompilerConfigurationKey.create("script definitions");
public static final CompilerConfigurationKey<Boolean> DISABLE_CALL_ASSERTIONS =
CompilerConfigurationKey.create("disable not-null call assertions");
public static final CompilerConfigurationKey<Boolean> DISABLE_PARAM_ASSERTIONS =
@@ -58,7 +66,4 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<List<String>> FRIEND_PATHS =
CompilerConfigurationKey.create("friend module paths");
public static final CompilerConfigurationKey<String> MODULE_NAME =
CompilerConfigurationKey.create("module name");
}
@@ -20,6 +20,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.analyzer.AnalysisResult;
import org.jetbrains.kotlin.config.CommonConfigurationKeys;
import org.jetbrains.kotlin.config.CompilerConfiguration;
import org.jetbrains.kotlin.config.JVMConfigurationKeys;
import org.jetbrains.kotlin.context.ContextKt;
@@ -144,7 +145,7 @@ public enum TopDownAnalyzerFacadeForJVM {
ProjectContext projectContext = ContextKt.ProjectContext(project);
JvmBuiltIns builtIns = new JvmBuiltIns(projectContext.getStorageManager());
MutableModuleContext context = ContextKt.ContextForNewModule(
projectContext, Name.special("<" + configuration.getNotNull(JVMConfigurationKeys.MODULE_NAME) + ">"),
projectContext, Name.special("<" + configuration.getNotNull(CommonConfigurationKeys.MODULE_NAME) + ">"),
JvmPlatform.INSTANCE, builtIns
);
builtIns.setOwnerModuleDescriptor(context.getModule());