Introduce Parameter: Forbid inside of annotation entries
#KT-18594 Fixed
This commit is contained in:
+7
@@ -369,6 +369,13 @@ open class KotlinIntroduceParameterHandler(
|
||||
}
|
||||
|
||||
if (file !is KtFile) return
|
||||
|
||||
val elementAtCaret = file.findElementAt(editor.caretModel.offset) ?: return
|
||||
if (elementAtCaret.getNonStrictParentOfType<KtAnnotationEntry>() != null) {
|
||||
showErrorHint(project, editor, "Introduce Parameter is not available inside of annotation entries", INTRODUCE_PARAMETER)
|
||||
return
|
||||
}
|
||||
|
||||
selectNewParameterContext(editor, file) { elements, targetParent ->
|
||||
val expression = ((elements.singleOrNull() as? KtBlockExpression)?.statements ?: elements).singleOrNull()
|
||||
if (expression is KtExpression) {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
annotation class FromCollection1(val value: String)
|
||||
@FromCollection1(<caret>"a") class CollectionValueUserJ
|
||||
@@ -0,0 +1 @@
|
||||
Introduce Parameter is not available inside of annotation entries
|
||||
+6
@@ -3344,6 +3344,12 @@ public class ExtractionTestGenerated extends AbstractExtractionTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceParameter"), Pattern.compile("^(.+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("annotationArgument.kt")
|
||||
public void testAnnotationArgument() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceParameter/annotationArgument.kt");
|
||||
doIntroduceSimpleParameterTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("assignment.kt")
|
||||
public void testAssignment() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceParameter/assignment.kt");
|
||||
|
||||
Reference in New Issue
Block a user