Implement SequenceCallChecker
This commit is contained in:
committed by
Yan Zhulanow
parent
98d698290e
commit
f98d50265b
+15
-2
@@ -1,18 +1,31 @@
|
|||||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||||
package com.intellij.debugger.streams.kotlin.psi.sequence
|
package com.intellij.debugger.streams.kotlin.psi.sequence
|
||||||
|
|
||||||
|
import com.intellij.debugger.streams.kotlin.psi.KotlinPsiUtil
|
||||||
import com.intellij.debugger.streams.kotlin.psi.StreamCallChecker
|
import com.intellij.debugger.streams.kotlin.psi.StreamCallChecker
|
||||||
|
import com.intellij.debugger.streams.kotlin.psi.receiverType
|
||||||
|
import com.intellij.debugger.streams.kotlin.psi.resolveType
|
||||||
import org.jetbrains.kotlin.psi.KtCallExpression
|
import org.jetbrains.kotlin.psi.KtCallExpression
|
||||||
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.typeUtil.supertypes
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vitaliy.Bibaev
|
* @author Vitaliy.Bibaev
|
||||||
*/
|
*/
|
||||||
class SequenceCallChecker : StreamCallChecker {
|
class SequenceCallChecker : StreamCallChecker {
|
||||||
override fun isIntermediateCall(expression: KtCallExpression): Boolean {
|
override fun isIntermediateCall(expression: KtCallExpression): Boolean {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
val receiverType = expression.receiverType() ?: return false
|
||||||
|
return isSequenceInheritor(receiverType) && isSequenceInheritor(expression.resolveType())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isTerminationCall(expression: KtCallExpression): Boolean {
|
override fun isTerminationCall(expression: KtCallExpression): Boolean {
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
val receiverType = expression.receiverType() ?: return false
|
||||||
|
return isSequenceInheritor(receiverType) && !isSequenceInheritor(expression.resolveType())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isSequenceInheritor(type: KotlinType): Boolean =
|
||||||
|
isSequenceType(type) || type.supertypes().any(this::isSequenceType)
|
||||||
|
|
||||||
|
private fun isSequenceType(type: KotlinType): Boolean =
|
||||||
|
"kotlin.sequences.Sequence" == KotlinPsiUtil.getTypeWithoutTypeParameters(type)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user