FIR IDE: Do not try to shorten type without qualifier
This commit is contained in:
+5
@@ -144,6 +144,11 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest {
|
|||||||
runTest("idea/testData/shortenRefsFir/types/ParameterTypeNestedType.kt");
|
runTest("idea/testData/shortenRefsFir/types/ParameterTypeNestedType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ParameterTypeNestedTypeWithoutPackageNotShorten.kt")
|
||||||
|
public void testParameterTypeNestedTypeWithoutPackageNotShorten() throws Exception {
|
||||||
|
runTest("idea/testData/shortenRefsFir/types/ParameterTypeNestedTypeWithoutPackageNotShorten.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ParameterTypeNonImportedClass.kt")
|
@TestMetadata("ParameterTypeNonImportedClass.kt")
|
||||||
public void testParameterTypeNonImportedClass() throws Exception {
|
public void testParameterTypeNonImportedClass() throws Exception {
|
||||||
runTest("idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.kt");
|
runTest("idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.kt");
|
||||||
|
|||||||
+9
-2
@@ -185,6 +185,9 @@ internal class KtFirReferenceShortener(
|
|||||||
val positionScopes = findScopesAtPosition(wholeTypeElement, namesToImport) ?: return
|
val positionScopes = findScopesAtPosition(wholeTypeElement, namesToImport) ?: return
|
||||||
|
|
||||||
for ((classId, typeElement) in allClassIds.zip(allTypeElements)) {
|
for ((classId, typeElement) in allClassIds.zip(allTypeElements)) {
|
||||||
|
// if qualifier is null, then this type have no package and thus cannot be shortened
|
||||||
|
if (typeElement.qualifier == null) return
|
||||||
|
|
||||||
val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId
|
val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId
|
||||||
|
|
||||||
if (firstFoundClass == classId) {
|
if (firstFoundClass == classId) {
|
||||||
@@ -234,7 +237,7 @@ internal class KtFirReferenceShortener(
|
|||||||
val singleAvailableProperty = findSinglePropertyInScopesByName(scopes, propertyId.callableName)
|
val singleAvailableProperty = findSinglePropertyInScopesByName(scopes, propertyId.callableName)
|
||||||
|
|
||||||
if (singleAvailableProperty?.callableId == propertyId) {
|
if (singleAvailableProperty?.callableId == propertyId) {
|
||||||
callsToShorten.add(qualifiedProperty)
|
addElementToShorten(qualifiedProperty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,9 +254,13 @@ internal class KtFirReferenceShortener(
|
|||||||
val singleAvailableCallable = findSingleFunctionInScopesByName(scopes, callableId.callableName)
|
val singleAvailableCallable = findSingleFunctionInScopesByName(scopes, callableId.callableName)
|
||||||
|
|
||||||
if (singleAvailableCallable?.callableId == callableId) {
|
if (singleAvailableCallable?.callableId == callableId) {
|
||||||
callsToShorten.add(qualifiedCallExpression)
|
addElementToShorten(qualifiedCallExpression)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun addElementToShorten(element: KtDotQualifiedExpression) {
|
||||||
|
callsToShorten.add(element)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
|
package test
|
||||||
|
|
||||||
|
class T {
|
||||||
|
class TT
|
||||||
|
}
|
||||||
|
|
||||||
|
<selection>fun foo(t: T.TT) {}</selection>
|
||||||
Vendored
+8
@@ -0,0 +1,8 @@
|
|||||||
|
// FIR_COMPARISON
|
||||||
|
package test
|
||||||
|
|
||||||
|
class T {
|
||||||
|
class TT
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo(t: T.TT) {}
|
||||||
Reference in New Issue
Block a user