mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Check generated icons file under read action if needed
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user