Fix "Remove redundant qualifier name" for KtUserType with type parameter

#KT-30916 Fixed
This commit is contained in:
Dmitry Gridin
2019-04-10 12:18:46 +07:00
parent f3faae7bb4
commit 86a3daa302
6 changed files with 31 additions and 1 deletions
@@ -124,7 +124,7 @@ class RemoveRedundantQualifierNameQuickFix : LocalQuickFix {
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
val file = descriptor.psiElement.containingFile as KtFile
val range = when (val element = descriptor.psiElement) {
is KtUserType -> IntRange(element.startOffset, element.referenceExpression?.endOffset ?: return)
is KtUserType -> IntRange(element.startOffset, element.endOffset)
is KtDotQualifiedExpression -> IntRange(
element.startOffset,
element.getLastParentOfTypeInRowWithSelf<KtDotQualifiedExpression>()?.getQualifiedElementSelector()?.endOffset ?: return
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun main() {
val a: kotlin<caret>.Pair<Int, Int>
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun main() {
val a: Pair<Int, Int>
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun main() {
kotlin<caret>.Pair<Int, Int>(1, 1)
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun main() {
Pair<Int, Int>(1, 1)
}
@@ -6469,6 +6469,16 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
public void testTypeWithRuntime() throws Exception {
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/typeWithRuntime.kt");
}
@TestMetadata("userTypeWithTypeParameter.kt")
public void testUserTypeWithTypeParameter() throws Exception {
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/userTypeWithTypeParameter.kt");
}
@TestMetadata("withTypeParameter.kt")
public void testWithTypeParameter() throws Exception {
runTest("idea/testData/inspectionsLocal/removeRedundantQualifierName/withTypeParameter.kt");
}
}
@TestMetadata("idea/testData/inspectionsLocal/removeRedundantSpreadOperator")