Find conflicts within selection set.

    Find all conflicts found "within" a selection set, including those found via
    spreading in fragments.

    Called when visiting each SelectionSet in the GraphQL Document.
190669
def find_conflicts_within_selection_set(
    context: ValidationContext,
    cached_fields_and_fragment_names: Dict,
    compared_fragment_pairs: "PairSet",
    parent_type: Optional[GraphQLNamedType],
    selection_set: SelectionSetNode,
) -> List[Conflict]:
    
    conflicts: List[Conflict] = []

    field_map, fragment_names = get_fields_and_fragment_names(
        context, cached_fields_and_fragment_names, parent_type, selection_set
    )

    # (A) Find all conflicts "within" the fields of this selection set.
    # Note: this is the *only place* `collect_conflicts_within` is called.
    collect_conflicts_within(
        context,
        conflicts,
        cached_fields_and_fragment_names,
        compared_fragment_pairs,
        field_map,
    )

    if fragment_names:
        compared_fragments: Set[str] = set()
        # (B) Then collect conflicts between these fields and those represented by each
        # spread fragment name found.
        for i, fragment_name in enumerate(fragment_names):
            collect_conflicts_between_fields_and_fragment(
                context,
                conflicts,
                cached_fields_and_fragment_names,
                compared_fragments,
                compared_fragment_pairs,
                False,
                field_map,
                fragment_name,
            )
            # (C) Then compare this fragment with all other fragments found in this
            # selection set to collect conflicts within fragments spread together.
            # This compares each item in the list of fragment names to every other
            # item in that same list (except for itself).
            for other_fragment_name in fragment_names[i + 1 :]:
                collect_conflicts_between_fragments(
                    context,
                    conflicts,
                    cached_fields_and_fragment_names,
                    compared_fragment_pairs,
                    False,
                    fragment_name,
                    other_fragment_name,
                )

    return conflicts
88547
func (rule *overlappingFieldsCanBeMergedRule) findConflictsBetweenSubSelectionSets(areMutuallyExclusive bool, parentType1 Named, selectionSet1 *ast.SelectionSet, parentType2 Named, selectionSet2 *ast.SelectionSet) []conflict {
	conflicts := []conflict{}

	fieldsInfo1 := rule.getFieldsAndFragmentNames(parentType1, selectionSet1)
	fieldsInfo2 := rule.getFieldsAndFragmentNames(parentType2, selectionSet2)

	// (H) First, collect all conflicts between these two collections of field.
	conflicts = rule.collectConflictsBetween(conflicts, areMutuallyExclusive, fieldsInfo1, fieldsInfo2)

	// (I) Then collect conflicts between the first collection of fields and
	// those referenced by each fragment name associated with the second.
	for _, fragmentName2 := range fieldsInfo2.fragmentNames {
		conflicts = rule.collectConflictsBetweenFieldsAndFragment(conflicts, areMutuallyExclusive, fieldsInfo1, fragmentName2)
	}

	// (I) Then collect conflicts between the second collection of fields and
	// those referenced by each fragment name associated with the first.
	for _, fragmentName1 := range fieldsInfo1.fragmentNames {
		conflicts = rule.collectConflictsBetweenFieldsAndFragment(conflicts, areMutuallyExclusive, fieldsInfo2, fragmentName1)
	}

	// (J) Also collect conflicts between any fragment names by the first and
	// fragment names by the second. This compares each item in the first set of
	// names to each item in the second set of names.
	for _, fragmentName1 := range fieldsInfo1.fragmentNames {
		for _, fragmentName2 := range fieldsInfo2.fragmentNames {
			conflicts = rule.collectConflictsBetweenFragments(conflicts, areMutuallyExclusive, fragmentName1, fragmentName2)
		}
	}
	return conflicts
}
21435
function(node) {

    if (isTask(node)) {

      // This is a task so do nothing.
      return [node];

    } else if (isBranch(node)) {

      // Concat map children with a recMap.
      node.children = _.flatten(_.map(node.children, recMap));

      // Sort children.
      node.children.sort(compareBranchOrTask);

      // Resolve duplicate named children.
      // Group children by name.
      var nameMap = _.groupBy(node.children, getName);

      // Resolve conflicts.
      node.children = _.map(_.values(nameMap), function(children) {

        if (children.length === 1) {

          // No conflicts so just return head of array.
          return children[0];

        } else {

          // Resolve conflict by finding a single node with the override flag.
          var overrides = _.filter(children, function(child) {
            return child.__override;
          });

          if (overrides.length === 1) {

            // Conflict resolved.
            return overrides[0];

          } else {

            // Conflict can not be resolved, throw an error.
            throw new Error('Conflicting task names can not be resolved: ' +
              pp(children));

          }

        }

      });

      if (getName(node) === appName) {

        // Replace this node with this nodes children.
        _.each(node.children, function(child) {
          // Mark each child with an override flag so we can resolve conflicts.
          child.__override = true;
        });
        return node.children;

      } else {

        // Just return.
        return [node];

      }

    } else {

      // This should never happen.
      assert(false);

    }

  }
677370
private static void updateCheckConflict(
            Map<TemporalField, Long> fieldValues,
            TemporalField targetField,
            TemporalField changeField,
            long changeValue) {
        
        Long old = fieldValues.put(changeField, changeValue);
        if (old != null && changeValue != old.longValue()) {
            throw new DateTimeException(
                    "Conflict found: " + changeField + " " + old +
                    " differs from " + changeField + " " + changeValue +
                    " while resolving  " + targetField);
        }
    }
193885
public static AbstractElement findFirstWithSameConflicts(final AbstractElement element, final Grammar grammar) {
		final List<String> conflicting = getConflictingKeywords(element, grammar);
		AbstractElement result = element;
		Iterator<AbstractElement> iterator = Iterators.filter(
				Iterators.filter(EcoreUtil.getAllContents(grammar, true), AbstractElement.class),
				new Predicate<AbstractElement>() {
					@Override
					public boolean apply(AbstractElement param) {
						final List<String> otherConflicting = getConflictingKeywords(param, grammar);
						return otherConflicting != null && otherConflicting.equals(conflicting);
					}
				});
		if (iterator.hasNext())
			result = iterator.next();

		return result;
	}
88455
def should_include_node(
        self, node: Union[FragmentSpreadNode, FieldNode, InlineFragmentNode]
    ) -> bool:
        
        skip = get_directive_values(GraphQLSkipDirective, node, self.variable_values)
        if skip and skip["if"]:
            return False

        include = get_directive_values(
            GraphQLIncludeDirective, node, self.variable_values
        )
        if include and not include["if"]:
            return False

        return True
856919
public function detectConflicts()
    {
        $conflicts = [];
        $apps = $this->graph->getLeafNodes();
        foreach ($apps as $name => $latest) {
            if (count($latest) > 1) {
                $conflicts[$name] = $latest;
            }
        }

        return $conflicts;
    }
822737
public static Map<IssueCategoryModel, List<ProblemSummary>> getProblemSummaries(
            GraphContext graphContext,
            Set<ProjectModel> projectModels,
            Set<String> includeTags,
            Set<String> excludeTags)
    {
        return getProblemSummaries(graphContext, projectModels, includeTags, excludeTags, false, false);
    }
936074
private Set<SNode> getMatchedNodes(SDocumentGraph graph) {

    Set<SNode> matchedNodes = new HashSet<>();

    for (SNode node: graph.getNodes()) {
       if (node.getFeature(AnnisConstants.ANNIS_NS, AnnisConstants.FEAT_MATCHEDNODE) != null)
         matchedNodes.add(node);
    }

    return matchedNodes;
  }
102404
public boolean isIntersecting(Collection<RangeSet>  rangeSets)
    {
        for (RangeSet rs : rangeSets)
        {
            for (CharRange r1 : rs)
            {
                for (CharRange r2 : this)
                {
                    if (r1.intersect(r2))
                    {
                        return true;
                    }
                }
            }
        }
        return false;
    }
1041706
public BugSet query(BugAspects a) {
        BugSet result = this;
        for (SortableValue sp : a) {
            result = result.query(sp);
        }

        return result;
    }
1116350
@Override
  public boolean intersects(IVersionRange yourRange)
  {
    // The set has explicit versions, so just check these against the supplied range
    for (IVersion version : set) {
      if (yourRange.contains(version)) {
        return true;
      }
    }
    return false;
  }
602764
def find_conflicts_between_sub_selection_sets(
    context: ValidationContext,
    cached_fields_and_fragment_names: Dict,
    compared_fragment_pairs: "PairSet",
    are_mutually_exclusive: bool,
    parent_type1: Optional[GraphQLNamedType],
    selection_set1: SelectionSetNode,
    parent_type2: Optional[GraphQLNamedType],
    selection_set2: SelectionSetNode,
) -> List[Conflict]:
    
    conflicts: List[Conflict] = []

    field_map1, fragment_names1 = get_fields_and_fragment_names(
        context, cached_fields_and_fragment_names, parent_type1, selection_set1
    )
    field_map2, fragment_names2 = get_fields_and_fragment_names(
        context, cached_fields_and_fragment_names, parent_type2, selection_set2
    )

    # (H) First, collect all conflicts between these two collections of field.
    collect_conflicts_between(
        context,
        conflicts,
        cached_fields_and_fragment_names,
        compared_fragment_pairs,
        are_mutually_exclusive,
        field_map1,
        field_map2,
    )

    # (I) Then collect conflicts between the first collection of fields and those
    # referenced by each fragment name associated with the second.
    if fragment_names2:
        compared_fragments: Set[str] = set()
        for fragment_name2 in fragment_names2:
            collect_conflicts_between_fields_and_fragment(
                context,
                conflicts,
                cached_fields_and_fragment_names,
                compared_fragments,
                compared_fragment_pairs,
                are_mutually_exclusive,
                field_map1,
                fragment_name2,
            )

    # (I) Then collect conflicts between the second collection of fields and those
    # referenced by each fragment name associated with the first.
    if fragment_names1:
        compared_fragments = set()
        for fragment_name1 in fragment_names1:
            collect_conflicts_between_fields_and_fragment(
                context,
                conflicts,
                cached_fields_and_fragment_names,
                compared_fragments,
                compared_fragment_pairs,
                are_mutually_exclusive,
                field_map2,
                fragment_name1,
            )

    # (J) Also collect conflicts between any fragment names by the first and fragment
    # names by the second. This compares each item in the first set of names to each
    # item in the second set of names.
    for fragment_name1 in fragment_names1:
        for fragment_name2 in fragment_names2:
            collect_conflicts_between_fragments(
                context,
                conflicts,
                cached_fields_and_fragment_names,
                compared_fragment_pairs,
                are_mutually_exclusive,
                fragment_name1,
                fragment_name2,
            )

    return conflicts
471757
def get_fields_and_fragment_names(
    context: ValidationContext,
    cached_fields_and_fragment_names: Dict,
    parent_type: Optional[GraphQLNamedType],
    selection_set: SelectionSetNode,
) -> Tuple[NodeAndDefCollection, List[str]]:
    
    cached = cached_fields_and_fragment_names.get(selection_set)
    if not cached:
        node_and_defs: NodeAndDefCollection = {}
        fragment_names: Dict[str, bool] = {}
        collect_fields_and_fragment_names(
            context, parent_type, selection_set, node_and_defs, fragment_names
        )
        cached = (node_and_defs, list(fragment_names))
        cached_fields_and_fragment_names[selection_set] = cached
    return cached
138355
def add_selection(self, selection, conflict = 'warning'):
		
		selection = selection.replace(' ', '').replace('=.', '=0.')
		if not selection:
			return
		if selection.count(',') or selection.count('_'):
			raise VersionFormatError(('Version string "{0:s}" is incorrect. Perhaps you\'re trying to add a combined one; ' +
				'you should use add_selections for that').format(selection))
		if selection.count('.') > 1:
			raise VersionFormatError(('Version string "{0:s}" is incorrect. Perhaps it contains a version longer than 2 numbers ' +
				'(e.g. "3.14)" which is intentionally not supported. Version numbers beyond the second are for bugfixes only.').format(selection))
		regex = r'^([><=]=?)(\d+|\*)(?:\.(\d*|\*))?$'
		found = findall(regex, selection)
		if not found:
			raise VersionFormatError('Version string "{0:s}" not properly formatted according to "{1:s}".'.format(selection, regex))
		operation, majorstr, minorstr = found[0]
		if majorstr == '*':
			return
		major = int(majorstr)
		if minorstr == '*':
			self.update_values(conflict=conflict,
				min = self.to_nr(major, 0),
				max = self.to_nr(major + 1, 0) - 1,
			)
			return
		exclusive = int(not operation.endswith('='))
		major_only = int(not minorstr)
		nr = self.to_nr(major, int(minorstr or 0))
		if operation.startswith('='):
			self.update_values(conflict=conflict,
				min = nr,
				max = nr + major_only * self.limit - major_only,
			)
		elif operation.startswith('<'):
			self.update_values(conflict=conflict,
				max = nr - exclusive + (not exclusive) * (major_only * self.limit - major_only),
			)
		elif operation.startswith('>'):
			self.update_values(conflict=conflict,
				min = nr + exclusive + exclusive * (major_only * self.limit - major_only),
			)
		else:
			raise VersionFormatError('Version (in)equality operator "{0:s}" not recognized. ' +
				'Full operation "{1:s}"'.format(operation, selection))
406702
def check_conflicts(self):
        """"""
        conflicts = []
        if len(self._qsequences) == 0:
            return conflicts

        new_qsequence = self.new_qsequence
        for shortcut in self.shortcuts:
            shortcut_qsequence = QKeySequence.fromString(str(shortcut.key))
            if shortcut_qsequence.isEmpty():
                continue
            if (shortcut.context, shortcut.name) == (self.context, self.name):
                continue
            if shortcut.context in [self.context, '_'] or self.context == '_':
                if (shortcut_qsequence.matches(new_qsequence) or
                        new_qsequence.matches(shortcut_qsequence)):
                    conflicts.append(shortcut)
        return conflicts
334782
public void intersect(Collection<? extends Range> ranges) {
		Ranges targetRanges;
		if (ranges instanceof Ranges) {
			targetRanges = (Ranges) ranges;
		} else {
			targetRanges = new Ranges(ranges);
		}

		List<Range> newList = new ArrayList<>();
		for (Iterator<? extends Range> iterator = this.ranges.iterator(); iterator.hasNext();) {
			Range r = iterator.next();
			List<Range> hasIntersections = getHasIntersections(targetRanges, r);
			if (hasIntersections.isEmpty()) {
				iterator.remove();
			} else {
				if (hasIntersections.size() == 1) {
					Range target = hasIntersections.get(0);
					if (r.equals(target)) {
						continue;
					}
				}
				iterator.remove();
				for (Range rangeHasIntersection : hasIntersections) {
					newList.add(rangeHasIntersection.intersection(r));
				}
			}
		}
		addAll(newList);
	}