Revert "[SLC] Support generics and ignore whitespace in KtSuperTypeList.findEntry"

This reverts commit e77f5c7764.
This commit is contained in:
Dmitrii Gridin
2023-02-13 17:28:35 +01:00
parent 761553ea75
commit 607b8f6b61
5 changed files with 17 additions and 32 deletions
@@ -13,11 +13,24 @@ import com.intellij.util.IncorrectOperationException
import org.jetbrains.kotlin.analyzer.KotlinModificationTrackerService
import org.jetbrains.kotlin.psi.*
fun KtSuperTypeList.findEntry(fqNameToFind: String): KtSuperTypeListEntry? =
entries.find { it.typeAsUserType?.simpleName == fqNameToFind }
fun KtSuperTypeList.findEntry(fqNameToFind: String): KtSuperTypeListEntry? {
val name = fqNameToFind.substringAfterLast(delimiter = '.', missingDelimiterValue = "")
if (name.isEmpty()) {
return entries.find { it.typeAsUserType?.textMatches(fqNameToFind) == true }
}
private val KtUserType.simpleName: String?
get() = qualifier?.let { "${it.simpleName}.$referencedName" } ?: referencedName
val qualifier = fqNameToFind.substringBeforeLast('.')
val entries = entries.mapNotNull { entry -> entry.typeAsUserType?.let { entry to it } }
.filter { (_, type) -> type.referencedName == name && (type.qualifier?.textMatches(qualifier) != false) }
.ifEmpty { return null }
return if (entries.size == 1) {
entries.first().first
} else {
val entry = entries.firstOrNull { it.second.qualifier != null } ?: entries.firstOrNull()
entry?.first
}
}
// NOTE: avoid using blocking lazy in light classes, it leads to deadlocks
fun <T> lazyPub(initializer: () -> T) = lazy(LazyThreadSafetyMode.PUBLICATION, initializer)
@@ -300,12 +300,6 @@ public class SymbolLightClassesByPsiForLibraryTestGenerated extends AbstractSymb
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/typealiasInTypeArguments.kt");
}
@Test
@TestMetadata("unresolvedGenericSupertypes.kt")
public void testUnresolvedGenericSupertypes() throws Exception {
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/unresolvedGenericSupertypes.kt");
}
@Test
@TestMetadata("unresolvedWithAliasedImport.kt")
public void testUnresolvedWithAliasedImport() throws Exception {
@@ -300,12 +300,6 @@ public class SymbolLightClassesByPsiForSourceTestGenerated extends AbstractSymbo
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/typealiasInTypeArguments.kt");
}
@Test
@TestMetadata("unresolvedGenericSupertypes.kt")
public void testUnresolvedGenericSupertypes() throws Exception {
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/unresolvedGenericSupertypes.kt");
}
@Test
@TestMetadata("unresolvedWithAliasedImport.kt")
public void testUnresolvedWithAliasedImport() throws Exception {
@@ -1,7 +0,0 @@
public final class C1 /* C1*/ extends Super<T, U> implements Intf1<A, B>, Intf2<X, Y<Z>> {
public C1();// .ctor()
}
public final class C2 /* C2*/ extends com.example.Super<T, U> implements com.example.Intf1<A, B>, com.example.Intf2<X, Y<Z>> {
public C2();// .ctor()
}
@@ -1,9 +0,0 @@
public class C1: Intf1 < A , B >, Super < T , U >(42),
Intf2 < X ,
Y < Z >>
public class C2: com . example . Intf1 < A , B >, com . example . Super < T , U >(42),
com . example . Intf2 < X ,
Y < Z >>
// COMPILATION_ERRORS