public void Initialize(PythonAnalyzer state) { _pythonInterpreter.Initialize(state); if (_state != null) { _state.SearchPathsChanged -= PythonAnalyzer_SearchPathsChanged; } _state = state; SpecializeClrFunctions(); if (_state != null) { _state.SearchPathsChanged += PythonAnalyzer_SearchPathsChanged; PythonAnalyzer_SearchPathsChanged(_state, EventArgs.Empty); } }
internal PythonAnalyzer(IPythonInterpreterFactory factory, IPythonInterpreter pythonInterpreter, string builtinName) { if (pythonInterpreter == null) { throw new ArgumentNullException("pythonInterpreter"); } _interpreterFactory = factory; _langVersion = factory.GetLanguageVersion(); _interpreter = pythonInterpreter; _builtinName = builtinName ?? (_langVersion.Is3x() ? SharedDatabaseState.BuiltinName3x : SharedDatabaseState.BuiltinName2x); _modules = new ModuleTable(this, _interpreter); _modulesByFilename = new ConcurrentDictionary <string, ModuleInfo>(StringComparer.OrdinalIgnoreCase); _modulesWithUnresolvedImports = new HashSet <ModuleInfo>(); _itemCache = new Dictionary <object, AnalysisValue>(); try { using (var key = Registry.CurrentUser.OpenSubKey(AnalysisLimitsKey)) { Limits = AnalysisLimits.LoadFromStorage(key); } } catch (SecurityException) { Limits = new AnalysisLimits(); } catch (UnauthorizedAccessException) { Limits = new AnalysisLimits(); } catch (IOException) { Limits = new AnalysisLimits(); } _queue = new Deque <AnalysisUnit>(); LoadKnownTypes(); pythonInterpreter.Initialize(this); _defaultContext = _interpreter.CreateModuleContext(); _evalUnit = new AnalysisUnit(null, null, new ModuleInfo("$global", new ProjectEntry(this, "$global", String.Empty, null), _defaultContext).Scope, true); AnalysisLog.NewUnit(_evalUnit); }