From 1b29a112dc2d2b1ce43c50833a550277742126f3 Mon Sep 17 00:00:00 2001 From: Marco Bajtl Date: Wed, 4 Dec 2024 11:58:43 +0100 Subject: [PATCH] Fixed ViewGoto for Controller2View and View2View --- .run/RunInCmdPlugin.run.xml | 12 -- build.gradle.kts | 114 +++++++++--------- gradle.properties | 36 ++---- .../nvlad/yii2support/common/ClassUtils.java | 5 +- 4 files changed, 74 insertions(+), 93 deletions(-) delete mode 100644 .run/RunInCmdPlugin.run.xml diff --git a/.run/RunInCmdPlugin.run.xml b/.run/RunInCmdPlugin.run.xml deleted file mode 100644 index b7160a4..0000000 --- a/.run/RunInCmdPlugin.run.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 111f21d..56f81d6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,36 +1,55 @@ -import io.gitlab.arturbosch.detekt.Detekt -import org.jetbrains.changelog.closure -import org.jetbrains.changelog.markdownToHTML - plugins { id("java") -// id("org.jetbrains.kotlin.jvm") version "1.4.10" - id("org.jetbrains.intellij") version "1.16.1" - id("org.jetbrains.changelog") version "1.1.2" - id("io.gitlab.arturbosch.detekt") version "1.14.2" +// id("org.jetbrains.kotlin.jvm") version "2.0.0" + id("org.jetbrains.intellij") version "1.17.3" + id("org.jetbrains.changelog") version "2.2.0" + id("io.gitlab.arturbosch.detekt") version "1.23.6" + id("idea") } -fun properties(key: String) = project.findProperty(key).toString() +// Import variables from gradle.properties file +// `pluginName_` variable ends with `_` because of the collision with Kotlin magic getter in the `intellij` closure. +// Read more about the issue: https://github.com/JetBrains/intellij-platform-plugin-template/issues/29 +val pluginName_: String by project +val pluginVersion: String by project +val pluginSinceBuild: String by project +val pluginVerifierIdeVersions: String by project -val platformPluginsAssociation = hashMapOf() -platformPluginsAssociation["2019.1.4"] = "com.jetbrains.php:191.8026.56, org.jetbrains.plugins.phpstorm-remote-interpreter:191.5849.22, com.jetbrains.twig:191.6183.95" -platformPluginsAssociation["2020.2.3"] = "com.jetbrains.php:202.7660.42, org.jetbrains.plugins.phpstorm-remote-interpreter:202.6397.59, com.jetbrains.twig:202.6397.21" -platformPluginsAssociation["2020.3.3"] = "com.jetbrains.php:203.7717.11, org.jetbrains.plugins.phpstorm-remote-interpreter:203.5981.155, com.jetbrains.twig:203.6682.75" -platformPluginsAssociation["2021.1"] = "com.jetbrains.php:211.6693.120, org.jetbrains.plugins.phpstorm-remote-interpreter:211.6693.65, com.jetbrains.twig:211.6693.44, PsiViewer:211-SNAPSHOT" -platformPluginsAssociation["2021.2"] = "com.jetbrains.php:212.4746.92, org.jetbrains.plugins.phpstorm-remote-interpreter:212.4746.52, com.jetbrains.twig:212.4746.57, PsiViewer:212-SNAPSHOT" -//platformPluginsAssociation["2023.3"] = "com.jetbrains.php:233.11799.232, org.jetbrains.plugins.phpstorm-remote-interpreter:233.11799.172, com.jetbrains.twig:233.11799.244, PsiViewer:233.2" -platformPluginsAssociation["2022.3.2"] = "com.jetbrains.php:223.8617.59, org.jetbrains.plugins.phpstorm-remote-interpreter:223.7571.117, com.jetbrains.twig:223.8617.59, PsiViewer:2022.3" -val bundledPlugins = "DatabaseTools, webDeployment, terminal, java-i18n, properties" - -val platformPlugins = buildString { - append(platformPluginsAssociation["2022.3.2"]) - append(", $bundledPlugins") -} +val platformType: String by project +val platformVersion: String by project +val platformDownloadSources: String by project +group = "com.nvlad" +version = pluginVersion + +println("Plugin Version: $pluginVersion") + + +val platformPluginsAssociation = hashMapOf() +platformPluginsAssociation["2019.1.4"] = + "com.jetbrains.php:191.8026.56, org.jetbrains.plugins.phpstorm-remote-interpreter:191.5849.22, com.jetbrains.twig:191.6183.95" +platformPluginsAssociation["2020.2.3"] = + "com.jetbrains.php:202.7660.42, org.jetbrains.plugins.phpstorm-remote-interpreter:202.6397.59, com.jetbrains.twig:202.6397.21" +platformPluginsAssociation["2020.3.3"] = + "com.jetbrains.php:203.7717.11, org.jetbrains.plugins.phpstorm-remote-interpreter:203.5981.155, com.jetbrains.twig:203.6682.75" +platformPluginsAssociation["2021.1"] = + "com.jetbrains.php:211.6693.120, org.jetbrains.plugins.phpstorm-remote-interpreter:211.6693.65, com.jetbrains.twig:211.6693.44, PsiViewer:211-SNAPSHOT" +platformPluginsAssociation["2021.2"] = + "com.jetbrains.php:212.4746.92, org.jetbrains.plugins.phpstorm-remote-interpreter:212.4746.52, com.jetbrains.twig:212.4746.57, PsiViewer:212-SNAPSHOT" +platformPluginsAssociation["2022.3"] = + "com.jetbrains.php:223.8617.59, org.jetbrains.plugins.phpstorm-remote-interpreter:223.7571.117, com.jetbrains.twig:223.8617.59, PsiViewer:2022.3" + +platformPluginsAssociation["2023.1.4"] = + "com.jetbrains.php:231.9225.18, org.jetbrains.plugins.phpstorm-remote-interpreter:231.8770.17, com.jetbrains.twig:231.9225.21, PsiViewer:231-SNAPSHOT, com.intellij.properties:231.8770.3" + +platformPluginsAssociation["2024.1"] = + "com.jetbrains.php:241.14494.237, org.jetbrains.plugins.phpstorm-remote-interpreter, com.jetbrains.twig, PsiViewer:241.14494.158-EAP-SNAPSHOT, com.intellij.properties:241.14494.150" + +val bundledPlugins = "DatabaseTools, webDeployment, com.intellij.css, terminal" +val platformPlugins = platformPluginsAssociation[platformVersion] + ", $bundledPlugins" repositories { mavenCentral() - jcenter() } dependencies { @@ -44,18 +63,10 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter:5.4.2") } -var pluginarray = "com.jetbrains.php:223.8617.59, org.jetbrains.plugins.phpstorm-remote-interpreter:223.7571.117, com.jetbrains.twig:223.8617.59, PsiViewer:2022.3, DatabaseTools, webDeployment, terminal, java-i18n, properties" - intellij { - pluginName.set(properties("pluginName")) - version.set(properties("platformVersion")) - type.set(properties("platformType")) - - plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty)) - - - - // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file + version.set(platformVersion) + type.set("PS") + plugins.set(listOf(*platformPlugins.split(',').map(String::trim).filter(String::isNotEmpty).toTypedArray())) } sourceSets { @@ -76,36 +87,29 @@ sourceSets { } tasks { + named("buildPlugin") { + archiveFileName.set("yii2support.zip") + } // Set the compatibility versions to 1.8 withType { - sourceCompatibility = "1.8" - targetCompatibility = "1.8" - } - - withType { - jvmTarget = "1.8" + sourceCompatibility = "17" + targetCompatibility = "17" } patchPluginXml { - version.set(properties("pluginVersion")) - sinceBuild.set(properties("pluginSinceBuild")) - untilBuild.set(properties("pluginUntilBuild")) - //changeNotes.set(file("src/main/resources/META-INF/change-notes.html").readText().replace("", "").replace("", "")) - } - - test { - //useJUnitPlatform() - reports { - //junitXml.isEnabled = true - } + version.set(pluginVersion) + untilBuild.set("") } - +// runPluginVerifier { +// ideVersions.set(listOf(*pluginVerifierIdeVersions.split(',').map(String::trim).filter(String::isNotEmpty).toTypedArray())) +// } publishPlugin { dependsOn("patchChangelog") + token.set(System.getenv("PUBLISH_TOKEN")) // pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: // https://jetbrains.org/intellij/sdk/docs/tutorials/build_system/deployment.html#specifying-a-release-channel - channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first())) + channels.set(listOf("beta")) } -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index b6cbdb8..ce64de7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,40 +4,26 @@ #phpPluginVersion = 191.8026.56 #phpRemoteInterpreterPluginVersion = 191.5849.22 #twigPluginVersion = 191.6183.95 - - #runIdePath = /AppData/Local/JetBrains/Toolbox/apps/PhpStorm/ch-1/193.5662.42 ##runIdePath = /Users/nvlad/Library/Application Support/JetBrains/Toolbox/apps/PhpStorm/ch-2/181.5281.35/PhpStorm.app #ideVersion = 2019.3 #phpPluginVersion = 193.5233.102 #phpRemoteInterpreterPluginVersion = 193.5233.57 #twigPluginVersion = 193.5233.116 - - -platformType = PS -platformVersion = 2023.3.2 -#platformVersion = 2021.2 -platformDownloadSources = true - -org.gradle.java.home=C:/Users/WORKER/.jdks/jbr_jcef-17.0.9-windows-x64-b1166.2 -#org.gradle.java.home=C:/Users/WORKER/AppData/Local/Programs/IntelliJ IDEA Ultimate - -pluginName = Yii2 Support -pluginVersion = 0.10.61 -pluginSinceBuild = 193 -pluginUntilBuild = +platformType=PS +#platformVersion = 2020.3.3 +platformVersion=2024.1 +platformDownloadSources=true +pluginName_=Yii2 Support +pluginVersion=0.12 +pluginSinceBuild=192 #pluginVerifierIdeVersions = IU-2019.1.4, IU-2019.3.5, IU-2020.1.4, IU-2020.2.3 -pluginVerifierIdeVersions = IU-2020.2.3, IU-2020.3.3, IU-2021.1, IU-2021.2, IU-2022.3.2, PS-2023.3.2 - +pluginVerifierIdeVersions=IU-2020.2.3, IU-2020.3.3, IU-2021.1, IU-2021.2, IU-2022.3, PS-2023.3.2, PS-2023.1.4, PS-2024.1 +#runIdePath = /home/gl/.local/share/JetBrains/Toolbox/apps/PhpStorm/ch-1/211.6693.78 #ideVersion = LATEST-EAP-SNAPSHOT #phpPluginVersion = 203.5251.40 #phpRemoteInterpreterPluginVersion = 203.5251.40 #twigPluginVersion = 203.5251.28 - -#platformPlugins = DatabaseTools,webDeployment,css-impl,terminal,remoteRun,yaml,xpath,webDeployment,JavaScript,com.jetbrains.php:223.8617.59,de.espend.idea.php.annotation:8.3.0,de.espend.idea.php.toolbox:6.1.0,com.jetbrains.twig:223.8617.59,com.jetbrains.php.dql:223.7571.117 -platformPlugins = DatabaseTools,webDeployment,css-impl,terminal,remoteRun,yaml,xpath,webDeployment,JavaScript,com.jetbrains.php:233.11799.300,de.espend.idea.php.annotation:8.3.0,de.espend.idea.php.toolbox:6.1.0,com.jetbrains.twig:233.11799.244,com.jetbrains.php.dql:233.11799.172 - -org.gradle.jvmargs=-Xmx1536M --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED - +org.gradle.jvmargs=-Xmx4608m ORG_GRADLE_PROJECT_USERNAME= -ORG_GRADLE_PROJECT_PASSWORD= +ORG_GRADLE_PROJECT_PASSWORD= \ No newline at end of file diff --git a/src/com/nvlad/yii2support/common/ClassUtils.java b/src/com/nvlad/yii2support/common/ClassUtils.java index 6fb5aa6..5c5cbff 100644 --- a/src/com/nvlad/yii2support/common/ClassUtils.java +++ b/src/com/nvlad/yii2support/common/ClassUtils.java @@ -71,7 +71,9 @@ public static PhpClass getPhpClassUniversal(Project project, PhpPsiElement value @Nullable public static PhpClass getClass(PhpIndex phpIndex, String className) { - Collection classes = phpIndex.getAnyByFQN(className); + String sanitizedClassName = className.split("\\|")[0]; + + Collection classes = phpIndex.getAnyByFQN(sanitizedClassName); return classes.isEmpty() ? null : classes.iterator().next(); } @@ -132,6 +134,7 @@ public static PhpClass getPhpClassByCallChain(MethodReference methodRef) { if (index1 >= 0 && index2 >= 0 && index2 > index1) { String className = strType.substring(index1, index2); + return ClassUtils.getClass(PhpIndex.getInstance(methodRef.getProject()), className); } else { return null;