boolean ( @NotNull ClosureDescriptor descriptor, @NotNull PsiMethod method, @NotNull GroovyPsiElement place ) { String name = descriptor.getMethodName(); if (!name.equals(method.getName())) { return false; } PsiElement typeContext; if (descriptor.getUsePlaceContextForTypes()) { typeContext = place; } else { PsiTypeParameterList typeParameterList = method.getTypeParameterList(); typeContext = typeParameterList != null ? typeParameterList : method; } List<PsiType> types = new ArrayList<>(); for (String type : descriptor.getMethodParameterTypes()) { types.add(convertToPsiType(type, typeContext)); } final boolean isConstructor = descriptor.isMethodConstructor(); final MethodSignature signature = MethodSignatureUtil.createMethodSignature( name, types.toArray(PsiType.createArray(types.size())), method.getTypeParameters(), PsiSubstitutor.EMPTY, isConstructor ); final GrSignature closureSignature = GrClosureSignatureUtil.createSignature(signature); if (method instanceof ClsMethodImpl) method = ((ClsMethodImpl)method).getSourceMirrorMethod(); final PsiParameter[] parameters = method.getParameterList().getParameters(); final PsiType[] typeArray = ContainerUtil.map( parameters, parameter -> parameter.getType(), PsiType.createArray(parameters.length) ); return GrClosureSignatureUtil.isSignatureApplicable(Collections.singletonList(closureSignature), typeArray, place); }