fernando88to commented on code in PR #17: URL: https://github.com/apache/grails-intellij-plugin/pull/17#discussion_r3775129716
########## plugin/src/main/java/org/apache/grails/intellij/plugin/references/domain/criteria/BuildableCriteriaImplicitMemberContributor.java: ########## @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.grails.intellij.plugin.references.domain.criteria; + +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiMethod; +import com.intellij.psi.PsiType; +import com.intellij.psi.ResolveState; +import com.intellij.psi.scope.DelegatingScopeProcessor; +import com.intellij.psi.scope.PsiScopeProcessor; +import com.intellij.psi.util.InheritanceUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor; +import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; +import org.jetbrains.plugins.groovy.util.dynamicMembers.DynamicMemberUtils; + +import java.util.Set; + +/** + * Since GORM 4 {@code createCriteria()} comes from the {@code GormEntity} trait and is declared to return + * {@link #BUILDABLE_CRITERIA_CLASS}, not {@link CriteriaBuilderUtil#CRITERIA_BUILDER_CLASS}. That interface + * declares {@code get}, {@code list}, {@code listDistinct} and {@code scroll}, which is why those forms + * resolve out of the box, but the remaining closure-terminal calls only exist in + * {@code AbstractHibernateCriteriaBuilder.invokeMethod(...)} and are therefore invisible to resolution: + * {@code Ddd.createCriteria().count { ... }} used to resolve to nothing, which in turn left + * {@link CriteriaBuilderUtil#checkCriteriaClosure} unable to find the domain class, so no property inside + * the closure could be navigated either. + */ +final class BuildableCriteriaImplicitMemberContributor extends NonCodeMembersContributor { + public static final String BUILDABLE_CRITERIA_CLASS = "org.grails.datastore.mapping.query.api.BuildableCriteria"; Review Comment: Moved to `GormClassNames` as `BUILDABLE_CRITERIA` in 39697b7, next to `QUERY_CREATOR`. I picked `GormClassNames` over `CriteriaBuilderUtil` because `BuildableCriteria` is a datastore-core type — same `org.grails.datastore.mapping.query` prefix as `QUERY_CREATOR` — whereas `CRITERIA_BUILDER_CLASS` is a Hibernate-plugin type, so that split seemed the more consistent of the two homes you offered. Also dropped the `_CLASS` suffix to match the neighbours. Value unchanged, so no behaviour change. -- 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]
