Search in sources :

Example 1 with GroovyClassDescriptor

use of org.jetbrains.plugins.groovy.dsl.GroovyClassDescriptor in project intellij-community by JetBrains.

the class GdkMethodDslProvider method processCategoryMethods.

private static void processCategoryMethods(final String className, final GdslMembersHolderConsumer consumer, final boolean isStatic) {
    final GlobalSearchScope scope = consumer.getResolveScope();
    final PsiClass categoryClass = JavaPsiFacade.getInstance(consumer.getProject()).findClass(className, scope);
    if (categoryClass == null) {
        return;
    }
    final VolatileNotNullLazyValue<GdkMethodHolder> methodsMap = new VolatileNotNullLazyValue<GdkMethodHolder>() {

        @NotNull
        @Override
        protected GdkMethodHolder compute() {
            return GdkMethodHolder.getHolderForClass(categoryClass, isStatic, scope);
        }
    };
    consumer.addMemberHolder(new CustomMembersHolder() {

        @Override
        public boolean processMembers(GroovyClassDescriptor descriptor, PsiScopeProcessor _processor, ResolveState state) {
            for (PsiScopeProcessor each : GroovyResolverProcessor.allProcessors(_processor)) {
                if (ResolveUtil.shouldProcessMethods(each.getHint(ElementClassHint.KEY)) && !methodsMap.getValue().processMethods(each, state, descriptor.getPsiType(), descriptor.getProject())) {
                    return false;
                }
            }
            return true;
        }
    });
}
Also used : GdkMethodHolder(org.jetbrains.plugins.groovy.dgm.GdkMethodHolder) CustomMembersHolder(org.jetbrains.plugins.groovy.dsl.holders.CustomMembersHolder) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) PsiClass(com.intellij.psi.PsiClass) GroovyClassDescriptor(org.jetbrains.plugins.groovy.dsl.GroovyClassDescriptor) VolatileNotNullLazyValue(com.intellij.openapi.util.VolatileNotNullLazyValue) PsiScopeProcessor(com.intellij.psi.scope.PsiScopeProcessor) ResolveState(com.intellij.psi.ResolveState)

Aggregations

VolatileNotNullLazyValue (com.intellij.openapi.util.VolatileNotNullLazyValue)1 PsiClass (com.intellij.psi.PsiClass)1 ResolveState (com.intellij.psi.ResolveState)1 PsiScopeProcessor (com.intellij.psi.scope.PsiScopeProcessor)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 GdkMethodHolder (org.jetbrains.plugins.groovy.dgm.GdkMethodHolder)1 GroovyClassDescriptor (org.jetbrains.plugins.groovy.dsl.GroovyClassDescriptor)1 CustomMembersHolder (org.jetbrains.plugins.groovy.dsl.holders.CustomMembersHolder)1