Skip to content

Commit df10e23

Browse files
committed
fix(dependencies): update file extension check and visibility logic #308
- Add 'vm' to the list of disabled file extensions. - Replace 'isEnabled' with 'isVisible' for better UI handling. - Use 'BuildFileProvider' to check file support instead of 'PackageService'.
1 parent e5733e5 commit df10e23

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

exts/ext-dependencies/src/233/main/kotlin/cc/unitmesh/dependencies/AutoDevDependenciesCheck.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.intellij.openapi.actionSystem.AnAction
55
import com.intellij.openapi.actionSystem.AnActionEvent
66
import com.intellij.openapi.actionSystem.PlatformDataKeys
77
import com.intellij.openapi.fileEditor.FileDocumentManager
8+
import com.intellij.packageChecker.api.BuildFileProvider
89
import com.intellij.packageChecker.service.PackageChecker
910
import com.intellij.packageChecker.service.PackageService
1011
import com.intellij.psi.PsiManager
@@ -18,13 +19,15 @@ class AutoDevDependenciesCheck : AnAction("Check dependencies has Issues") {
1819
val document = editor.document
1920
val file = FileDocumentManager.getInstance().getFile(document) ?: return
2021

21-
if (file.extension == "md" || file.extension == "txt" || file.extension == "devin") {
22-
e.presentation.isEnabled = false
22+
if (file.extension == "md" || file.extension == "txt" || file.extension == "devin" || file.extension == "vm") {
23+
e.presentation.isVisible = false
2324
return
2425
}
2526

2627
val psiFile = PsiManager.getInstance(project).findFile(file) ?: return
27-
e.presentation.isEnabled = PackageService.getInstance(project).declaredDependencies(psiFile).isNotEmpty()
28+
e.presentation.isVisible = BuildFileProvider.EP_NAME.getExtensions(project).any {
29+
it.supports(psiFile)
30+
}
2831
}
2932

3033
override fun actionPerformed(event: AnActionEvent) {

0 commit comments

Comments
 (0)