From ff78e2d6e790099d3805f302aaf62363740463af Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Mon, 17 Jul 2017 18:36:58 +0300 Subject: [PATCH] icon classes generation: update warning message --- .../intellij/build/images/IconsClassGenerator.kt | 2 +- .../src/internal/IconsGeneratedSourcesFilter.java | 5 ++++- .../internal/IconsGeneratedSourcesTest.java | 10 ++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/IconsClassGenerator.kt b/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/IconsClassGenerator.kt index 221f8e84b14f..bfae5657e9b0 100644 --- a/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/IconsClassGenerator.kt +++ b/platform/build-scripts/icons/src/org/jetbrains/intellij/build/images/IconsClassGenerator.kt @@ -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) diff --git a/plugins/devkit/src/internal/IconsGeneratedSourcesFilter.java b/plugins/devkit/src/internal/IconsGeneratedSourcesFilter.java index 8b065b5b1b2c..cfed7ba88724 100644 --- a/plugins/devkit/src/internal/IconsGeneratedSourcesFilter.java +++ b/plugins/devkit/src/internal/IconsGeneratedSourcesFilter.java @@ -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"); } } } diff --git a/plugins/devkit/testSources/internal/IconsGeneratedSourcesTest.java b/plugins/devkit/testSources/internal/IconsGeneratedSourcesTest.java index 1118f872540f..b3bf2163438d 100644 --- a/plugins/devkit/testSources/internal/IconsGeneratedSourcesTest.java +++ b/plugins/devkit/testSources/internal/IconsGeneratedSourcesTest.java @@ -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" +