GrLightMethodBuilder (@NonNls MethodDescriptor descriptor, PsiElement place, PsiManager manager) { final GrLightMethodBuilder method = new GrLightMethodBuilder(manager, descriptor.getName()).addModifier(PsiModifier.PUBLIC); if (descriptor.isConstructor()) { method.setConstructor(true); } else { method.setReturnType(convertToPsiType(descriptor.getReturnType(), place)); } List<NamedParameterDescriptor> descriptorNamedParams = descriptor.getNamedParameters(); if (!descriptorNamedParams.isEmpty()) { Map<String, NamedArgumentDescriptor> namedParams = new HashMap<>(); for (NamedParameterDescriptor paramDescriptor : descriptorNamedParams) { String typeString = paramDescriptor.getType(); GdslNamedParameter parameter = new GdslNamedParameter( paramDescriptor.getName(), paramDescriptor.getDoc(), place, typeString ); namedParams.put( paramDescriptor.getName(), new NamedArgumentDescriptorImpl(NamedArgumentDescriptor.Priority.ALWAYS_ON_TOP, parameter) { @Override public boolean checkType(@NotNull PsiType type, @NotNull GroovyPsiElement context) { return ClassContextFilter.isSubtype(type, context.getContainingFile(), typeString); } } ); } method.addParameter("args", convertToPsiType(CommonClassNames.JAVA_UTIL_MAP, place)); method.setNamedParameters(namedParams); } for (VariableDescriptor paramDescriptor : descriptor.getParameters()) { method.addParameter(paramDescriptor.getName(), convertToPsiType(paramDescriptor.getType(), place)); } if (descriptor.isStatic()) { method.addModifier(PsiModifier.STATIC); } final PsiElement bindsTo = descriptor.getBindsTo(); if (bindsTo != null) { method.setNavigationElement(bindsTo); } final List<String> toThrow = descriptor.getThrows(); for (String o : toThrow) { final PsiType psiType = convertToPsiType(o, place); if (psiType instanceof PsiClassType) { method.addException((PsiClassType)psiType); } } String doc = descriptor.getDoc(); if (doc != null) { method.putUserData(DOCUMENTATION, doc); } String docUrl = descriptor.getDocUrl(); if (docUrl != null) { method.putUserData(DOCUMENTATION_URL, docUrl); } String qName = descriptor.getContainingClass(); if (qName != null) { PsiClass foundClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(qName, place.getResolveScope()); if (foundClass != null) { method.setContainingClass(foundClass); } } return method; }