Icon (@NotNull VirtualFile virtualFile, @Iconable.IconFlags int flags, @Nullable Project project) { if (project == null || !FileTypeRegistry.getInstance().isFileOfType(virtualFile, GroovyFileType.GROOVY_FILE_TYPE)) return null; final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile); if (!(psiFile instanceof GroovyFile file)) return null; final Icon icon; if (file.isScript()) { icon = GroovyScriptTypeDetector.getIcon(file); } else if (GrFileIndexUtil.isGroovySourceFile(file)) { final GrTypeDefinition[] typeDefinitions = file.getTypeDefinitions(); icon = typeDefinitions.length > 0 ? typeDefinitions[0].getIcon(flags) : JetgroovyIcons.Groovy.GroovyFile; } else { icon = JetgroovyIcons.Groovy.Groovy_outsideSources; } return IconManager.getInstance().createLayeredIcon(psiFile, icon, ElementBase.transformFlags(psiFile, flags)); }