From 5af152b20c326ae1d73dbc197410a31efaf7f097 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Tue, 11 Jan 2022 10:14:47 +0700 Subject: [PATCH] [live-templates] else-if: add CONDITION variable GitOrigin-RevId: 00e4800c96682bded8589a54efade59572f73d2b --- java/java-tests/testData/codeInsight/template/ElseIf-out.java | 3 ++- java/java-tests/testData/codeInsight/template/ElseIf2-out.java | 3 ++- java/java-tests/testData/codeInsight/template/ElseIf3-out.java | 3 ++- .../java/codeInsight/template/JavaLiveTemplateTest.groovy | 3 +++ resources/src/liveTemplates/Java.xml | 3 ++- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/java/java-tests/testData/codeInsight/template/ElseIf-out.java b/java/java-tests/testData/codeInsight/template/ElseIf-out.java index 255ae3e80f03..f4c829177ed7 100644 --- a/java/java-tests/testData/codeInsight/template/ElseIf-out.java +++ b/java/java-tests/testData/codeInsight/template/ElseIf-out.java @@ -2,7 +2,8 @@ import java.util.*; class Foo { void test(int x){ - if(x > 0) {} else if () { + if(x > 0) {} else if () { + } } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/template/ElseIf2-out.java b/java/java-tests/testData/codeInsight/template/ElseIf2-out.java index 9113f164ffce..08ab7eac1d00 100644 --- a/java/java-tests/testData/codeInsight/template/ElseIf2-out.java +++ b/java/java-tests/testData/codeInsight/template/ElseIf2-out.java @@ -2,7 +2,8 @@ import java.util.*; class Foo { void test(int x){ - if(x > 0) {} else if () { + if(x > 0) {} else if () { + } else {} } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/template/ElseIf3-out.java b/java/java-tests/testData/codeInsight/template/ElseIf3-out.java index 37b0dc0ffb38..cbb818fe33a4 100644 --- a/java/java-tests/testData/codeInsight/template/ElseIf3-out.java +++ b/java/java-tests/testData/codeInsight/template/ElseIf3-out.java @@ -3,7 +3,8 @@ import java.util.*; class Foo { void test(int x){ if(x > 0) {} - else if(x == 0) {} else if () { + else if(x == 0) {} else if () { + } else {} } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/template/JavaLiveTemplateTest.groovy b/java/java-tests/testSrc/com/intellij/java/codeInsight/template/JavaLiveTemplateTest.groovy index 0dd31714b76d..297f4fd3c8ac 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/template/JavaLiveTemplateTest.groovy +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/template/JavaLiveTemplateTest.groovy @@ -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() } diff --git a/resources/src/liveTemplates/Java.xml b/resources/src/liveTemplates/Java.xml index 376fa3681bc7..b03ff4e59e2e 100644 --- a/resources/src/liveTemplates/Java.xml +++ b/resources/src/liveTemplates/Java.xml @@ -7,7 +7,8 @@