@@ -2,13 +2,17 @@ package com.github.tommykw.phptraitinlineviewer
22
33import com.intellij.openapi.actionSystem.AnAction
44import com.intellij.openapi.actionSystem.AnActionEvent
5+ import com.intellij.openapi.actionSystem.ActionUpdateThread
56import com.intellij.openapi.actionSystem.CommonDataKeys
67import com.intellij.psi.util.PsiTreeUtil
78import com.jetbrains.php.lang.psi.PhpFile
89import com.jetbrains.php.lang.psi.elements.PhpClass
910import com.jetbrains.php.lang.psi.elements.PhpTraitUseRule
1011
1112class TraitInlineViewerAction : AnAction () {
13+ override fun getActionUpdateThread (): ActionUpdateThread {
14+ return ActionUpdateThread .BGT
15+ }
1216 override fun update (event : AnActionEvent ) {
1317 event.presentation.text = " View PHP Trait Inline"
1418
@@ -36,13 +40,8 @@ class TraitInlineViewerAction : AnAction() {
3640 return
3741 }
3842
39- val hasTraitUses = phpClass.traitUseRules()?.isEmpty == false
40- event.presentation.isEnabled = hasTraitUses
41- event.presentation.description = if (hasTraitUses) {
42- " Open an inline view of ${phpClass.name ? : " this class" } with merged traits."
43- } else {
44- " No trait use statements found in ${phpClass.name ? : " this class" } ."
45- }
43+ event.presentation.isEnabled = true
44+ event.presentation.description = " Open an inline view of ${phpClass.name ? : " this class" } with merged traits."
4645 }
4746
4847 override fun actionPerformed (event : AnActionEvent ) {
@@ -68,7 +67,10 @@ class TraitInlineViewerAction : AnAction() {
6867 return
6968 }
7069
71- if (phpClass.traitUseRules()?.isEmpty != false ) {
70+ val traits = phpClass.traits
71+ val hasTraits = traits.isNotEmpty()
72+
73+ if (! hasTraits) {
7274 TraitInlineNotifier .warn(project, " ${phpClass.name ? : " This class" } does not use any traits." )
7375 return
7476 }
0 commit comments