Minor cleanup
This commit is contained in:
@@ -159,19 +159,18 @@ object SmartCastImpossibleExclExclFixFactory: KotlinSingleIntentionActionFactory
|
|||||||
|
|
||||||
object MissingIteratorExclExclFixFactory : KotlinSingleIntentionActionFactory() {
|
object MissingIteratorExclExclFixFactory : KotlinSingleIntentionActionFactory() {
|
||||||
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
||||||
val element = diagnostic.psiElement
|
val element = diagnostic.psiElement as? KtExpression ?: return null
|
||||||
if (element !is KtExpression) return null
|
|
||||||
|
|
||||||
val analyze = element.analyze(BodyResolveMode.PARTIAL)
|
val analyze = element.analyze(BodyResolveMode.PARTIAL)
|
||||||
val type = analyze.getType(element)
|
val type = analyze.getType(element)
|
||||||
if (type == null || !TypeUtils.isNullableType(type)) return null
|
if (type == null || !TypeUtils.isNullableType(type)) return null
|
||||||
|
|
||||||
val descriptor = type.constructor.declarationDescriptor
|
val descriptor = type.constructor.declarationDescriptor
|
||||||
|
|
||||||
fun hasIteratorFunction(descriptor: ClassifierDescriptor?) : Boolean {
|
fun hasIteratorFunction(classifierDescriptor: ClassifierDescriptor?) : Boolean {
|
||||||
if (descriptor !is ClassDescriptor) return false
|
if (classifierDescriptor !is ClassDescriptor) return false
|
||||||
|
|
||||||
val memberScope = descriptor.unsubstitutedMemberScope
|
val memberScope = classifierDescriptor.unsubstitutedMemberScope
|
||||||
val functions = memberScope.getContributedFunctions(OperatorNameConventions.ITERATOR, NoLookupLocation.FROM_IDE)
|
val functions = memberScope.getContributedFunctions(OperatorNameConventions.ITERATOR, NoLookupLocation.FROM_IDE)
|
||||||
|
|
||||||
return functions.any { it.isValidOperator() }
|
return functions.any { it.isValidOperator() }
|
||||||
|
|||||||
Reference in New Issue
Block a user