Suggest assert/return postfix templates only for statements

#KT-14079 Fixed
 #KT-14090 Fixed
This commit is contained in:
Denis Zharkov
2016-09-28 18:17:10 +03:00
parent ce128c5d6e
commit bff9dd4ef5
4 changed files with 14 additions and 2 deletions
@@ -63,7 +63,7 @@ internal object KtAssertPostfixTemplate : ConstantStringBasedPostfixTemplate(
"assert",
"assert(expr) { \"\" }",
"assert(\$expr$) { \"\$END$\" }",
createExpressionSelector(statementsOnly = false, predicate = KotlinType::isBoolean)
createExpressionSelector(statementsOnly = true, predicate = KotlinType::isBoolean)
)
internal object KtParenthesizedPostfixTemplate : ConstantStringBasedPostfixTemplate(
@@ -83,7 +83,7 @@ internal object KtReturnPostfixTemplate : ConstantStringBasedPostfixTemplate(
"return",
"return expr",
"return \$expr$\$END$",
createExpressionSelector(statementsOnly = false)
createExpressionSelector(statementsOnly = true)
)
internal object KtWhilePostfixTemplate : ConstantStringBasedPostfixTemplate(
@@ -0,0 +1,3 @@
fun foo(x: Any): Any {
val y = x.return<caret>
}
@@ -0,0 +1,3 @@
fun foo(x: Any): Any {
val y = x.return <caret>
}
@@ -71,6 +71,12 @@ public class PostfixTemplateProviderTestGenerated extends AbstractPostfixTemplat
doTest(fileName);
}
@TestMetadata("noReturnForNonStatement.kt")
public void testNoReturnForNonStatement() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/postfix/noReturnForNonStatement.kt");
doTest(fileName);
}
@TestMetadata("notBoolean.kt")
public void testNotBoolean() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/postfix/notBoolean.kt");