From 79d2e31132e70dc1c37229f9099d4e25e67f9a48 Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Sat, 1 Sep 2012 19:38:42 +0400 Subject: [PATCH] IDEA-90860 Reformat Code breaks Copyright/Header 1. Don't preserve blank lines when formatter is called explicitly on operations like refactoring; 2. Test data is corrected; --- .../psi/formatter/java/JavaSpacePropertyProcessor.java | 4 +++- .../codeInsight/intention/AddImportActionTest.groovy | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java index ee6e6eb397e5..9b6894bb5fa9 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java @@ -72,7 +72,9 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor { if (myChild1 == null) { // Given node corresponds to the first document block. - createSpaceInCode(false); + if (FormatterUtil.isFormatterCalledExplicitly()) { + createSpaceInCode(false); + } return; } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy index b148e7522b0b..682662a39d57 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/intention/AddImportActionTest.groovy @@ -24,7 +24,7 @@ public class AddImportActionTest extends LightCodeInsightFixtureTestCase { public void testMap15() { IdeaTestUtil.setModuleLanguageLevel(myModule, LanguageLevel.JDK_1_5) - myFixture.configureByText 'a.java', ''' + myFixture.configureByText 'a.java', '''\ public class Foo { void foo() { Map<> l; @@ -50,7 +50,7 @@ public class Foo { public void testMapLatestLanguageLevel() { IdeaTestUtil.setModuleLanguageLevel(myModule, LanguageLevel.HIGHEST) - myFixture.configureByText 'a.java', ''' + myFixture.configureByText 'a.java', '''\ public class Foo { void foo() { Map<> l; @@ -71,7 +71,7 @@ public class Foo { public void testStringValue() { myFixture.addClass 'package java.lang; class StringValue {}' myFixture.addClass 'package foo; public class StringValue {}' - myFixture.configureByText 'a.java', ''' + myFixture.configureByText 'a.java', '''\ public class Foo { StringValue sv; } @@ -90,7 +90,7 @@ public class Foo { myFixture.addClass 'package foo; public class Log {}' myFixture.addClass 'package bar; public class Log {}' myFixture.addClass 'package bar; public class LogFactory { public static Log log(){} }' - myFixture.configureByText 'a.java', ''' + myFixture.configureByText 'a.java', '''\ public class Foo { Log l = bar.LogFactory.log(); }