org.jetbrains.kotlin.fir.extensions.FirExtensionDeclarationsSymbolProvider.kt Maven / Gradle / Ivy
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.extensions
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.FirSessionComponent
import org.jetbrains.kotlin.fir.caches.*
import org.jetbrains.kotlin.fir.declarations.validate
import org.jetbrains.kotlin.fir.ownerGenerator
import org.jetbrains.kotlin.fir.render
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolNamesProvider
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProviderInternals
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope
import org.jetbrains.kotlin.fir.scopes.processClassifiersByName
import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.name.CallableId
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.utils.addToStdlib.flatGroupBy
@OptIn(FirExtensionApiInternals::class)
class FirExtensionDeclarationsSymbolProvider private constructor(
session: FirSession,
cachesFactory: FirCachesFactory,
private val extensions: List
) : FirSymbolProvider(session), FirSessionComponent {
companion object {
fun createIfNeeded(session: FirSession): FirExtensionDeclarationsSymbolProvider? {
val extensions = session.extensionService.declarationGenerators
if (extensions.isEmpty()) return null
return FirExtensionDeclarationsSymbolProvider(session, session.firCachesFactory, extensions)
}
}
// ------------------------------------------ caches ------------------------------------------
private val classCache: FirCache?, Nothing?> = cachesFactory.createCache { classId, _ ->
generateClassLikeDeclaration(classId)
}
private val functionCache: FirCache, Nothing?> = cachesFactory.createCache { callableId, _ ->
generateTopLevelFunctions(callableId)
}
private val propertyCache: FirCache, Nothing?> = cachesFactory.createCache { callableId, _ ->
generateTopLevelProperties(callableId)
}
private val packageCache: FirCache = cachesFactory.createCache { packageFqName, _ ->
hasPackage(packageFqName)
}
private val callableNamesInPackageCache: FirLazyValue
© 2015 - 2024 Weber Informatics LLC | Privacy Policy