private static void collectMethods( PsiClass currentClass, PsiSubstitutor currentClassSubstitutor, boolean shouldProcessDeprecated, GrTypeDefinition classToDelegateTo, Collection<PsiMethod> collector, boolean keepParameterAnnotations) { final List<PsiMethod> methods; if (currentClass instanceof GrTypeDefinition) { methods = new ArrayList<PsiMethod>(); GrClassImplUtil.collectMethodsFromBody((GrTypeDefinition) currentClass, methods); } else { methods = Arrays.asList(currentClass.getMethods()); } for (PsiMethod method : methods) { if (method.isConstructor() || method.hasModifierProperty(PsiModifier.STATIC)) continue; if (overridesObjectOrGroovyObject(method)) continue; if (!shouldProcessDeprecated && PsiImplUtil.getAnnotation(method, CommonClassNames.JAVA_LANG_DEPRECATED) != null) continue; collector.add( generateDelegateMethod( method, classToDelegateTo, currentClassSubstitutor, keepParameterAnnotations)); } }
/** * Adds all code methods of clazz add its super classes to signatures. Doesn't walk into * interfaces because all methods from them will be overloaded in any case. Besides Some of * interfaces came from delegates and they should be visited during the following processing. * * @param clazz current class * @param substitutor super class substitutor of clazz * @param signatures map to initialize * @param classes already visited classes */ private static void initializeSignatures( PsiClass clazz, PsiSubstitutor substitutor, Map<MethodSignature, PsiMethod> signatures, Set<PsiClass> classes) { if (clazz.isInterface()) return; if (classes.add(clazz)) { final List<PsiMethod> methods; if (clazz instanceof GrTypeDefinition) { methods = new ArrayList<PsiMethod>(); GrClassImplUtil.collectMethodsFromBody((GrTypeDefinition) clazz, methods); } else { methods = Arrays.asList(clazz.getMethods()); } for (PsiMethod method : methods) { addMethodChecked(signatures, method, substitutor, null); } for (PsiClassType type : getSuperTypes(clazz)) { final PsiClassType.ClassResolveResult result = type.resolveGenerics(); final PsiClass superClass = result.getElement(); if (superClass == null) continue; final PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(superClass, clazz, substitutor); initializeSignatures(superClass, superClassSubstitutor, signatures, classes); } } }