KTIJ-26713 [AA] Handle FirFunctionTypeParameter in KtFirReferenceShortener
^KTIJ-26713 Fixed
This commit is contained in:
+3
-2
@@ -85,7 +85,7 @@ internal class KtFirReferenceShortener(
|
||||
val declarationToVisit = file.findSmallestElementOfTypeContainingSelection<KtDeclaration>(selection)
|
||||
?: file
|
||||
|
||||
val firDeclaration = declarationToVisit.getCorrespondingFirDeclaration() ?: return ShortenCommandImpl(
|
||||
val firDeclaration = declarationToVisit.getCorrespondingFirElement() ?: return ShortenCommandImpl(
|
||||
file.createSmartPointer(),
|
||||
importsToAdd = emptySet(),
|
||||
starImportsToAdd = emptySet(),
|
||||
@@ -140,7 +140,7 @@ internal class KtFirReferenceShortener(
|
||||
)
|
||||
}
|
||||
|
||||
private fun KtElement.getCorrespondingFirDeclaration(): FirDeclaration? {
|
||||
private fun KtElement.getCorrespondingFirElement(): FirElement? {
|
||||
require(this is KtFile || this is KtDeclaration)
|
||||
|
||||
val firElement = getOrBuildFir(firResolveSession)
|
||||
@@ -148,6 +148,7 @@ internal class KtFirReferenceShortener(
|
||||
return when (firElement) {
|
||||
is FirDeclaration -> firElement
|
||||
is FirAnonymousFunctionExpression -> firElement.anonymousFunction
|
||||
is FirFunctionTypeParameter -> firElement
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -274,6 +274,12 @@ public class FirIdeNormalAnalysisSourceModuleReferenceShortenerTestGenerated ext
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/extensionProperty_objectReceiverWithOtherThisInScope.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionalType_parameterPosition.kt")
|
||||
public void testFunctionalType_parameterPosition() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/functionalType_parameterPosition.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kdoc.kt")
|
||||
public void testKdoc() throws Exception {
|
||||
|
||||
+6
@@ -274,6 +274,12 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceShortenerTestGenera
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/extensionProperty_objectReceiverWithOtherThisInScope.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionalType_parameterPosition.kt")
|
||||
public void testFunctionalType_parameterPosition() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/functionalType_parameterPosition.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kdoc.kt")
|
||||
public void testKdoc() throws Exception {
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// FILE: main.kt
|
||||
package test
|
||||
|
||||
fun take(action: (<expr>dependency.Foo</expr>) -> Unit) {}
|
||||
|
||||
// FILE: dependency.kt
|
||||
package dependency
|
||||
|
||||
class Foo
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
Before shortening: dependency.Foo
|
||||
with DO_NOT_SHORTEN:
|
||||
with SHORTEN_IF_ALREADY_IMPORTED:
|
||||
with SHORTEN_AND_IMPORT:
|
||||
[type] dependency.Foo
|
||||
with SHORTEN_AND_STAR_IMPORT:
|
||||
[type] dependency.Foo
|
||||
Reference in New Issue
Block a user