[Analysis API] Generify 'KtCodeFragmentModule' to support ordinary files

This commit introduces dangling file modules, which may be either
code fragments or ordinary Kotlin files. As before, code fragments are
analyzed against some context element, however ordinary files only
have a context module.

Code fragments can also have a dangling file module as a contextual one,
including other code fragment. This is done to support potential usages
in completion, intentions and refactorings.
This commit is contained in:
Yan Zhulanow
2023-11-08 19:47:27 +09:00
committed by Space Team
parent 916e46debe
commit b7c774b9e5
16 changed files with 111 additions and 92 deletions
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.project.structure.llFirMo
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirSession
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.llFirSession
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.codeFragment
import org.jetbrains.kotlin.analysis.project.structure.KtCodeFragmentModule
import org.jetbrains.kotlin.analysis.project.structure.KtDanglingFileModule
import org.jetbrains.kotlin.analysis.project.structure.KtModule
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
@@ -248,7 +248,7 @@ internal class KtFirCompilerFacility(
private fun computeTargetModules(module: KtModule): List<KtModule> {
return when (module) {
is KtCodeFragmentModule -> listOf(module.contextModule, module)
is KtDanglingFileModule -> listOf(module.contextModule, module)
else -> listOf(module)
}
}