/********************************************************************

The Multiverse Platform is made available under the MIT License.

Copyright (c) 2012 The Multiverse Foundation

Permission is hereby granted, free of charge, to any person 
obtaining a copy of this software and associated documentation 
files (the "Software"), to deal in the Software without restriction, 
including without limitation the rights to use, copy, modify, 
merge, publish, distribute, sublicense, and/or sell copies 
of the Software, and to permit persons to whom the Software 
is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be 
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 
OR OTHER DEALINGS IN THE SOFTWARE.

*********************************************************************/

/***************************************************************************

Copyright (c) Microsoft Corporation. All rights reserved.
This code is licensed under the Visual Studio SDK license terms.
THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.

***************************************************************************/

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Samples.VisualStudio.IronPythonInference;

using Microsoft.VisualStudio.Package;

namespace Microsoft.Samples.VisualStudio.IronPythonLanguageService {
    class PythonMethods : Methods {
        private IList<FunctionInfo> methods;

        public PythonMethods(IList<FunctionInfo> methods) {
            this.methods = methods;
        }

        public override int GetCount() {
            return methods != null ? methods.Count : 0;
        }

        public override string GetDescription(int index) {
            return methods != null && 0 <= index && index < methods.Count ? methods[index].Description : "";
        }

        public override string GetType(int index) {
            return methods != null && 0 <= index && index < methods.Count ? methods[index].Type : "";
        }

        public override int GetParameterCount(int index) {
            return methods != null && 0 <= index && index < methods.Count ? methods[index].ParameterCount : 0;
        }

        public override void GetParameterInfo(int index, int parameter, out string name, out string display, out string description) {
            if (methods != null && 0 <= index && index < methods.Count) {
                methods[index].GetParameterInfo(parameter, out name, out display, out description);
            } else {
                name = display = description = string.Empty;
            }
        }

        public override string GetName(int index) {
            return methods != null && 0 <= index && index < methods.Count ? methods[index].Name : "";
        }
    }
}
