Minor, remove/simplify unnecessary utilities in util.runtime
This commit is contained in:
+1
-2
@@ -36,7 +36,6 @@ import org.jetbrains.kotlin.resolve.constants.ConstantValueFactory
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.resolveTopLevelClass
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.utils.keysToMapExceptNulls
|
||||
import org.jetbrains.kotlin.utils.valuesToMap
|
||||
|
||||
fun LazyJavaResolverContext.resolveAnnotation(annotation: JavaAnnotation): LazyJavaAnnotationDescriptor? {
|
||||
val classId = annotation.getClassId()
|
||||
@@ -78,7 +77,7 @@ class LazyJavaAnnotationDescriptor(
|
||||
val constructors = getAnnotationClass().getConstructors()
|
||||
if (constructors.isEmpty()) return mapOf()
|
||||
|
||||
val nameToArg = javaAnnotation.getArguments().valuesToMap { it.name }
|
||||
val nameToArg = javaAnnotation.getArguments().toMapBy { it.name }
|
||||
|
||||
return constructors.first().getValueParameters().keysToMapExceptNulls { valueParameter ->
|
||||
var javaAnnotationArgument = nameToArg[valueParameter.getName()]
|
||||
|
||||
+2
-2
@@ -604,11 +604,11 @@ public class LazyJavaClassMemberScope(
|
||||
}
|
||||
|
||||
private val nestedClassIndex = c.storageManager.createLazyValue {
|
||||
jClass.getInnerClasses().valuesToMap { c -> c.getName() }
|
||||
jClass.innerClasses.toMapBy { c -> c.name }
|
||||
}
|
||||
|
||||
private val enumEntryIndex = c.storageManager.createLazyValue {
|
||||
jClass.getFields().filter { it.isEnumEntry() }.valuesToMap { f -> f.getName() }
|
||||
jClass.fields.filter { it.isEnumEntry }.toMapBy { f -> f.name }
|
||||
}
|
||||
|
||||
private val nestedClasses = c.storageManager.createMemoizedFunctionWithNullableValues {
|
||||
|
||||
+8
-6
@@ -16,12 +16,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.java.lazy.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.load.java.structure.*
|
||||
import org.jetbrains.kotlin.load.java.components.DescriptorResolverUtils
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaField
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMember
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.utils.valuesToMap
|
||||
import java.util.HashSet
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import java.util.*
|
||||
|
||||
interface MemberIndex {
|
||||
fun findMethodsByName(name: Name): Collection<JavaMethod>
|
||||
@@ -55,8 +57,8 @@ open class ClassMemberIndex(val jClass: JavaClass, val memberFilter: (JavaMember
|
||||
memberFilter(m) && !DescriptorResolverUtils.isObjectMethodInInterface(m)
|
||||
}
|
||||
|
||||
private val methods = jClass.getMethods().asSequence().filter(methodFilter).groupBy { m -> m.getName() }
|
||||
private val fields = jClass.getFields().asSequence().filter(memberFilter).valuesToMap { m -> m.getName() }
|
||||
private val methods = jClass.methods.asSequence().filter(methodFilter).groupBy { m -> m.name }
|
||||
private val fields = jClass.fields.asSequence().filter(memberFilter).toMapBy { m -> m.name }
|
||||
|
||||
override fun findMethodsByName(name: Name): Collection<JavaMethod> = methods[name] ?: listOf()
|
||||
override fun getMethodNames(nameFilter: (Name) -> Boolean): Collection<Name> =
|
||||
|
||||
Reference in New Issue
Block a user