Don't suggest "Remove explicit type specification" for an annotated type
So #KT-20622 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
fbda2a4343
commit
5f4233e4bf
@@ -42,6 +42,7 @@ class RemoveExplicitTypeIntention : SelfTargetingRangeIntention<KtCallableDeclar
|
|||||||
fun getRange(element: KtCallableDeclaration): TextRange? {
|
fun getRange(element: KtCallableDeclaration): TextRange? {
|
||||||
if (element.containingFile is KtCodeFragment) return null
|
if (element.containingFile is KtCodeFragment) return null
|
||||||
val typeReference = element.typeReference ?: return null
|
val typeReference = element.typeReference ?: return null
|
||||||
|
if (typeReference.annotationEntries.isNotEmpty()) return null
|
||||||
|
|
||||||
if (element is KtParameter) {
|
if (element is KtParameter) {
|
||||||
if (element.isLoopParameter) return element.textRange
|
if (element.isLoopParameter) return element.textRange
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
@Target(AnnotationTarget.TYPE)
|
||||||
|
annotation class Foo
|
||||||
|
|
||||||
|
fun foo(): @Foo Int<caret> = 1
|
||||||
@@ -13184,6 +13184,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("hasAnnotation.kt")
|
||||||
|
public void testHasAnnotation() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeExplicitType/hasAnnotation.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("notOnParameterOfFunctionType.kt")
|
@TestMetadata("notOnParameterOfFunctionType.kt")
|
||||||
public void testNotOnParameterOfFunctionType() throws Exception {
|
public void testNotOnParameterOfFunctionType() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeExplicitType/notOnParameterOfFunctionType.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeExplicitType/notOnParameterOfFunctionType.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user