[AA] KtModule#project shouldn't be null
^KT-55336
This commit is contained in:
committed by
Space Team
parent
f0642d6c9a
commit
5c9aa88617
+4
-2
@@ -24,7 +24,8 @@ internal class KtModuleProviderImpl(
|
||||
) : ProjectStructureProvider() {
|
||||
private val ktNotUnderContentRootModuleWithoutPsiFile by lazy {
|
||||
KtNotUnderContentRootModuleImpl(
|
||||
moduleDescription = "Standalone-not-under-content-root-module-without-psi-file"
|
||||
moduleDescription = "Standalone-not-under-content-root-module-without-psi-file",
|
||||
project = project,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -44,7 +45,8 @@ internal class KtModuleProviderImpl(
|
||||
?: return notUnderContentRootModuleCache.getOrPut(containingFileAsPsiFile) {
|
||||
KtNotUnderContentRootModuleImpl(
|
||||
moduleDescription = "Standalone-not-under-content-root-module-for-$containingFileAsPsiFile",
|
||||
psiFile = containingFileAsPsiFile
|
||||
psiFile = containingFileAsPsiFile,
|
||||
project = project,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.project.structure.impl
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtModule
|
||||
@@ -20,9 +21,10 @@ internal class KtNotUnderContentRootModuleImpl(
|
||||
override val platform: TargetPlatform = JvmPlatforms.defaultJvmPlatform,
|
||||
psiFile: 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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,8 +53,7 @@ public inline fun <R> analyze(
|
||||
nonDefaultLifetimeTokenFactory: KtLifetimeTokenFactory? = null,
|
||||
crossinline action: KtAnalysisSession.() -> R
|
||||
): R {
|
||||
checkNotNull(useSiteKtModule.project)
|
||||
val sessionProvider = KtAnalysisSessionProvider.getInstance(useSiteKtModule.project!!)
|
||||
val sessionProvider = KtAnalysisSessionProvider.getInstance(useSiteKtModule.project)
|
||||
return sessionProvider.analyze(useSiteKtModule, nonDefaultLifetimeTokenFactory, action)
|
||||
}
|
||||
|
||||
|
||||
+5
-12
@@ -65,7 +65,7 @@ public sealed interface KtModule {
|
||||
* [Project] to which module belongs.
|
||||
* If current module depends on some other modules, all those modules should have the same [Project] as the current one.
|
||||
*/
|
||||
public val project: Project?
|
||||
public val project: Project
|
||||
|
||||
/**
|
||||
* Human-readable description of the module. E.g, "main sources of module 'analysis-api'"
|
||||
@@ -73,16 +73,12 @@ public sealed interface KtModule {
|
||||
public val moduleDescription: String
|
||||
}
|
||||
|
||||
public sealed interface KtModuleWithProject : KtModule {
|
||||
override val project: Project
|
||||
}
|
||||
|
||||
/**
|
||||
* A module which consists of a set of source declarations inside a projects.
|
||||
*
|
||||
* Generally, a main or test Source Set.
|
||||
*/
|
||||
public interface KtSourceModule : KtModule, KtModuleWithProject {
|
||||
public interface KtSourceModule : KtModule {
|
||||
public val moduleName: String
|
||||
|
||||
override val moduleDescription: String
|
||||
@@ -97,7 +93,7 @@ public interface KtSourceModule : KtModule, KtModuleWithProject {
|
||||
/**
|
||||
* A module which consists of binary declarations.
|
||||
*/
|
||||
public sealed interface KtBinaryModule : KtModule, KtModuleWithProject {
|
||||
public sealed interface KtBinaryModule : KtModule {
|
||||
/**
|
||||
* A list of binary files which forms a binary module. It can be a list of JARs, KLIBs, folders with .class files.
|
||||
* Should be consistent with [contentScope],
|
||||
@@ -137,7 +133,7 @@ public interface KtSdkModule : KtBinaryModule {
|
||||
/**
|
||||
* A sources for some [KtLibraryModule]
|
||||
*/
|
||||
public interface KtLibrarySourceModule : KtModuleWithProject {
|
||||
public interface KtLibrarySourceModule : KtModule {
|
||||
public val libraryName: String
|
||||
|
||||
/**
|
||||
@@ -174,7 +170,4 @@ 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 {
|
||||
override val project: Project?
|
||||
get() = null
|
||||
}
|
||||
public interface KtNotUnderContentRootModule : KtModule
|
||||
|
||||
Reference in New Issue
Block a user