private void AddOverload(FunctionDefinition fd, 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(fd)) { var stubOverload = GetOverloadFromStub(fd); if (stubOverload != null) { if (!string.IsNullOrEmpty(fd.GetDocumentation())) { stubOverload.SetDocumentationProvider(_ => fd.GetDocumentation()); } addOverload(stubOverload); _table.ReplacedByStubs.Add(fd); return; } } if (!_table.Contains(fd)) { // 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 overload = new PythonFunctionOverload(fd, function, _eval.GetLocationOfName(fd)); addOverload(overload); _table.Add(new FunctionEvaluator(_eval, overload)); } }
public PythonFunctionOverload(IPythonClassMember cm, FunctionDefinition fd, Location location, string returnDocumentation) : this(cm, location) { Documentation = fd.GetDocumentation(); cm.DeclaringModule.AddAstNode(this, fd); _returnDocumentation = returnDocumentation; }
public PythonFunctionType( FunctionDefinition fd, IPythonType declaringType, Location location ) : base(fd.Name, location, fd.Name == "__init__" ? (declaringType?.Documentation ?? fd.GetDocumentation()) : fd.GetDocumentation(), declaringType != null ? BuiltinTypeId.Method : BuiltinTypeId.Function) { DeclaringType = declaringType; location.Module.AddAstNode(this, fd); ProcessDecorators(fd); }
public PythonFunctionType( FunctionDefinition fd, IPythonType declaringType, Location location ) : base(fd.Name, location, fd.Name == "__init__" ? (declaringType?.Documentation ?? fd.GetDocumentation()) : fd.GetDocumentation(), declaringType is IPythonClassType ? BuiltinTypeId.Method : BuiltinTypeId.Function) { DeclaringType = declaringType; // IsStub must be set permanently so when location of the stub is reassigned // to the primary module for navigation purposes, function still remembers // that it case from a stub. IsStub = location.Module.ModuleType == ModuleType.Stub; location.Module.AddAstNode(this, fd); ProcessDecorators(fd); }
public PythonPropertyType(FunctionDefinition fd, Location location, IPythonType declaringType, bool isAbstract) : this(fd.Name, location, fd.GetDocumentation(), declaringType, isAbstract) { declaringType.DeclaringModule.AddAstNode(this, fd); }