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:
Ilya Kirillov
2020-07-16 13:58:57 +03:00
parent 1957be8757
commit 5f424ed1ec
47 changed files with 1492 additions and 920 deletions
+7 -2
View File
@@ -88,8 +88,7 @@ The Kotlin FIR plugin provides language support in IntelliJ IDEA and Android Stu
<applicationService serviceImplementation="org.jetbrains.kotlin.idea.PluginStartupService"/>
<highlightRangeExtension implementation="org.jetbrains.kotlin.idea.fir.highlighter.KotlinFirPsiChecker"/>
<annotator language="kotlin" implementationClass="org.jetbrains.kotlin.idea.fir.highlighter.KotlinFirPsiChecker"/>
<projectService serviceInterface="org.jetbrains.kotlin.idea.fir.low.level.api.FirIdeResolveStateService"
serviceImplementation="org.jetbrains.kotlin.idea.fir.low.level.api.FirIdeResolveStateServiceImpl"/>
<projectService serviceImplementation="org.jetbrains.kotlin.idea.fir.low.level.api.FirIdeResolveStateService"/>
<projectService serviceImplementation="org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade"/>
<completion.contributor language="kotlin"
@@ -157,10 +156,16 @@ The Kotlin FIR plugin provides language support in IntelliJ IDEA and Android Stu
<projectService serviceInterface="org.jetbrains.kotlin.idea.framework.LibraryEffectiveKindProvider"
serviceImplementation="org.jetbrains.kotlin.idea.framework.LibraryEffectiveKindProviderImpl"/>
<applicationService
serviceInterface="org.jetbrains.kotlin.platform.DefaultIdeTargetPlatformKindProvider"
serviceImplementation="org.jetbrains.kotlin.platform.impl.IdeaDefaultIdeTargetPlatformKindProvider"/>
</extensions>
<extensions defaultExtensionNs="com.intellij">
<projectService serviceImplementation="org.jetbrains.kotlin.idea.caches.resolve.IdePackageOracleFactory"/>
<projectService serviceImplementation="org.jetbrains.kotlin.idea.caches.trackers.KotlinCodeBlockModificationListener"/>
<projectService serviceInterface="org.jetbrains.kotlin.load.kotlin.MetadataFinderFactory"