Add "arg" postfix template (KT-29398)
#KT-29398 Fixed
This commit is contained in:
committed by
Nikolay Krasko
parent
0c0f035241
commit
6acf3ad629
@@ -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 == '!'
|
||||
|
||||
+12
-1
@@ -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
@@ -0,0 +1,3 @@
|
||||
fun foo(s: String) {
|
||||
s.arg<caret>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(s: String) {
|
||||
(s<caret>)
|
||||
}
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user