From ef620e5c65b5eddbd4c7632e5a8cf389525a77f6 Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Tue, 20 Oct 2015 18:32:45 +0300 Subject: [PATCH] Check generated icons file under read action if needed --- .../internal/IconsGeneratedSourcesFilter.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/plugins/devkit/src/internal/IconsGeneratedSourcesFilter.java b/plugins/devkit/src/internal/IconsGeneratedSourcesFilter.java index a5e8e04bd3f2..41b1678fffb5 100644 --- a/plugins/devkit/src/internal/IconsGeneratedSourcesFilter.java +++ b/plugins/devkit/src/internal/IconsGeneratedSourcesFilter.java @@ -15,8 +15,10 @@ */ package org.jetbrains.idea.devkit.internal; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.GeneratedSourcesFilter; +import com.intellij.openapi.util.Computable; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.javadoc.PsiDocComment; @@ -24,17 +26,23 @@ import org.jetbrains.annotations.NotNull; public class IconsGeneratedSourcesFilter extends GeneratedSourcesFilter { @Override - public boolean isGeneratedSource(@NotNull VirtualFile file, @NotNull Project project) { + public boolean isGeneratedSource(@NotNull final VirtualFile file, @NotNull final Project project) { if (file.getName().endsWith("Icons.java")) { - PsiFile psiFile = PsiManager.getInstance(project).findFile(file); - if (psiFile instanceof PsiJavaFile) { - for (PsiClass aClass : ((PsiJavaFile)psiFile).getClasses()) { - if (aClass.hasModifierProperty(PsiModifier.PUBLIC)) { - PsiDocComment comment = aClass.getDocComment(); - return comment != null && comment.getText().contains("run build/scripts/icons.gant instead"); + return ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public Boolean compute() { + PsiFile psiFile = PsiManager.getInstance(project).findFile(file); + if (psiFile instanceof PsiJavaFile) { + for (PsiClass aClass : ((PsiJavaFile)psiFile).getClasses()) { + if (aClass.hasModifierProperty(PsiModifier.PUBLIC)) { + PsiDocComment comment = aClass.getDocComment(); + return comment != null && comment.getText().contains("run build/scripts/icons.gant instead"); + } + } } + return false; } - } + }); } return false; }