Get rid of getModuleName(), pass configuration to createContextWithSealedModule

Add KotlinTestUtils.newConfiguration() which creates a configuration and sets
the module name to the default test one ("test-module")
This commit is contained in:
Alexander Udalov
2016-05-23 14:19:50 +03:00
parent 69343549b7
commit c5e2f55ea7
15 changed files with 46 additions and 73 deletions
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.cli.common.output.outputUtils.writeAll
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
import org.jetbrains.kotlin.cli.jvm.config.addJavaSourceRoot
import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoot
import org.jetbrains.kotlin.cli.jvm.config.getModuleName
import org.jetbrains.kotlin.cli.jvm.config.jvmClasspathRoots
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.state.GenerationState
@@ -291,7 +290,7 @@ object KotlinToJVMBytecodeCompiler {
override fun analyze(): AnalysisResult {
val sharedTrace = CliLightClassGenerationSupport.NoScopeRecordCliBindingTrace()
val moduleContext =
TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(environment.project, environment.getModuleName())
TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(environment.project, environment.configuration)
return TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
moduleContext,
@@ -1,22 +0,0 @@
/*
* Copyright 2010-2016 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.cli.jvm.config
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.config.JVMConfigurationKeys
fun KotlinCoreEnvironment.getModuleName(): String = configuration.get(JVMConfigurationKeys.MODULE_NAME)!!
@@ -20,7 +20,6 @@ import com.intellij.psi.search.ProjectScope
import org.jetbrains.kotlin.cli.jvm.compiler.CliLightClassGenerationSupport
import org.jetbrains.kotlin.cli.jvm.compiler.JvmPackagePartProvider
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.cli.jvm.config.getModuleName
import org.jetbrains.kotlin.cli.jvm.repl.di.createContainerForReplWithJava
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
import org.jetbrains.kotlin.descriptors.impl.CompositePackageFragmentProvider
@@ -38,7 +37,7 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.*
import org.jetbrains.kotlin.resolve.repl.ReplState
import org.jetbrains.kotlin.script.ScriptPriorities
class CliReplAnalyzerEngine(private val environment: KotlinCoreEnvironment) {
class CliReplAnalyzerEngine(environment: KotlinCoreEnvironment) {
private val topDownAnalysisContext: TopDownAnalysisContext
private val topDownAnalyzer: LazyTopDownAnalyzerForTopLevel
private val resolveSession: ResolveSession
@@ -48,7 +47,7 @@ class CliReplAnalyzerEngine(private val environment: KotlinCoreEnvironment) {
val trace: BindingTraceContext = CliLightClassGenerationSupport.NoScopeRecordCliBindingTrace()
init {
val moduleContext = TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(environment.project, environment.getModuleName())
val moduleContext = TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(environment.project, environment.configuration)
this.module = moduleContext.module
scriptDeclarationFactory = ScriptMutableDeclarationProviderFactory()