override fun update()

in src/main/kotlin/mobi/hsz/idea/gitignore/actions/IgnoreFileGroupAction.kt [55:76]


    override fun update(e: AnActionEvent) {
        val file = e.getData(CommonDataKeys.VIRTUAL_FILE)
        val project = e.getData(CommonDataKeys.PROJECT)
        val presentation = e.presentation

        files.clear()
        if (project != null && file != null) {
            try {
                presentation.isVisible = true
                baseDir = Utils.getModuleRootForFile(file, project)
                IgnoreBundle.LANGUAGES
                    // skip already bundled languages for ignore action
                    .filterNot { this !is UnignoreFileGroupAction && (it is GitLanguage || it is MercurialLanguage) }
                    .map { it.fileType }
                    .forEach { files[it.languageName] = getSuitableIgnoreFiles(project, it, file).reversed() }
            } catch (e: ExternalFileException) {
                presentation.isVisible = false
            }
        }

        presentation.isPopupGroup = countFiles() > 1
    }