-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
entity: mark getters/setters as implicitly used [closes #12]
- Loading branch information
Showing
4 changed files
with
36 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
pluginGroup = org.nextras.orm.intellij | ||
pluginName = Nextras Orm Plugin | ||
pluginVersion = 0.8.3 | ||
pluginVersion = 0.9.0 | ||
|
||
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl | ||
# See https://jb.gg/intellij-platform-builds-list for available build versions. | ||
pluginVerifierIdeVersions = PS-2020.3.3, PS-2021.1, PS-2021.2 | ||
pluginVerifierIdeVersions = PS-2021.3 | ||
|
||
platformType = IU | ||
platformVersion = 2021.2 | ||
platformVersion = 2021.3.1 | ||
platformDownloadSources = true | ||
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html | ||
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 | ||
platformPlugins = com.jetbrains.php:212.4746.100 | ||
platformPlugins = com.jetbrains.php:213.6461.83 |
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/org/nextras/orm/intellij/usageProvider/EntityUsageProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.nextras.orm.intellij.usageProvider | ||
|
||
import com.intellij.codeInsight.daemon.ImplicitUsageProvider | ||
import com.intellij.psi.PsiElement | ||
import com.jetbrains.php.PhpIndex | ||
import com.jetbrains.php.lang.psi.elements.Method | ||
import org.nextras.orm.intellij.utils.OrmUtils | ||
|
||
class EntityUsageProvider : ImplicitUsageProvider { | ||
override fun isImplicitUsage(element: PsiElement): Boolean { | ||
val method = element as? Method ?: return false | ||
if (!method.name.startsWith("getter") && !method.name.startsWith("setter")) return false | ||
|
||
val clazz = method.containingClass ?: return false | ||
val phpIndex = PhpIndex.getInstance(element.project) | ||
if (!OrmUtils.OrmClass.ENTITY.`is`(clazz, phpIndex)) return false | ||
|
||
val propertyName = method.name.substring(6) | ||
val tags = clazz.docComment?.propertyTags ?: return false | ||
return tags.any { it.property?.text?.substring(1).equals(propertyName, ignoreCase = true) } | ||
} | ||
|
||
override fun isImplicitRead(element: PsiElement): Boolean = false | ||
|
||
override fun isImplicitWrite(element: PsiElement): Boolean = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters