Introduce TargetEnvironment and CompilerEnvironment
This commit is contained in:
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.load.java.JavaClassFinderImpl
|
|||||||
import org.jetbrains.kotlin.load.java.lazy.SingleModuleClassResolver
|
import org.jetbrains.kotlin.load.java.lazy.SingleModuleClassResolver
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||||
import org.jetbrains.kotlin.resolve.BodyResolveCache
|
import org.jetbrains.kotlin.resolve.BodyResolveCache
|
||||||
|
import org.jetbrains.kotlin.resolve.CompilerEnvironment
|
||||||
import org.jetbrains.kotlin.resolve.LazyTopDownAnalyzerForTopLevel
|
import org.jetbrains.kotlin.resolve.LazyTopDownAnalyzerForTopLevel
|
||||||
import org.jetbrains.kotlin.resolve.jvm.JavaClassFinderPostConstruct
|
import org.jetbrains.kotlin.resolve.jvm.JavaClassFinderPostConstruct
|
||||||
import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolver
|
import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolver
|
||||||
@@ -44,7 +45,8 @@ public fun createContainerForReplWithJava(
|
|||||||
|
|
||||||
useInstance(additionalFileScopeProvider)
|
useInstance(additionalFileScopeProvider)
|
||||||
useInstance(declarationProviderFactory)
|
useInstance(declarationProviderFactory)
|
||||||
useInstance(BodyResolveCache.ThrowException)
|
|
||||||
|
CompilerEnvironment.configure(this)
|
||||||
|
|
||||||
useImpl<FileScopeProviderImpl>()
|
useImpl<FileScopeProviderImpl>()
|
||||||
useImpl<SingleModuleClassResolver>()
|
useImpl<SingleModuleClassResolver>()
|
||||||
|
|||||||
@@ -32,10 +32,7 @@ import org.jetbrains.kotlin.load.java.sam.SamConversionResolverImpl
|
|||||||
import org.jetbrains.kotlin.load.java.structure.impl.JavaPropertyInitializerEvaluatorImpl
|
import org.jetbrains.kotlin.load.java.structure.impl.JavaPropertyInitializerEvaluatorImpl
|
||||||
import org.jetbrains.kotlin.load.kotlin.DeserializationComponentsForJava
|
import org.jetbrains.kotlin.load.kotlin.DeserializationComponentsForJava
|
||||||
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinderFactory
|
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinderFactory
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
import org.jetbrains.kotlin.resolve.*
|
||||||
import org.jetbrains.kotlin.resolve.BodyResolveCache
|
|
||||||
import org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer
|
|
||||||
import org.jetbrains.kotlin.resolve.LazyTopDownAnalyzerForTopLevel
|
|
||||||
import org.jetbrains.kotlin.resolve.jvm.JavaClassFinderPostConstruct
|
import org.jetbrains.kotlin.resolve.jvm.JavaClassFinderPostConstruct
|
||||||
import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolver
|
import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolver
|
||||||
import org.jetbrains.kotlin.resolve.jvm.JavaLazyAnalyzerPostConstruct
|
import org.jetbrains.kotlin.resolve.jvm.JavaLazyAnalyzerPostConstruct
|
||||||
@@ -80,7 +77,9 @@ public fun createContainerForLazyResolveWithJava(
|
|||||||
useInstance(moduleClassResolver)
|
useInstance(moduleClassResolver)
|
||||||
|
|
||||||
useInstance(declarationProviderFactory)
|
useInstance(declarationProviderFactory)
|
||||||
useInstance(BodyResolveCache.ThrowException)
|
|
||||||
|
CompilerEnvironment.configure(this)
|
||||||
|
|
||||||
useImpl<FileScopeProviderImpl>()
|
useImpl<FileScopeProviderImpl>()
|
||||||
useImpl<LazyResolveToken>()
|
useImpl<LazyResolveToken>()
|
||||||
}.let {
|
}.let {
|
||||||
@@ -101,7 +100,8 @@ public fun createContainerForTopDownAnalyzerForJvm(
|
|||||||
configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project, lookupTracker)
|
configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project, lookupTracker)
|
||||||
|
|
||||||
useInstance(declarationProviderFactory)
|
useInstance(declarationProviderFactory)
|
||||||
useInstance(BodyResolveCache.ThrowException)
|
|
||||||
|
CompilerEnvironment.configure(this)
|
||||||
|
|
||||||
useImpl<SingleModuleClassResolver>()
|
useImpl<SingleModuleClassResolver>()
|
||||||
useImpl<FileScopeProviderImpl>()
|
useImpl<FileScopeProviderImpl>()
|
||||||
|
|||||||
@@ -60,7 +60,9 @@ public fun createContainerForBodyResolve(
|
|||||||
configureModule(moduleContext, platform, bindingTrace)
|
configureModule(moduleContext, platform, bindingTrace)
|
||||||
|
|
||||||
useInstance(statementFilter)
|
useInstance(statementFilter)
|
||||||
useInstance(BodyResolveCache.ThrowException)
|
|
||||||
|
CompilerEnvironment.configure(this)
|
||||||
|
|
||||||
useImpl<BodyResolver>()
|
useImpl<BodyResolver>()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +92,9 @@ public fun createContainerForLazyLocalClassifierAnalyzer(
|
|||||||
useImpl<LazyTopDownAnalyzer>()
|
useImpl<LazyTopDownAnalyzer>()
|
||||||
|
|
||||||
useInstance(NoTopLevelDescriptorProvider)
|
useInstance(NoTopLevelDescriptorProvider)
|
||||||
useInstance(BodyResolveCache.ThrowException)
|
|
||||||
|
CompilerEnvironment.configure(this)
|
||||||
|
|
||||||
useInstance(FileScopeProvider.ThrowException)
|
useInstance(FileScopeProvider.ThrowException)
|
||||||
|
|
||||||
useImpl<DeclarationScopeProviderForLocalClassifierAnalyzer>()
|
useImpl<DeclarationScopeProviderForLocalClassifierAnalyzer>()
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* 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.resolve
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.container.StorageComponentContainer
|
||||||
|
import org.jetbrains.kotlin.container.useImpl
|
||||||
|
import org.jetbrains.kotlin.container.useInstance
|
||||||
|
|
||||||
|
public object CompilerEnvironment : TargetEnvironment("Compiler") {
|
||||||
|
override fun configure(container: StorageComponentContainer) {
|
||||||
|
container.useInstance(BodyResolveCache.ThrowException)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* 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.resolve
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.container.StorageComponentContainer
|
||||||
|
|
||||||
|
public abstract class TargetEnvironment(private val name: String) {
|
||||||
|
public abstract fun configure(container: StorageComponentContainer)
|
||||||
|
|
||||||
|
override fun toString() = name
|
||||||
|
}
|
||||||
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.incremental.components.LookupTracker
|
|||||||
import org.jetbrains.kotlin.js.resolve.JsPlatform
|
import org.jetbrains.kotlin.js.resolve.JsPlatform
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||||
import org.jetbrains.kotlin.resolve.BodyResolveCache
|
import org.jetbrains.kotlin.resolve.BodyResolveCache
|
||||||
|
import org.jetbrains.kotlin.resolve.CompilerEnvironment
|
||||||
import org.jetbrains.kotlin.resolve.LazyTopDownAnalyzerForTopLevel
|
import org.jetbrains.kotlin.resolve.LazyTopDownAnalyzerForTopLevel
|
||||||
import org.jetbrains.kotlin.resolve.lazy.FileScopeProviderImpl
|
import org.jetbrains.kotlin.resolve.lazy.FileScopeProviderImpl
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||||
@@ -42,7 +43,9 @@ public fun createTopDownAnalyzerForJs(
|
|||||||
|
|
||||||
useInstance(declarationProviderFactory)
|
useInstance(declarationProviderFactory)
|
||||||
useImpl<FileScopeProviderImpl>()
|
useImpl<FileScopeProviderImpl>()
|
||||||
useInstance(BodyResolveCache.ThrowException)
|
|
||||||
|
CompilerEnvironment.configure(this)
|
||||||
|
|
||||||
useInstance(LookupTracker.DO_NOTHING)
|
useInstance(LookupTracker.DO_NOTHING)
|
||||||
useImpl<ResolveSession>()
|
useImpl<ResolveSession>()
|
||||||
useImpl<LazyTopDownAnalyzerForTopLevel>()
|
useImpl<LazyTopDownAnalyzerForTopLevel>()
|
||||||
|
|||||||
Reference in New Issue
Block a user