public static void AddMemberReference(this IPythonType type, string name, IExpressionEvaluator eval, Location location)
        {
            var m = type.GetMember(name);

            if (m is LocatedMember lm)
            {
                lm.AddReference(location);
            }
            else if (type is IPythonClassType cls)
            {
                using (eval.OpenScope(cls.DeclaringModule, cls.ClassDefinition)) {
                    eval.LookupNameInScopes(name, out _, out var v, LookupOptions.Local);
                    v?.AddReference(location);
                }
            }
        }
        public static void AddMemberReference(this IPythonType type, string name, IExpressionEvaluator eval, Location location)
        {
            var m = type.GetMember(name);

            if (m is LocatedMember lm)
            {
                lm.AddReference(location);
            }
            else if (type is IPythonClassType cls)
            {
                using (eval.OpenScope(cls)) {
                    eval.LookupNameInScopes(name, out _, out var v, LookupOptions.Local);
                    v?.AddReference(location);
                }
            }
            else if (type is IPythonModule module && module.GlobalScope != null && module.GlobalScope.Variables.TryGetVariable(name, out var variable))
            {
                variable.AddReference(location);
            }
        }
Esempio n. 3
0
 public static IDisposable OpenScope(this IExpressionEvaluator eval, IPythonFunctionType ft)
 => eval.OpenScope(ft.DeclaringModule, ft.FunctionDefinition);
Esempio n. 4
0
 public static IDisposable OpenScope(this IExpressionEvaluator eval, IPythonClassType cls)
 => eval.OpenScope(cls.DeclaringModule, cls.ClassDefinition);