icon classes generation: update warning message

This commit is contained in:
Aleksey Pivovarov
2017-07-17 21:12:14 +03:00
parent 0c92e8aac8
commit ff78e2d6e7
3 changed files with 15 additions and 2 deletions
@@ -125,7 +125,7 @@ class IconsClassGenerator(val projectHome: File, val util: JpsModule) {
// please do corresponding changes in IconsGeneratedSourcesFilter as well
append(answer, "/**", 0)
append(answer, " * NOTE THIS FILE IS AUTO-GENERATED", 0)
append(answer, " * DO NOT EDIT IT BY HAND, run build/scripts/icons.gant instead", 0)
append(answer, " * DO NOT EDIT IT BY HAND, run \"Generate icon classes\" configuration instead", 0)
append(answer, " */", 0)
append(answer, "public class $className {", 0)
@@ -33,7 +33,10 @@ public class IconsGeneratedSourcesFilter extends GeneratedSourcesFilter {
for (PsiClass aClass : ((PsiJavaFile)psiFile).getClasses()) {
if (aClass.isValid() && aClass.hasModifierProperty(PsiModifier.PUBLIC)) {
PsiDocComment comment = aClass.getDocComment();
return comment != null && comment.getText().contains("run build/scripts/icons.gant instead");
if (comment == null) return false;
String docText = comment.getText();
return docText.contains("NOTE THIS FILE IS AUTO-GENERATED") &&
docText.contains("DO NOT EDIT IT BY HAND");
}
}
}
@@ -29,6 +29,16 @@ public class IconsGeneratedSourcesTest extends LightCodeInsightFixtureTestCase {
assertTrue(new IconsGeneratedSourcesFilter().isGeneratedSource(file.getVirtualFile(), myFixture.getProject()));
}
public void testNewGeneratedFile() {
PsiFile file = myFixture.configureByText("MyIcons.java", "package icons;\n" +
"/**\n" +
" * NOTE THIS FILE IS AUTO-GENERATED\n" +
" * DO NOT EDIT IT BY HAND, run \"Generate icon classes\" configuration instead\n" +
" */\n" +
"public class RubyIcons {}");
assertTrue(new IconsGeneratedSourcesFilter().isGeneratedSource(file.getVirtualFile(), myFixture.getProject()));
}
public void testFilterByName() {
PsiFile file = myFixture.configureByText("MyIconsTest.java", "package icons;\n" +
"/**\n" +