"Create type parameter from usage": don't suggest for not extension property

#KT-33300 Fixed
This commit is contained in:
Toshiaki Kameyama
2019-09-20 14:20:14 +09:00
committed by Dmitry Gridin
parent 68609401c4
commit 30c41e6720
11 changed files with 92 additions and 1 deletions
@@ -109,7 +109,7 @@ fun getPossibleTypeParameterContainers(startFrom: PsiElement): List<KtTypeParame
.filter {
((it is KtClass && !it.isInterface() && it !is KtEnumEntry) ||
it is KtNamedFunction ||
(it is KtProperty && !it.isLocal) ||
(it is KtProperty && !it.isLocal && it.receiverTypeReference != null) ||
it is KtTypeAlias) && it.nameIdentifier != null
}
.toList()
@@ -0,0 +1,3 @@
// "Create type parameter 'T' in property 'a'" "true"
val T.a: <caret>T?
get() = null
@@ -0,0 +1,3 @@
// "Create type parameter 'T' in property 'a'" "true"
val <T> T.a: T?
get() = null
@@ -0,0 +1,5 @@
// "Create type parameter 'T' in property 'a'" "true"
class Test {
val T.a: <caret>T?
get() = null
}
@@ -0,0 +1,5 @@
// "Create type parameter 'T' in property 'a'" "true"
class Test {
val <T> T.a: T?
get() = null
}
@@ -0,0 +1,6 @@
// "Create type parameter 'T' in property 'a'" "true"
val T.a: String
get() {
val b: T<caret>
return ""
}
@@ -0,0 +1,6 @@
// "Create type parameter 'T' in property 'a'" "true"
val <T> T.a: String
get() {
val b: T
return ""
}
@@ -0,0 +1,10 @@
// "Create type parameter 'T' in property 'a'" "false"
// ACTION: Convert property initializer to getter
// ACTION: Convert to lazy property
// ACTION: Create annotation 'T'
// ACTION: Create class 'T'
// ACTION: Create enum 'T'
// ACTION: Create interface 'T'
// ACTION: Remove explicit type specification
// ERROR: Unresolved reference: T
val a: <caret>T? = null
@@ -0,0 +1,14 @@
// "Create type parameter 'T' in property 'a'" "false"
// ACTION: Convert property initializer to getter
// ACTION: Convert to lazy property
// ACTION: Create annotation 'T'
// ACTION: Create class 'T'
// ACTION: Create enum 'T'
// ACTION: Create interface 'T'
// ACTION: Create type parameter 'T' in class 'Test'
// ACTION: Move to constructor
// ACTION: Remove explicit type specification
// ERROR: Unresolved reference: T
class Test {
val a: <caret>T? = null
}
@@ -0,0 +1,9 @@
// "Create type parameter 'T' in property 'a'" "false"
// ACTION: Create annotation 'T'
// ACTION: Create class 'T'
// ACTION: Create enum 'T'
// ACTION: Create interface 'T'
// ERROR: Unresolved reference: T
val a = fun() {
val b: T<caret>
}
@@ -4748,6 +4748,36 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
runTest("idea/testData/quickfix/createFromUsage/createTypeParameter/inContainingDeclaration/inAnnotation.kt");
}
@TestMetadata("inExtensionProperty.kt")
public void testInExtensionProperty() throws Exception {
runTest("idea/testData/quickfix/createFromUsage/createTypeParameter/inContainingDeclaration/inExtensionProperty.kt");
}
@TestMetadata("inExtensionProperty2.kt")
public void testInExtensionProperty2() throws Exception {
runTest("idea/testData/quickfix/createFromUsage/createTypeParameter/inContainingDeclaration/inExtensionProperty2.kt");
}
@TestMetadata("inExtensionProperty3.kt")
public void testInExtensionProperty3() throws Exception {
runTest("idea/testData/quickfix/createFromUsage/createTypeParameter/inContainingDeclaration/inExtensionProperty3.kt");
}
@TestMetadata("inProperty.kt")
public void testInProperty() throws Exception {
runTest("idea/testData/quickfix/createFromUsage/createTypeParameter/inContainingDeclaration/inProperty.kt");
}
@TestMetadata("inProperty2.kt")
public void testInProperty2() throws Exception {
runTest("idea/testData/quickfix/createFromUsage/createTypeParameter/inContainingDeclaration/inProperty2.kt");
}
@TestMetadata("inProperty3.kt")
public void testInProperty3() throws Exception {
runTest("idea/testData/quickfix/createFromUsage/createTypeParameter/inContainingDeclaration/inProperty3.kt");
}
@TestMetadata("inSuperTypeEntry.kt")
public void testInSuperTypeEntry() throws Exception {
runTest("idea/testData/quickfix/createFromUsage/createTypeParameter/inContainingDeclaration/inSuperTypeEntry.kt");