Do not suggest "create local variable" inside primary constructor
#KT-26158 Fixed EA-99300 Fixed
This commit is contained in:
+1
-1
@@ -44,7 +44,7 @@ object CreateLocalVariableActionFactory : KotlinSingleIntentionActionFactory() {
|
||||
val propertyName = refExpr.getReferencedName()
|
||||
|
||||
val container = refExpr.parents
|
||||
.filter { it is KtBlockExpression || it is KtDeclarationWithBody }
|
||||
.filter { it is KtBlockExpression || it is KtDeclarationWithBody && it.bodyExpression != null }
|
||||
.firstOrNull() as? KtElement ?: return null
|
||||
|
||||
return object : CreateFromUsageFixBase<KtSimpleNameExpression>(refExpr) {
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Create local variable 'defaultPreferencesName'" "false"
|
||||
// ACTION: Create abstract property 'defaultPreferencesName'
|
||||
// ACTION: Create parameter 'defaultPreferencesName'
|
||||
// ACTION: Create property 'defaultPreferencesName'
|
||||
// ACTION: Rename reference
|
||||
// ERROR: Unresolved reference: defaultPreferencesName
|
||||
// ERROR: Default value of annotation parameter must be a compile-time constant
|
||||
|
||||
class AppModule {
|
||||
val defaultPreferencesName = "defaultPreferences"
|
||||
|
||||
annotation class Preferences(val type: String = <caret>defaultPreferencesName)
|
||||
}
|
||||
@@ -4204,6 +4204,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
runTest("idea/testData/quickfix/createFromUsage/createVariable/localVariable/inAccessorWithExpressionBody.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inAnnotation.kt")
|
||||
public void testInAnnotation() throws Exception {
|
||||
runTest("idea/testData/quickfix/createFromUsage/createVariable/localVariable/inAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inBinaryOperation.kt")
|
||||
public void testInBinaryOperation() throws Exception {
|
||||
runTest("idea/testData/quickfix/createFromUsage/createVariable/localVariable/inBinaryOperation.kt");
|
||||
|
||||
Reference in New Issue
Block a user