Revert "KT-14252 Completion could suggest constructors available via typealiases"

Reverted due problems with tests
This reverts commit 55eeb74c08.
This commit is contained in:
Simon Ogorodnik
2017-01-30 16:46:38 +03:00
parent 77aa685496
commit d117b0210f
11 changed files with 25 additions and 171 deletions
@@ -49,7 +49,6 @@ import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.isHiddenInResolution
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.asSimpleType
import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList
import java.lang.reflect.Field
import java.lang.reflect.Modifier
@@ -176,33 +175,29 @@ class KotlinIndicesHelper(
}
fun resolveTypeAliasesUsingIndex(type: KotlinType, originalTypeName: String): Set<TypeAliasDescriptor> {
val typeConstructor = type.constructor
private fun resolveTypeAliasesUsingIndex(type: KotlinType, originalTypeName: String, out: MutableCollection<String>) {
val index = KotlinTypeAliasByExpansionShortNameIndex.INSTANCE
val out = mutableSetOf<TypeAliasDescriptor>()
fun searchRecursively(typeName: String) {
ProgressManager.checkCanceled()
index[typeName, project, scope].asSequence()
.map { it.resolveToDescriptorIfAny() as? TypeAliasDescriptor }
.filterNotNull()
.filter { it.expandedType.constructor == typeConstructor }
.filter { it !in out }
.onEach { out.add(it) }
.filter { it.expandedType == type }
.map { it.name.asString() }
.forEach(::searchRecursively)
.filter { it !in out }
.onEach(::searchRecursively)
.toCollection(out)
}
searchRecursively(originalTypeName)
return out
}
private fun MutableCollection<String>.addTypeNames(type: KotlinType) {
val constructor = type.constructor
constructor.declarationDescriptor?.name?.asString()?.let { typeName ->
add(typeName)
resolveTypeAliasesUsingIndex(type, typeName).mapTo(this, { it.name.asString() })
resolveTypeAliasesUsingIndex(type, typeName, this)
}
constructor.supertypes.forEach { addTypeNames(it) }
}