Exemplo n.º 1
0
        private void AddOverload(FunctionDefinition node, IPythonClassMember function, Action <IPythonFunctionOverload> addOverload)
        {
            // Check if function exists in stubs. If so, take overload from stub
            // and the documentation from this actual module.
            if (!_table.ReplacedByStubs.Contains(node))
            {
                var stubOverload = GetOverloadFromStub(node);
                if (stubOverload != null)
                {
                    if (!string.IsNullOrEmpty(node.GetDocumentation()))
                    {
                        stubOverload.SetDocumentationProvider(_ => node.GetDocumentation());
                    }
                    addOverload(stubOverload);
                    _table.ReplacedByStubs.Add(node);
                    return;
                }
            }

            if (!_table.Contains(node))
            {
                // Do not evaluate parameter types just yet. During light-weight top-level information
                // collection types cannot be determined as imports haven't been processed.
                var location = _eval.GetLocOfName(node, node.NameExpression);
                var overload = new PythonFunctionOverload(node, function, _eval.Module, location);
                addOverload(overload);
                _table.Add(new FunctionEvaluator(_eval, node, overload, function));
            }
        }