All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.jetbrains.kotlin.frontend.di.injection.kt Maven / Gradle / Ivy
/*
* 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.frontend.di
import org.jetbrains.kotlin.container.*
import org.jetbrains.kotlin.context.LazyResolveToken
import org.jetbrains.kotlin.context.ModuleContext
import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.lazy.*
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
import org.jetbrains.kotlin.types.expressions.DeclarationScopeProviderForLocalClassifierAnalyzer
import org.jetbrains.kotlin.types.expressions.LocalClassDescriptorHolder
import org.jetbrains.kotlin.types.expressions.LocalLazyDeclarationResolver
fun StorageComponentContainer.configureModule(
moduleContext: ModuleContext, platform: TargetPlatform
) {
useInstance(moduleContext)
useInstance(moduleContext.module)
useInstance(moduleContext.project)
useInstance(moduleContext.storageManager)
useInstance(moduleContext.builtIns)
useInstance(moduleContext.platformToKotlinClassMap)
useInstance(platform)
platform.platformConfigurator.configure(this)
for (extension in StorageComponentContainerContributor.getInstances(moduleContext.project)) {
extension.addDeclarations(this, platform)
}
configurePlatformIndependentComponents()
}
private fun StorageComponentContainer.configurePlatformIndependentComponents() {
useImpl()
}
fun StorageComponentContainer.configureModule(
moduleContext: ModuleContext, platform: TargetPlatform, trace: BindingTrace
) {
configureModule(moduleContext, platform)
useInstance(trace)
}
fun createContainerForBodyResolve(
moduleContext: ModuleContext, bindingTrace: BindingTrace,
platform: TargetPlatform, statementFilter: StatementFilter
): StorageComponentContainer = createContainer("BodyResolve") {
configureModule(moduleContext, platform, bindingTrace)
useInstance(statementFilter)
useInstance(LookupTracker.DO_NOTHING)
useInstance(BodyResolveCache.ThrowException)
useImpl()
}
fun createContainerForLazyBodyResolve(
moduleContext: ModuleContext, kotlinCodeAnalyzer: KotlinCodeAnalyzer,
bindingTrace: BindingTrace, platform: TargetPlatform,
bodyResolveCache: BodyResolveCache
): StorageComponentContainer = createContainer("LazyBodyResolve") {
configureModule(moduleContext, platform, bindingTrace)
useInstance(LookupTracker.DO_NOTHING)
useInstance(kotlinCodeAnalyzer)
useInstance(kotlinCodeAnalyzer.getFileScopeProvider())
useInstance(bodyResolveCache)
useImpl()
useImpl()
}
fun createContainerForLazyLocalClassifierAnalyzer(
moduleContext: ModuleContext,
bindingTrace: BindingTrace,
platform: TargetPlatform,
lookupTracker: LookupTracker,
localClassDescriptorHolder: LocalClassDescriptorHolder
): StorageComponentContainer = createContainer("LocalClassifierAnalyzer") {
configureModule(moduleContext, platform, bindingTrace)
useInstance(localClassDescriptorHolder)
useInstance(lookupTracker)
useImpl()
useInstance(NoTopLevelDescriptorProvider)
CompilerEnvironment.configure(this)
useInstance(FileScopeProvider.ThrowException)
useImpl()
useImpl()
}
fun createContainerForLazyResolve(
moduleContext: ModuleContext,
declarationProviderFactory: DeclarationProviderFactory,
bindingTrace: BindingTrace,
platform: TargetPlatform,
targetEnvironment: TargetEnvironment
): StorageComponentContainer = createContainer("LazyResolve") {
configureModule(moduleContext, platform, bindingTrace)
useInstance(declarationProviderFactory)
useInstance(LookupTracker.DO_NOTHING)
targetEnvironment.configure(this)
useImpl()
useImpl()
}
@JvmOverloads fun createLazyResolveSession(
moduleContext: ModuleContext,
declarationProviderFactory: DeclarationProviderFactory,
bindingTrace: BindingTrace,
platform: TargetPlatform,
targetEnvironment: TargetEnvironment = CompilerEnvironment
): ResolveSession = createContainerForLazyResolve(moduleContext, declarationProviderFactory, bindingTrace, platform, targetEnvironment).get()