internal PythonAnalyzer(IPythonInterpreterFactory factory, IPythonInterpreter pythonInterpreter) { _interpreterFactory = factory; _langVersion = factory.GetLanguageVersion(); _disposeInterpreter = pythonInterpreter == null; _interpreter = pythonInterpreter ?? factory.CreateInterpreter(); _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>(); Limits = AnalysisLimits.GetDefaultLimits(); _queue = new Deque <AnalysisUnit>(); _defaultContext = _interpreter.CreateModuleContext(); _evalUnit = new AnalysisUnit(null, null, new ModuleInfo("$global", new ProjectEntry(this, "$global", String.Empty, null), _defaultContext).Scope, true); AnalysisLog.NewUnit(_evalUnit); try { LoadInitialKnownTypes(); } catch (Exception ex) { if (ex.IsCriticalException()) { throw; } // This will be rethrown in LoadKnownTypesAsync _loadKnownTypesException = ExceptionDispatchInfo.Capture(ex); } }
internal PythonAnalyzer(IPythonInterpreterFactory factory, IPythonInterpreter pythonInterpreter, string builtinName) { _interpreterFactory = factory; _langVersion = factory.GetLanguageVersion(); _disposeInterpreter = pythonInterpreter == null; _interpreter = pythonInterpreter ?? factory.CreateInterpreter(); _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>(); _defaultContext = _interpreter.CreateModuleContext(); _evalUnit = new AnalysisUnit(null, null, new ModuleInfo("$global", new ProjectEntry(this, "$global", String.Empty, null), _defaultContext).Scope, true); AnalysisLog.NewUnit(_evalUnit); LoadInitialKnownTypes(); }
/// <summary> /// Returns a new set of limits, set to the default for analyzing a /// standard library. /// </summary> public static AnalysisLimits GetStandardLibraryLimits() { var limits = new AnalysisLimits(); limits.CallDepth = 2; limits.DecreaseCallDepth = 20; limits.NormalArgumentTypes = 10; limits.ListArgumentTypes = 5; limits.DictArgumentTypes = 5; limits.ReturnTypes = 10; limits.YieldTypes = 10; limits.InstanceMembers = 5; limits.DictKeyTypes = 5; limits.DictValueTypes = 20; limits.IndexTypes = 5; limits.AssignedTypes = 50; limits.UnifyCallsToNew = true; limits.ProcessCustomDecorators = true; return limits; }
internal PythonAnalyzer(IPythonInterpreterFactory factory) { InterpreterFactory = factory; LanguageVersion = factory.GetLanguageVersion(); Interpreter = factory.CreateInterpreter(); _pathResolver = new PathResolver(LanguageVersion); _builtinName = BuiltinTypeId.Unknown.GetModuleName(LanguageVersion); Modules = new ModuleTable(this, Interpreter); ModulesByFilename = new ConcurrentDictionary <string, ModuleInfo>(StringComparer.OrdinalIgnoreCase); Limits = AnalysisLimits.GetDefaultLimits(); Queue = new Deque <AnalysisUnit>(); _defaultContext = Interpreter.CreateModuleContext(); _evalUnit = new AnalysisUnit(null, null, new ModuleInfo("$global", new ProjectEntry(this, "$global", String.Empty, null, null), _defaultContext).Scope, true); AnalysisLog.NewUnit(_evalUnit); }
/// <summary> /// Returns a new set of limits, set to the default for analyzing a /// standard library. /// </summary> public static AnalysisLimits GetStandardLibraryLimits() { var limits = new AnalysisLimits(); limits.CallDepth = 2; limits.DecreaseCallDepth = 20; limits.NormalArgumentTypes = 10; limits.ListArgumentTypes = 5; limits.DictArgumentTypes = 5; limits.ReturnTypes = 10; limits.YieldTypes = 10; limits.InstanceMembers = 5; limits.DictKeyTypes = 5; limits.DictValueTypes = 20; limits.IndexTypes = 5; limits.AssignedTypes = 50; limits.UnifyCallsToNew = true; return(limits); }
internal PythonAnalyzer(IPythonInterpreterFactory factory, IPythonInterpreter pythonInterpreter) { _interpreterFactory = factory; _langVersion = factory.GetLanguageVersion(); _disposeInterpreter = pythonInterpreter == null; _interpreter = pythonInterpreter ?? factory.CreateInterpreter(); _builtinName = BuiltinTypeId.Unknown.GetModuleName(_langVersion); _modules = new ModuleTable(this, _interpreter); _modulesByFilename = new ConcurrentDictionary <string, ModuleInfo>(StringComparer.OrdinalIgnoreCase); _modulesWithUnresolvedImports = new HashSet <ModuleInfo>(); _itemCache = new Dictionary <object, AnalysisValue>(); Limits = AnalysisLimits.GetDefaultLimits(); Queue = new Deque <AnalysisUnit>(); _defaultContext = _interpreter.CreateModuleContext(); _evalUnit = new AnalysisUnit(null, null, new ModuleInfo("$global", new ProjectEntry(this, "$global", String.Empty, null, null), _defaultContext).Scope, true); AnalysisLog.NewUnit(_evalUnit); }