don't offer functions with block body and functions with declared return type as candidates for "show expression type"
This commit is contained in:
@@ -29,10 +29,13 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class KotlinExpressionTypeProvider : ExpressionTypeProvider<KtExpression>() {
|
||||
override fun getExpressionsAt(elementAt: PsiElement): List<KtExpression> =
|
||||
elementAt.parentsWithSelf.filterIsInstance<KtExpression>().filterNot { it.shouldSkip() }.toList()
|
||||
elementAt.parentsWithSelf.filterIsInstance<KtExpression>().filter { it.shouldShowType() }.toList()
|
||||
|
||||
private fun KtExpression.shouldSkip(): Boolean {
|
||||
return this is KtStatementExpression && this !is KtFunction && this !is KtProperty
|
||||
private fun KtExpression.shouldShowType() = when(this) {
|
||||
is KtFunction -> !hasBlockBody() && !hasDeclaredReturnType()
|
||||
is KtProperty -> true
|
||||
is KtStatementExpression -> false
|
||||
else -> true
|
||||
}
|
||||
|
||||
override fun getInformationHint(element: KtExpression): String {
|
||||
|
||||
Reference in New Issue
Block a user