From 46c9431d881b37fe68c009f3bbeeafaee97417b6 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 3 Feb 2010 15:56:32 +0000 Subject: [PATCH] IDEA-51918 Smart enter moves caret to parent code block in Groovy --- .../completion/smartEnter/GroovySmartEnterProcessor.java | 2 +- .../plugins/groovy/lang/smartEnter/SmartEnterTest.java | 1 + .../testdata/groovy/actions/smartEnter/gotoParentInIf.test | 13 +++++++++++++ .../highlighting/MissingReturnOvertReturnType.groovy | 5 +++++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 plugins/groovy/testdata/groovy/actions/smartEnter/gotoParentInIf.test create mode 100644 plugins/groovy/testdata/highlighting/MissingReturnOvertReturnType.groovy diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/smartEnter/GroovySmartEnterProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/smartEnter/GroovySmartEnterProcessor.java index 4482431dae..c26d1e7e50 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/smartEnter/GroovySmartEnterProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/smartEnter/GroovySmartEnterProcessor.java @@ -266,7 +266,7 @@ public class GroovySmartEnterProcessor extends SmartEnterProcessor { if (statementAtCaret instanceof GrBlockStatement) return null; if (statementAtCaret == null) return null; - GrControlStatement controlStatement = PsiTreeUtil.getParentOfType(statementAtCaret, GrControlStatement.class); + GrControlStatement controlStatement = PsiTreeUtil.getParentOfType(statementAtCaret, GrControlStatement.class, false); if (controlStatement != null && !PsiTreeUtil.hasErrorElements(statementAtCaret)) { return controlStatement; diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/smartEnter/SmartEnterTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/smartEnter/SmartEnterTest.java index 7e53f070f2..87138f32b3 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/smartEnter/SmartEnterTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/smartEnter/SmartEnterTest.java @@ -37,6 +37,7 @@ public class SmartEnterTest extends LightCodeInsightFixtureTestCase { public void testMissRQuoteInCompStr() throws Throwable { doTest(); } public void testGotoNextLineInFor() throws Throwable { doTest(); } + public void testGotoParentInIf() throws Throwable { doTest(); } protected static List getSmartProcessors(Language grLanguage) { return SmartEnterProcessors.INSTANCE.forKey(grLanguage); diff --git a/plugins/groovy/testdata/groovy/actions/smartEnter/gotoParentInIf.test b/plugins/groovy/testdata/groovy/actions/smartEnter/gotoParentInIf.test new file mode 100644 index 0000000000..a21e7c14e6 --- /dev/null +++ b/plugins/groovy/testdata/groovy/actions/smartEnter/gotoParentInIf.test @@ -0,0 +1,13 @@ +if (suitable) { + expectations.each {pattern, action -> + if (cloud.match(pattern, action)) + } +} +----- +if (suitable) { + expectations.each {pattern, action -> + if (cloud.match(pattern, action)) { + + } + } +} diff --git a/plugins/groovy/testdata/highlighting/MissingReturnOvertReturnType.groovy b/plugins/groovy/testdata/highlighting/MissingReturnOvertReturnType.groovy new file mode 100644 index 0000000000..4c12eb35cc --- /dev/null +++ b/plugins/groovy/testdata/highlighting/MissingReturnOvertReturnType.groovy @@ -0,0 +1,5 @@ +def promote(List active) { + if (f) { + active.removeLast() + } +} \ No newline at end of file -- 2.11.4.GIT