Add "arg" postfix template (KT-29398)

#KT-29398 Fixed
This commit is contained in:
Toshiaki Kameyama
2019-02-27 17:49:42 +03:00
committed by Nikolay Krasko
parent 0c0f035241
commit 6acf3ad629
8 changed files with 36 additions and 2 deletions
@@ -0,0 +1,3 @@
fun foo(s: String) {
<spot>call(s)</sport>
}
@@ -0,0 +1,3 @@
fun foo(s: String) {
<spot>s</sport>$key
}
@@ -0,0 +1,5 @@
<html>
<body>
Wraps expression with a function call.
</body>
</html>
@@ -63,7 +63,8 @@ class KtPostfixTemplateProvider : PostfixTemplateProvider {
KtWrapWithSetOfPostfixTemplate,
KtWrapWithArrayOfPostfixTemplate,
KtWrapWithSequenceOfPostfixTemplate,
KtSpreadPostfixTemplate
KtSpreadPostfixTemplate,
KtArgumentPostfixTemplate
)
override fun isTerminalSymbol(currentChar: Char) = currentChar == '.' || currentChar == '!'
@@ -119,4 +119,15 @@ internal object KtSpreadPostfixTemplate : ConstantStringBasedPostfixTemplate(
"*expr",
"*\$expr$\$END$",
createExpressionSelector(typePredicate = { KotlinBuiltIns.isArray(it) || KotlinBuiltIns.isPrimitiveArray(it) })
)
)
internal object KtArgumentPostfixTemplate : ConstantStringBasedPostfixTemplate(
"arg",
"functionCall(expr)",
"\$call$(\$expr$\$END$)",
createExpressionSelector(statementsOnly = true)
) {
override fun setVariables(template: Template, element: PsiElement) {
template.addVariable("call", "", "", true)
}
}
+3
View File
@@ -0,0 +1,3 @@
fun foo(s: String) {
s.arg<caret>
}
+3
View File
@@ -0,0 +1,3 @@
fun foo(s: String) {
(s<caret>)
}
@@ -29,6 +29,11 @@ public class PostfixTemplateProviderTestGenerated extends AbstractPostfixTemplat
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/codeInsight/postfix"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("arg.kt")
public void testArg() throws Exception {
runTest("idea/testData/codeInsight/postfix/arg.kt");
}
@TestMetadata("assert.kt")
public void testAssert() throws Exception {
runTest("idea/testData/codeInsight/postfix/assert.kt");