From 3fc16188f05cdb84964d36a5252e33cc681e3fa7 Mon Sep 17 00:00:00 2001 From: Jan Skrasek Date: Thu, 23 Jan 2025 12:38:46 +0100 Subject: [PATCH] fixed autocompletion & reference contribution (ctrl+click) in `getBy()` methods --- changelog.md | 4 +++- gradle.properties | 2 +- .../org/nextras/orm/intellij/utils/OrmUtils.kt | 14 +++++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index 7f37ab2..eba3afb 100644 --- a/changelog.md +++ b/changelog.md @@ -2,13 +2,15 @@ ## Unreleased +- Fixed autocompletion & reference contribution (ctrl+click) in `getBy()` methods on various complex expression. #106 + ### Changed ## 2.0.1 - 2025-01-22 ### Changed -- Fixed autocompletion & reference contribution (ctrl+click) in findBy() +- Fixed autocompletion & reference contribution (ctrl+click) in `findBy()` methods on various complex expression. #103 ## 2.0.0 - 2024-12-15 diff --git a/gradle.properties b/gradle.properties index f0abc4d..14a2441 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ pluginGroup = org.nextras.orm.intellij pluginName = Nextras Orm Plugin -pluginVersion = 2.0.1 +pluginVersion = 2.0.2 kotlin.stdlib.default.dependency = false diff --git a/src/main/kotlin/org/nextras/orm/intellij/utils/OrmUtils.kt b/src/main/kotlin/org/nextras/orm/intellij/utils/OrmUtils.kt index 0833520..7e3e225 100644 --- a/src/main/kotlin/org/nextras/orm/intellij/utils/OrmUtils.kt +++ b/src/main/kotlin/org/nextras/orm/intellij/utils/OrmUtils.kt @@ -29,9 +29,17 @@ object OrmUtils { fun findQueriedEntities(ref: MemberReference): Collection { val phpIndex = PhpIndex.getInstance(ref.project) val completedType = phpIndex.completeType(ref.project, ref.type, null) - val types = completedType.typesWithParametrisedParts.mapNotNull { type -> - if (!type.contains(OrmClass.COLLECTION.className)) return@mapNotNull null - PhpType.getParametrizedParts(type).firstOrNull() + val isCollectionKind = ref.name?.startsWith("getBy") != true + val types = when (isCollectionKind) { + true -> { + completedType.typesWithParametrisedParts.mapNotNull { type -> + if (!type.contains(OrmClass.COLLECTION.className)) return@mapNotNull null + PhpType.getParametrizedParts(type).firstOrNull() + } + } + false -> { + completedType.types + } } return types.flatMap { PhpIndexUtils.getByType(PhpType().add(it), phpIndex) } }