[compiler] replace Enum values() with entries

To fix warnings. Also, use of `Enum.entries` may improve the performance

^KT-48872
This commit is contained in:
Dmitrii Gridin
2024-02-15 00:02:32 +01:00
committed by Space Team
parent ec167d4d42
commit 072d191306
60 changed files with 174 additions and 267 deletions
@@ -1,6 +1,6 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.spec.consistency
@@ -26,7 +26,7 @@ class SpecTestsConsistencyTest : TestCase() {
fun getTestFiles(): Stream<String> {
val testFiles = mutableListOf<String>()
TestArea.values().forEach { testArea ->
TestArea.entries.forEach { testArea ->
val testDataPath =
"${GeneralConfiguration.SPEC_TESTDATA_PATH}/${testArea.testDataPath}/${SpecTestLinkedType.LINKED.testDataPath}"
@@ -1,6 +1,6 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.spec.utils
@@ -10,9 +10,9 @@ import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.LINKED_TESTS_PATH
import org.jetbrains.kotlin.spec.utils.models.LinkedSpecTestFileInfoElementType
import org.jetbrains.kotlin.spec.utils.models.NotLinkedSpecTestFileInfoElementType
import org.jetbrains.kotlin.spec.utils.parsers.BasePatterns
import org.jetbrains.kotlin.spec.utils.parsers.CommonParser.withSpaces
import org.jetbrains.kotlin.spec.utils.parsers.LinkedSpecTestPatterns
import org.jetbrains.kotlin.spec.utils.parsers.NotLinkedSpecTestPatterns
import org.jetbrains.kotlin.spec.utils.parsers.CommonParser.withSpaces
import java.util.*
import java.util.regex.Matcher
import java.util.regex.Pattern
@@ -27,8 +27,8 @@ enum class TestType(val type: String) {
NEGATIVE("neg");
companion object {
private val map = values().associateBy(TestType::type)
val joinedValues = values().joinToString("|").withSpaces()
private val map = entries.associateBy(TestType::type)
val joinedValues = entries.joinToString("|").withSpaces()
fun fromValue(type: String) = map[type]
}
@@ -51,7 +51,7 @@ enum class TestArea(val testDataPath: String) {
CODEGEN_BOX("codegen/box");
companion object {
val joinedValues = values().joinToString("|").withSpaces()
val joinedValues = entries.joinToString("|").withSpaces()
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -56,7 +56,7 @@ object SectionsJsonMapGenerator {
) {
companion object {
private fun identifyTestArea(path: String): TestArea {
TestArea.values().forEach {
TestArea.entries.forEach {
if (path.startsWith(it.testDataPath)) return it
}
throw IllegalArgumentException("testsMap path doesn't contain test area path")
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -66,7 +66,7 @@ object TestsJsonMapGenerator {
testOrigin: TestOrigin,
) {
val isImplementationTest = testOrigin == TestOrigin.IMPLEMENTATION
TestArea.values().forEach { testArea ->
TestArea.entries.forEach { testArea ->
File(testOrigin.getFilePath(testArea)).walkTopDown()
.forEach testFiles@{ file ->
if (!file.isFile || file.extension != "kt" || file.isCustomTestData) return@testFiles
@@ -1,6 +1,6 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.spec.utils
@@ -42,7 +42,7 @@ object TestsStatisticCollector {
fun collect(testLinkedType: SpecTestLinkedType): Map<TestArea, SpecTestsStatElement> {
val statistic = mutableMapOf<TestArea, SpecTestsStatElement>()
for (specTestArea in TestArea.values()) {
for (specTestArea in TestArea.entries) {
val specTestsPath = "$SPEC_TESTDATA_PATH/${specTestArea.name.lowercase().replace("_", "/")}/${testLinkedType.testDataPath}"
statistic[specTestArea] =