mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] KTIJ-29507 MakeModuleOptInFix migrated to K2
GitOrigin-RevId: bcd0d0b211c6ae962a3c8844623c789c85370d4a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ca59b640d0
commit
b7d2a6f4ad
+1
@@ -424,6 +424,7 @@ class KotlinK2QuickFixRegistrar : KotlinQuickFixRegistrar() {
|
||||
)
|
||||
|
||||
registerFactory(OptInAnnotationWrongTargetFixFactory.optInAnnotationWrongTargetFixFactory)
|
||||
registerFactory(OptInModuleLevelFixFactories.optInIsNotEnabledFactory)
|
||||
registerFactory(OptInFileLevelFixFactories.optInUsageFactory)
|
||||
registerFactory(OptInFileLevelFixFactories.optInUsageErrorFactory)
|
||||
registerFactory(OptInFileLevelFixFactories.optInOverrideFactory)
|
||||
|
||||
+21
-6
@@ -1,12 +1,15 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.k2.codeinsight.fixes
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.createSmartPointer
|
||||
import com.intellij.psi.util.findParentOfType
|
||||
import org.jetbrains.kotlin.analysis.api.KaSession
|
||||
import org.jetbrains.kotlin.analysis.api.fir.diagnostics.KaFirDiagnostic
|
||||
import org.jetbrains.kotlin.idea.base.util.module
|
||||
import org.jetbrains.kotlin.idea.codeinsight.api.applicators.fixes.KotlinQuickFixFactory
|
||||
import org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
import org.jetbrains.kotlin.idea.quickfix.UseOptInFileAnnotationFix
|
||||
import org.jetbrains.kotlin.idea.util.findAnnotation
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
@@ -36,7 +39,7 @@ internal object OptInFileLevelFixFactories {
|
||||
context(KaSession)
|
||||
private fun createQuickFix(
|
||||
diagnostic: KaFirDiagnostic<PsiElement>,
|
||||
): List<UseOptInFileAnnotationFix> {
|
||||
): List<IntentionAction> {
|
||||
val element = diagnostic.psi.findParentOfType<KtElement>()
|
||||
?: return emptyList()
|
||||
|
||||
@@ -54,12 +57,24 @@ internal object OptInFileLevelFixFactories {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
return listOf(
|
||||
UseOptInFileAnnotationFix(
|
||||
containingFile, optInFqName, optInMarkerClassId.asSingleFqName(),
|
||||
findFileAnnotation(containingFile, optInFqName)?.createSmartPointer()
|
||||
)
|
||||
val result = mutableListOf<IntentionAction>()
|
||||
val argumentClassFqName = optInMarkerClassId.asSingleFqName()
|
||||
result += UseOptInFileAnnotationFix(
|
||||
file = containingFile,
|
||||
optInFqName = optInFqName,
|
||||
argumentClassFqName = argumentClassFqName,
|
||||
existingAnnotationEntry = findFileAnnotation(containingFile, optInFqName)?.createSmartPointer(),
|
||||
)
|
||||
|
||||
containingFile.module?.let { module ->
|
||||
result += AddModuleOptInFix(
|
||||
file = containingFile,
|
||||
module = module,
|
||||
annotationFqName = argumentClassFqName,
|
||||
)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// Find the existing file-level annotation of the specified class if it exists
|
||||
|
||||
+7
-7
@@ -5,7 +5,7 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.analysis.api.KaExperimentalApi
|
||||
import org.jetbrains.kotlin.analysis.api.KaSession
|
||||
import org.jetbrains.kotlin.analysis.api.fir.diagnostics.KaFirDiagnostic
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaNamedClassOrObjectSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KaNamedClassSymbol
|
||||
import org.jetbrains.kotlin.idea.base.util.names.FqNames
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -26,17 +26,17 @@ internal object OptInFixUtils {
|
||||
?: FqNames.OptInFqNames.OLD_USE_EXPERIMENTAL_FQ_NAME.takeIf { it.annotationApplicable() }
|
||||
|
||||
context (KaSession)
|
||||
private fun FqName.annotationApplicable(): Boolean =
|
||||
getClassOrObjectSymbolByClassId(ClassId.topLevel(this)) != null
|
||||
fun FqName.annotationApplicable(): Boolean =
|
||||
findClass(ClassId.topLevel(this)) != null
|
||||
|
||||
context (KaSession)
|
||||
fun findAnnotation(classId: ClassId): KaNamedClassOrObjectSymbol? =
|
||||
getClassOrObjectSymbolByClassId(classId) as? KaNamedClassOrObjectSymbol
|
||||
fun findAnnotation(classId: ClassId): KaNamedClassSymbol? =
|
||||
findClass(classId) as? KaNamedClassSymbol
|
||||
|
||||
context (KaSession)
|
||||
@OptIn(KaExperimentalApi::class)
|
||||
fun annotationIsVisible(annotation: KaNamedClassOrObjectSymbol, from: KtElement): Boolean {
|
||||
val file = from.containingKtFile.getFileSymbol()
|
||||
fun annotationIsVisible(annotation: KaNamedClassSymbol, from: KtElement): Boolean {
|
||||
val file = from.containingKtFile.symbol
|
||||
return isVisible(annotation, file, receiverExpression = null, from)
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.k2.codeinsight.fixes
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.fir.diagnostics.KaFirDiagnostic
|
||||
import org.jetbrains.kotlin.idea.base.util.module
|
||||
import org.jetbrains.kotlin.idea.base.util.names.FqNames
|
||||
import org.jetbrains.kotlin.idea.codeinsight.api.applicators.fixes.KotlinQuickFixFactory
|
||||
import org.jetbrains.kotlin.idea.k2.codeinsight.fixes.OptInFixUtils.annotationApplicable
|
||||
import org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
import org.jetbrains.kotlin.resolve.checkers.OptInNames
|
||||
|
||||
internal object OptInModuleLevelFixFactories {
|
||||
|
||||
val optInIsNotEnabledFactory = KotlinQuickFixFactory.IntentionBased { diagnostic: KaFirDiagnostic.OptInIsNotEnabled ->
|
||||
val file = diagnostic.psi.containingKtFile
|
||||
val module = file.module
|
||||
?: return@IntentionBased emptyList()
|
||||
|
||||
val annotationFqName = OptInNames.REQUIRES_OPT_IN_FQ_NAME.takeIf { it.annotationApplicable() }
|
||||
?: FqNames.OptInFqNames.OLD_EXPERIMENTAL_FQ_NAME.takeIf { it.annotationApplicable() }
|
||||
?: return@IntentionBased emptyList()
|
||||
|
||||
val quickFix = AddModuleOptInFix(
|
||||
file = file,
|
||||
module = module,
|
||||
annotationFqName = annotationFqName,
|
||||
)
|
||||
listOf(quickFix)
|
||||
}
|
||||
}
|
||||
-10
@@ -1479,11 +1479,6 @@ public abstract class K2QuickFixTestGenerated extends AbstractK2QuickFixTest {
|
||||
runTest("../../../idea/tests/testData/quickfix/optIn/basicFunctionNotApplicable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("basicFunctionNotApplicableFir.kt")
|
||||
public void testBasicFunctionNotApplicableFir() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/optIn/basicFunctionNotApplicableFir.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("basicModule.kt")
|
||||
public void testBasicModule() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/optIn/basicModule.kt");
|
||||
@@ -1634,11 +1629,6 @@ public abstract class K2QuickFixTestGenerated extends AbstractK2QuickFixTest {
|
||||
runTest("../../../idea/tests/testData/quickfix/optIn/override.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overrideFir.kt")
|
||||
public void testOverrideFir() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/optIn/overrideFir.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propagateOptIn.kt")
|
||||
public void testPropagateOptIn() throws Exception {
|
||||
runTest("../../../idea/tests/testData/quickfix/optIn/propagateOptIn.kt");
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
<orderEntry type="module" module-name="kotlin.code-insight.utils" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util" />
|
||||
<orderEntry type="module" module-name="intellij.maven" />
|
||||
<orderEntry type="module" module-name="kotlin.base.plugin" />
|
||||
<orderEntry type="module" module-name="kotlin.base.project-structure" />
|
||||
<orderEntry type="module" module-name="kotlin.project-configuration" />
|
||||
</component>
|
||||
</module>
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.quickfix
|
||||
|
||||
import com.intellij.codeInspection.util.IntentionFamilyName
|
||||
import com.intellij.codeInspection.util.IntentionName
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.idea.base.resources.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.codeinsight.api.classic.quickfixes.KotlinQuickFixAction
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinPluginLayout
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinProjectConfigurator
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
|
||||
/**
|
||||
* A quick fix that adds an opt-in compiler argument to the current module configuration facet.
|
||||
*/
|
||||
class AddModuleOptInFix(
|
||||
file: KtFile,
|
||||
private val module: Module,
|
||||
private val annotationFqName: FqName,
|
||||
) : KotlinQuickFixAction<KtFile>(file) {
|
||||
|
||||
private val configurator by lazy {
|
||||
KotlinProjectConfigurator.EP_NAME
|
||||
.lazySequence()
|
||||
.filter { it.canAddModuleWideOptIn }
|
||||
.firstOrNull { it.isApplicable(module) }
|
||||
}
|
||||
|
||||
override fun getText(): @IntentionName String = KotlinBundle.message(
|
||||
"fix.opt_in.text.use.module",
|
||||
annotationFqName.shortName().asString(),
|
||||
configurator?.userVisibleNameFor(module) ?: module.name,
|
||||
)
|
||||
|
||||
override fun getFamilyName(): @IntentionFamilyName String =
|
||||
KotlinBundle.message("add.an.opt.in.requirement.marker.compiler.argument")
|
||||
|
||||
/**
|
||||
* The actual name of the opt-in compiler argument depends on the Kotlin compiler version:
|
||||
* * `-opt-in` (since Kotlin 1.6) https://youtrack.jetbrains.com/issue/KT-47099
|
||||
* * `-Xopt-in` (before Kotlin 1.6) https://blog.jetbrains.com/kotlin/2020/03/kotlin-1-3-70-released/
|
||||
* * `-Xuse-experimental` (before Kotlin 1.3.70), a fallback if `RequireOptIn` annotation does not exist
|
||||
*/
|
||||
override fun invoke(
|
||||
project: Project,
|
||||
editor: Editor?,
|
||||
file: KtFile,
|
||||
) {
|
||||
val optInPrefix = if (KotlinPluginLayout.standaloneCompilerVersion.kotlinVersion.isAtLeast(1, 6, 0)) ""
|
||||
else "X"
|
||||
|
||||
configurator?.addModuleWideOptIn(
|
||||
module,
|
||||
annotationFqName,
|
||||
"-${optInPrefix}opt-in=${annotationFqName}",
|
||||
)
|
||||
}
|
||||
|
||||
override fun isAvailable(
|
||||
project: Project,
|
||||
editor: Editor?,
|
||||
file: KtFile,
|
||||
): Boolean = configurator != null
|
||||
}
|
||||
@@ -3,74 +3,27 @@
|
||||
package org.jetbrains.kotlin.idea.quickfix
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.base.resources.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.base.util.names.FqNames
|
||||
import org.jetbrains.kotlin.idea.caches.project.toDescriptor
|
||||
import org.jetbrains.kotlin.idea.codeinsight.api.classic.quickfixes.KotlinQuickFixAction
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinPluginLayout
|
||||
import org.jetbrains.kotlin.idea.configuration.allConfigurators
|
||||
import org.jetbrains.kotlin.idea.util.projectStructure.module
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.checkers.OptInNames
|
||||
|
||||
/**
|
||||
* A quick fix that adds an opt-in compiler argument to the current module configuration facet.
|
||||
*/
|
||||
open class MakeModuleOptInFix(
|
||||
file: KtFile,
|
||||
private val module: Module,
|
||||
private val annotationFqName: FqName,
|
||||
) : KotlinQuickFixAction<KtFile>(file) {
|
||||
internal object MakeModuleOptInFix : KotlinSingleIntentionActionFactory() {
|
||||
|
||||
private val configurator by lazy {
|
||||
allConfigurators().find { it.isApplicable(module) && it.canAddModuleWideOptIn }
|
||||
}
|
||||
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
||||
val containingKtFile = diagnostic.psiElement.containingFile as? KtFile ?: return null
|
||||
val module = containingKtFile.module ?: return null
|
||||
val moduleDescriptor = module.toDescriptor()
|
||||
|
||||
/**
|
||||
* The actual name of the opt-in compiler argument depends on the Kotlin compiler version:
|
||||
* * `-opt-in` (since Kotlin 1.6) https://youtrack.jetbrains.com/issue/KT-47099
|
||||
* * `-Xopt-in` (before Kotlin 1.6) https://blog.jetbrains.com/kotlin/2020/03/kotlin-1-3-70-released/
|
||||
* * `-Xuse-experimental` (before Kotlin 1.3.70), a fallback if `RequireOptIn` annotation does not exist
|
||||
*/
|
||||
private val compilerArgName = when {
|
||||
module.toDescriptor()?.let { OptInFixesUtils.annotationExists(it, OptInNames.REQUIRES_OPT_IN_FQ_NAME) } == false -> "-Xuse-experimental"
|
||||
KotlinPluginLayout.standaloneCompilerVersion.kotlinVersion.isAtLeast(1, 6, 0) -> "-opt-in"
|
||||
else -> "-Xopt-in"
|
||||
}
|
||||
|
||||
private val compilerArgument = "$compilerArgName=$annotationFqName"
|
||||
|
||||
override fun getText(): String = KotlinBundle.message(
|
||||
"fix.opt_in.text.use.module",
|
||||
annotationFqName.shortName().asString(),
|
||||
configurator?.userVisibleNameFor(module) ?: module.name
|
||||
)
|
||||
|
||||
override fun getFamilyName(): String = KotlinBundle.message("add.an.opt.in.requirement.marker.compiler.argument")
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
configurator?.addModuleWideOptIn(module, annotationFqName, compilerArgument)
|
||||
}
|
||||
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean = configurator != null
|
||||
|
||||
companion object : KotlinSingleIntentionActionFactory() {
|
||||
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
||||
val containingKtFile = diagnostic.psiElement.containingFile as? KtFile ?: return null
|
||||
val module = containingKtFile.module ?: return null
|
||||
val moduleDescriptor = module.toDescriptor()
|
||||
return MakeModuleOptInFix(
|
||||
containingKtFile,
|
||||
module,
|
||||
OptInNames.REQUIRES_OPT_IN_FQ_NAME.takeIf {
|
||||
moduleDescriptor != null && OptInFixesUtils.annotationExists(moduleDescriptor, it)
|
||||
} ?: FqNames.OptInFqNames.OLD_EXPERIMENTAL_FQ_NAME
|
||||
)
|
||||
}
|
||||
return AddModuleOptInFix(
|
||||
containingKtFile,
|
||||
module,
|
||||
OptInNames.REQUIRES_OPT_IN_FQ_NAME.takeIf {
|
||||
moduleDescriptor != null && OptInFixesUtils.annotationExists(moduleDescriptor, it)
|
||||
} ?: FqNames.OptInFqNames.OLD_EXPERIMENTAL_FQ_NAME
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -3,8 +3,6 @@
|
||||
package org.jetbrains.kotlin.idea.quickfix
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.codeInsight.intention.LowPriorityAction
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.psi.createSmartPointer
|
||||
import com.intellij.psi.util.findParentOfType
|
||||
import org.jetbrains.kotlin.descriptors.resolveClassByFqName
|
||||
@@ -42,20 +40,22 @@ internal object OptInFileLevelFixesFactory : KotlinIntentionActionsFactory() {
|
||||
|
||||
val optInFqName = OptInFixesUtils.optInFqName(moduleDescriptor)
|
||||
|
||||
val result = mutableListOf<IntentionAction>()
|
||||
|
||||
val containingFile = element.containingKtFile
|
||||
val module = containingFile.module
|
||||
|
||||
result.add(
|
||||
UseOptInFileAnnotationFix(
|
||||
containingFile, optInFqName, annotationFqName,
|
||||
findFileAnnotation(containingFile, optInFqName)?.createSmartPointer()
|
||||
)
|
||||
val result = mutableListOf<IntentionAction>()
|
||||
result += UseOptInFileAnnotationFix(
|
||||
file = containingFile,
|
||||
optInFqName = optInFqName,
|
||||
argumentClassFqName = annotationFqName,
|
||||
existingAnnotationEntry = findFileAnnotation(containingFile, optInFqName)?.createSmartPointer(),
|
||||
)
|
||||
|
||||
if (module != null) {
|
||||
result.add(MakeModuleOptInFix(containingFile, module, annotationFqName))
|
||||
containingFile.module?.let { module ->
|
||||
result += AddModuleOptInFix(
|
||||
file = containingFile,
|
||||
module = module,
|
||||
annotationFqName = annotationFqName,
|
||||
)
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
-10
@@ -12398,11 +12398,6 @@ public abstract class K1QuickFixTestGenerated extends AbstractK1QuickFixTest {
|
||||
runTest("testData/quickfix/optIn/basicFunctionNotApplicable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("basicFunctionNotApplicableFir.kt")
|
||||
public void testBasicFunctionNotApplicableFir() throws Exception {
|
||||
runTest("testData/quickfix/optIn/basicFunctionNotApplicableFir.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("basicModule.kt")
|
||||
public void testBasicModule() throws Exception {
|
||||
runTest("testData/quickfix/optIn/basicModule.kt");
|
||||
@@ -12553,11 +12548,6 @@ public abstract class K1QuickFixTestGenerated extends AbstractK1QuickFixTest {
|
||||
runTest("testData/quickfix/optIn/override.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overrideFir.kt")
|
||||
public void testOverrideFir() throws Exception {
|
||||
runTest("testData/quickfix/optIn/overrideFir.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propagateOptIn.kt")
|
||||
public void testPropagateOptIn() throws Exception {
|
||||
runTest("testData/quickfix/optIn/propagateOptIn.kt");
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// "Propagate 'MyExperimentalAPI' opt-in requirement to 'bar'" "false"
|
||||
// IGNORE_K2
|
||||
// COMPILER_ARGUMENTS: -opt-in=kotlin.RequiresOptIn
|
||||
// WITH_STDLIB
|
||||
// ACTION: Opt in for 'MyExperimentalAPI' in containing file 'basicFunctionNotApplicable.kt'
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// "Propagate 'MyExperimentalAPI' opt-in requirement to 'bar'" "false"
|
||||
// IGNORE_K1
|
||||
// COMPILER_ARGUMENTS: -opt-in=kotlin.RequiresOptIn
|
||||
// WITH_STDLIB
|
||||
// ACTION: Opt in for 'MyExperimentalAPI' in containing file 'basicFunctionNotApplicableFir.kt'
|
||||
// ACTION: Opt in for 'MyExperimentalAPI' on 'bar'
|
||||
// ACTION: Opt in for 'MyExperimentalAPI' on containing class 'Bar'
|
||||
// ACTION: Propagate 'MyExperimentalAPI' opt-in requirement to containing class 'Bar'
|
||||
// ERROR: This declaration needs opt-in. Its usage must be marked with '@MyExperimentalAPI' or '@OptIn(MyExperimentalAPI::class)'
|
||||
// ERROR: This declaration needs opt-in. Its usage must be marked with '@MyExperimentalAPI' or '@OptIn(MyExperimentalAPI::class)'
|
||||
// ERROR: This annotation is not applicable to target 'member function'
|
||||
|
||||
@RequiresOptIn
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
annotation class MyExperimentalAPI
|
||||
|
||||
@MyExperimentalAPI
|
||||
class Some {
|
||||
@MyExperimentalAPI
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
class Bar {
|
||||
fun bar() {
|
||||
Some().foo<caret>()
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
// "Opt in for 'MyExperimentalAPI' in module 'light_idea_test_case'" "true"
|
||||
// IGNORE_K2
|
||||
// COMPILER_ARGUMENTS: -opt-in=kotlin.RequiresOptIn
|
||||
// COMPILER_ARGUMENTS_AFTER: -opt-in=kotlin.RequiresOptIn -opt-in=test.MyExperimentalAPI
|
||||
// DISABLE-ERRORS
|
||||
@@ -22,4 +21,5 @@ class Bar {
|
||||
}
|
||||
}
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MakeModuleOptInFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
@@ -1,5 +1,4 @@
|
||||
// "Opt in for 'MyExperimentalAPI' in module 'light_idea_test_case'" "true"
|
||||
// IGNORE_K2
|
||||
// COMPILER_ARGUMENTS: -opt-in=kotlin.RequiresOptIn
|
||||
// COMPILER_ARGUMENTS_AFTER: -opt-in=kotlin.RequiresOptIn -opt-in=test.MyExperimentalAPI
|
||||
// DISABLE-ERRORS
|
||||
@@ -22,4 +21,5 @@ class Bar {
|
||||
}
|
||||
}
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MakeModuleOptInFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
@@ -3,6 +3,7 @@
|
||||
// COMPILER_ARGUMENTS: -opt-in=kotlin.RequiresOptIn
|
||||
// WITH_STDLIB
|
||||
// ACTION: Opt in for 'MyExperimentalAPI' in containing file 'nestedClassesFir.kt'
|
||||
// ACTION: Opt in for 'MyExperimentalAPI' in module 'light_idea_test_case'
|
||||
// ACTION: Opt in for 'MyExperimentalAPI' on 'bar'
|
||||
// ACTION: Opt in for 'MyExperimentalAPI' on containing class 'Inner'
|
||||
// ACTION: Propagate 'MyExperimentalAPI' opt-in requirement to 'bar'
|
||||
@@ -13,7 +14,8 @@
|
||||
annotation class MyExperimentalAPI
|
||||
|
||||
@MyExperimentalAPI
|
||||
fun foo() {}
|
||||
fun foo() {
|
||||
}
|
||||
|
||||
class Outer {
|
||||
class Bar {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// "Propagate 'MyExperimentalAPI' opt-in requirement to containing class 'Derived'" "false"
|
||||
// IGNORE_K2
|
||||
// COMPILER_ARGUMENTS: -opt-in=kotlin.RequiresOptIn
|
||||
// WITH_STDLIB
|
||||
// ACTION: Enable a trailing comma by default in the formatter
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
// "Propagate 'MyExperimentalAPI' opt-in requirement to containing class 'Derived'" "false"
|
||||
// IGNORE_K1
|
||||
// COMPILER_ARGUMENTS: -opt-in=kotlin.RequiresOptIn
|
||||
// WITH_STDLIB
|
||||
// ACTION: Enable a trailing comma by default in the formatter
|
||||
// ACTION: Go To Super Method
|
||||
// ACTION: Opt in for 'MyExperimentalAPI' in containing file 'overrideFir.kt'
|
||||
// ACTION: Opt in for 'MyExperimentalAPI' on 'foo'
|
||||
// ACTION: Opt in for 'MyExperimentalAPI' on containing class 'Derived'
|
||||
// ACTION: Propagate 'MyExperimentalAPI' opt-in requirement to 'foo'
|
||||
// ERROR: Base declaration of supertype 'Base' needs opt-in. The declaration override must be annotated with '@MyExperimentalAPI' or '@OptIn(MyExperimentalAPI::class)'
|
||||
|
||||
@RequiresOptIn
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
annotation class MyExperimentalAPI
|
||||
|
||||
open class Base {
|
||||
@MyExperimentalAPI
|
||||
open fun foo() {}
|
||||
}
|
||||
|
||||
class Derived : Base() {
|
||||
override fun foo<caret>() {}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
// IGNORE_K1
|
||||
// ERROR: This declaration needs opt-in. Its usage must be marked with '@UnstableApi' or '@OptIn(UnstableApi::class)'
|
||||
// ACTION: Opt in for 'UnstableApi' in containing file 'propagateOptIn8Fir.kt'
|
||||
// ACTION: Opt in for 'UnstableApi' in module 'light_idea_test_case'
|
||||
// ACTION: Opt in for 'UnstableApi' on 'foo'
|
||||
// ACTION: Propagate 'UnstableApi' opt-in requirement to 'foo'
|
||||
// COMPILER_ARGUMENTS: -opt-in=kotlin.RequiresOptIn
|
||||
|
||||
@@ -27,4 +27,4 @@ class Bar {
|
||||
}
|
||||
}
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MakeModuleOptInFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
+1
-1
@@ -27,4 +27,4 @@ class Bar {
|
||||
}
|
||||
}
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MakeModuleOptInFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
@@ -7,4 +7,4 @@
|
||||
@RequiresOptIn<caret>
|
||||
annotation class MyExperimentalAPI
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MakeModuleOptInFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
+1
-1
@@ -7,4 +7,4 @@
|
||||
@RequiresOptIn
|
||||
annotation class MyExperimentalAPI
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MakeModuleOptInFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
+1
-1
@@ -7,4 +7,4 @@
|
||||
@RequiresOptIn<caret>
|
||||
annotation class MyExperimentalAPI
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MakeModuleOptInFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
+1
-1
@@ -7,4 +7,4 @@
|
||||
@RequiresOptIn
|
||||
annotation class MyExperimentalAPI
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MakeModuleOptInFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
@@ -1,5 +1,4 @@
|
||||
// "Opt in for 'RequiresOptIn' in module 'light_idea_test_case'" "true"
|
||||
// IGNORE_K2
|
||||
// COMPILER_ARGUMENTS: -version
|
||||
// COMPILER_ARGUMENTS_AFTER: -version -opt-in=kotlin.RequiresOptIn
|
||||
// DISABLE-ERRORS
|
||||
@@ -9,4 +8,5 @@
|
||||
@RequiresOptIn<caret>
|
||||
annotation class MyExperimentalAPI
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MakeModuleOptInFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
@@ -1,5 +1,4 @@
|
||||
// "Opt in for 'RequiresOptIn' in module 'light_idea_test_case'" "true"
|
||||
// IGNORE_K2
|
||||
// COMPILER_ARGUMENTS: -version
|
||||
// COMPILER_ARGUMENTS_AFTER: -version -opt-in=kotlin.RequiresOptIn
|
||||
// DISABLE-ERRORS
|
||||
@@ -9,4 +8,5 @@
|
||||
@RequiresOptIn
|
||||
annotation class MyExperimentalAPI
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MakeModuleOptInFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
@@ -1,5 +1,4 @@
|
||||
// "Opt in for 'RequiresOptIn' in module 'light_idea_test_case'" "true"
|
||||
// IGNORE_K2
|
||||
// COMPILER_ARGUMENTS: -version -opt-in=AnotherMarker
|
||||
// COMPILER_ARGUMENTS_AFTER: -version -opt-in=AnotherMarker -opt-in=kotlin.RequiresOptIn
|
||||
// DISABLE-ERRORS
|
||||
@@ -9,4 +8,5 @@
|
||||
@RequiresOptIn<caret>
|
||||
annotation class MyExperimentalAPI
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MakeModuleOptInFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
+2
-2
@@ -1,5 +1,4 @@
|
||||
// "Opt in for 'RequiresOptIn' in module 'light_idea_test_case'" "true"
|
||||
// IGNORE_K2
|
||||
// COMPILER_ARGUMENTS: -version -opt-in=AnotherMarker
|
||||
// COMPILER_ARGUMENTS_AFTER: -version -opt-in=AnotherMarker -opt-in=kotlin.RequiresOptIn
|
||||
// DISABLE-ERRORS
|
||||
@@ -9,4 +8,5 @@
|
||||
@RequiresOptIn
|
||||
annotation class MyExperimentalAPI
|
||||
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.MakeModuleOptInFix
|
||||
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddModuleOptInFix
|
||||
Reference in New Issue
Block a user