Drop JavaTypeParameter#getIndex
This commit is contained in:
-5
@@ -31,11 +31,6 @@ public class JavaTypeParameterImpl extends JavaClassifierImpl<PsiTypeParameter>
|
|||||||
super(psiTypeParameter);
|
super(psiTypeParameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getIndex() {
|
|
||||||
return getPsi().getIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Name getName() {
|
public Name getName() {
|
||||||
|
|||||||
+2
-1
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.descriptors.SourceElement
|
|||||||
class LazyJavaTypeParameterDescriptor(
|
class LazyJavaTypeParameterDescriptor(
|
||||||
private val c: LazyJavaResolverContext,
|
private val c: LazyJavaResolverContext,
|
||||||
public val javaTypeParameter: JavaTypeParameter,
|
public val javaTypeParameter: JavaTypeParameter,
|
||||||
|
index: Int,
|
||||||
containingDeclaration: DeclarationDescriptor
|
containingDeclaration: DeclarationDescriptor
|
||||||
) : AbstractLazyTypeParameterDescriptor(
|
) : AbstractLazyTypeParameterDescriptor(
|
||||||
c.storageManager,
|
c.storageManager,
|
||||||
@@ -37,7 +38,7 @@ class LazyJavaTypeParameterDescriptor(
|
|||||||
javaTypeParameter.getName(),
|
javaTypeParameter.getName(),
|
||||||
Variance.INVARIANT,
|
Variance.INVARIANT,
|
||||||
/* isReified = */ false,
|
/* isReified = */ false,
|
||||||
javaTypeParameter.getIndex(),
|
index,
|
||||||
SourceElement.NO_SOURCE
|
SourceElement.NO_SOURCE
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|||||||
@@ -16,16 +16,17 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.load.java.lazy
|
package org.jetbrains.kotlin.load.java.lazy
|
||||||
|
|
||||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
|
||||||
import org.jetbrains.kotlin.load.java.structure.JavaTypeParameter
|
|
||||||
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaTypeParameterDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
|
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaTypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||||
|
import org.jetbrains.kotlin.load.java.structure.JavaTypeParameter
|
||||||
import org.jetbrains.kotlin.load.java.structure.JavaTypeParameterListOwner
|
import org.jetbrains.kotlin.load.java.structure.JavaTypeParameterListOwner
|
||||||
|
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
|
||||||
|
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||||
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
|
import org.jetbrains.kotlin.utils.mapToIndex
|
||||||
|
|
||||||
//TODO: (module refactoring) usages of this interface should be replaced by ModuleClassResolver
|
//TODO: (module refactoring) usages of this interface should be replaced by ModuleClassResolver
|
||||||
trait LazyJavaClassResolver {
|
trait LazyJavaClassResolver {
|
||||||
@@ -45,13 +46,13 @@ class LazyJavaTypeParameterResolver(
|
|||||||
private val containingDeclaration: DeclarationDescriptor,
|
private val containingDeclaration: DeclarationDescriptor,
|
||||||
typeParameterOwner: JavaTypeParameterListOwner
|
typeParameterOwner: JavaTypeParameterListOwner
|
||||||
) : TypeParameterResolver {
|
) : TypeParameterResolver {
|
||||||
private val typeParameters = typeParameterOwner.getTypeParameters().toSet()
|
private val typeParameters: Map<JavaTypeParameter, Int> = typeParameterOwner.getTypeParameters().mapToIndex()
|
||||||
|
|
||||||
private val resolve = c.storageManager.createMemoizedFunctionWithNullableValues {
|
private val resolve = c.storageManager.createMemoizedFunctionWithNullableValues {
|
||||||
(javaTypeParameter: JavaTypeParameter) ->
|
(typeParameter: JavaTypeParameter) ->
|
||||||
if (javaTypeParameter in typeParameters)
|
typeParameters[typeParameter]?.let { index ->
|
||||||
LazyJavaTypeParameterDescriptor(c.child(this), javaTypeParameter, containingDeclaration)
|
LazyJavaTypeParameterDescriptor(c.child(this), typeParameter, index, containingDeclaration)
|
||||||
else null
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun resolveTypeParameter(javaTypeParameter: JavaTypeParameter): TypeParameterDescriptor? {
|
override fun resolveTypeParameter(javaTypeParameter: JavaTypeParameter): TypeParameterDescriptor? {
|
||||||
|
|||||||
-2
@@ -22,8 +22,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public interface JavaTypeParameter extends JavaClassifier {
|
public interface JavaTypeParameter extends JavaClassifier {
|
||||||
int getIndex();
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
Collection<JavaClassifierType> getUpperBounds();
|
Collection<JavaClassifierType> getUpperBounds();
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,14 @@ public fun <K, V: Any> Iterable<K>.keysToMapExceptNulls(value: (K) -> V?): Map<K
|
|||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public fun <K> Iterable<K>.mapToIndex(): Map<K, Int> {
|
||||||
|
val map = LinkedHashMap<K, Int>()
|
||||||
|
for ((index, k) in this.withIndex()) {
|
||||||
|
map[k] = index
|
||||||
|
}
|
||||||
|
return map
|
||||||
|
}
|
||||||
|
|
||||||
public fun <T, C: Collection<T>> C.ifEmpty(body: () -> C): C = if (isEmpty()) body() else this
|
public fun <T, C: Collection<T>> C.ifEmpty(body: () -> C): C = if (isEmpty()) body() else this
|
||||||
|
|
||||||
public fun <T: Any> emptyOrSingletonList(item: T?): List<T> = if (item == null) listOf() else listOf(item)
|
public fun <T: Any> emptyOrSingletonList(item: T?): List<T> = if (item == null) listOf() else listOf(item)
|
||||||
|
|||||||
Reference in New Issue
Block a user