detekt/detekt-intellij-plugin

AutoCorrect is not working when right clicking the directory

mondaylord opened this issue · 1 comments

Description

Autocorrect works as expected when I right-click a file or a blank space within the code in the IDE.

However, when I attempt to run autocorrect by right-clicking on the directory itself, it does not work.
This behavior persists even when the directory contains only one kotlin file.

I am not sure if this is a bug or an intentional feature that autocorrect cannot be executed on a directory.

AutoCorrect was implemented to run just on a single file:

val file: VirtualFile = event.getData(CommonDataKeys.VIRTUAL_FILE) ?: return

detekt core should be able to handle directories and the plugin can be updates to support directories like the RunAnalysionAction

override fun update(event: AnActionEvent) {
val selectedFiles = event.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY) ?: return
val isDirectoryOrKotlinFile = selectedFiles.any { it.isDirectory || it.extension in KOTLIN_FILE_EXTENSIONS }
event.presentation.isEnabledAndVisible = isDirectoryOrKotlinFile
}
override fun actionPerformed(e: AnActionEvent) {
val selectedFiles = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY)
if (selectedFiles.isNullOrEmpty()) {
return
}
: