/// <summary> /// From the supplied names selects packages that are not in the index and attempts /// to add them to the index. This typically applies to packages that were just installed. /// </summary> private async Task<IEnumerable<IPackageInfo>> TryAddMissingPackagesAsync(IEnumerable<string> packageNames) { var list = new List<IPackageInfo>(); // Do not attempt to add new package when index is still being built if (packageNames.Any() && _buildIndexLock.IsSet) { try { var installedPackages = await GetInstalledPackagesAsync(); var packagesNotInIndex = installedPackages.Where(p => packageNames.Contains(p.Package)); foreach (var p in packagesNotInIndex) { var info = new PackageInfo(_host, p.Package, p.Description, p.Version); _packages[p.Package] = info; await info.LoadFunctionsIndexAsync(); _functionIndex.RegisterPackageFunctions(info); list.Add(info); } } catch (RHostDisconnectedException) { } } return list; }
private async Task BuildInstalledPackagesIndexAsync() { var packages = await GetInstalledPackagesAsync(); foreach (var p in packages) { _packages[p.Package] = new PackageInfo(_host, p.Package, p.Description, p.Version); } _packages["rtvs"] = new PackageInfo(_host, "rtvs", "R Tools", "1.0"); }