fernando88to opened a new pull request, #17:
URL: https://github.com/apache/grails-intellij-plugin/pull/17

   Follow-up to the criteria closure fix that went in earlier. Navigation 
inside criteria
     closures works now, but only for the terminal calls that are real methods 
— `count { }` was
     still unresolved, and nothing inside its closure could be navigated:
   
     ```groovy
     Foo.createCriteria().count {
         ge('createdAt', someDate)   // no navigation
         eq('owner', someUser)
     }
   
     Written with get { } instead, the same query was fine.
   
     The reason is that since GORM 4 createCriteria() comes from the GormEntity 
trait and is
     declared to return BuildableCriteria, not HibernateCriteriaBuilder. 
BuildableCriteria
     declares get, list, listDistinct and scroll, so those resolve; count, call 
and
     doCall live only in AbstractHibernateCriteriaBuilder.invokeMethod(...), so 
nothing sees
     them. We already declare those members in 
CriteriaBuilderImplicitMemberContributor, but it's
     registered for HibernateCriteriaBuilder, which is no longer the type you 
get.
   
     The lost navigation was a knock-on effect: with count unresolved,
     checkCriteriaClosure() has no method to look at and can't work out which 
domain class the
     closure belongs to, so the property references inside it have nowhere to 
go.
   
     So I added a second contributor registered for BuildableCriteria that 
contributes just the
     three members the interface is missing. It reuses the existing 
CLASS_SOURCE, which keeps
     isMine(), isCriteriaBuilderMethod() and CriteriaReturnTypeCalculator 
working untouched.
     It bails out when the qualifier is a HibernateCriteriaBuilder — that class 
implements
     BuildableCriteria from GORM 4 on, so both contributors would fire and 
every member would
     show up twice in completion. call/doCall are in there because the 
shorthand form was
     broken the same way:
   
     def c = Foo.createCriteria()
     c { ge('bar', baz) }
   
   


-- 
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]

Reply via email to