Check generated icons file under read action if needed

This commit is contained in:
Alexander Zolotov
2015-10-20 18:43:11 +03:00
parent 7e2ba8b821
commit ef620e5c65
@@ -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<Boolean>() {
@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;
}