divinenickname / utgen-kotlin-idea-plugin

Simplify your testing process with automated test generation tailored for Kotlin codebases.
https://plugins.jetbrains.com/plugin/23907-utgen
Apache License 2.0
3 stars 1 forks source link

Hide button on non-kotlin files #9

Closed divinenickname closed 3 months ago

divinenickname commented 3 months ago

Our plugin show context menu on any folder or file in project. It's really weird and this behaviour may provide runtime errors. We need to show button if and only if user right-click on .kt file.

image

I had tried to do that using

override fun update(e: AnActionEvent) {
    super.update(e)
    val virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE)

    e.presentation.isEnabledAndVisible = virtualFile != null
}

But I couldn't succeed. If you know how to accomplish it, please help me by submitting a pull request or replying on my Stack Overflow question.