don't show type of statements if they are not used as expressions
This commit is contained in:
@@ -39,6 +39,7 @@ class KotlinExpressionTypeProvider : ExpressionTypeProvider<KtExpression>() {
|
||||
is KtFunction -> !hasBlockBody() && !hasDeclaredReturnType()
|
||||
is KtProperty, is KtDestructuringDeclarationEntry -> true
|
||||
is KtStatementExpression, is KtDestructuringDeclaration -> false
|
||||
is KtIfExpression, is KtLoopExpression, is KtWhenExpression, is KtTryExpression -> parent !is KtBlockExpression
|
||||
else -> true
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
val x = if (2 > 1) <caret>3 else 4
|
||||
|
||||
// TYPE: 3 -> <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>
|
||||
@@ -4,6 +4,5 @@ fun foo(x: Any) {
|
||||
}
|
||||
}
|
||||
|
||||
// TYPE: if (x is String) { x.length } -> <html>Unit</html>
|
||||
// TYPE: x -> <html>String (smart cast)</html>
|
||||
// TYPE: x.length -> <html>Int</html>
|
||||
|
||||
@@ -41,6 +41,12 @@ public class ExpressionTypeTestGenerated extends AbstractExpressionTypeTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("IfAsExpression.kt")
|
||||
public void testIfAsExpression() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/expressionType/IfAsExpression.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("MultiDeclaration.kt")
|
||||
public void testMultiDeclaration() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/expressionType/MultiDeclaration.kt");
|
||||
|
||||
Reference in New Issue
Block a user