Пример #1
0
 private IMember AddFunction(FunctionDefinition node, IPythonType declaringType, LocationInfo loc)
 {
     if (!(_eval.LookupNameInScopes(node.Name, LookupOptions.Local) is PythonFunctionType existing))
     {
         existing = new PythonFunctionType(node, _eval.Module, declaringType, loc);
         _eval.DeclareVariable(node.Name, existing, VariableSource.Declaration, loc);
     }
     AddOverload(node, existing, o => existing.AddOverload(o));
     return(existing);
 }
 private void AddFunction(FunctionDefinition fd, IPythonType declaringType)
 {
     if (!(_eval.LookupNameInScopes(fd.Name, LookupOptions.Local) is PythonFunctionType existing))
     {
         existing = new PythonFunctionType(fd, declaringType, _eval.GetLocationOfName(fd));
         // The variable is transient (non-user declared) hence it does not have location.
         // Function type is tracking locations for references and renaming.
         _eval.DeclareVariable(fd.Name, existing, VariableSource.Declaration);
     }
     AddOverload(fd, existing, o => existing.AddOverload(o));
 }
 private void AddFunction(FunctionDefinition fd, PythonType declaringType)
 {
     if (!(_eval.LookupNameInScopes(fd.Name, LookupOptions.Local) is PythonFunctionType f))
     {
         f = new PythonFunctionType(fd, declaringType, _eval.GetLocationOfName(fd));
         // The variable is transient (non-user declared) hence it does not have location.
         // Function type is tracking locations for references and renaming.
         _eval.DeclareVariable(fd.Name, f, VariableSource.Declaration);
         _typeMap[fd] = f;
         declaringType?.AddMember(f.Name, f, overwrite: true);
     }
     AddOverload(fd, f, o => f.AddOverload(o));
 }
        private void AddFunction(FunctionDefinition fd, PythonType declaringType)
        {
            if (!(_eval.LookupNameInScopes(fd.Name, LookupOptions.Local) is PythonFunctionType f))
            {
                f = new PythonFunctionType(fd, declaringType, _eval.GetLocationOfName(fd));
                // The variable is transient (non-user declared) hence it does not have location.
                // Function type is tracking locations for references and renaming.

                // if there are multiple functions with same name exist, only the very first one will be
                // maintained in the scope. we should improve this if possible.
                // https://github.com/microsoft/python-language-server/issues/1693
                _eval.DeclareVariable(fd.Name, f, VariableSource.Declaration);
                _typeMap[fd] = f;
                declaringType?.AddMember(f.Name, f, overwrite: true);
            }
            AddOverload(fd, f, o => f.AddOverload(o));
        }