don't offer functions with block body and functions with declared return type as candidates for "show expression type"

This commit is contained in:
Dmitry Jemerov
2016-08-25 20:48:09 +02:00
parent 7b644e2c52
commit fbd2c48fbd
4 changed files with 18 additions and 4 deletions
@@ -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 {