[live-templates] else-if: add CONDITION variable

GitOrigin-RevId: 00e4800c96682bded8589a54efade59572f73d2b
This commit is contained in:
Tagir Valeev
2022-01-11 09:28:37 +00:00
committed by intellij-monorepo-bot
parent f70f46661f
commit 5af152b20c
5 changed files with 11 additions and 4 deletions
@@ -2,7 +2,8 @@ import java.util.*;
class Foo {
void test(int x){
if(x > 0) {} else if (<caret>) {
if(x > 0) {} else if () {
<caret>
}
}
}
@@ -2,7 +2,8 @@ import java.util.*;
class Foo {
void test(int x){
if(x > 0) {} else if (<caret>) {
if(x > 0) {} else if () {
<caret>
} else {}
}
}
@@ -3,7 +3,8 @@ import java.util.*;
class Foo {
void test(int x){
if(x > 0) {}
else if(x == 0) {} else if (<caret>) {
else if(x == 0) {} else if () {
<caret>
} else {}
}
}
@@ -161,18 +161,21 @@ class Outer {
void testElseIf() throws Throwable {
configure()
startTemplate("else-if", "Java")
WriteCommandAction.runWriteCommandAction(project) { state.gotoEnd(false) }
checkResult()
}
void testElseIf2() throws Throwable {
configure()
startTemplate("else-if", "Java")
WriteCommandAction.runWriteCommandAction(project) { state.gotoEnd(false) }
checkResult()
}
void testElseIf3() throws Throwable {
configure()
startTemplate("else-if", "Java")
WriteCommandAction.runWriteCommandAction(project) { state.gotoEnd(false) }
checkResult()
}
+2 -1
View File
@@ -7,7 +7,8 @@
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template name="else-if" value="else if($END$){} " description="Add else-if branch" toReformat="true" toShortenFQNames="false">
<template name="else-if" value="else if($CONDITION$){&#10;$END$&#10;} " description="Add else-if branch" toReformat="true" toShortenFQNames="false">
<variable name="CONDITION" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_ELSE_PLACE" value="true" />
</context>