private async Task UpdateSearchPathPackagesAsync(CancellationToken cancellationToken) { var packageDict = new Dictionary <string, string>(); foreach (var searchPath in _searchPaths.MaybeEnumerate()) { cancellationToken.ThrowIfCancellationRequested(); IReadOnlyCollection <string> packages = null; if (File.Exists(searchPath)) { packages = await GetPackagesFromZipFileAsync(searchPath, cancellationToken); } else if (Directory.Exists(searchPath)) { packages = await GetPackagesFromDirectoryAsync(searchPath, cancellationToken); } foreach (var package in packages.MaybeEnumerate()) { packageDict[package] = searchPath; } } cancellationToken.ThrowIfCancellationRequested(); Interlocked.Exchange(ref _searchPathPackages, packageDict); ModuleNamesChanged?.Invoke(this, EventArgs.Empty); }
private void PythonAnalyzer_SearchPathsChanged(object sender, EventArgs e) { _searchPaths = _state.GetSearchPaths(); _searchPathDb = null; _zipPackageCache = null; ModuleNamesChanged?.Invoke(this, EventArgs.Empty); }
private void Factory_ImportableModulesChanged(object sender, EventArgs e) { _modules.Clear(); #if USE_TYPESHED lock (_typeShedPathsLock) { _typeShedPaths = null; } #endif ModuleNamesChanged?.Invoke(this, EventArgs.Empty); }
private void Factory_ImportableModulesChanged(object sender, EventArgs e) { _modules.Clear(); if (_builtinModule != null) { _modules[BuiltinModuleName] = _builtinModule; } ModuleCache.Clear(); ModuleNamesChanged?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Removes a module. If <c>retainName</c> is true, keeps returning /// the module name from <see cref="GetModuleNames"/>. /// </summary> public void RemoveModule(string name, bool retainName = false) { if (retainName) { _moduleNames.Add(name); } if (_modules.Remove(name)) { ModuleNamesChanged?.Invoke(this, EventArgs.Empty); } }
private void Analyzer_SearchPathsChanged(object sender, EventArgs e) { lock (_userSearchPathsLock) { // Remove imported modules from search paths so we will import them again. foreach (var name in _userSearchPathImported.MaybeEnumerate().ToArray()) { _modules.TryRemove(name, out var mod); } _userSearchPathImported = null; _userSearchPathPackages = null; _userSearchPaths = _analyzer.GetSearchPaths(); } ModuleNamesChanged?.Invoke(this, EventArgs.Empty); }
private void Analyzer_SearchPathsChanged(object sender, EventArgs e) { var moduleNames = _analyzer.CurrentPathResolver.GetInterpreterModuleNames().Append(BuiltinModuleName); lock (_userSearchPathsLock) { // Remove imported modules from search paths so we will import them again. var modulesNamesToRemove = _modules.Keys.Except(moduleNames).ToList(); foreach (var moduleName in modulesNamesToRemove) { _modules.TryRemove(moduleName, out _); } } ModuleNamesChanged?.Invoke(this, EventArgs.Empty); }
private async void OnNewDatabaseAvailable(object sender, EventArgs e) { var factory = _factory; if (factory == null) { // We have been disposed already, so ignore this event return; } _typeDb = factory.GetCurrentDatabase(); _searchPathDb = null; _zipPackageCache = null; ModuleNamesChanged?.Invoke(this, EventArgs.Empty); }
internal void RaiseModuleNamesChanged() { ModuleNamesChanged?.Invoke(this, EventArgs.Empty); }
private void Factory_ImportableModulesChanged(object sender, EventArgs e) { _modules.Clear(); ModuleNamesChanged?.Invoke(this, EventArgs.Empty); }
public void AddModule(string name, IPythonModule module) { _modules[name] = module; ModuleNamesChanged?.Invoke(this, EventArgs.Empty); }