[kotlin] Specify return types explicitly

#KTIJ-30828

GitOrigin-RevId: 11b9b1a362309582abcdbdea63dfd293eee0254b
This commit is contained in:
Vladimir Dolzhenko
2024-08-26 21:11:47 +00:00
committed by intellij-monorepo-bot
parent 8aac86723f
commit 9809443391
23 changed files with 100 additions and 85 deletions
@@ -7,7 +7,6 @@ import com.intellij.ui.PlatformIcons
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.kotlin.analysis.api.KaSession
import org.jetbrains.kotlin.analysis.api.symbols.*
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.psi.KtElement
import javax.swing.Icon
@@ -21,13 +21,13 @@ abstract class AbstractCommonIdePlatformKindTooling : IdePlatformKindTooling() {
private const val MAVEN_COMMON_STDLIB_ID = "kotlin-stdlib-common"
}
override val kind = CommonIdePlatformKind
override val kind: CommonIdePlatformKind get() = CommonIdePlatformKind
override val mavenLibraryIds = listOf(MAVEN_COMMON_STDLIB_ID)
override val gradlePluginId = "kotlin-platform-common"
override val mavenLibraryIds: List<String> = listOf(MAVEN_COMMON_STDLIB_ID)
override val gradlePluginId get() = "kotlin-platform-common"
override val gradlePlatformIds: List<KotlinPlatform> get() = listOf(KotlinPlatform.COMMON)
override val libraryKind = KotlinCommonLibraryKind
override val libraryKind: KotlinCommonLibraryKind get() = KotlinCommonLibraryKind
override fun getTestIcon(declaration: KtNamedDeclaration, allowSlowOperations: Boolean): Icon? {
val platform = declaration.module?.platform
@@ -34,13 +34,13 @@ abstract class AbstractJsIdePlatformKindTooling : IdePlatformKindTooling() {
private const val MAVEN_OLD_JS_STDLIB_ID = "kotlin-js-library"
}
override val kind = JsIdePlatformKind
override val kind: JsIdePlatformKind get() = JsIdePlatformKind
override val mavenLibraryIds = listOf(PathUtil.JS_LIB_NAME, MAVEN_OLD_JS_STDLIB_ID)
override val gradlePluginId = "kotlin-platform-js"
override val mavenLibraryIds: List<String> = listOf(PathUtil.JS_LIB_NAME, MAVEN_OLD_JS_STDLIB_ID)
override val gradlePluginId: String get() = "kotlin-platform-js"
override val gradlePlatformIds: List<KotlinPlatform> get() = listOf(KotlinPlatform.JS)
override val libraryKind = KotlinJavaScriptLibraryKind
override val libraryKind: KotlinJavaScriptLibraryKind get() = KotlinJavaScriptLibraryKind
override fun acceptsAsEntryPoint(function: KtFunction): Boolean {
val contexts by lazy { computeConfigurationContexts(function) }
@@ -22,9 +22,9 @@ import org.jetbrains.kotlin.utils.PathUtil
import javax.swing.Icon
abstract class AbstractJvmIdePlatformKindTooling : IdePlatformKindTooling() {
override val kind = JvmIdePlatformKind
override val kind: JvmIdePlatformKind = JvmIdePlatformKind
override val mavenLibraryIds = listOf(
override val mavenLibraryIds: List<String> = listOf(
PathUtil.KOTLIN_JAVA_STDLIB_NAME,
PathUtil.KOTLIN_JAVA_RUNTIME_JRE7_NAME,
PathUtil.KOTLIN_JAVA_RUNTIME_JDK7_NAME,
@@ -32,12 +32,12 @@ abstract class AbstractJvmIdePlatformKindTooling : IdePlatformKindTooling() {
PathUtil.KOTLIN_JAVA_RUNTIME_JDK8_NAME
)
override val gradlePluginId = "kotlin-platform-jvm"
override val gradlePluginId: String get() = "kotlin-platform-jvm"
override val gradlePlatformIds: List<KotlinPlatform> get() = listOf(KotlinPlatform.JVM, KotlinPlatform.ANDROID)
override val libraryKind: PersistentLibraryKind<*>? = null
override val libraryKind: PersistentLibraryKind<*>? get() = null
override fun acceptsAsEntryPoint(function: KtFunction) = true
override fun acceptsAsEntryPoint(function: KtFunction): Boolean = true
override fun getTestIcon(declaration: KtNamedDeclaration, allowSlowOperations: Boolean): Icon? {
val calculatedTestFrameworkValue = declaration.getUserData(TEST_FRAMEWORK_NAME_KEY)
@@ -84,6 +84,6 @@ abstract class AbstractJvmIdePlatformKindTooling : IdePlatformKindTooling() {
}
private companion object {
val TEST_FRAMEWORK_NAME_KEY = Key.create<CachedValue<String>>("TestFramework:name")
val TEST_FRAMEWORK_NAME_KEY: Key<CachedValue<String>?> = Key.create<CachedValue<String>>("TestFramework:name")
}
}
@@ -24,13 +24,13 @@ interface KotlinNativeRunConfigurationProvider {
}
abstract class AbstractNativeIdePlatformKindTooling : IdePlatformKindTooling() {
override val kind = NativeIdePlatformKind
override val kind: NativeIdePlatformKind = NativeIdePlatformKind
override val mavenLibraryIds: List<String> get() = emptyList()
override val gradlePluginId: String get() = ""
override val gradlePlatformIds: List<KotlinPlatform> get() = listOf(KotlinPlatform.NATIVE)
override val libraryKind: PersistentLibraryKind<*> = KotlinNativeLibraryKind
override val libraryKind: PersistentLibraryKind<*> get() = KotlinNativeLibraryKind
override fun acceptsAsEntryPoint(function: KtFunction): Boolean {
val functionName = function.fqName?.asString() ?: return false
@@ -12,29 +12,25 @@ import javax.swing.Icon
abstract class AbstractWasmIdePlatformKindTooling : IdePlatformKindTooling() {
override val mavenLibraryIds = emptyList<String>()
override val gradlePluginId = ""
override val gradlePlatformIds: List<KotlinPlatform> get() = listOf(KotlinPlatform.WASM)
override val mavenLibraryIds: List<String> get() = emptyList<String>()
override val gradlePluginId: String get() = ""
override val gradlePlatformIds: List<KotlinPlatform> = listOf(KotlinPlatform.WASM)
override fun acceptsAsEntryPoint(function: KtFunction): Boolean {
return false
}
override fun acceptsAsEntryPoint(function: KtFunction): Boolean = false
override fun getTestIcon(declaration: KtNamedDeclaration, allowSlowOperations: Boolean): Icon? {
return null
}
override fun getTestIcon(declaration: KtNamedDeclaration, allowSlowOperations: Boolean): Icon? = null
}
abstract class AbstractWasmJsIdePlatformKindTooling : AbstractWasmIdePlatformKindTooling() {
override val kind = WasmJsIdePlatformKind
override val kind: WasmJsIdePlatformKind get() = WasmJsIdePlatformKind
override val libraryKind = KotlinWasmJsLibraryKind
override val libraryKind: KotlinWasmJsLibraryKind get() = KotlinWasmJsLibraryKind
}
abstract class AbstractWasmWasiIdePlatformKindTooling : AbstractWasmIdePlatformKindTooling() {
override val kind = WasmWasiIdePlatformKind
override val kind: WasmWasiIdePlatformKind get() = WasmWasiIdePlatformKind
override val libraryKind = KotlinWasmWasiLibraryKind
override val libraryKind: KotlinWasmWasiLibraryKind get() = KotlinWasmWasiLibraryKind
}
@@ -31,9 +31,9 @@ abstract class IdePlatformKindTooling {
companion object : ApplicationExtensionDescriptor<IdePlatformKindTooling>(
"org.jetbrains.kotlin.idePlatformKindTooling", IdePlatformKindTooling::class.java
) {
private val ALL_TOOLING_SUPPORT by lazy { getInstances() }
private val ALL_TOOLING_SUPPORT: List<IdePlatformKindTooling> by lazy { getInstances() }
private val TOOLING_SUPPORT_BY_KIND by lazy {
private val TOOLING_SUPPORT_BY_KIND: Map<IdePlatformKind, IdePlatformKindTooling> by lazy {
val allPlatformKinds = IdePlatformKind.ALL_KINDS
val groupedTooling = ALL_TOOLING_SUPPORT.groupBy { it.kind }.mapValues { it.value.single() }
@@ -49,7 +49,7 @@ abstract class IdePlatformKindTooling {
groupedTooling
}
private val TOOLING_SUPPORT_BY_PLATFORM_ID by lazy {
private val TOOLING_SUPPORT_BY_PLATFORM_ID: Map<KotlinPlatform, IdePlatformKindTooling> by lazy {
ALL_TOOLING_SUPPORT.flatMap { tooling -> tooling.gradlePlatformIds.map { it to tooling } }.toMap()
}
@@ -27,18 +27,21 @@ fun hasSomethingInPackage(indexId: ID<FqName, Void>, fqName: FqName, scope: Glob
@ApiStatus.Internal
object FqNameKeyDescriptor : KeyDescriptor<FqName> {
override fun save(output: DataOutput, value: FqName) = IOUtil.writeUTF(output, value.asString())
override fun read(input: DataInput) = FqName(IOUtil.readUTF(input))
override fun getHashCode(value: FqName) = value.asString().hashCode()
override fun isEqual(val1: FqName?, val2: FqName?) = val1 == val2
override fun save(output: DataOutput, value: FqName) {
IOUtil.writeUTF(output, value.asString())
}
override fun read(input: DataInput): FqName = FqName(IOUtil.readUTF(input))
override fun getHashCode(value: FqName): Int = value.asString().hashCode()
override fun isEqual(val1: FqName?, val2: FqName?): Boolean = val1 == val2
}
abstract class KotlinFileIndexBase : ScalarIndexExtension<FqName>() {
protected val LOG = Logger.getInstance(javaClass)
protected val LOG: Logger = Logger.getInstance(javaClass)
override fun dependsOnFileContent() = true
override fun dependsOnFileContent(): Boolean = true
override fun getKeyDescriptor() = FqNameKeyDescriptor
override fun getKeyDescriptor(): FqNameKeyDescriptor = FqNameKeyDescriptor
protected fun indexer(f: (FileContent) -> FqName?): DataIndexer<FqName, Void, FileContent> {
return DataIndexer {
@@ -64,15 +67,15 @@ class KotlinClassFileIndex : KotlinFileIndexBase() {
val NAME: ID<FqName, Void> = ID.create("org.jetbrains.kotlin.idea.vfilefinder.KotlinClassFileIndex")
}
override fun getName() = NAME
override fun getName(): ID<FqName, Void> = NAME
override fun getIndexer() = INDEXER
override fun getIndexer(): DataIndexer<FqName, Void, FileContent> = INDEXER
override fun getInputFilter() = DefaultFileTypeSpecificInputFilter(JavaClassFileType.INSTANCE)
override fun getInputFilter(): DefaultFileTypeSpecificInputFilter = DefaultFileTypeSpecificInputFilter(JavaClassFileType.INSTANCE)
override fun getVersion() = 3
override fun getVersion(): Int = 3
private val INDEXER = indexer { fileContent ->
private val INDEXER: DataIndexer<FqName, Void, FileContent> = indexer { fileContent ->
val headerInfo = ClsKotlinBinaryClassCache.getInstance().getKotlinBinaryClassHeaderData(fileContent.file, fileContent.content)
if (headerInfo != null && headerInfo.metadataVersion.isCompatible()) headerInfo.classId.asSingleFqName() else null
}
@@ -89,16 +92,16 @@ class KotlinStdlibIndex : KotlinFileIndexBase() {
private const val STDLIB_TAG_MANIFEST_ATTRIBUTE = "Kotlin-Runtime-Component"
}
override fun getName() = NAME
override fun getName(): ID<FqName, Void> = NAME
override fun getIndexer() = INDEXER
override fun getIndexer(): DataIndexer<FqName, Void, FileContent> = INDEXER
override fun getInputFilter() = DefaultFileTypeSpecificInputFilter(ManifestFileType.INSTANCE)
override fun getInputFilter(): DefaultFileTypeSpecificInputFilter = DefaultFileTypeSpecificInputFilter(ManifestFileType.INSTANCE)
override fun getVersion() = 1
override fun getVersion(): Int = 1
// TODO: refactor [KotlinFileIndexBase] and get rid of FqName here, it's never a proper fully qualified name, just a String wrapper
private val INDEXER = indexer { fileContent ->
private val INDEXER: DataIndexer<FqName, Void, FileContent> = indexer { fileContent ->
if (fileContent.fileType is ManifestFileType) {
val manifest = Manifest(ByteArrayInputStream(fileContent.content))
val attributes = manifest.mainAttributes
@@ -64,7 +64,7 @@ class IdePlatformKindProjectStructure(private val project: Project) {
@JvmStatic
fun getInstance(project: Project): IdePlatformKindProjectStructure = project.service()
private val PLATFORM_EXTENSIONS = mapOf(
private val PLATFORM_EXTENSIONS: Map<String, IdePlatformKind> = mapOf(
METADATA_FILE_EXTENSION to CommonIdePlatformKind,
"js" to JsIdePlatformKind,
"kjsm" to JsIdePlatformKind
@@ -47,7 +47,7 @@ fun VirtualFile.isKlibLibraryRootForPlatform(targetPlatform: TargetPlatform): Bo
try {
return children?.any { checkKlibComponent(it, targetPlatform, requestedBuiltInsPlatform) } == true
} catch (e: InvalidVirtualFileAccessException) {
} catch (_: InvalidVirtualFileAccessException) {
return false
}
}
@@ -10,10 +10,12 @@ import com.intellij.openapi.project.ProjectBundle
import com.intellij.openapi.roots.OrderRootType
import com.intellij.openapi.roots.libraries.DummyLibraryProperties
import com.intellij.openapi.roots.libraries.LibraryType
import com.intellij.openapi.roots.libraries.LibraryType.EP_NAME
import com.intellij.openapi.roots.libraries.LibraryTypeService
import com.intellij.openapi.roots.libraries.NewLibraryConfiguration
import com.intellij.openapi.roots.libraries.ui.DescendentBasedRootFilter
import com.intellij.openapi.roots.libraries.ui.LibraryEditorComponent
import com.intellij.openapi.roots.libraries.ui.LibraryPropertiesEditor
import com.intellij.openapi.roots.libraries.ui.RootDetector
import com.intellij.openapi.roots.ui.configuration.libraryEditor.DefaultLibraryRootsComponentDescriptor
import com.intellij.openapi.util.text.StringUtil
@@ -22,13 +24,16 @@ import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.base.platforms.KotlinBasePlatformsBundle
import org.jetbrains.kotlin.idea.base.platforms.KotlinJavaScriptLibraryKind
import javax.swing.Icon
import javax.swing.JComponent
class JSLibraryType : LibraryType<DummyLibraryProperties>(KotlinJavaScriptLibraryKind) {
override fun createPropertiesEditor(editorComponent: LibraryEditorComponent<DummyLibraryProperties>) = null
override fun createPropertiesEditor(editorComponent: LibraryEditorComponent<DummyLibraryProperties>): LibraryPropertiesEditor? {
return null
}
@Suppress("HardCodedStringLiteral")
override fun getCreateActionName() = "Kotlin/JS"
override fun getCreateActionName(): String = "Kotlin/JS"
override fun createNewLibrary(
parentComponent: JComponent,
@@ -40,11 +45,11 @@ class JSLibraryType : LibraryType<DummyLibraryProperties>(KotlinJavaScriptLibrar
project
)
override fun getIcon(properties: DummyLibraryProperties?) = KotlinIcons.JS
override fun getIcon(properties: DummyLibraryProperties?): Icon = KotlinIcons.JS
companion object {
@Suppress("DEPRECATION")
fun getInstance() = Extensions.findExtension(EP_NAME, JSLibraryType::class.java)
fun getInstance(): JSLibraryType = Extensions.findExtension(EP_NAME, JSLibraryType::class.java)
}
object RootsComponentDescriptor : DefaultLibraryRootsComponentDescriptor() {
@@ -60,7 +65,7 @@ class JSLibraryType : LibraryType<DummyLibraryProperties>(KotlinJavaScriptLibrar
return descriptor
}
override fun getRootTypes() = arrayOf(OrderRootType.CLASSES, OrderRootType.SOURCES)
override fun getRootTypes(): Array<OrderRootType?> = arrayOf(OrderRootType.CLASSES, OrderRootType.SOURCES)
override fun getRootDetectors(): List<RootDetector> = arrayListOf(
DescendentBasedRootFilter(OrderRootType.CLASSES, false, KotlinBasePlatformsBundle.message("presentable.type.js.files")) {
@@ -71,4 +76,4 @@ class JSLibraryType : LibraryType<DummyLibraryProperties>(KotlinJavaScriptLibrar
}
}
private fun isAcceptedForJsLibrary(extension: String?) = extension == "js" || extension == "kjsm"
private fun isAcceptedForJsLibrary(extension: String?): Boolean = extension == "js" || extension == "kjsm"
@@ -6,14 +6,16 @@ import com.intellij.openapi.roots.libraries.DummyLibraryProperties
import com.intellij.openapi.roots.libraries.LibraryType
import com.intellij.openapi.roots.libraries.PersistentLibraryKind
import com.intellij.openapi.roots.libraries.ui.LibraryEditorComponent
import com.intellij.openapi.roots.libraries.ui.LibraryPropertiesEditor
import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.base.platforms.KotlinWasmJsLibraryKind
import org.jetbrains.kotlin.idea.base.platforms.KotlinWasmWasiLibraryKind
import javax.swing.Icon
import javax.swing.JComponent
abstract class WasmLibraryType(libraryKind: PersistentLibraryKind<DummyLibraryProperties>) : LibraryType<DummyLibraryProperties>(libraryKind) {
override fun createPropertiesEditor(editorComponent: LibraryEditorComponent<DummyLibraryProperties>) = null
override fun createPropertiesEditor(editorComponent: LibraryEditorComponent<DummyLibraryProperties>): LibraryPropertiesEditor? = null
override fun getCreateActionName(): Nothing? = null
@@ -23,7 +25,7 @@ abstract class WasmLibraryType(libraryKind: PersistentLibraryKind<DummyLibraryPr
project: Project
): Nothing? = null
override fun getIcon(properties: DummyLibraryProperties?) = KotlinIcons.JS
override fun getIcon(properties: DummyLibraryProperties?): Icon = KotlinIcons.JS
}
class WasmJsLibraryType : WasmLibraryType(KotlinWasmJsLibraryKind)
@@ -17,6 +17,7 @@ import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.ThrowableComputable
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.VirtualFileSystem
import com.intellij.platform.backend.workspace.WorkspaceModelChangeListener
import com.intellij.platform.backend.workspace.WorkspaceModelTopics
import com.intellij.platform.workspace.jps.entities.ModuleEntity
@@ -48,9 +49,9 @@ interface KotlinStdlibCache {
?: error("Failed to load service ${KotlinStdlibCache::class.java.name}")
}
val Disabled = object : KotlinStdlibCache {
override fun isStdlib(libraryInfo: LibraryInfo) = false
override fun isStdlibDependency(libraryInfo: LibraryInfo) = false
val Disabled: KotlinStdlibCache = object : KotlinStdlibCache {
override fun isStdlib(libraryInfo: LibraryInfo): Boolean = false
override fun isStdlibDependency(libraryInfo: LibraryInfo): Boolean = false
override fun findStdlibInModuleDependencies(module: IdeaModuleInfo): LibraryInfo? = null
}
}
@@ -79,11 +80,11 @@ internal class KotlinStdlibCacheImpl(private val project: Project) : KotlinStdli
project: Project,
private val directories: Set<VirtualFile>
) : DelegatingGlobalSearchScope(GlobalSearchScope.allScope(project)) {
private val fileSystems = directories.mapTo(hashSetOf(), VirtualFile::getFileSystem)
private val fileSystems: Set<VirtualFileSystem> = directories.mapTo(hashSetOf(), VirtualFile::getFileSystem)
override fun contains(file: VirtualFile): Boolean = file.fileSystem in fileSystems && VfsUtilCore.isUnder(file, directories)
override fun toString() = "All files under: $directories"
override fun toString(): String = "All files under: $directories"
}
private fun libraryScopeContainsIndexedFilesForName(libraryInfo: LibraryInfo, name: FqName): Boolean {
@@ -93,9 +94,9 @@ internal class KotlinStdlibCacheImpl(private val project: Project) : KotlinStdli
})
}
private fun isFatJar(libraryInfo: LibraryInfo) = libraryInfo.getLibraryRoots().size > 1
private fun isFatJar(libraryInfo: LibraryInfo): Boolean = libraryInfo.getLibraryRoots().size > 1
private fun isKotlinJavaRuntime(libraryInfo: LibraryInfo) = libraryInfo.library.name == KOTLIN_JAVA_RUNTIME_NAME
private fun isKotlinJavaRuntime(libraryInfo: LibraryInfo): Boolean = libraryInfo.library.name == KOTLIN_JAVA_RUNTIME_NAME
override fun isStdlib(libraryInfo: LibraryInfo): Boolean = stdlibCache[libraryInfo]
@@ -107,7 +108,7 @@ internal class KotlinStdlibCacheImpl(private val project: Project) : KotlinStdli
return stdlibDependency.libraryInfo
}
override fun dispose() = Unit
override fun dispose() {}
private sealed class BaseStdLibCache(project: Project) :
SynchronizedFineGrainedEntityCache<LibraryInfo, Boolean>(project, doSelfInitialization = false, cleanOnLowMemory = true),
@@ -154,7 +155,7 @@ internal class KotlinStdlibCacheImpl(private val project: Project) : KotlinStdli
else -> moduleCache[key]
}
override fun dispose() = Unit
override fun dispose() {}
private abstract inner class AbstractCache<Key : IdeaModuleInfo> :
SynchronizedFineGrainedEntityCache<Key, StdlibDependency>(project, doSelfInitialization = false, cleanOnLowMemory = true),
@@ -8,11 +8,14 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.impl.libraries.LibraryEx
import org.jetbrains.kotlin.idea.base.util.asKotlinLogger
import org.jetbrains.kotlin.konan.file.File
import org.jetbrains.kotlin.library.*
import org.jetbrains.kotlin.library.KotlinLibrary
import org.jetbrains.kotlin.library.ToolingSingleFileKlibResolveStrategy
import org.jetbrains.kotlin.library.metadata.KlibMetadataVersion
import org.jetbrains.kotlin.library.metadata.isCInteropLibrary
import org.jetbrains.kotlin.library.metadata.isCommonizedCInteropLibrary
import org.jetbrains.kotlin.library.metadata.metadataVersion
import org.jetbrains.kotlin.library.resolveSingleFileKlib
import org.jetbrains.kotlin.library.uniqueName
import org.jetbrains.kotlin.platform.TargetPlatform
/**
@@ -33,7 +36,7 @@ abstract class AbstractKlibLibraryInfo internal constructor(project: Project, li
val compatibilityInfo: KlibCompatibilityInfo by lazy { resolvedKotlinLibrary.compatibilityInfo }
final override fun getLibraryRoots() = listOf(libraryRoot)
final override fun getLibraryRoots(): List<String> = listOf(libraryRoot)
abstract override val platform: TargetPlatform // must override
@@ -42,7 +45,7 @@ abstract class AbstractKlibLibraryInfo internal constructor(project: Project, li
val isInterop: Boolean by lazy { resolvedKotlinLibrary.isCInteropLibrary() || resolvedKotlinLibrary.isCommonizedCInteropLibrary() }
companion object {
private val LOG = Logger.getInstance(AbstractKlibLibraryInfo::class.java).asKotlinLogger()
private val LOG: org.jetbrains.kotlin.util.Logger = Logger.getInstance(AbstractKlibLibraryInfo::class.java).asKotlinLogger()
}
}
@@ -15,11 +15,12 @@ data class ModuleProductionSourceInfo internal constructor(
override val module: Module
) : ModuleSourceInfoWithExpectedBy(forProduction = true) {
override val name = Name.special("<production sources for module ${module.name}>")
override val name: Name
get() = Name.special("<production sources for module ${module.name}>")
override val stableName: Name by lazy { module.stableName }
override fun keyForSdk() = KeyForSdks
override fun keyForSdk(): KeyForSdks = KeyForSdks
override val contentScope: GlobalSearchScope
get() = KotlinResolveScopeEnlarger.enlargeScope(module.moduleProductionSourceScope, module, isTestScope = false)
@@ -4,6 +4,7 @@ package org.jetbrains.kotlin.idea.base.projectStructure.moduleInfo
import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.ModificationTracker
import com.intellij.openapi.util.NlsSafe
import com.intellij.serviceContainer.AlreadyDisposedException
import org.jetbrains.kotlin.analyzer.ModuleSourceInfoBase
import org.jetbrains.kotlin.analyzer.TrackableModuleInfo
@@ -19,7 +20,7 @@ interface ModuleSourceInfo : OldModuleSourceInfo, IdeaModuleInfo, TrackableModul
override val expectedBy: List<ModuleSourceInfo>
override val displayedName get() = module.name
override val displayedName: @NlsSafe String get() = module.name
override val moduleOrigin: ModuleOrigin
get() = ModuleOrigin.MODULE
@@ -8,7 +8,6 @@ import com.intellij.util.SmartList
import org.jetbrains.kotlin.analyzer.ModuleInfo
import org.jetbrains.kotlin.caches.project.cacheByClassInvalidatingOnRootModifications
import org.jetbrains.kotlin.idea.base.facet.additionalVisibleModules
import org.jetbrains.kotlin.idea.base.facet.isTestModule
import org.jetbrains.kotlin.idea.base.facet.stableName
import org.jetbrains.kotlin.idea.base.projectStructure.KotlinBaseProjectStructureBundle
import org.jetbrains.kotlin.idea.base.projectStructure.KotlinResolveScopeEnlarger
@@ -22,9 +21,10 @@ import org.jetbrains.kotlin.utils.closure
data class ModuleTestSourceInfo internal constructor(
override val module: Module
) : ModuleSourceInfoWithExpectedBy(forProduction = false), IdeaModuleInfo {
override val name = Name.special("<test sources for module ${module.name}>")
override val name: Name
get() = Name.special("<test sources for module ${module.name}>")
override val displayedName
override val displayedName: String
get() = KotlinBaseProjectStructureBundle.message("module.name.0.test", module.name)
override val stableName: Name by lazy { module.stableName }
@@ -54,7 +54,7 @@ data class ModuleTestSourceInfo internal constructor(
private object KeyForModulesWhoseInternalsAreVisible
override fun keyForSdk() = KeyForSdks
override fun keyForSdk(): KeyForSdks = KeyForSdks
protected object KeyForSdks
}
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.scripting.definitions.ScriptDefinition
sealed class ScriptDependenciesInfo(override val project: Project) : IdeaModuleInfo, BinaryModuleInfo {
abstract val sdk: Sdk?
override val name = Name.special("<Script dependencies>")
override val name: Name get() = Name.special("<Script dependencies>")
override val displayedName: String
get() = KotlinBaseScriptingBundle.message("script.dependencies")
@@ -45,7 +45,8 @@ data class ScriptModuleInfo(
override val moduleOrigin: ModuleOrigin
get() = ModuleOrigin.OTHER
override val name: Name = Name.special("<script ${scriptFile.name} ${scriptDefinition.name}>")
override val name: Name
get() = Name.special("<script ${scriptFile.name} ${scriptDefinition.name}>")
override val displayedName: String
get() = KotlinBaseProjectStructureBundle.message("script.0.1", scriptFile.presentableName, scriptDefinition.name)
@@ -35,7 +35,8 @@ class BundledScriptDefinitionContributor(val project: Project) : ScriptDefinitio
override fun getDefinitions() = listOf(myLegacyBundledIdeScriptDefinition)
@Deprecated("migrating to new configuration refinement: drop usages")
override val id: String = "StandardKotlinScript"
override val id: String
get() = "StandardKotlinScript"
}
class LegacyBundledIdeScriptDefinition internal constructor(project: Project) : KotlinScriptDefinition(ScriptTemplateWithArgs::class) {
@@ -31,7 +31,7 @@ open class KotlinJsModuleConfigurator : KotlinWithLibraryConfigurator<DummyLibra
override val presentableText: String
get() = KotlinProjectConfigurationBundle.message("language.name.javascript")
override fun isConfigured(module: Module) = hasKotlinJsLegacyRuntimeInScope(module)
override fun isConfigured(module: Module): Boolean = hasKotlinJsLegacyRuntimeInScope(module)
override val libraryName: String
get() = JSLibraryStdDescription.LIBRARY_NAME
@@ -437,7 +437,8 @@ abstract class KotlinWithLibraryConfigurator<P : LibraryProperties<*>> protected
)
}
override val canAddModuleWideOptIn: Boolean = true
override val canAddModuleWideOptIn: Boolean
get() = true
override fun addModuleWideOptIn(module: Module, annotationFqName: FqName, compilerArgument: String) {
module.addCompilerArgumentToKotlinFacet(compilerArgument)
@@ -38,7 +38,8 @@ import org.junit.runners.JUnit4
@TestRoot("project-wizard/tests")
@RunWith(JUnit4::class)
class MavenNewKotlinModuleTest : MavenNewProjectWizardTestCase(), NewKotlinProjectTestUtils {
override val testDirectory = "testData/mavenNewProjectWizard"
override val testDirectory: String
get() = "testData/mavenNewProjectWizard"
private val newModuleName = "module"
@JvmField