Introduce Parameter: Forbid inside of annotation entries

#KT-18594 Fixed
This commit is contained in:
Alexey Sedunov
2017-09-28 16:37:45 +03:00
parent e2fd9a71df
commit bf3769f37e
4 changed files with 16 additions and 0 deletions
@@ -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
@@ -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");