[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:
committed by
Space Team
parent
ec167d4d42
commit
072d191306
+3
-3
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.intellij.pom.java.LanguageLevel
|
||||
|
||||
fun Project.setupHighestLanguageLevel() {
|
||||
LanguageLevelProjectExtension.getInstance(this).languageLevel =
|
||||
LanguageLevel.values().firstOrNull { it.name == "JDK_17" }
|
||||
?: LanguageLevel.values().firstOrNull { it.name == "JDK_15_PREVIEW" }
|
||||
LanguageLevel.entries.firstOrNull { it.name == "JDK_17" }
|
||||
?: LanguageLevel.entries.firstOrNull { it.name == "JDK_15_PREVIEW" }
|
||||
?: LanguageLevel.JDK_X
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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.
|
||||
*/
|
||||
|
||||
@@ -1027,7 +1027,7 @@ The corresponding calls' declarations may not be marked with @BuilderInference."
|
||||
if (value == null) null
|
||||
else LanguageVersion.fromVersionString(value)
|
||||
?: run {
|
||||
val versionStrings = LanguageVersion.values().filterNot(LanguageVersion::isUnsupported).map(LanguageVersion::description)
|
||||
val versionStrings = LanguageVersion.entries.filterNot(LanguageVersion::isUnsupported).map(LanguageVersion::description)
|
||||
val message = "Unknown $versionOf version: $value\nSupported $versionOf versions: ${versionStrings.joinToString(", ")}"
|
||||
collector.report(CompilerMessageSeverity.ERROR, message, null)
|
||||
null
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 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.
|
||||
*/
|
||||
|
||||
@@ -856,7 +856,7 @@ This option is deprecated and will be deleted in future versions."""
|
||||
result[JvmAnalysisFlags.jvmDefaultMode] = it
|
||||
} ?: collector.report(
|
||||
CompilerMessageSeverity.ERROR,
|
||||
"Unknown -Xjvm-default mode: $jvmDefault, supported modes: ${JvmDefaultMode.values().map(JvmDefaultMode::description)}"
|
||||
"Unknown -Xjvm-default mode: $jvmDefault, supported modes: ${JvmDefaultMode.entries.map(JvmDefaultMode::description)}"
|
||||
)
|
||||
result[JvmAnalysisFlags.inheritMultifileParts] = inheritMultifileParts
|
||||
result[JvmAnalysisFlags.sanitizeParentheses] = sanitizeParentheses
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* 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.runner
|
||||
@@ -45,7 +34,7 @@ object Main {
|
||||
val validValues = "${GUESS.argName} (default), ${CLASSFILE.argName}, ${JAR.argName}, ${SCRIPT.argName} (or .<script filename extension>)"
|
||||
|
||||
fun fromArg(name: String): HowToRun? =
|
||||
HowToRun.values().find { it.argName == name }
|
||||
HowToRun.entries.find { it.argName == name }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -79,7 +79,7 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
|
||||
} else {
|
||||
messageCollector.report(
|
||||
ERROR, "Unknown JVM target version: $jvmTargetValue\n" +
|
||||
"Supported versions: ${JvmTarget.values().joinToString { it.description }}"
|
||||
"Supported versions: ${JvmTarget.entries.joinToString { it.description }}"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
|
||||
} else {
|
||||
messageCollector.report(
|
||||
ERROR, "Unknown `-Xstring-concat` mode: $stringConcat\n" +
|
||||
"Supported modes: ${JvmStringConcat.values().joinToString { it.description }}"
|
||||
"Supported modes: ${JvmStringConcat.entries.joinToString { it.description }}"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ private fun CompilerConfiguration.handleClosureGenerationSchemeArgument(
|
||||
messageCollector.report(
|
||||
ERROR,
|
||||
"Unknown `$flag` argument: ${value}\n." +
|
||||
"Supported arguments: ${JvmClosureGenerationScheme.values().joinToString { it.description }}"
|
||||
"Supported arguments: ${JvmClosureGenerationScheme.entries.joinToString { it.description }}"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -268,7 +268,7 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
|
||||
if (abiStability == null) {
|
||||
messageCollector.report(
|
||||
ERROR,
|
||||
"Unknown ABI stability mode: ${arguments.abiStability}, supported modes: ${JvmAbiStability.values().map { it.description }}"
|
||||
"Unknown ABI stability mode: ${arguments.abiStability}, supported modes: ${JvmAbiStability.entries.map { it.description }}"
|
||||
)
|
||||
} else if (!useIR && abiStability == JvmAbiStability.UNSTABLE) {
|
||||
messageCollector.report(ERROR, "-Xabi-stability=unstable is not supported in the old JVM backend")
|
||||
@@ -306,7 +306,7 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
|
||||
if (assertionsMode == null) {
|
||||
messageCollector.report(
|
||||
ERROR,
|
||||
"Unknown assertions mode: ${arguments.assertionsMode}, supported modes: ${JVMAssertionsMode.values().map { it.description }}"
|
||||
"Unknown assertions mode: ${arguments.assertionsMode}, supported modes: ${JVMAssertionsMode.entries.map { it.description }}"
|
||||
)
|
||||
}
|
||||
put(JVMConfigurationKeys.ASSERTIONS_MODE, assertionsMode ?: JVMAssertionsMode.DEFAULT)
|
||||
|
||||
Reference in New Issue
Block a user