diff --git a/java/java-tests/testData/codeInsight/template/Itm-out.java b/java/java-tests/testData/codeInsight/template/Itm-out.java new file mode 100644 index 000000000000..a2ed25231b9c --- /dev/null +++ b/java/java-tests/testData/codeInsight/template/Itm-out.java @@ -0,0 +1,14 @@ +import java.util.*; + +class BarGoo {} + +class Foo { + { + Map goos; + for (Map.Entry stringBarGooEntry : goos.entrySet()) { + String key = stringBarGooEntry.getKey(); + BarGoo value = stringBarGooEntry.getValue(); + + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/template/Itm.java b/java/java-tests/testData/codeInsight/template/Itm.java new file mode 100644 index 000000000000..2fb9c8655d15 --- /dev/null +++ b/java/java-tests/testData/codeInsight/template/Itm.java @@ -0,0 +1,10 @@ +import java.util.*; + +class BarGoo {} + +class Foo { + { + Map goos; + + } +} \ 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 4ac48675d190..550ee5338a8a 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 @@ -221,7 +221,7 @@ class Outer { private void stripTrailingSpaces() { DocumentImpl document = (DocumentImpl)getEditor().getDocument() document.setStripTrailingSpacesEnabled(true) - document.stripTrailingSpaces(getProject()) + document.stripTrailingSpaces(getProject()) PsiDocumentManager.getInstance(getProject()).commitAllDocuments() } @@ -243,6 +243,13 @@ class Outer { startTemplate("soutp", "Java") checkResult() } + + void testItm() { + configure() + startTemplate("itm", "Java") + WriteCommandAction.runWriteCommandAction(project) { state.gotoEnd(false) } + checkResult() + } void testSoutConsumerApplicability() { for (String name : ["soutc", "serrc"]) { @@ -507,7 +514,7 @@ class Foo { ''' } - void "test ritar template in expression lambda"() { + void "test itar template in expression lambda"() { myFixture.configureByText 'a.java', '''class Foo { void test(int[] arr) { Runnable r = () -> itar diff --git a/platform/lang-api/resources/messages/CodeInsightBundle.properties b/platform/lang-api/resources/messages/CodeInsightBundle.properties index 44291369334c..344b3e135b8b 100644 --- a/platform/lang-api/resources/messages/CodeInsightBundle.properties +++ b/platform/lang-api/resources/messages/CodeInsightBundle.properties @@ -179,6 +179,7 @@ livetemplate.description.itco=Iterate elements of java.util.Collection livetemplate.description.iten=Iterate java.util.Enumeration livetemplate.description.itit=Iterate java.util.Iterator livetemplate.description.itli=Iterate elements of java.util.List +livetemplate.description.itm=Iterate keys and values of java.util.Map livetemplate.description.ittok=Iterate tokens from String livetemplate.description.ritar=Iterate elements of array in reverse order livetemplate.description.iter=Iterate Iterable or array diff --git a/resources/src/liveTemplates/Java.xml b/resources/src/liveTemplates/Java.xml index 60f0a78b9ecb..9a7bfee9df2c 100644 --- a/resources/src/liveTemplates/Java.xml +++ b/resources/src/liveTemplates/Java.xml @@ -71,6 +71,18 @@