mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-359853 convert LanguageLevel#previewLevel and #nonPreviewLevel to functions
by Tagir's request GitOrigin-RevId: 97b051c2dab03ac835a7cae3ebb3665141150d16
This commit is contained in:
committed by
intellij-monorepo-bot
parent
483d3bb0b3
commit
4a5fb18d1f
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.roots.ui.configuration
|
||||
|
||||
import com.intellij.ide.JavaUiBundle
|
||||
@@ -29,7 +29,7 @@ abstract class LanguageLevelCombo @JvmOverloads constructor(
|
||||
val items = mutableListOf<Any>()
|
||||
items.add(defaultItem ?: "")
|
||||
|
||||
val highestPreviewLevel = LanguageLevel.HIGHEST.previewLevel
|
||||
val highestPreviewLevel = LanguageLevel.HIGHEST.getPreviewLevel()
|
||||
val highestWithPreview = highestPreviewLevel ?: LanguageLevel.HIGHEST
|
||||
|
||||
fun MutableList<Any>.filterAndAdd(levels: Collection<LanguageLevel>) = levels.filter(levelFilter).also { addAll(it) }
|
||||
|
||||
@@ -106,25 +106,23 @@ enum class LanguageLevel {
|
||||
/**
|
||||
* @return corresponding preview level, or `null` if level has no paired preview level
|
||||
*/
|
||||
val previewLevel: LanguageLevel?
|
||||
get() {
|
||||
if (this.isPreview) return this
|
||||
try {
|
||||
return valueOf(name + "_PREVIEW")
|
||||
}
|
||||
catch (_: IllegalArgumentException) {
|
||||
return null
|
||||
}
|
||||
fun getPreviewLevel(): LanguageLevel? {
|
||||
if (isPreview) return this
|
||||
try {
|
||||
return valueOf(name + "_PREVIEW")
|
||||
}
|
||||
catch (_: IllegalArgumentException) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return corresponding non-preview level; this if this level is non-preview already
|
||||
*/
|
||||
val nonPreviewLevel: LanguageLevel
|
||||
get() {
|
||||
if (!this.isPreview) return this
|
||||
return requireNotNull(ourStandardVersions[myVersion.feature])
|
||||
}
|
||||
fun getNonPreviewLevel(): LanguageLevel {
|
||||
if (!isPreview) return this
|
||||
return requireNotNull(ourStandardVersions[myVersion.feature])
|
||||
}
|
||||
|
||||
val presentableText: @Nls String
|
||||
get() = myPresentableText()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection
|
||||
|
||||
import com.intellij.analysis.JvmAnalysisBundle
|
||||
@@ -170,7 +170,7 @@ class JavaApiUsageInspection : AbstractBaseUastLocalInspectionTool() {
|
||||
if (module != null) {
|
||||
languageLevel = getEffectiveLanguageLevel(module)
|
||||
if (languageLevel.isUnsupported) {
|
||||
languageLevel = languageLevel.nonPreviewLevel
|
||||
languageLevel = languageLevel.getNonPreviewLevel()
|
||||
}
|
||||
}
|
||||
else if (sourcePsi.containingFile.virtualFile is LightVirtualFile) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.idea.maven.importing
|
||||
|
||||
import com.intellij.build.events.MessageEvent
|
||||
@@ -310,14 +310,14 @@ object MavenImportUtil {
|
||||
private fun adjustPreviewLanguageLevel(mavenProject: MavenProject, level: LanguageLevel): LanguageLevel {
|
||||
val enablePreviewProperty = mavenProject.properties.getProperty("maven.compiler.enablePreview")
|
||||
if (enablePreviewProperty.toBoolean()) {
|
||||
return level.previewLevel ?: level
|
||||
return level.getPreviewLevel() ?: level
|
||||
}
|
||||
|
||||
val compilerConfiguration = mavenProject.getPluginConfiguration(COMPILER_PLUGIN_GROUP_ID, COMPILER_PLUGIN_ARTIFACT_ID)
|
||||
if (compilerConfiguration != null) {
|
||||
val enablePreviewParameter = compilerConfiguration.getChildTextTrim("enablePreview")
|
||||
if (enablePreviewParameter.toBoolean()) {
|
||||
return level.previewLevel ?: level
|
||||
return level.getPreviewLevel() ?: level
|
||||
}
|
||||
|
||||
val compilerArgs = compilerConfiguration.getChild("compilerArgs")
|
||||
@@ -326,7 +326,7 @@ object MavenImportUtil {
|
||||
compilerArgs.getChildren("arg").any { isPreviewText(it) } ||
|
||||
compilerArgs.getChildren("compilerArg").any{ isPreviewText(it) }
|
||||
) {
|
||||
return level.previewLevel ?: level
|
||||
return level.getPreviewLevel() ?: level
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user