private IReadOnlyList <ProjectData> GetProjects( IEnumerable <Process> allProcesses, Dictionary <PipId, AbsolutePath> sealedDirectoriesFromWrappers) { return(Measure( "Constructing Project Data", () => { var groups = allProcesses.GroupBy(p => p.Provenance.Token.Path).ToArray(); var projects = new ProjectData[groups.Length]; Parallel.For( 0, groups.Length, i => { var specFileGroupedProcesses = groups[i]; var projectFolder = specFileGroupedProcesses.Key.GetParent(PathTable); var project = new ProjectData(projectFolder); foreach (var process in specFileGroupedProcesses) { foreach (var dependency in PipGraph.RetrievePipReferenceImmediateDependencies(process.PipId, PipType.Process)) { project.AddProjectDependency(GetProjectFolder(dependency.HydratePip())); } foreach (var dependency in PipGraph.RetrievePipReferenceImmediateDependencies(process.PipId, PipType.SealDirectory)) { AbsolutePath projectDependency; if (sealedDirectoriesFromWrappers.TryGetValue(dependency.PipId, out projectDependency)) { project.AddProjectDependency(projectDependency); } else { project.AddSourceFolderDependency(GetProjectFolder(dependency.HydratePip())); } } } projects[i] = project; }); return projects; })); }
/// <summary> /// Generates the PipMetadata for a given Pip /// </summary> public PipMetadata GeneratePipMetadata(Pip pip) { PipMetadata pipMetadata = new PipMetadata { PipId = pip.PipId.Value, SemiStableHash = pip.FormattedSemiStableHash, PipType = pip.PipType, Tags = pip.Tags.IsValid ? pip.Tags.Select(tag => tag.ToString(StringTable)).ToList() : null }; pipMetadata.Tags = pipMetadata.Tags.Any() ? pipMetadata.Tags : null; PipProvenance provenance = pip.Provenance; pipMetadata.Qualifier = PipGraph.Context.QualifierTable.GetCanonicalDisplayString(provenance.QualifierId); pipMetadata.Usage = provenance.Usage.IsValid ? provenance.Usage.ToString(PathTable) : null; pipMetadata.SpecFilePath = provenance.Token.Path.ToString(PathTable); pipMetadata.OutputValueSymbol = provenance.OutputValueSymbol.ToString(SymbolTable); pipMetadata.ModuleId = provenance.ModuleId.Value; pipMetadata.SpecFilePath = provenance.Token.Path.ToString(PathTable); pipMetadata.PipDependencies = PipGraph.RetrievePipReferenceImmediateDependencies(pip.PipId, null) .Where(pipRef => pipRef.PipType != PipType.HashSourceFile) .Select(pipRef => pipRef.PipId) .Select(pipId => PipTable.HydratePip(pipId, PipQueryContext.ViewerAnalyzer)) .Select(pipHash => pipHash.FormattedSemiStableHash) .ToList(); pipMetadata.PipDependents = PipGraph.RetrievePipReferenceImmediateDependents(pip.PipId, null) .Select(pipRef => pipRef.PipId) .Select(pipId => PipTable.HydratePip(pipId, PipQueryContext.ViewerAnalyzer)) .Select(pipData => pipData.FormattedSemiStableHash) .ToList(); pipMetadata.PipDependencies = pipMetadata.PipDependencies.Any() ? pipMetadata.PipDependencies : null; pipMetadata.PipDependents = pipMetadata.PipDependents.Any() ? pipMetadata.PipDependents : null; return(pipMetadata); }