"Show expression type" no longer shows elements which enclose the element at caret (KT-14436)
This commit is contained in:
@@ -36,8 +36,10 @@ class KotlinExpressionTypeProvider : ExpressionTypeProvider<KtExpression>() {
|
|||||||
textFormat = RenderingFormat.HTML
|
textFormat = RenderingFormat.HTML
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getExpressionsAt(elementAt: PsiElement): List<KtExpression> =
|
override fun getExpressionsAt(elementAt: PsiElement): List<KtExpression> {
|
||||||
elementAt.parentsWithSelf.filterIsInstance<KtExpression>().filter { it.shouldShowType() }.toList()
|
val candidates = elementAt.parentsWithSelf.filterIsInstance<KtExpression>().filter { it.shouldShowType() }.toList()
|
||||||
|
return candidates.takeWhile { it.textRange.startOffset == candidates.first().textRange.startOffset }
|
||||||
|
}
|
||||||
|
|
||||||
private fun KtExpression.shouldShowType() = when (this) {
|
private fun KtExpression.shouldShowType() = when (this) {
|
||||||
is KtFunctionLiteral -> false
|
is KtFunctionLiteral -> false
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
val x = if (2 > 1) <caret>3 else 4
|
val x = if (2 > 1) <caret>3 else 4
|
||||||
|
|
||||||
// TYPE: if (2 > 1) 3 else 4 -> <html>Int</html>
|
// TYPE: if (2 > 1) 3 else 4 -> <html>Int</html>
|
||||||
// TYPE: val x = if (2 > 1) 3 else 4 -> <html>Int</html>
|
|
||||||
|
|||||||
@@ -3,5 +3,3 @@ val x = if (flag) {
|
|||||||
} else 42
|
} else 42
|
||||||
|
|
||||||
// TYPE: if (flag2) 13 else 7 -> <html>Int</html>
|
// TYPE: if (flag2) 13 else 7 -> <html>Int</html>
|
||||||
// TYPE: if (flag) { if (flag2) 13 else 7 } else 42 -> <html>Int</html>
|
|
||||||
// TYPE: val x = if (flag) { if (flag2) 13 else 7 } else 42 -> <html>Int</html>
|
|
||||||
|
|||||||
+1
-5
@@ -1,7 +1,3 @@
|
|||||||
val x = listOf(1).map { q -> println(<caret>q) }
|
val x = listOf(1).map {<caret> q -> println(q) }
|
||||||
|
|
||||||
// TYPE: q -> <html>Int</html>
|
|
||||||
// TYPE: println(q) -> <html>Unit</html>
|
|
||||||
// TYPE: { q -> println(q) } -> <html>(Int) → Unit</html>
|
// TYPE: { q -> println(q) } -> <html>(Int) → Unit</html>
|
||||||
// TYPE: listOf(1).map { q -> println(q) } -> <html>List<Unit></html>
|
|
||||||
// TYPE: val x = listOf(1).map { q -> println(q) } -> <html>List<Unit></html>
|
|
||||||
|
|||||||
@@ -6,4 +6,3 @@ fun bar() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TYPE: ::foo -> <html>KFunction0<Unit></html>
|
// TYPE: ::foo -> <html>KFunction0<Unit></html>
|
||||||
// TYPE: run(::foo) -> <html>Unit</html>
|
|
||||||
|
|||||||
@@ -6,5 +6,3 @@ fun f(x: List<IntStringPair>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TYPE: first -> <html>Int</html>
|
// TYPE: first -> <html>Int</html>
|
||||||
// TYPE: { (first, second) -> } -> <html>(IntStringPair) → Unit</html>
|
|
||||||
// TYPE: x.forEach { (first, second) -> } -> <html>Unit</html>
|
|
||||||
|
|||||||
@@ -11,4 +11,3 @@ fun fn(value: Any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TYPE: value -> <html>A & B (smart cast from Any)</html>
|
// TYPE: value -> <html>A & B (smart cast from Any)</html>
|
||||||
// TYPE: println(value) -> <html>Unit</html>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user