FIR IDE: rewrite low level API
- Cache ModuleResolveState for module till the world changes
- Resolve every file under a lock
- All creation of raw fir files and resolve of them happens in FirFileBuilder
- Lazy resolve of fir elements happens in FirElementBuilder
Caching works like the following:
- FirModuleResolveState holds PsiToFirCache & DiagnosticsCollector & FileCacheForModuleProvider
- FileCacheForModuleProvider holds a mapping from ModuleInfo to ModuleFileCache
- ModuleFileCache caches
- KtFile -> FirFile mapping
- ClassId -> FirClassLikeDeclaration, CallableId -> FirCallableSymbol
which used in corresponding FirProvider
- mapping from declaration to it's file
which used in corresponding FirProvider
- locks for fir file resolving
- PsiToFirCache provides mapping from KtElement to FirElement
- DiagnosticsCollector collects diagnostics for file and caches them
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 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.
|
||||
*/
|
||||
|
||||
@@ -65,7 +65,7 @@ class FirJavaModuleBasedSession private constructor(
|
||||
|
||||
|
||||
init {
|
||||
sessionProvider.sessionCache[moduleInfo] = this
|
||||
sessionProvider.registerSession(moduleInfo, this)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,14 +118,18 @@ class FirLibrarySession private constructor(
|
||||
}
|
||||
|
||||
init {
|
||||
sessionProvider.sessionCache[moduleInfo] = this
|
||||
sessionProvider.registerSession(moduleInfo, this)
|
||||
}
|
||||
}
|
||||
|
||||
class FirProjectSessionProvider(override val project: Project) : FirSessionProvider {
|
||||
open class FirProjectSessionProvider(override val project: Project) : FirSessionProvider {
|
||||
override fun getSession(moduleInfo: ModuleInfo): FirSession? {
|
||||
return sessionCache[moduleInfo]
|
||||
}
|
||||
|
||||
val sessionCache = mutableMapOf<ModuleInfo, FirSession>()
|
||||
fun registerSession(moduleInfo: ModuleInfo, session: FirSession) {
|
||||
sessionCache[moduleInfo] = session
|
||||
}
|
||||
|
||||
protected open val sessionCache: MutableMap<ModuleInfo, FirSession> = mutableMapOf()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user