MethodDeclarationSyntax PortCategoryMethod(CXCursor cursor)
        {
            var objcMethod = new ObjCMethod (cursor);
            IEnumerable<ParameterSyntax> mParams = FetchParamInfos (cursor);

            ParameterSyntax thisParam = SF.Parameter (SF.Identifier ("self"))
                .WithType (SF.ParseTypeName (CategoryImplContext.ExtendedClassName));
            mParams = (new ParameterSyntax[] { thisParam }).Concat (mParams);

            TypeSyntax retType = TypePorter.PortType (objcMethod.ReturnType);
            string methodName = MethodHelper.ConvertToMehtodName (objcMethod.Selector);

            var mb = new MethodBuilder ();
            MethodDeclarationSyntax mDecl = mb.BuildExtensionMethod (retType, methodName, mParams);

            IEnumerable<CXCursor> children = cursor.GetChildren ();
            var compoundStmt = children.First (c => c.kind == CXCursorKind.CXCursor_CompoundStmt);
            return AddBody (compoundStmt, mDecl);
        }
        BaseMethodDeclarationSyntax PortMethod(CXCursor cursor)
        {
            var objcMethod = new ObjCMethod (cursor);
            IEnumerable<ParameterSyntax> mParams = FetchParamInfos (cursor);

            MethodDefinition mDef;
            MethodDeclarationSyntax mDecl = null;
            ConstructorDeclarationSyntax ctorDecl = null;

            var mb = new MethodBuilder ();
            var isBound = bindingLocator.TryFindMethod (ImplContext.SuperClassName, objcMethod.Selector, out mDef);
            if (isBound) {
                if (mDef.IsConstructor)
                    ctorDecl = mb.BuildCtor (mDef, ImplContext.ClassName, mParams);
                else
                    mDecl = mb.BuildDeclaration (mDef, mParams);
            } else {
                if (objcMethod.IsInitializer)
                    ctorDecl = mb.BuildCtor (ImplContext.ClassName, mParams);
                else
                    mDecl = BuildDefaultDeclaration (objcMethod, mParams);
            }

            IEnumerable<CXCursor> children = cursor.GetChildren ();
            var compoundStmt = children.First (c => c.kind == CXCursorKind.CXCursor_CompoundStmt);

            if (ctorDecl != null)
                return AddBody (compoundStmt, ctorDecl);
            else
                return AddBody (compoundStmt, mDecl);
        }
        MethodDeclarationSyntax BuildDefaultDeclaration(ObjCMethod objcMethod, IEnumerable<ParameterSyntax> mParams)
        {
            TypeSyntax retType = TypePorter.PortType (objcMethod.ReturnType);
            string methodName = MethodHelper.ConvertToMehtodName (objcMethod.Selector);

            var mb = new MethodBuilder ();
            MethodDeclarationSyntax mDecl = mb.BuildDeclaration (retType, methodName, mParams);

            if (objcMethod.IsStatic)
                mDecl = mDecl.WithStaticKeyword ();

            return mDecl;
        }