fernando88to opened a new pull request, #6:
URL: https://github.com/apache/grails-intellij-plugin/pull/6
Restores, for **Grails 3+** (Gradle) projects, the behavior that already
existed on Grails 2.x:
- **Ctrl+click** on a domain class name inside an HQL query navigates to
the class.
- **Rename** of a domain property/class updates the references inside HQL
strings.
The feature depends on two independent things, and on Grails 3+ **both**
were broken:
1. **HQL language injection into the string** — the old injection
(IntelliLang, `languageInjections.xml`) only matched synthetic methods marked
with the `DOMAIN_DYNAMIC_METHOD` kind, which
are only generated for GORM < 4. On GORM 4+ the finders
(`find`/`findAll`/`executeQuery`/`executeUpdate`) come from the `GormEntity`
trait and aren't marked that way, so the injection
never fired.
2. **Resolving names inside the HQL** — the JPA persistence model HQL uses
to resolve identifiers is only populated if the module has a Hibernate/JPA
facet. That facet is only added by the
legacy Grails 2.x structure-sync path, which doesn't run for Grails 3+
modules imported via Gradle.
## Changes
- **`GormHqlInjector`** (new) — a programmatic `MultiHostInjector` that
injects HQL by resolving the domain class directly (`GormUtils.isGormBean`)
instead of relying on the synthetic
method marker. Works across all GORM versions.
- **`languageInjections.xml`** — removes the old IntelliLang injection
(avoids double injection on GORM < 4).
- **`Grails3HibernateFacetActivity`** (new) — a `postStartupActivity` in
the `:hibernate` module that adds a `"Gorm"` Hibernate facet (idempotent) to
every Grails 3+ app module, activating
the existing persistence bridge (`GormSessionFactoryContributor` →
`GormPersistenceMapping` → `GormEntity`).
- Registered the new components in `plugin.xml` and in the `:hibernate`
module descriptor.
## Test plan
- [x] `./gradlew compileJava` and `:hibernate:compileJava` — succeed.
- [x] `./gradlew test --tests 'GormHqlInjectionTest'` — 5/5 tests passing
(cover injection on `find`/`executeQuery`, an unqualified call inside the
domain class, and the negative cases: a
non-finder method and a non-domain qualifier).
- [x] `./gradlew rat` — new files approved (`AL`), no pending license
issues.
- [ ] Manual validation on a real Grails 3+ project (`./gradlew runIde`):
confirm the "Gorm" Hibernate facet appears in Project Structure, Ctrl+click
navigates to the domain class inside
`executeQuery`, and renaming a property updates the query.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]