From 2b0f9f092b80d20f7eef09caf70a25d8f75944fe Mon Sep 17 00:00:00 2001 From: Peter Gromov Date: Mon, 31 Aug 2009 15:41:49 +0400 Subject: [PATCH] groovy suppress for statement: don't merge line comment with the statement on one line --- .../groovy/lang/parser/GroovyParserDefinition.java | 2 +- .../plugins/groovy/lang/GroovyFixesTest.groovy | 30 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyFixesTest.groovy diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyParserDefinition.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyParserDefinition.java index afbf63b9cf..0d541f52ee 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyParserDefinition.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyParserDefinition.java @@ -88,7 +88,7 @@ public class GroovyParserDefinition implements ParserDefinition { else if (left.getElementType() == MODIFIERS && right.getElementType() == MODIFIERS) { return MUST; } - if (left.getElementType() == mSEMI) { + if (left.getElementType() == mSEMI || left.getElementType() == mSL_COMMENT) { return MUST_LINE_BREAK; } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyFixesTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyFixesTest.groovy new file mode 100644 index 0000000000..aa2674d0ea --- /dev/null +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyFixesTest.groovy @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved. + * Use is subject to license terms. + */ +package org.jetbrains.plugins.groovy.lang; + +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase +import org.jetbrains.plugins.groovy.codeInspection.control.GroovyConstantIfStatementInspection.ConstantIfStatementVisitor +import org.jetbrains.plugins.groovy.codeInspection.control.GroovyConstantIfStatementInspection; + +/** + * @author peter + */ +public class GroovyFixesTest extends LightCodeInsightFixtureTestCase { + + public void testSuppressForIfStatement() throws Throwable { + myFixture.enableInspections new GroovyConstantIfStatementInspection() + myFixture.configureByText("a.groovy", """ +if (true) { + aaa +}""") + myFixture.launchAction(myFixture.findSingleIntention("Suppress for statement")) + myFixture.checkResult """ +//noinspection GroovyConstantIfStatement +if (true) { + aaa +}""" + } + +} \ No newline at end of file -- 2.11.4.GIT