diff --git a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java index d79baf1abf09..d3a707544a49 100644 --- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java +++ b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/FileHeaderChecker.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -102,15 +102,20 @@ public class FileHeaderChecker { String newText; try { - newText = template.getText(computeProperties(matcher, offsetToProperty, project)); + newText = template.getText(computeProperties(matcher, offsetToProperty, project)).trim(); } catch (IOException e) { LOG.error(e); return; } - PsiDocComment newComment = JavaPsiFacade.getElementFactory(project).createDocCommentFromText(newText); - element.replace(newComment); + if (!newText.isEmpty()) { + PsiDocComment newComment = JavaPsiFacade.getElementFactory(project).createDocCommentFromText(newText); + element.replace(newComment); + } + else { + element.delete(); + } } }; diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DefaultFileTemplateUsageInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DefaultFileTemplateUsageInspectionTest.java index 3230fa6f1483..87c1cdf58390 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DefaultFileTemplateUsageInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DefaultFileTemplateUsageInspectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,8 +30,12 @@ public class DefaultFileTemplateUsageInspectionTest extends LightCodeInsightFixt public void testX3() { doTest(); } public void testRange() { doTest(); } - public void doTest() { + private void doTest() { myFixture.enableInspections(new DefaultFileTemplateUsageInspection()); myFixture.testHighlighting(true, false, true, getTestName(false) + ".java"); } + + public void testWtf() throws Exception { + + } }