Skip to content

Commit 03c74ba

Browse files
authored
Merge pull request #8 from tommykw/fix/phpstorm-comatibility
PhpStorm compatibility and improve trait detection
2 parents 6f7756e + bdeccfb commit 03c74ba

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies {
3636

3737
// IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
3838
intellijPlatform {
39-
intellijIdea(providers.gradleProperty("platformVersion"))
39+
create("PS", providers.gradleProperty("platformVersion"))
4040

4141
// Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
4242
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })

src/main/kotlin/com/github/tommykw/phptraitinlineviewer/TraitInlineViewerAction.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ package com.github.tommykw.phptraitinlineviewer
22

33
import com.intellij.openapi.actionSystem.AnAction
44
import com.intellij.openapi.actionSystem.AnActionEvent
5+
import com.intellij.openapi.actionSystem.ActionUpdateThread
56
import com.intellij.openapi.actionSystem.CommonDataKeys
67
import com.intellij.psi.util.PsiTreeUtil
78
import com.jetbrains.php.lang.psi.PhpFile
89
import com.jetbrains.php.lang.psi.elements.PhpClass
910
import com.jetbrains.php.lang.psi.elements.PhpTraitUseRule
1011

1112
class 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

Comments
 (0)