Replace map + filterNotNull -> mapNotNull in project
This commit is contained in:
+5
-3
@@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.preprocessor
|
package org.jetbrains.kotlin.preprocessor
|
||||||
|
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.KtAnnotated
|
||||||
|
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||||
|
import org.jetbrains.kotlin.psi.KtUserType
|
||||||
|
|
||||||
interface Conditional {
|
interface Conditional {
|
||||||
|
|
||||||
@@ -52,10 +54,10 @@ interface Conditional {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun KtAnnotated.parseConditionalAnnotations(): List<Conditional> =
|
fun KtAnnotated.parseConditionalAnnotations(): List<Conditional> =
|
||||||
annotationEntries.map {
|
annotationEntries.mapNotNull {
|
||||||
val parser = Conditional.ANNOTATIONS.get(it.typeReferenceName)
|
val parser = Conditional.ANNOTATIONS.get(it.typeReferenceName)
|
||||||
parser?.parse?.invoke(it.valueArguments.splitToPositionalAndNamed())
|
parser?.parse?.invoke(it.valueArguments.splitToPositionalAndNamed())
|
||||||
}.filterNotNull()
|
}
|
||||||
|
|
||||||
|
|
||||||
val KtAnnotationEntry.typeReferenceName: String? get() =
|
val KtAnnotationEntry.typeReferenceName: String? get() =
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ import org.jetbrains.kotlin.load.java.lazy.ModuleClassResolverImpl
|
|||||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer
|
import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer
|
||||||
import org.jetbrains.kotlin.resolve.jvm.extensions.PackageFragmentProviderExtension
|
|
||||||
import org.jetbrains.kotlin.resolve.TargetEnvironment
|
import org.jetbrains.kotlin.resolve.TargetEnvironment
|
||||||
import org.jetbrains.kotlin.resolve.TargetPlatform
|
import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||||
|
import org.jetbrains.kotlin.resolve.jvm.extensions.PackageFragmentProviderExtension
|
||||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
|
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactoryService
|
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactoryService
|
||||||
@@ -99,8 +99,7 @@ object JvmAnalyzerFacade : AnalyzerFacade<JvmPlatformParameters>() {
|
|||||||
javaDescriptorResolver.packageFragmentProvider)
|
javaDescriptorResolver.packageFragmentProvider)
|
||||||
|
|
||||||
providersForModule += PackageFragmentProviderExtension.getInstances(project)
|
providersForModule += PackageFragmentProviderExtension.getInstances(project)
|
||||||
.map { it.getPackageFragmentProvider(project, moduleDescriptor, moduleContext.storageManager, trace, moduleInfo) }
|
.mapNotNull { it.getPackageFragmentProvider(project, moduleDescriptor, moduleContext.storageManager, trace, moduleInfo) }
|
||||||
.filterNotNull()
|
|
||||||
|
|
||||||
return ResolverForModule(CompositePackageFragmentProvider(providersForModule), container)
|
return ResolverForModule(CompositePackageFragmentProvider(providersForModule), container)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.intellij.psi.util.PsiTreeUtil
|
|||||||
import com.intellij.util.SmartFMap
|
import com.intellij.util.SmartFMap
|
||||||
import com.intellij.util.containers.ContainerUtil
|
import com.intellij.util.containers.ContainerUtil
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
|
import org.jetbrains.kotlin.cfg.ControlFlowBuilder.PredefinedOperation.*
|
||||||
import org.jetbrains.kotlin.cfg.pseudocode.ControlFlowInstructionsGenerator
|
import org.jetbrains.kotlin.cfg.pseudocode.ControlFlowInstructionsGenerator
|
||||||
import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue
|
import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue
|
||||||
import org.jetbrains.kotlin.cfg.pseudocode.Pseudocode
|
import org.jetbrains.kotlin.cfg.pseudocode.Pseudocode
|
||||||
@@ -31,30 +32,30 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.InstructionWithValu
|
|||||||
import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.MagicKind
|
import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.MagicKind
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
|
||||||
|
import org.jetbrains.kotlin.diagnostics.Errors.*
|
||||||
import org.jetbrains.kotlin.lexer.KtToken
|
import org.jetbrains.kotlin.lexer.KtToken
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
|
import org.jetbrains.kotlin.lexer.KtTokens.*
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.BindingContextUtils
|
import org.jetbrains.kotlin.resolve.BindingContextUtils
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||||
import org.jetbrains.kotlin.resolve.CompileTimeConstantUtils
|
import org.jetbrains.kotlin.resolve.CompileTimeConstantUtils
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.*
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||||
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator
|
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
import org.jetbrains.kotlin.cfg.ControlFlowBuilder.PredefinedOperation.*
|
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors.*
|
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens.*
|
|
||||||
|
|
||||||
class ControlFlowProcessor(private val trace: BindingTrace) {
|
class ControlFlowProcessor(private val trace: BindingTrace) {
|
||||||
|
|
||||||
private val builder: ControlFlowBuilder = ControlFlowInstructionsGenerator()
|
private val builder: ControlFlowBuilder = ControlFlowInstructionsGenerator()
|
||||||
@@ -202,7 +203,7 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun elementsToValues(from: List<KtElement?>): List<PseudoValue> {
|
private fun elementsToValues(from: List<KtElement?>): List<PseudoValue> {
|
||||||
return from.map { element -> getBoundOrUnreachableValue(element) }.filterNotNull()
|
return from.mapNotNull { element -> getBoundOrUnreachableValue(element) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun generateInitializer(declaration: KtDeclaration, initValue: PseudoValue) {
|
private fun generateInitializer(declaration: KtDeclaration, initValue: PseudoValue) {
|
||||||
@@ -1268,7 +1269,7 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
|
|||||||
|
|
||||||
private fun generateCallOrMarkUnresolved(call: KtCallElement) {
|
private fun generateCallOrMarkUnresolved(call: KtCallElement) {
|
||||||
if (!generateCall(call)) {
|
if (!generateCall(call)) {
|
||||||
val arguments = call.valueArguments.map { valueArgument -> valueArgument.getArgumentExpression() }.filterNotNull()
|
val arguments = call.valueArguments.mapNotNull { valueArgument -> valueArgument.getArgumentExpression() }
|
||||||
|
|
||||||
for (argument in arguments) {
|
for (argument in arguments) {
|
||||||
generateInstructions(argument)
|
generateInstructions(argument)
|
||||||
|
|||||||
+1
-1
@@ -105,7 +105,7 @@ class ConstraintSystemBuilderImpl : ConstraintSystem.Builder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun getNestedTypeVariables(type: KotlinType): List<TypeVariable> =
|
internal fun getNestedTypeVariables(type: KotlinType): List<TypeVariable> =
|
||||||
type.getNestedTypeParameters().map { getMyTypeVariable(it) }.filterNotNull()
|
type.getNestedTypeParameters().mapNotNull { getMyTypeVariable(it) }
|
||||||
|
|
||||||
override fun addSubtypeConstraint(constrainingType: KotlinType?, subjectType: KotlinType?, constraintPosition: ConstraintPosition) {
|
override fun addSubtypeConstraint(constrainingType: KotlinType?, subjectType: KotlinType?, constraintPosition: ConstraintPosition) {
|
||||||
addConstraint(SUB_TYPE, constrainingType, subjectType, ConstraintContext(constraintPosition, initial = true))
|
addConstraint(SUB_TYPE, constrainingType, subjectType, ConstraintContext(constraintPosition, initial = true))
|
||||||
|
|||||||
+2
-2
@@ -57,7 +57,7 @@ internal fun KotlinType.getNestedArguments(): List<TypeProjection> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun KotlinType.getNestedTypeParameters(): List<TypeParameterDescriptor> {
|
internal fun KotlinType.getNestedTypeParameters(): List<TypeParameterDescriptor> {
|
||||||
return getNestedArguments().map { typeProjection ->
|
return getNestedArguments().mapNotNull { typeProjection ->
|
||||||
typeProjection.type.constructor.declarationDescriptor as? TypeParameterDescriptor
|
typeProjection.type.constructor.declarationDescriptor as? TypeParameterDescriptor
|
||||||
}.filterNotNull()
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -268,7 +268,7 @@ class BindingContextSuppressCache(val context: BindingContext) : KotlinSuppressC
|
|||||||
return descriptor.annotations.toList()
|
return descriptor.annotations.toList()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return annotated.annotationEntries.map { context.get(BindingContext.ANNOTATION, it) }.filterNotNull()
|
return annotated.annotationEntries.mapNotNull { context.get(BindingContext.ANNOTATION, it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -470,9 +470,9 @@ class LazyJavaClassMemberScope(
|
|||||||
simpleFunctionDescriptor: SimpleFunctionDescriptor
|
simpleFunctionDescriptor: SimpleFunctionDescriptor
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val candidatesToOverride =
|
val candidatesToOverride =
|
||||||
getFunctionsFromSupertypes(simpleFunctionDescriptor.name).map {
|
getFunctionsFromSupertypes(simpleFunctionDescriptor.name).mapNotNull {
|
||||||
BuiltinMethodsWithSpecialGenericSignature.getOverriddenBuiltinFunctionWithErasedValueParametersInJava(it)
|
BuiltinMethodsWithSpecialGenericSignature.getOverriddenBuiltinFunctionWithErasedValueParametersInJava(it)
|
||||||
}.filterNotNull()
|
}
|
||||||
|
|
||||||
return candidatesToOverride.any {
|
return candidatesToOverride.any {
|
||||||
candidate ->
|
candidate ->
|
||||||
|
|||||||
+2
-3
@@ -40,11 +40,10 @@ class LazyJavaPackageFragment(
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal val kotlinBinaryClasses by c.storageManager.createLazyValue {
|
internal val kotlinBinaryClasses by c.storageManager.createLazyValue {
|
||||||
val simpleNames = c.components.packageMapper.findPackageParts(fqName.asString())
|
c.components.packageMapper.findPackageParts(fqName.asString()).mapNotNull {
|
||||||
simpleNames.map {
|
|
||||||
val classId = ClassId(fqName, Name.identifier(it))
|
val classId = ClassId(fqName, Name.identifier(it))
|
||||||
c.components.kotlinClassFinder.findKotlinClass(classId)
|
c.components.kotlinClassFinder.findKotlinClass(classId)
|
||||||
}.filterNotNull()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun resolveTopLevelClass(javaClass: JavaClass) = topLevelClasses(javaClass)
|
internal fun resolveTopLevelClass(javaClass: JavaClass) = topLevelClasses(javaClass)
|
||||||
|
|||||||
+3
-3
@@ -132,7 +132,7 @@ fun KotlinType.computeIndexedQualifiersForOverride(fromSupertypes: Collection<Ko
|
|||||||
assert(isHeadTypeConstructor || !onlyHeadTypeConstructor) { "Only head type constructors should be computed" }
|
assert(isHeadTypeConstructor || !onlyHeadTypeConstructor) { "Only head type constructors should be computed" }
|
||||||
|
|
||||||
val qualifiers = indexedThisType[index]
|
val qualifiers = indexedThisType[index]
|
||||||
val verticalSlice = indexedFromSupertypes.map { it.getOrElse(index, { null }) }.filterNotNull()
|
val verticalSlice = indexedFromSupertypes.mapNotNull { it.getOrNull(index) }
|
||||||
|
|
||||||
// Only the head type constructor is safely co-variant
|
// Only the head type constructor is safely co-variant
|
||||||
qualifiers.computeQualifiersForOverride(verticalSlice, isCovariant && isHeadTypeConstructor)
|
qualifiers.computeQualifiersForOverride(verticalSlice, isCovariant && isHeadTypeConstructor)
|
||||||
@@ -142,8 +142,8 @@ fun KotlinType.computeIndexedQualifiersForOverride(fromSupertypes: Collection<Ko
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun KotlinType.computeQualifiersForOverride(fromSupertypes: Collection<KotlinType>, isCovariant: Boolean): JavaTypeQualifiers {
|
private fun KotlinType.computeQualifiersForOverride(fromSupertypes: Collection<KotlinType>, isCovariant: Boolean): JavaTypeQualifiers {
|
||||||
val nullabilityFromSupertypes = fromSupertypes.map { it.extractQualifiers().nullability }.filterNotNull().toSet()
|
val nullabilityFromSupertypes = fromSupertypes.mapNotNull { it.extractQualifiers().nullability }.toSet()
|
||||||
val mutabilityFromSupertypes = fromSupertypes.map { it.extractQualifiers().mutability }.filterNotNull().toSet()
|
val mutabilityFromSupertypes = fromSupertypes.mapNotNull { it.extractQualifiers().mutability }.toSet()
|
||||||
|
|
||||||
val own = extractQualifiersFromAnnotations()
|
val own = extractQualifiersFromAnnotations()
|
||||||
|
|
||||||
|
|||||||
@@ -122,9 +122,9 @@ class CompositeAnnotations(
|
|||||||
|
|
||||||
override fun hasAnnotation(fqName: FqName) = delegates.asSequence().any { it.hasAnnotation(fqName) }
|
override fun hasAnnotation(fqName: FqName) = delegates.asSequence().any { it.hasAnnotation(fqName) }
|
||||||
|
|
||||||
override fun findAnnotation(fqName: FqName) = delegates.asSequence().map { it.findAnnotation(fqName) }.filterNotNull().firstOrNull()
|
override fun findAnnotation(fqName: FqName) = delegates.asSequence().mapNotNull { it.findAnnotation(fqName) }.firstOrNull()
|
||||||
|
|
||||||
override fun findExternalAnnotation(fqName: FqName) = delegates.asSequence().map { it.findExternalAnnotation(fqName) }.filterNotNull().firstOrNull()
|
override fun findExternalAnnotation(fqName: FqName) = delegates.asSequence().mapNotNull { it.findExternalAnnotation(fqName) }.firstOrNull()
|
||||||
|
|
||||||
override fun getUseSiteTargetedAnnotations() = delegates.flatMap { it.getUseSiteTargetedAnnotations() }
|
override fun getUseSiteTargetedAnnotations() = delegates.flatMap { it.getUseSiteTargetedAnnotations() }
|
||||||
|
|
||||||
|
|||||||
@@ -95,8 +95,7 @@ class DescriptorKindFilter(
|
|||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
val predefinedFilterName = DEBUG_PREDEFINED_FILTERS_MASK_NAMES.firstOrNull { it.mask == kindMask } ?.name
|
val predefinedFilterName = DEBUG_PREDEFINED_FILTERS_MASK_NAMES.firstOrNull { it.mask == kindMask } ?.name
|
||||||
val kindString = predefinedFilterName ?: DEBUG_MASK_BIT_NAMES
|
val kindString = predefinedFilterName ?: DEBUG_MASK_BIT_NAMES
|
||||||
.map { if (acceptsKinds(it.mask)) it.name else null }
|
.mapNotNull { if (acceptsKinds(it.mask)) it.name else null }
|
||||||
.filterNotNull()
|
|
||||||
.joinToString(separator = " | ")
|
.joinToString(separator = " | ")
|
||||||
|
|
||||||
return "DescriptorKindFilter($kindString, $excludes)"
|
return "DescriptorKindFilter($kindString, $excludes)"
|
||||||
@@ -138,21 +137,19 @@ class DescriptorKindFilter(
|
|||||||
private class MaskToName(val mask: Int, val name: String)
|
private class MaskToName(val mask: Int, val name: String)
|
||||||
|
|
||||||
private val DEBUG_PREDEFINED_FILTERS_MASK_NAMES = staticFields<DescriptorKindFilter>()
|
private val DEBUG_PREDEFINED_FILTERS_MASK_NAMES = staticFields<DescriptorKindFilter>()
|
||||||
.map { field ->
|
.mapNotNull { field ->
|
||||||
val filter = field.get(null) as? DescriptorKindFilter
|
val filter = field.get(null) as? DescriptorKindFilter
|
||||||
if (filter != null) MaskToName(filter.kindMask, field.name) else null
|
if (filter != null) MaskToName(filter.kindMask, field.name) else null
|
||||||
}
|
}
|
||||||
.filterNotNull()
|
|
||||||
.toReadOnlyList()
|
.toReadOnlyList()
|
||||||
|
|
||||||
private val DEBUG_MASK_BIT_NAMES = staticFields<DescriptorKindFilter>()
|
private val DEBUG_MASK_BIT_NAMES = staticFields<DescriptorKindFilter>()
|
||||||
.filter { it.type == Integer.TYPE }
|
.filter { it.type == Integer.TYPE }
|
||||||
.map { field ->
|
.mapNotNull { field ->
|
||||||
val mask = field.get(null) as Int
|
val mask = field.get(null) as Int
|
||||||
val isOneBitMask = mask == (mask and (-mask))
|
val isOneBitMask = mask == (mask and (-mask))
|
||||||
if (isOneBitMask) MaskToName(mask, field.name) else null
|
if (isOneBitMask) MaskToName(mask, field.name) else null
|
||||||
}
|
}
|
||||||
.filterNotNull()
|
|
||||||
.toReadOnlyList()
|
.toReadOnlyList()
|
||||||
|
|
||||||
private inline fun <reified T : Any> staticFields() = T::class.java.fields.filter { Modifier.isStatic(it.modifiers) }
|
private inline fun <reified T : Any> staticFields() = T::class.java.fields.filter { Modifier.isStatic(it.modifiers) }
|
||||||
|
|||||||
+1
-1
@@ -50,7 +50,7 @@ class AnnotationDeserializer(private val module: ModuleDescriptor) {
|
|||||||
val constructor = annotationClass.constructors.singleOrNull()
|
val constructor = annotationClass.constructors.singleOrNull()
|
||||||
if (constructor != null) {
|
if (constructor != null) {
|
||||||
val parameterByName = constructor.valueParameters.associateBy { it.name }
|
val parameterByName = constructor.valueParameters.associateBy { it.name }
|
||||||
arguments = proto.argumentList.map { resolveArgument(it, parameterByName, nameResolver) }.filterNotNull().toMap()
|
arguments = proto.argumentList.mapNotNull { resolveArgument(it, parameterByName, nameResolver) }.toMap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ internal class KClassImpl<T : Any>(override val jClass: Class<T>) : KDeclaration
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val nestedClasses: Collection<KClass<*>>
|
override val nestedClasses: Collection<KClass<*>>
|
||||||
get() = descriptor.unsubstitutedInnerClassesScope.getContributedDescriptors().filterNot(DescriptorUtils::isEnumEntry).map {
|
get() = descriptor.unsubstitutedInnerClassesScope.getContributedDescriptors().filterNot(DescriptorUtils::isEnumEntry).mapNotNull {
|
||||||
nestedClass ->
|
nestedClass ->
|
||||||
val source = (nestedClass as DeclarationDescriptorWithSource).source
|
val source = (nestedClass as DeclarationDescriptorWithSource).source
|
||||||
when (source) {
|
when (source) {
|
||||||
@@ -139,7 +139,7 @@ internal class KClassImpl<T : Any>(override val jClass: Class<T>) : KDeclaration
|
|||||||
}
|
}
|
||||||
else -> throw KotlinReflectionInternalError("Unsupported class: $nestedClass (source = $source)")
|
else -> throw KotlinReflectionInternalError("Unsupported class: $nestedClass (source = $source)")
|
||||||
}
|
}
|
||||||
}.filterNotNull().map { KClassImpl(it) }
|
}.map { KClassImpl(it) }
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
private val objectInstance_ = ReflectProperties.lazy {
|
private val objectInstance_ = ReflectProperties.lazy {
|
||||||
|
|||||||
@@ -75,10 +75,9 @@ internal abstract class KDeclarationContainerImpl : ClassBasedDeclarationContain
|
|||||||
.filter { descriptor ->
|
.filter { descriptor ->
|
||||||
descriptor !is MemberDescriptor || descriptor.visibility != Visibilities.INVISIBLE_FAKE
|
descriptor !is MemberDescriptor || descriptor.visibility != Visibilities.INVISIBLE_FAKE
|
||||||
}
|
}
|
||||||
.map { descriptor ->
|
.mapNotNull { descriptor ->
|
||||||
descriptor.accept(visitor, Unit)
|
descriptor.accept(visitor, Unit)
|
||||||
}
|
}
|
||||||
.filterNotNull()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createProperty(descriptor: PropertyDescriptor): KPropertyImpl<*> {
|
private fun createProperty(descriptor: PropertyDescriptor): KPropertyImpl<*> {
|
||||||
|
|||||||
+1
-1
@@ -171,7 +171,7 @@ class KotlinCacheServiceImpl(val project: Project) : KotlinCacheService {
|
|||||||
return annotatedDescriptor.annotations.toList()
|
return annotatedDescriptor.annotations.toList()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return annotated.annotationEntries.map { context.get(BindingContext.ANNOTATION, it) }.filterNotNull()
|
return annotated.annotationEntries.mapNotNull { context.get(BindingContext.ANNOTATION, it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, LibraryModificationTracker.getInstance(project), PsiModificationTracker.MODIFICATION_COUNT)
|
}, LibraryModificationTracker.getInstance(project), PsiModificationTracker.MODIFICATION_COUNT)
|
||||||
|
|||||||
+1
-2
@@ -319,7 +319,7 @@ object KotlinIntroduceVariableHandler : RefactoringActionHandler {
|
|||||||
private fun KtExpression.findOccurrences(occurrenceContainer: PsiElement): List<KtExpression> {
|
private fun KtExpression.findOccurrences(occurrenceContainer: PsiElement): List<KtExpression> {
|
||||||
return toRange()
|
return toRange()
|
||||||
.match(occurrenceContainer, KotlinPsiUnifier.DEFAULT)
|
.match(occurrenceContainer, KotlinPsiUnifier.DEFAULT)
|
||||||
.map {
|
.mapNotNull {
|
||||||
val candidate = it.range.elements.first()
|
val candidate = it.range.elements.first()
|
||||||
when (candidate) {
|
when (candidate) {
|
||||||
is KtExpression -> candidate
|
is KtExpression -> candidate
|
||||||
@@ -327,7 +327,6 @@ object KotlinIntroduceVariableHandler : RefactoringActionHandler {
|
|||||||
else -> throw AssertionError("Unexpected candidate element: " + candidate.text)
|
else -> throw AssertionError("Unexpected candidate element: " + candidate.text)
|
||||||
} as? KtExpression
|
} as? KtExpression
|
||||||
}
|
}
|
||||||
.filterNotNull()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun KtExpression.shouldReplaceOccurrence(bindingContext: BindingContext, container: PsiElement?): Boolean {
|
private fun KtExpression.shouldReplaceOccurrence(bindingContext: BindingContext, container: PsiElement?): Boolean {
|
||||||
|
|||||||
@@ -611,11 +611,11 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
|
|||||||
val args = expression.operands.map {
|
val args = expression.operands.map {
|
||||||
codeConverter.convertExpression(it, expression.type).assignPrototype(it, commentsAndSpacesInheritance)
|
codeConverter.convertExpression(it, expression.type).assignPrototype(it, commentsAndSpacesInheritance)
|
||||||
}
|
}
|
||||||
val operators = expression.operands.map {
|
val operators = expression.operands.mapNotNull {
|
||||||
expression.getTokenBeforeOperand(it)?.let {
|
expression.getTokenBeforeOperand(it)?.let {
|
||||||
Operator(it.tokenType).assignPrototype(it, commentsAndSpacesInheritance)
|
Operator(it.tokenType).assignPrototype(it, commentsAndSpacesInheritance)
|
||||||
}
|
}
|
||||||
}.filterNotNull()
|
}
|
||||||
|
|
||||||
result = PolyadicExpression(args, operators).assignPrototype(expression)
|
result = PolyadicExpression(args, operators).assignPrototype(expression)
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -22,7 +22,10 @@ import org.jetbrains.kotlin.android.synthetic.codegen.AndroidExpressionCodegenEx
|
|||||||
import org.jetbrains.kotlin.android.synthetic.codegen.AndroidOnDestroyClassBuilderInterceptorExtension
|
import org.jetbrains.kotlin.android.synthetic.codegen.AndroidOnDestroyClassBuilderInterceptorExtension
|
||||||
import org.jetbrains.kotlin.android.synthetic.diagnostic.AndroidExtensionPropertiesCallChecker
|
import org.jetbrains.kotlin.android.synthetic.diagnostic.AndroidExtensionPropertiesCallChecker
|
||||||
import org.jetbrains.kotlin.android.synthetic.diagnostic.DefaultErrorMessagesAndroid
|
import org.jetbrains.kotlin.android.synthetic.diagnostic.DefaultErrorMessagesAndroid
|
||||||
import org.jetbrains.kotlin.android.synthetic.res.*
|
import org.jetbrains.kotlin.android.synthetic.res.AndroidLayoutXmlFileManager
|
||||||
|
import org.jetbrains.kotlin.android.synthetic.res.AndroidVariant
|
||||||
|
import org.jetbrains.kotlin.android.synthetic.res.CliAndroidLayoutXmlFileManager
|
||||||
|
import org.jetbrains.kotlin.android.synthetic.res.CliAndroidPackageFragmentProviderExtension
|
||||||
import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension
|
import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension
|
||||||
import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension
|
import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension
|
||||||
import org.jetbrains.kotlin.compiler.plugin.CliOption
|
import org.jetbrains.kotlin.compiler.plugin.CliOption
|
||||||
@@ -73,7 +76,7 @@ class AndroidComponentRegistrar : ComponentRegistrar {
|
|||||||
|
|
||||||
override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
|
override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
|
||||||
val applicationPackage = configuration.get(AndroidConfigurationKeys.PACKAGE)
|
val applicationPackage = configuration.get(AndroidConfigurationKeys.PACKAGE)
|
||||||
val variants = configuration.get(AndroidConfigurationKeys.VARIANT)?.map { parseVariant(it) }?.filterNotNull() ?: emptyList()
|
val variants = configuration.get(AndroidConfigurationKeys.VARIANT)?.mapNotNull { parseVariant(it) } ?: emptyList()
|
||||||
|
|
||||||
if (variants.isNotEmpty() && !applicationPackage.isNullOrBlank()) {
|
if (variants.isNotEmpty() && !applicationPackage.isNullOrBlank()) {
|
||||||
val layoutXmlFileManager = CliAndroidLayoutXmlFileManager(project, applicationPackage!!, variants)
|
val layoutXmlFileManager = CliAndroidLayoutXmlFileManager(project, applicationPackage!!, variants)
|
||||||
|
|||||||
+1
-2
@@ -41,7 +41,7 @@ class AndroidGotoDeclarationHandler : GotoDeclarationHandler {
|
|||||||
val propertyDescriptor = resolvePropertyDescriptor(simpleNameExpression) ?: return null
|
val propertyDescriptor = resolvePropertyDescriptor(simpleNameExpression) ?: return null
|
||||||
|
|
||||||
val psiElements = layoutManager.propertyToXmlAttributes(propertyDescriptor)
|
val psiElements = layoutManager.propertyToXmlAttributes(propertyDescriptor)
|
||||||
val valueElements = psiElements.map { (it as? XmlAttribute)?.valueElement as? PsiElement }.filterNotNull()
|
val valueElements = psiElements.mapNotNull { (it as? XmlAttribute)?.valueElement as? PsiElement }
|
||||||
if (valueElements.isNotEmpty()) return valueElements.toTypedArray()
|
if (valueElements.isNotEmpty()) return valueElements.toTypedArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,5 +64,4 @@ class AndroidGotoDeclarationHandler : GotoDeclarationHandler {
|
|||||||
override fun getActionText(context: DataContext?): String? {
|
override fun getActionText(context: DataContext?): String? {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user