public bool Matches([CanBeNull] IEnumerable <Dependency> incoming, Item i, [CanBeNull] IEnumerable <Dependency> outgoing) { return((_atLeastOneIncomingDependencyPattern == null || incoming != null && incoming.Any(d => _atLeastOneIncomingDependencyPattern.IsMatch(d))) && ItemMatch.IsMatch(_itemMatch, i) && (_atLeastOneOutgoingDependencyPattern == null || outgoing != null && outgoing.Any(d => _atLeastOneOutgoingDependencyPattern.IsMatch(d)))); }
private void RecursivelyFlood(Item root, Item from, HashSet <Item> visited, Dictionary <FromTo, Dependency> checkPresence, DependencyPattern idempotentPattern, Dictionary <Item, Dependency[]> outgoing, IEnumerable <ItemMatch> toItemMatches, List <DependencyMatch> matches, List <DependencyMatch> excludes, Dictionary <string, int> markersToAddOrNull, List <Dependency> result, Dependency collectedEdge, [NotNull] Action checkAbort, WorkingGraph workingGraph, bool ignoreCase) { if (outgoing.ContainsKey(from)) { checkAbort(); foreach (var d in outgoing[from].Where(d => d.IsMarkerMatch(matches, excludes))) { Item target = d.UsedItem; if (visited.Add(target)) { Dependency rootToTarget = collectedEdge == null ? d : workingGraph.CreateDependency(root, target, d.Source, new MutableMarkerSet(ignoreCase, markersToAddOrNull ?? MutableMarkerSet.ConcatOrUnionWithMarkers(collectedEdge.AbstractMarkerSet, d.AbstractMarkerSet, ignoreCase)), collectedEdge.Ct + d.Ct, collectedEdge.QuestionableCt + d.QuestionableCt, collectedEdge.BadCt + d.BadCt, collectedEdge.NotOkReason ?? d.NotOkReason, d.ExampleInfo); if (IsMatch(toItemMatches, target)) { Dependency alreadyThere; var rootTargetKey = new FromTo(root, target); if (checkPresence.TryGetValue(rootTargetKey, out alreadyThere) && idempotentPattern.IsMatch(alreadyThere)) { // we do not add a dependency } else { checkPresence[rootTargetKey] = rootToTarget; result.Add(rootToTarget); } } // Continue search RecursivelyFlood(root, target, visited, checkPresence, idempotentPattern, outgoing, toItemMatches, matches, excludes, markersToAddOrNull, result, rootToTarget, checkAbort, workingGraph, ignoreCase); } } } }