[AAPI] Introduce PsiFile in KtNotUnderContentRootModule

Indices are not available in the IDE for files outside content roots,
and the newly introduced 'PsiFile' can be used for searching
classifiers instead.
This commit is contained in:
Yan Zhulanow
2022-12-13 23:59:11 +09:00
committed by Space Team
parent edacf27810
commit 00a266fd88
3 changed files with 8 additions and 4 deletions
@@ -45,7 +45,7 @@ internal class KtModuleProviderImpl(
?: return notUnderContentRootModuleCache.getOrPut(containingFileAsPsiFile) {
KtNotUnderContentRootModuleImpl(
moduleDescription = "Standalone-not-under-content-root-module-for-$containingFileAsPsiFile",
psiFile = containingFileAsPsiFile,
file = containingFileAsPsiFile,
project = project,
)
}
@@ -19,12 +19,12 @@ internal class KtNotUnderContentRootModuleImpl(
override val directRefinementDependencies: List<KtModule> = emptyList(),
override val directFriendDependencies: List<KtModule> = emptyList(),
override val platform: TargetPlatform = JvmPlatforms.defaultJvmPlatform,
psiFile: PsiFile? = null,
override val file: PsiFile? = null,
override val moduleDescription: String,
override val project: Project,
) : KtNotUnderContentRootModule, KtModuleWithPlatform {
override val analyzerServices: PlatformDependentAnalyzerServices = super.analyzerServices
override val contentScope: GlobalSearchScope =
if (psiFile != null) GlobalSearchScope.fileScope(psiFile) else GlobalSearchScope.EMPTY_SCOPE
if (file != null) GlobalSearchScope.fileScope(file) else GlobalSearchScope.EMPTY_SCOPE
}
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.analysis.project.structure
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiFile
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.platform.TargetPlatform
@@ -170,4 +171,7 @@ public class KtBuiltinsModule(
/**
* A set of sources which lives outside project content root. E.g, testdata files or source files of some other project.
*/
public interface KtNotUnderContentRootModule : KtModule
public interface KtNotUnderContentRootModule : KtModule {
public val file: PsiFile?
get() = null
}