EA-64506 (correct handling of empty file header template)

This commit is contained in:
Roman Shevchenko
2015-02-08 12:09:52 +01:00
parent cbbe283dbf
commit b738e35d43
2 changed files with 15 additions and 6 deletions
@@ -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();
}
}
};
@@ -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 {
}
}