Create from Usage: Do not create type parameter by constuctor reference

#KT-17353 Fixed
This commit is contained in:
Alexey Sedunov
2017-07-06 16:25:38 +03:00
parent 2e76a76088
commit 0365d3a3d6
4 changed files with 33 additions and 0 deletions
@@ -51,6 +51,7 @@ data class CreateTypeParameterData(
object CreateTypeParameterByUnresolvedRefActionFactory : KotlinIntentionActionFactoryWithDelegate<KtUserType, CreateTypeParameterData>() {
override fun getElementOfInterest(diagnostic: Diagnostic): KtUserType? {
val ktUserType = diagnostic.psiElement.getParentOfTypeAndBranch<KtUserType> { referenceExpression } ?: return null
if (ktUserType.getParentOfTypeAndBranch<KtConstructorCalleeExpression> { typeReference } != null) return null
if (ktUserType.qualifier != null) return null
if (ktUserType.getParentOfTypeAndBranch<KtUserType>(true) { qualifier } != null) return null
if (ktUserType.typeArgumentList != null) return null
@@ -0,0 +1,12 @@
// "Create type parameter 'Test' in class 'C'" "false"
// ACTION: Add 'testng' to classpath
// ACTION: Create annotation 'Test'
// ACTION: Make internal
// ACTION: Make private
// ACTION: Make protected
// ERROR: Unresolved reference: Test
class C {
@<caret>Test fun foo() {
}
}
@@ -0,0 +1,8 @@
// "Create type parameter 'Test' in class 'C'" "false"
// ACTION: Add 'testng' to classpath
// ACTION: Create class 'Test'
// ACTION: Create test
// ERROR: Unresolved reference: Test
class C : <caret>Test() {
}
@@ -3537,6 +3537,18 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
doTest(fileName);
}
@TestMetadata("inAnnotation.kt")
public void testInAnnotation() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createTypeParameter/inContainingDeclaration/inAnnotation.kt");
doTest(fileName);
}
@TestMetadata("inSuperTypeEntry.kt")
public void testInSuperTypeEntry() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createTypeParameter/inContainingDeclaration/inSuperTypeEntry.kt");
doTest(fileName);
}
@TestMetadata("qualifiedType.kt")
public void testQualifiedType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createTypeParameter/inContainingDeclaration/qualifiedType.kt");