[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
@@ -194,10 +194,13 @@ class SymbolKotlinAsJavaSupport(project: Project) : KotlinAsJavaSupportBase<KtMo
private fun KtElement.isFromSourceOrLibraryBinary(): Boolean = getModuleIfSupportEnabled()?.isFromSourceOrLibraryBinary() == true
private fun KtModule.isFromSourceOrLibraryBinary() = when (this) {
is KtSourceModule -> true
is KtLibraryModule -> true
else -> false
private fun KtModule.isFromSourceOrLibraryBinary(): Boolean {
return when (this) {
is KtSourceModule -> true
is KtLibraryModule -> true
is KtDanglingFileModule -> contextModule.isFromSourceOrLibraryBinary()
else -> false
}
}
}