List<ClosureParameterInfo> (InsertionContext context, PsiMethod method, PsiSubstitutor substitutor, PsiElement place) { final ArrayList<ClosureDescriptor> descriptors = new ArrayList<>(); GrReferenceExpression ref = (GrReferenceExpression)place; PsiType qtype = PsiImplUtil.getQualifierType(ref); if (qtype == null) return null; GrExpression qualifier = ref.getQualifier(); if (qualifier != null) { PsiType type = qualifier.getType(); if (!(type instanceof PsiClassType)) return null; processExecutors((PsiClassType)qtype, ref, descriptors); } else { PsiElementFactory factory = JavaPsiFacade.getElementFactory(context.getProject()); for (PsiElement parent = ref.getParent(); parent != null; parent = parent.getParent()) { if (parent instanceof GrClosableBlock) { processExecutors(TypesUtil.createTypeByFQClassName(GroovyCommonClassNames.GROOVY_LANG_CLOSURE, ref), ref, descriptors); } else if (parent instanceof GrTypeDefinition) { processExecutors(factory.createType(((GrTypeDefinition)parent), PsiType.EMPTY_ARRAY), ref, descriptors); } } } for (ClosureDescriptor descriptor : descriptors) { if (isMethodApplicable(descriptor, method, ref)) { return ContainerUtil.map(descriptor.getParameters(), d -> new ClosureParameterInfo(d.getName(), d.getType())); } } return null; }