[migration to Kotlin LV 2.3] Update Kotlin code w.r.t. KTLC-284 (2)

(non-trivial migrations w/ increased null safety)

GitOrigin-RevId: 187042c28c6d6326013b3d48249f8b7d1e106f2f
This commit is contained in:
Stanislav Ruban
2025-08-02 10:33:39 +00:00
committed by intellij-monorepo-bot
parent ad3231ac2f
commit b70d71a1f7
3 changed files with 7 additions and 9 deletions
@@ -62,10 +62,9 @@ object FileTypeUsageCounterCollector : CounterUsagesCollector() {
private val FILE_TEMPLATE_FIELD: EventField<String?> = StringValidatedByCustomRule(FILE_TEMPLATE_NAME,
BundledFileTemplateValidationRule::class.java)
private fun registerFileTypeEvent(eventId: String, vararg extraFields: EventField<*>?): VarargEventId {
val baseFields = arrayOf<EventField<*>?>(EventFields.PluginInfoFromInstance, EventFields.FileType, EventFields.AnonymizedPath,
SCHEMA, FILE_EXTENSION)
return GROUP.registerVarargEvent(eventId, *ArrayUtil.mergeArrays<EventField<*>?>(baseFields, extraFields))
private fun registerFileTypeEvent(eventId: String, vararg extraFields: EventField<*>): VarargEventId {
val baseFields = arrayOf(EventFields.PluginInfoFromInstance, EventFields.FileType, EventFields.AnonymizedPath, SCHEMA, FILE_EXTENSION)
return GROUP.registerVarargEvent(eventId, *ArrayUtil.mergeArrays(baseFields, extraFields))
}
private val SELECT: VarargEventId = registerFileTypeEvent("select")
@@ -21,10 +21,9 @@ class KotlinAllFilesScopeProvider(private val project: Project) {
KotlinSourceFilterScope.projectAndLibrarySources(GlobalSearchScope.allScope(project), project)
) {
private val projectIndex = ProjectRootManager.getInstance(this@KotlinAllFilesScopeProvider.project).fileIndex
private val scopeComparator = Comparator
.comparing<VirtualFile?, Boolean?> { projectIndex.isInSourceContent(it) }
.thenComparing<Boolean?> { projectIndex.isInLibrarySource(it) }
.thenComparing { file1, file2 -> super.compare(file1, file2) }
private val scopeComparator = compareBy<VirtualFile> { projectIndex.isInSourceContent(it) }
.thenComparing { file: VirtualFile -> projectIndex.isInLibrarySource(file) }
.thenComparing { file1: VirtualFile, file2: VirtualFile -> super.compare(file1, file2) }
override fun compare(file1: VirtualFile, file2: VirtualFile): Int = scopeComparator.compare(file1, file2)
}
@@ -308,7 +308,7 @@ abstract class MavenImportingTestCase : MavenTestCase() {
protected fun getModule(name: String): Module {
val m = ReadAction.compute<Module?, RuntimeException> { ModuleManager.getInstance(project).findModuleByName(name) }
assertNotNull("Module $name not found", m)
return m
return m as Module
}
protected fun assertMavenizedModule(name: String) {