void (@NotNull GrCall call, @NotNull GroovyResolveResult resolveResult, @Nullable String argumentName, boolean forCompletion, @NotNull Map<String, NamedArgumentDescriptor> result) { PsiElement resolve = resolveResult.getElement(); PsiType returnType = resolve == null ? null : ((PsiMethod)resolve).getReturnType(); PsiClass aClass = PsiTypesUtil.getPsiClass(returnType); if (aClass == null) return; Map<String, Pair<PsiType, PsiElement>> typeMap = null; if (!forCompletion) { typeMap = new HashMap<>(); } PsiManager manager = aClass.getManager(); for (PsiMethod method : aClass.getAllMethods()) { String methodName = method.getName(); String propertyName = GroovyPropertyUtils.getPropertyNameBySetterName(methodName); if (propertyName != null) { if (argumentName != null && !argumentName.equals(propertyName)) continue; PsiType methodReturnType = method.getReturnType(); if (methodReturnType != null && !PsiTypes.voidType().equals(methodReturnType)) continue; PsiParameter[] parameters = method.getParameterList().getParameters(); if (parameters.length != 1) continue; if (forCompletion) { // optimization, don't calculate types. result.put(propertyName, NamedArgumentDescriptor.SIMPLE_ON_TOP); } else { PsiType newType = parameters[0].getType(); Pair<PsiType, PsiElement> oldPair = typeMap.get(propertyName); if (oldPair == null) { typeMap.put(propertyName, new Pair<>(newType, method)); } else { typeMap.put(propertyName, new Pair<>(newType, null)); } } } else { PsiType closureType = null; if (methodName.startsWith("add")) { PsiParameter[] parameters = method.getParameterList().getParameters(); if (parameters.length != 1) continue; PsiClass paramClass = PsiTypesUtil.getPsiClass(parameters[0].getType()); if (paramClass == null || !InheritanceUtil.isInheritor(paramClass, "java.util.EventListener")) continue; for (PsiMethod psiMethod : paramClass.getMethods()) { if (!psiMethod.hasModifierProperty(PsiModifier.ABSTRACT)) continue; if (forCompletion) { result.put(psiMethod.getName(), NamedArgumentDescriptor.SIMPLE_ON_TOP); } else { if (closureType == null) { closureType = JavaPsiFacade.getElementFactory(manager.getProject()).createTypeByFQClassName(GroovyCommonClassNames.GROOVY_LANG_CLOSURE, call.getResolveScope()); } result.put(psiMethod.getName(), new TypeCondition(closureType, method)); } } } } } if (!forCompletion) { for (Map.Entry<String, Pair<PsiType, PsiElement>> entry : typeMap.entrySet()) { result.put(entry.getKey(), new TypeCondition(entry.getValue().first, entry.getValue().second)); } } }