public NameLookupContext Clone(bool copyScopeContents = false)
        {
            var ctxt = new NameLookupContext(
                Interpreter,
                Context,
                Ast,
                Module,
                FilePath,
                DocumentUri,
                IncludeLocationInfo,
                _builtinModule.IsValueCreated ? _builtinModule.Value : null,
                _log
                );

            ctxt.DefaultLookupOptions  = DefaultLookupOptions;
            ctxt.SuppressBuiltinLookup = SuppressBuiltinLookup;

            foreach (var scope in _scopes.Reverse())
            {
                if (copyScopeContents)
                {
                    ctxt._scopes.Push(new Dictionary <string, IMember>(scope));
                }
                else
                {
                    ctxt._scopes.Push(scope);
                }
            }

            return(ctxt);
        }
Beispiel #2
0
 public AstAnalysisWalker(
     IPythonInterpreter interpreter,
     PythonAst ast,
     IPythonModule module,
     string filePath,
     Uri documentUri,
     Dictionary <string, IMember> members,
     bool includeLocationInfo,
     bool warnAboutUndefinedValues,
     AnalysisLogWriter log = null
     )
 {
     _log     = log ?? (interpreter as AstPythonInterpreter)?._log;
     _module  = module ?? throw new ArgumentNullException(nameof(module));
     _members = members ?? throw new ArgumentNullException(nameof(members));
     _scope   = new NameLookupContext(
         interpreter ?? throw new ArgumentNullException(nameof(interpreter)),
         interpreter.CreateModuleContext(),
         ast ?? throw new ArgumentNullException(nameof(ast)),
         _module,
         filePath,
         documentUri,
         includeLocationInfo,
         log: warnAboutUndefinedValues ? _log : null
         );
     _postWalkers             = new List <AstAnalysisFunctionWalker>();
     WarnAboutUndefinedValues = warnAboutUndefinedValues;
 }
Beispiel #3
0
 public AstAnalysisWalker(
     IPythonInterpreter interpreter,
     PathResolverSnapshot pathResolver,
     PythonAst ast,
     IPythonModule module,
     string filePath,
     Uri documentUri,
     Dictionary <string, IMember> members,
     bool includeLocationInfo,
     bool warnAboutUndefinedValues,
     bool suppressBuiltinLookup,
     AnalysisLogWriter log = null
     )
 {
     _log     = log ?? (interpreter as AstPythonInterpreter)?.Log;
     _module  = module ?? throw new ArgumentNullException(nameof(module));
     _members = members ?? throw new ArgumentNullException(nameof(members));
     _scope   = new NameLookupContext(
         interpreter ?? throw new ArgumentNullException(nameof(interpreter)),
         interpreter.CreateModuleContext(),
         ast ?? throw new ArgumentNullException(nameof(ast)),
         _module,
         filePath,
         documentUri,
         includeLocationInfo,
         _functionWalkers,
         log: warnAboutUndefinedValues ? _log : null
         );
     _ast          = ast;
     _interpreter  = interpreter;
     _pathResolver = pathResolver;
     _scope.SuppressBuiltinLookup = suppressBuiltinLookup;
     _scope.PushScope(_typingScope);
     WarnAboutUndefinedValues = warnAboutUndefinedValues;
 }
 public AstAnalysisFunctionWalker(
     NameLookupContext scope,
     FunctionDefinition targetFunction,
     AstPythonFunctionOverload overload
     )
 {
     _scope    = scope ?? throw new ArgumentNullException(nameof(scope));
     Target    = targetFunction ?? throw new ArgumentNullException(nameof(targetFunction));
     _overload = overload ?? throw new ArgumentNullException(nameof(overload));
 }
 public AstAnalysisFunctionWalker(
     NameLookupContext scope,
     FunctionDefinition targetFunction
     )
 {
     _scope       = scope ?? throw new ArgumentNullException(nameof(scope));
     _target      = targetFunction ?? throw new ArgumentNullException(nameof(targetFunction));
     _returnTypes = new List <IPythonType>();
     _overload    = new AstPythonFunctionOverload(
         AstPythonFunction.MakeParameters(_scope.Ast, _target),
         _scope.GetLocOfName(_target, _target.NameExpression),
         _returnTypes
         );
 }
Beispiel #6
0
 public AstAnalysisWalker(
     IPythonInterpreter interpreter,
     PythonAst ast,
     IPythonModule module,
     string filePath,
     Dictionary <string, IMember> members,
     bool includeLocationInfo
     )
 {
     _scope = new NameLookupContext(
         interpreter ?? throw new ArgumentNullException(nameof(interpreter)),
         interpreter.CreateModuleContext(),
         ast ?? throw new ArgumentNullException(nameof(ast)),
         filePath,
         includeLocationInfo
         );
     _module      = module ?? throw new ArgumentNullException(nameof(module));
     _members     = members ?? throw new ArgumentNullException(nameof(members));
     _noneInst    = new AstPythonConstant(_interpreter.GetBuiltinType(BuiltinTypeId.NoneType));
     _postWalkers = new List <AstAnalysisFunctionWalker>();
 }
 public AstTypeAnnotationConverter(NameLookupContext scope)
 {
     _scope = scope ?? throw new ArgumentNullException(nameof(scope));
 }