Skip to content

Commit

Permalink
fixed autocompletion & reference contribution (ctrl+click) in `getBy(…
Browse files Browse the repository at this point in the history
…)` methods
  • Loading branch information
hrach committed Jan 23, 2025
1 parent 883c883 commit 3fc1618
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
14 changes: 11 additions & 3 deletions src/main/kotlin/org/nextras/orm/intellij/utils/OrmUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,17 @@ object OrmUtils {
fun findQueriedEntities(ref: MemberReference): Collection<PhpClass> {
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) }
}
Expand Down

0 comments on commit 3fc1618

Please sign in to comment.