nus-yam/ex-repair huggingface dataset:
Program: 93661
Project: 93661
Buggy source:
private static Rectangle getBounds(TableItem tableItem){
  Rectangle tableBounds=tableItem.getParent().getBounds();
  Rectangle itemBounds=tableItem.getBounds();
  Rectangle fill=new Rectangle(0,0,0,0);
  fill.x=2;
  fill.y=itemBounds.y + 2;
  fill.width=tableBounds.width - 6;
  fill.height=itemBounds.height - 3;
  return fill;
}

Fixed version (ground truth):
private static Rectangle getBounds(Event event){
  TableItem tableItem=(TableItem)event.item;
  Table table=tableItem.getParent();
  Rectangle tableBounds=table.getClientArea();
  Rectangle itemBounds=tableItem.getBounds();
  Rectangle fill=new Rectangle(0,0,0,0);
  fill.x=2;
  fill.y=itemBounds.y + 2;
  fill.width=tableBounds.width - 6;
  fill.height=itemBounds.height - 3;
  final GC g=event.gc;
  int columnCount=table.getColumnCount();
  if (event.index == columnCount - 1 || columnCount == 0) {
    int width=tableBounds.x + tableBounds.width - event.x;
    if (width > 0) {
      Region region=new Region();
      g.getClipping(region);
      region.add(event.x,event.y,width,event.height);
      g.setClipping(region);
      region.dispose();
    }
  }
  g.setAdvanced(true);
  return fill;
}
Program: 93662
Project: 93662
Buggy source:
private void handleEraseItemEvent(Event event){
  TableItem tableItem=(TableItem)event.item;
  Object data=tableItem.getData();
  boolean specialPaint=false;
  if (data instanceof DiffInsertionPoint) {
    DiffInsertionPoint insertionPoint=(DiffInsertionPoint)data;
    paintItemDiffBox(event,insertionPoint.getDiff(),getBoundsForInsertionPoint(tableItem));
    specialPaint=true;
  }
 else   if (fInput != null) {
    for (    Diff diff : fInput.getDiffFromThisSide()) {
      if (fInput.getValue(diff) == data) {
        paintItemDiffBox(event,diff,getBounds(tableItem));
        specialPaint=true;
      }
    }
    if (getSide() == MergeViewerSide.ANCESTOR) {
      for (      Diff diff : fInput.getDiffFromAncestor()) {
        if (fInput.getValue(diff) == data) {
          paintItemDiffBox(event,diff,getBounds(tableItem));
          specialPaint=true;
        }
      }
    }
  }
  if (!specialPaint) {
    paintItem(event,tableItem);
  }
}

Fixed version (ground truth):
private void handleEraseItemEvent(Event event){
  TableItem tableItem=(TableItem)event.item;
  Object data=tableItem.getData();
  boolean specialPaint=false;
  if (data instanceof DiffInsertionPoint) {
    DiffInsertionPoint insertionPoint=(DiffInsertionPoint)data;
    paintItemDiffBox(event,insertionPoint.getDiff(),getBoundsForInsertionPoint(event));
    specialPaint=true;
  }
 else   if (fInput != null) {
    for (    Diff diff : fInput.getDiffFromThisSide()) {
      if (fInput.getValue(diff) == data) {
        paintItemDiffBox(event,diff,getBounds(event));
        specialPaint=true;
      }
    }
    if (getSide() == MergeViewerSide.ANCESTOR) {
      for (      Diff diff : fInput.getDiffFromAncestor()) {
        if (fInput.getValue(diff) == data) {
          paintItemDiffBox(event,diff,getBounds(event));
          specialPaint=true;
        }
      }
    }
  }
  if (!specialPaint) {
    paintItem(event);
  }
}
Program: 93663
Project: 93663
Buggy source:
/** 
 * @param event
 * @param tableItem
 */
private void paintItem(Event event,TableItem tableItem){
  event.detail&=~SWT.HOT;
  if (isSelected(event)) {
    Rectangle fill=getBounds(tableItem);
    drawSelectionBox(event,fill);
  }
}

Fixed version (ground truth):
/** 
 * @param event
 * @param tableItem
 */
private void paintItem(Event event){
  event.detail&=~SWT.HOT;
  if (isSelected(event)) {
    Rectangle fill=getBounds(event);
    drawSelectionBox(event,fill);
  }
}
Program: 93664
Project: 93664
Buggy source:
/** 
 * The diff engine expects this to return the set of attributes that need to be checked for differences for the given   {@link Match} element.<p> This default implementation assumes that all three sides of the match are conform to the same metamodel, and simply returns one of the side's  {@link EClass#getEAllAttributes() side.eClass().getEAllAttributes()}, ignoring only the derived. </p>
 * @param match The match for which we are trying to compute differences.
 * @return The set of attributes that are to be checked by the diff engine. May be an empty iterator, inwhich case no difference will be detected on any of this <code>match</code>'s attributes.
 */
public Iterator<EAttribute> getAttributesToCheck(Match match){
  final EClass clazz;
  if (match.getLeft() != null) {
    clazz=match.getLeft().eClass();
  }
 else   if (match.getRight() != null) {
    clazz=match.getRight().eClass();
  }
 else {
    clazz=match.getOrigin().eClass();
  }
  return Iterators.filter(clazz.getEAllAttributes().iterator(),new Predicate<EAttribute>(){
    public boolean apply(    EAttribute input){
      return input != null && !input.isDerived();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * The diff engine expects this to return the set of attributes that need to be checked for differences for the given   {@link Match} element.<p> This default implementation assumes that all three sides of the match are conform to the same metamodel, and simply returns one of the side's  {@link EClass#getEAllAttributes() side.eClass().getEAllAttributes()}, ignoring only the derived. </p>
 * @param match The match for which we are trying to compute differences.
 * @return The set of attributes that are to be checked by the diff engine. May be an empty iterator, inwhich case no difference will be detected on any of this <code>match</code>'s attributes.
 */
public Iterator<EAttribute> getAttributesToCheck(Match match){
  final EClass clazz;
  if (match.getLeft() != null) {
    clazz=match.getLeft().eClass();
  }
 else   if (match.getRight() != null) {
    clazz=match.getRight().eClass();
  }
 else {
    clazz=match.getOrigin().eClass();
  }
  return Iterators.filter(clazz.getEAllAttributes().iterator(),new Predicate<EAttribute>(){
    public boolean apply(    EAttribute input){
      return input != null && !input.isDerived() && !input.isTransient();
    }
  }
);
}
Program: 93665
Project: 93665
Buggy source:
/** 
 * The diff engine expects this to return the set of references that need to be checked for differences for the given   {@link Match} element.<p> This default implementation assumes that all three sides of the match are conform to the same metamodel, and simply returns one of the side's  {@link EClass#getEAllReferences() side.eClass().getEAllReferences()}, ignoring only the derived and container. </p>
 * @param match The match for which we are trying to compute differences.
 * @return The set of references that are to be checked by the diff engine. May be an empty iterator, inwhich case no difference will be detected on any of this <code>match</code>'s references.
 */
public Iterator<EReference> getReferencesToCheck(Match match){
  final EClass clazz;
  if (match.getLeft() != null) {
    clazz=match.getLeft().eClass();
  }
 else   if (match.getRight() != null) {
    clazz=match.getRight().eClass();
  }
 else {
    clazz=match.getOrigin().eClass();
  }
  return Iterators.filter(clazz.getEAllReferences().iterator(),new Predicate<EReference>(){
    public boolean apply(    EReference input){
      return input != null && !input.isDerived() && !input.isContainer() && input.getEType() != EcorePackage.eINSTANCE.getEGenericType();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * The diff engine expects this to return the set of references that need to be checked for differences for the given   {@link Match} element.<p> This default implementation assumes that all three sides of the match are conform to the same metamodel, and simply returns one of the side's  {@link EClass#getEAllReferences() side.eClass().getEAllReferences()}, ignoring only the derived and container. </p>
 * @param match The match for which we are trying to compute differences.
 * @return The set of references that are to be checked by the diff engine. May be an empty iterator, inwhich case no difference will be detected on any of this <code>match</code>'s references.
 */
public Iterator<EReference> getReferencesToCheck(Match match){
  final EClass clazz;
  if (match.getLeft() != null) {
    clazz=match.getLeft().eClass();
  }
 else   if (match.getRight() != null) {
    clazz=match.getRight().eClass();
  }
 else {
    clazz=match.getOrigin().eClass();
  }
  return Iterators.filter(clazz.getEAllReferences().iterator(),new Predicate<EReference>(){
    public boolean apply(    EReference input){
      return input != null && !input.isDerived() && !input.isContainer() && input.getEType() != EcorePackage.eINSTANCE.getEGenericType() && !input.isTransient();
    }
  }
);
}
Program: 93666
Project: 93666
Buggy source:
public boolean apply(EAttribute input){
  return input != null && !input.isDerived();
}

Fixed version (ground truth):
public boolean apply(EAttribute input){
  return input != null && !input.isDerived() && !input.isTransient();
}
Program: 93667
Project: 93667
Buggy source:
/** 
 * Checks the potential equivalence from the given <code>difference</code>.
 * @param comparison The comparison this engine is expected to complete.
 * @param difference The difference that is to be checked
 */
protected void checkForEquivalences(Comparison comparison,Diff difference){
  if (difference instanceof ReferenceChange && ((ReferenceChange)difference).getReference().getEOpposite() != null) {
    ReferenceChange diff=(ReferenceChange)difference;
    Equivalence equivalence=diff.getEquivalence();
    if (equivalence == null) {
      equivalence=CompareFactory.eINSTANCE.createEquivalence();
      comparison.getEquivalences().add(equivalence);
      equivalence.getDifferences().add(diff);
      Set<ReferenceChange> equivalentDifferences=ReferenceUtil.getCrossReferences(crossReferencerModelObjectsToDiffs,MatchUtil.getContainer(comparison,diff),ComparePackage.eINSTANCE.getReferenceChange_Value(),ReferenceChange.class);
      for (      ReferenceChange referenceChange : equivalentDifferences) {
        if (referenceChange.getReference().getEOpposite() != null && referenceChange.getReference().getEOpposite().equals(diff.getReference()) && diff.getValue().equals(MatchUtil.getContainer(comparison,referenceChange))) {
          equivalence.getDifferences().add(referenceChange);
          break;
        }
      }
      addChangesFromOrigin(comparison,diff,equivalence);
    }
  }
}

Fixed version (ground truth):
/** 
 * Checks the potential equivalence from the given <code>difference</code>.
 * @param comparison The comparison this engine is expected to complete.
 * @param difference The difference that is to be checked
 */
protected void checkForEquivalences(Comparison comparison,Diff difference){
  if (difference instanceof ReferenceChange && ((ReferenceChange)difference).getReference().getEOpposite() != null && !((ReferenceChange)difference).getReference().getEOpposite().isContainer() && !((ReferenceChange)difference).getReference().getEOpposite().isDerived()) {
    ReferenceChange diff=(ReferenceChange)difference;
    Equivalence equivalence=diff.getEquivalence();
    if (equivalence == null) {
      equivalence=CompareFactory.eINSTANCE.createEquivalence();
      comparison.getEquivalences().add(equivalence);
      equivalence.getDifferences().add(diff);
      Set<ReferenceChange> equivalentDifferences=ReferenceUtil.getCrossReferences(crossReferencerModelObjectsToDiffs,MatchUtil.getContainer(comparison,diff),ComparePackage.eINSTANCE.getReferenceChange_Value(),ReferenceChange.class);
      for (      ReferenceChange referenceChange : equivalentDifferences) {
        if (referenceChange.getReference().getEOpposite() != null && referenceChange.getReference().getEOpposite().equals(diff.getReference()) && diff.getValue().equals(MatchUtil.getContainer(comparison,referenceChange))) {
          equivalence.getDifferences().add(referenceChange);
          break;
        }
      }
      addChangesFromOrigin(comparison,diff,equivalence);
    }
  }
}
Program: 93668
Project: 93668
Buggy source:
/** 
 * From a <code>sourceDifference</code> (ADD) on a containment mono-valued reference, it retrieves a potential DELETE difference on the origin value.
 * @param comparison The comparison this engine is expected to complete.
 * @param sourceDifference The given difference.
 * @return The found differences.
 */
private Set<ReferenceChange> getDELOriginValueOnContainmentRefSingle(Comparison comparison,ReferenceChange sourceDifference){
  Set<ReferenceChange> result=new HashSet<ReferenceChange>();
  if (!sourceDifference.getReference().isMany()) {
    EObject originContainer=MatchUtil.getOriginContainer(comparison,sourceDifference);
    Object originValue=originContainer.eGet(sourceDifference.getReference());
    if (originValue instanceof EObject) {
      result=getDifferenceOnGivenObject((EObject)originValue,DifferenceKind.DELETE);
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * From a <code>sourceDifference</code> (ADD) on a containment mono-valued reference, it retrieves a potential DELETE difference on the origin value.
 * @param comparison The comparison this engine is expected to complete.
 * @param sourceDifference The given difference.
 * @return The found differences.
 */
private Set<ReferenceChange> getDELOriginValueOnContainmentRefSingle(Comparison comparison,ReferenceChange sourceDifference){
  Set<ReferenceChange> result=new HashSet<ReferenceChange>();
  if (!sourceDifference.getReference().isMany()) {
    EObject originContainer=MatchUtil.getOriginContainer(comparison,sourceDifference);
    if (originContainer != null) {
      Object originValue=originContainer.eGet(sourceDifference.getReference());
      if (originValue instanceof EObject) {
        result=getDifferenceOnGivenObject((EObject)originValue,DifferenceKind.DELETE);
      }
    }
  }
  return result;
}
Program: 93669
Project: 93669
Buggy source:
/** 
 * From a <code>sourceDifference</code> (DELETE) on a containment reference, it retrieves potential DELETE differences on the outgoing references from the value object of the <code>sourceDifference</code>.
 * @param comparison The comparison this engine is expected to complete.
 * @param sourceDifference The given difference.
 * @return The found differences.
 */
private Set<ReferenceChange> getDELOutgoingReferences(Comparison comparison,ReferenceChange sourceDifference){
  Set<ReferenceChange> result=new HashSet<ReferenceChange>();
  EObject value=sourceDifference.getValue();
  List<EObject> outgoingReferences=value.eCrossReferences();
  for (  EObject outgoingRef : outgoingReferences) {
    Set<ReferenceChange> requiredDifferences=ReferenceUtil.getCrossReferences(crossReferencerModelObjectsToDiffs,outgoingRef,ComparePackage.eINSTANCE.getReferenceChange_Value(),ReferenceChange.class);
    for (    ReferenceChange diff : requiredDifferences) {
      if (!diff.getReference().isContainment() && (diff.getKind().equals(DifferenceKind.DELETE) || isChangeDelete(comparison,diff)) && value.eClass().getEAllReferences().contains(diff.getReference())) {
        result.add(diff);
        break;
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * From a <code>sourceDifference</code> (DELETE) on a containment reference, it retrieves potential DELETE differences on the outgoing references from the value object of the <code>sourceDifference</code>.
 * @param comparison The comparison this engine is expected to complete.
 * @param sourceDifference The given difference.
 * @return The found differences.
 */
private Set<ReferenceChange> getDELOutgoingReferences(Comparison comparison,ReferenceChange sourceDifference){
  Set<ReferenceChange> result=new HashSet<ReferenceChange>();
  EObject value=sourceDifference.getValue();
  final List<EObject> outgoingReferences=value.eCrossReferences();
  for (  EObject outgoingRef : outgoingReferences) {
    Set<ReferenceChange> requiredDifferences=ReferenceUtil.getCrossReferences(crossReferencerModelObjectsToDiffs,outgoingRef,ComparePackage.eINSTANCE.getReferenceChange_Value(),ReferenceChange.class);
    for (    ReferenceChange diff : requiredDifferences) {
      if (!diff.getReference().isContainment() && (diff.getKind().equals(DifferenceKind.DELETE) || isChangeDelete(comparison,diff)) && value.eClass().getEAllReferences().contains(diff.getReference())&& MatchUtil.getContainer(comparison,diff).equals(value)) {
        result.add(diff);
      }
    }
  }
  return result;
}
Program: 93670
Project: 93670
Buggy source:
/** 
 * Get the business model object containing the given <code>difference</code>.
 * @param comparison The comparison.
 * @param difference The difference.
 * @return The object.
 */
public static EObject getContainer(Comparison comparison,ReferenceChange difference){
  EObject result=null;
  final EObject obj=difference.getValue();
  Match valueMatch=comparison.getMatch(obj);
  if (valueMatch.getLeft() == obj) {
    result=difference.getMatch().getLeft();
  }
 else   if (valueMatch.getRight() == obj) {
    result=difference.getMatch().getRight();
  }
 else   if (valueMatch.getOrigin() == obj) {
    result=difference.getMatch().getOrigin();
  }
  return result;
}

Fixed version (ground truth):
public static EObject getContainer(Comparison comparison,Diff difference){
  if (difference instanceof AttributeChange) {
    return getContainer(comparison,(AttributeChange)difference);
  }
 else   if (difference instanceof ReferenceChange) {
    return getContainer(comparison,(ReferenceChange)difference);
  }
  return null;
}
Program: 93671
Project: 93671
Buggy source:
@DiffTest public void testIdentifierDiffTest(IComparisonScope scope,Comparison comparison){
  final List<Diff> differences=comparison.getDifferences();
  assertAdded(differences,"String_Node_Str",DifferenceSource.LEFT);
  assertAdded(differences,"String_Node_Str",DifferenceSource.LEFT);
  assertAdded(differences,"String_Node_Str",DifferenceSource.LEFT);
  assertAdded(differences,"String_Node_Str",DifferenceSource.LEFT);
  assertRemoved(differences,"String_Node_Str",DifferenceSource.LEFT);
  assertRemoved(differences,"String_Node_Str",DifferenceSource.LEFT);
  assertRemoved(differences,"String_Node_Str",DifferenceSource.LEFT);
  assertRemoved(differences,"String_Node_Str",DifferenceSource.LEFT);
}

Fixed version (ground truth):
@DiffTest public void testIdentifierDiffTest(IComparisonScope scope,Comparison comparison){
  final List<Diff> differences=comparison.getDifferences();
  assertAdded(differences,"String_Node_Str",DifferenceSource.LEFT);
  assertAdded(differences,"String_Node_Str",DifferenceSource.LEFT);
  assertAdded(differences,"String_Node_Str",DifferenceSource.LEFT);
  assertAdded(differences,"String_Node_Str",DifferenceSource.LEFT);
  assertRemoved(differences,"String_Node_Str",DifferenceSource.LEFT);
  assertRemoved(differences,"String_Node_Str",DifferenceSource.LEFT);
  assertRemoved(differences,"String_Node_Str",DifferenceSource.LEFT);
  assertChangedAttribute(differences,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",DifferenceSource.LEFT);
  assertChangedAttribute(differences,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",DifferenceSource.LEFT);
  if (comparison.isThreeWay()) {
    assertAdded(differences,"String_Node_Str",DifferenceSource.RIGHT);
    assertAdded(differences,"String_Node_Str",DifferenceSource.RIGHT);
    assertAdded(differences,"String_Node_Str",DifferenceSource.RIGHT);
    assertAdded(differences,"String_Node_Str",DifferenceSource.RIGHT);
    assertAdded(differences,"String_Node_Str",DifferenceSource.RIGHT);
    assertRemoved(differences,"String_Node_Str",DifferenceSource.RIGHT);
    assertRemoved(differences,"String_Node_Str",DifferenceSource.RIGHT);
    assertChangedReference(differences,"String_Node_Str","String_Node_Str",null,"String_Node_Str",DifferenceSource.RIGHT);
  }
 else {
    assertRemoved(differences,"String_Node_Str",DifferenceSource.LEFT);
    assertRemoved(differences,"String_Node_Str",DifferenceSource.LEFT);
    assertRemoved(differences,"String_Node_Str",DifferenceSource.LEFT);
    assertRemoved(differences,"String_Node_Str",DifferenceSource.LEFT);
    assertRemoved(differences,"String_Node_Str",DifferenceSource.LEFT);
    assertAdded(differences,"String_Node_Str",DifferenceSource.LEFT);
    assertAdded(differences,"String_Node_Str",DifferenceSource.LEFT);
  }
}
Program: 93672
Project: 93672
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.emf.compare.ui.viewer.AbstractOrderingAction#doRun(org.eclipse.emf.compare.ui.viewer.structure.ParameterizedStructureContentProvider)
 */
@Override protected void doRun(ParameterizedStructureContentProvider provider){
  final List<IDifferenceFilter> filters=new ArrayList<IDifferenceFilter>();
  filters.addAll(menu.getSelectedFilters());
  if (isChecked()) {
    filters.add(relatedFilter);
  }
 else {
    filters.remove(relatedFilter);
  }
  mViewer.getCompareConfiguration().setProperty(EMFCompareConstants.PROPERTY_STRUCTURE_FILTERS,filters);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.emf.compare.ui.viewer.AbstractOrderingAction#doRun(org.eclipse.emf.compare.ui.viewer.structure.ParameterizedStructureContentProvider)
 */
@Override protected void doRun(ParameterizedStructureContentProvider provider){
  final List<IDifferenceFilter> filters=new ArrayList<IDifferenceFilter>();
  if (isChecked()) {
    menu.getSelectedFilters().add(relatedFilter);
  }
 else {
    menu.getSelectedFilters().remove(relatedFilter);
  }
  filters.addAll(menu.getSelectedFilters());
  mViewer.getCompareConfiguration().setProperty(EMFCompareConstants.PROPERTY_STRUCTURE_FILTERS,filters);
}
Program: 93673
Project: 93673
Buggy source:
/** 
 * Sets the target of the given reference (The generic diff engine finds a target in the model, but stereotype values and features should apply to the "base" element of a diff).
 * @param updateReference {@link UpdateReference} from DiffModel.
 * @param ret {@link UpdateReference} which will be modified and return.
 * @see UMLUtil#getBaseElement(EObject)
 */
protected void setTargets(final UpdateReference updateReference,final UpdateReference ret){
  final EStructuralFeature reference=updateReference.getReference();
  final EObject diffRightTarget=updateReference.getRightTarget();
  final EObject rightTargetBase=UMLUtil.getBaseElement(diffRightTarget);
  if (rightTargetBase != null && rightTargetBase.eGet(reference) != null) {
    ret.setRightTarget(rightTargetBase);
  }
  final EObject diffLeftTarget=updateReference.getLeftTarget();
  final EObject leftTargetBase=UMLUtil.getBaseElement(diffLeftTarget);
  if (leftTargetBase != null && leftTargetBase.eGet(reference) != null) {
    ret.setLeftTarget(leftTargetBase);
  }
}

Fixed version (ground truth):
/** 
 * Sets the target of the given reference (The generic diff engine finds a target in the model, but stereotype values and features should apply to the "base" element of a diff).
 * @param updateReference {@link UpdateReference} from DiffModel.
 * @param ret {@link UpdateReference} which will be modified and return.
 * @see UMLUtil#getBaseElement(EObject)
 */
protected void setTargets(final UpdateReference updateReference,final UpdateReference ret){
  final EStructuralFeature reference=updateReference.getReference();
  final EObject rightTarget=updateReference.getRightTarget();
  final EObject rightTargetBase=UMLUtil.getBaseElement(rightTarget);
  if (rightTargetBase != null && rightTargetBase.eGet(reference) != null) {
    ret.setRightTarget(rightTargetBase);
  }
 else {
    ret.setRightTarget(rightTarget);
  }
  final EObject leftTarget=updateReference.getLeftTarget();
  final EObject leftTargetBase=UMLUtil.getBaseElement(leftTarget);
  if (leftTargetBase != null && leftTargetBase.eGet(reference) != null) {
    ret.setLeftTarget(leftTargetBase);
  }
 else {
    ret.setLeftTarget(leftTarget);
  }
}
Program: 93676
Project: 93676
Buggy source:
/** 
 * Checks if the given difference   {@link dest} is a good candidate to be added as required difference thespecified difference  {@link origin}. A good candidate is a   {@link ModelElementChange} which is not an{@link AbstractDiffExtension}.
 * @param origin The difference to fill.
 * @param dest The difference candidate.
 */
private static void linkDifferences(final DiffElement origin,final EObject dest){
  if (dest instanceof ModelElementChange && !(dest instanceof AbstractDiffExtension)) {
    final ModelElementChange mec=(ModelElementChange)dest;
    origin.getRequires().add(mec);
  }
}

Fixed version (ground truth):
/** 
 * Checks if the given difference   {@link dest} is a good candidate to be added as required difference thespecified difference  {@link origin}. A good candidate is a   {@link ModelElementChange} which is not an{@link AbstractDiffExtension}.
 * @param origin The difference to fill.
 * @param dest The difference candidate.
 */
private static void linkDifferences(final DiffElement origin,final EObject dest){
  if (dest instanceof ModelElementChange && !(dest instanceof AbstractDiffExtension)) {
    final ModelElementChange mec=(ModelElementChange)dest;
    origin.getRequires().add(mec);
    if (origin instanceof UpdateReference) {
      final UpdateReference updateDiff=(UpdateReference)origin;
      final EObject changedElement;
      if (mec instanceof ModelElementChangeLeftTarget) {
        changedElement=((ModelElementChangeLeftTarget)mec).getLeftElement();
      }
 else {
        changedElement=((ModelElementChangeRightTarget)mec).getRightElement();
      }
      if (updateDiff.getLeftTarget() == changedElement) {
        updateDiff.setLeftTarget(null);
      }
 else       if (updateDiff.getRightTarget() == changedElement) {
        updateDiff.setRightTarget(null);
      }
    }
  }
}
Program: 93677
Project: 93677
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.emf.compare.uml2.diff.internal.extension.IDiffExtensionFactory#create(org.eclipse.emf.compare.diff.metamodel.DiffElement,org.eclipse.emf.ecore.util.EcoreUtil.CrossReferencer)
 */
public AbstractDiffExtension create(DiffElement input,EcoreUtil.CrossReferencer crossReferencer){
  final UpdateReference updateReference=(UpdateReference)input;
  final EObject leftElement=updateReference.getLeftElement();
  final EObject rightElement=updateReference.getRightElement();
  final EObject leftBase=UMLUtil.getBaseElement(leftElement);
  final EObject rightBase=UMLUtil.getBaseElement(rightElement);
  final UMLStereotypeUpdateReference ret=UML2DiffFactory.eINSTANCE.createUMLStereotypeUpdateReference();
  ret.setStereotype(UMLUtil.getStereotype(rightElement));
  ret.setRemote(input.isRemote());
  ret.setReference(updateReference.getReference());
  ret.setLeftElement(leftBase);
  ret.setRightElement(rightBase);
  ret.setRightTarget(updateReference.getRightTarget());
  ret.setLeftTarget(updateReference.getLeftTarget());
  ret.getHideElements().add(input);
  ret.getRequires().add(input);
  return ret;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.emf.compare.uml2.diff.internal.extension.IDiffExtensionFactory#create(org.eclipse.emf.compare.diff.metamodel.DiffElement,org.eclipse.emf.ecore.util.EcoreUtil.CrossReferencer)
 */
public AbstractDiffExtension create(DiffElement input,EcoreUtil.CrossReferencer crossReferencer){
  final UpdateReference updateReference=(UpdateReference)input;
  final EObject leftElement=updateReference.getLeftElement();
  final EObject rightElement=updateReference.getRightElement();
  final EObject leftBase=UMLUtil.getBaseElement(leftElement);
  final EObject rightBase=UMLUtil.getBaseElement(rightElement);
  final UMLStereotypeUpdateReference ret=UML2DiffFactory.eINSTANCE.createUMLStereotypeUpdateReference();
  ret.setStereotype(UMLUtil.getStereotype(rightElement));
  ret.setRemote(input.isRemote());
  ret.setReference(updateReference.getReference());
  ret.setLeftElement(leftBase);
  ret.setRightElement(rightBase);
  setTargets(updateReference,ret);
  ret.getHideElements().add(input);
  ret.getRequires().add(input);
  return ret;
}
Program: 93678
Project: 93678
Buggy source:
/** 
 * Create a condition for emf query out of an ocl condition having an expression and optionally checking also the type.
 * @param condition An OCL condition containing an expression and information whether to also check the type.
 * @return A condition for EMF query or <code>null</code>, if the condition could not be created e.g. because theexpression was not parseable.
 */
public static EObjectCondition getWhereCondition(OclCondition condition){
  String key=condition.getElementReference().getType().getInstanceClassName() + (condition.isCheckType() ? "String_Node_Str" : "String_Node_Str") + condition.getExpression();
  EObjectCondition whereCondition=cachedConditions.get(key);
  if (whereCondition == null) {
    OCLHelper<EClassifier,?,?,?> helper=ocl.createOCLHelper();
    helper.setContext(condition.getElementReference().getType());
    Query<EClassifier,EClass,EObject> query;
    try {
      final OCLExpression<EClassifier> oclExpression=helper.createQuery(condition.getExpression());
      query=ocl.createQuery(oclExpression);
    }
 catch (    final ParserException e) {
      Activator.getDefault().logError("String_Node_Str" + condition.getExpression(),e);
      return null;
    }
    whereCondition=new BooleanOCLCondition<EClassifier,EClass,EObject>(ocl.getEnvironment(),query,condition.isCheckType() ? condition.getElementReference().getType() : null,PruneHandler.NEVER);
    cachedConditions.put(key,whereCondition);
  }
  return whereCondition;
}

Fixed version (ground truth):
/** 
 * Create a condition for emf query out of an ocl condition having an expression and optionally checking also the type.
 * @param condition An OCL condition containing an expression and information whether to also check the type.
 * @return A condition for EMF query or <code>null</code>, if the condition could not be created e.g. because theexpression was not parseable.
 */
public static EObjectCondition getWhereCondition(OclCondition condition){
  String key=condition.getElementReference().getType().getInstanceClassName() + (condition.isCheckType() ? "String_Node_Str" : "String_Node_Str") + condition.getExpression();
  EObjectCondition whereCondition=cachedConditions.get(key);
  if (whereCondition == null) {
    OCLHelper<EClassifier,?,?,?> helper=ocl.createOCLHelper();
    helper.setContext(condition.getElementReference().getType());
    Query<EClassifier,EClass,EObject> query;
    try {
      final String expression=condition.getExpression().replace("String_Node_Str","String_Node_Str");
      final OCLExpression<EClassifier> oclExpression=helper.createQuery(expression);
      query=ocl.createQuery(oclExpression);
    }
 catch (    final ParserException e) {
      Activator.getDefault().logError("String_Node_Str" + condition.getExpression(),e);
      return null;
    }
    whereCondition=new BooleanOCLCondition<EClassifier,EClass,EObject>(ocl.getEnvironment(),query,condition.isCheckType() ? condition.getElementReference().getType() : null,PruneHandler.NEVER);
    cachedConditions.put(key,whereCondition);
  }
  return whereCondition;
}
Program: 93679
Project: 93679
Buggy source:
/** 
 * Check the validity of all ocl expressions by parsing them.
 * @param mpatch MPatch.
 */
public static void checkOclExpressions(MPatchModel mpatch){
  final List<EObject> oclConditions=ExtEcoreUtils.collectTypedElements(mpatch.getChanges(),Collections.singleton(SymrefsPackage.Literals.OCL_CONDITION),true);
  for (  EObject eObject : oclConditions) {
    if (eObject instanceof OclCondition) {
      OclCondition oclCondition=(OclCondition)eObject;
      final EObjectCondition condition=OCLConditionHelper.getWhereCondition(oclCondition);
      if (condition == null)       OCLConditionHelper.getWhereCondition(oclCondition);
      assertNotNull("String_Node_Str" + oclCondition.getExpression(),condition);
    }
 else     fail("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Check the validity of all ocl expressions by parsing them.
 * @param mpatch MPatch.
 */
public static void checkOclExpressions(MPatchModel mpatch){
  final List<EObject> oclConditions=ExtEcoreUtils.collectTypedElements(mpatch.getChanges(),Collections.singleton(SymrefsPackage.Literals.OCL_CONDITION),true);
  for (  EObject eObject : oclConditions) {
    if (eObject instanceof OclCondition) {
      OclCondition oclCondition=(OclCondition)eObject;
      final EObjectCondition condition=OCLConditionHelper.getWhereCondition(oclCondition);
      assertNotNull("String_Node_Str" + oclCondition.getExpression(),condition);
    }
 else {
      fail("String_Node_Str");
    }
  }
}
Program: 93680
Project: 93680
Buggy source:
/** 
 * main mapping: an emfdiff diffmodel is mapped to an mpatch
 */
protected MPatchModel toMPatchModel(DiffModel diffModel){
  if (diffModel.getLeftRoots().isEmpty() || diffModel.getRightRoots().isEmpty()) {
    log("String_Node_Str",diffModel);
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!diffModel.getAncestorRoots().isEmpty()) {
    log("String_Node_Str",diffModel);
    throw new IllegalArgumentException("String_Node_Str");
  }
  final MPatchModel mpatch=MPatchFactory.eINSTANCE.createMPatchModel();
  final List<String> leftUris=new ArrayList<String>();
  final List<String> rightUris=new ArrayList<String>();
  for (  EObject left : diffModel.getLeftRoots())   leftUris.add(lib.toUriString(left.eResource()));
  for (  EObject right : diffModel.getRightRoots())   rightUris.add(lib.toUriString(right.eResource()));
  mpatch.setNewModel(CommonUtils.join(leftUris,"String_Node_Str"));
  mpatch.setOldModel(CommonUtils.join(rightUris,"String_Node_Str"));
  mpatch.setEmfdiff(lib.toUriString(diffModel.eResource()));
  final List<EObject> diffElements=ExtEcoreUtils.collectTypedElements(diffModel.getOwnedElements(),Collections.singleton(DiffPackage.Literals.DIFF_ELEMENT),true);
  for (  EObject diffElement : diffElements) {
    if (!(diffElement instanceof DiffGroup)) {
      mpatch.getChanges().add(toIndepChange((DiffElement)diffElement));
    }
  }
  log(mpatch.getChanges().size() + "String_Node_Str",null);
  return mpatch;
}

Fixed version (ground truth):
/** 
 * main mapping: an emfdiff diffmodel is mapped to an mpatch
 */
protected MPatchModel toMPatchModel(DiffModel diffModel){
  if (diffModel.getLeftRoots().isEmpty() || diffModel.getRightRoots().isEmpty()) {
    log("String_Node_Str",diffModel);
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!diffModel.getAncestorRoots().isEmpty()) {
    log("String_Node_Str",diffModel);
    throw new IllegalArgumentException("String_Node_Str");
  }
  final MPatchModel mpatch=MPatchFactory.eINSTANCE.createMPatchModel();
  final List<String> leftUris=new ArrayList<String>();
  final List<String> rightUris=new ArrayList<String>();
  for (  EObject left : diffModel.getLeftRoots())   leftUris.add(lib.toUriString(left.eResource()));
  for (  EObject right : diffModel.getRightRoots())   rightUris.add(lib.toUriString(right.eResource()));
  mpatch.setNewModel(CommonUtils.join(leftUris,"String_Node_Str"));
  mpatch.setOldModel(CommonUtils.join(rightUris,"String_Node_Str"));
  mpatch.setEmfdiff(lib.toUriString(diffModel.eResource()));
  final List<EObject> diffElements=ExtEcoreUtils.collectTypedElements(diffModel.getOwnedElements(),Collections.singleton(DiffPackage.Literals.DIFF_ELEMENT),true);
  for (  EObject diffElement : diffElements) {
    if (shallTransform((DiffElement)diffElement)) {
      mpatch.getChanges().add(toIndepChange((DiffElement)diffElement));
    }
  }
  log(mpatch.getChanges().size() + "String_Node_Str",null);
  return mpatch;
}
Program: 93681
Project: 93681
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.jface.wizard.Wizard#addPages()
 */
@Override public void addPages(){
  final String fileName=file == null ? "String_Node_Str" + MPatchConstants.FILE_EXTENSION_MPATCH : file.getName();
  page=new EmfdiffExportWizardPage(MPatchConstants.MPATCH_LONG_NAME + "String_Node_Str",new StructuredSelection(file));
  page.setTitle(MPatchConstants.MPATCH_LONG_NAME);
  page.setDescription("String_Node_Str" + MPatchConstants.MPATCH_LONG_NAME + "String_Node_Str");
  page.setFileName(fileName);
  addPage(page);
  super.addPages();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.jface.wizard.Wizard#addPages()
 */
@Override public void addPages(){
  final String fileName=file == null ? "String_Node_Str" + MPatchConstants.FILE_EXTENSION_MPATCH : file.getName();
  page=new EmfdiffExportWizardPage(MPatchConstants.MPATCH_LONG_NAME + "String_Node_Str",file == null ? StructuredSelection.EMPTY : new StructuredSelection(file));
  page.setTitle(MPatchConstants.MPATCH_LONG_NAME);
  page.setDescription("String_Node_Str" + MPatchConstants.MPATCH_LONG_NAME + "String_Node_Str");
  page.setFileName(fileName);
  addPage(page);
  super.addPages();
}
Program: 93682
Project: 93682
Buggy source:
/** 
 * This will initialize the core preferences to their default values.
 */
private void initializeDefaultPreferences(){
  final IEclipsePreferences defaultCorePreferences=new DefaultScope().getNode(PLUGIN_ID);
  defaultCorePreferences.putInt(EMFComparePreferenceConstants.PREFERENCES_KEY_SEARCH_WINDOW,EMFComparePreferenceConstants.PREFERENCES_DEFAULT_SEARCH_WINDOW);
}

Fixed version (ground truth):
/** 
 * This will initialize the core preferences to their default values.
 */
private void initializeDefaultPreferences(){
  final IEclipsePreferences defaultCorePreferences=DefaultScope.INSTANCE.getNode(PLUGIN_ID);
  defaultCorePreferences.putInt(EMFComparePreferenceConstants.PREFERENCES_KEY_SEARCH_WINDOW,EMFComparePreferenceConstants.PREFERENCES_DEFAULT_SEARCH_WINDOW);
}
Program: 93685
Project: 93685
Buggy source:
/** 
 * Check that all changes are resolved to the correct elements which represent either the state before or after the change. For example for an attribute change, check that the actual attribute exists having the value either before of after the change. The result is stored in   {@link ResolvedSymbolicReferences#getValidation()}. Note that   {@link UnknownChange}s are not allowed at all!
 * @param mapping The resolved mapping
 * @param strict If strict is <code>true</code>, then the property is checked for all resolved corresponding elements. E.g. in case of an attribute change, the value of the state before must exist for all corresponding elements. If <code>strict = false</code>, then just one elements must at least fulfill the precondition.
 */
static void validateElementStates(ResolvedSymbolicReferences mapping,boolean strict){
  final boolean forward=mapping.getDirection() == ResolvedSymbolicReferences.RESOLVE_UNCHANGED;
  final List<IndepChange> orderedChanges=orderChanges(mapping.getResolutionByChange().keySet(),!forward);
  for (  IndepChange change : orderedChanges) {
    final ValidationResult state=validateElementState(change,mapping,strict,forward);
    mapping.getValidation().put(change,state);
  }
}

Fixed version (ground truth):
/** 
 * Check that all changes are resolved to the correct elements which represent either the state before or after the change. For example for an attribute change, check that the actual attribute exists having the value either before of after the change. The result is stored in   {@link ResolvedSymbolicReferences#getValidation()}. Note that   {@link UnknownChange}s are not allowed at all!
 * @param mapping The resolved mapping
 * @param strict If strict is <code>true</code>, then the property is checked for all resolved corresponding elements. E.g. in case of an attribute change, the value of the state before must exist for all corresponding elements. If <code>strict = false</code>, then just one elements must at least fulfill the precondition.
 */
static void validateElementStates(ResolvedSymbolicReferences mapping,boolean strict){
  final boolean forward=mapping.getDirection() == ResolvedSymbolicReferences.RESOLVE_UNCHANGED;
  mapping.getValidation().clear();
  final List<IndepChange> orderedChanges=orderChanges(mapping.getResolutionByChange().keySet(),!forward);
  for (  IndepChange change : orderedChanges) {
    final ValidationResult state=validateElementState(change,mapping,strict,forward);
    mapping.getValidation().put(change,state);
  }
}
Program: 93686
Project: 93686
Buggy source:
/** 
 * Build the best checker depending on the options.
 */
private void prepareChecker(){
  if (!structuredOptions.shouldMatchDistinctMetamodels()) {
    checker=new DistinctEcoreSimilarityChecker(filter);
  }
 else {
    checker=new StatisticBasedSimilarityChecker(filter);
  }
  if (!structuredOptions.isIgnoringID()) {
    checker=new EcoreIDSimilarityChecker(filter);
  }
 else   if (!structuredOptions.isIgnoringXMIID()) {
    checker=new XMIIDSimilarityChecker(filter);
  }
}

Fixed version (ground truth):
/** 
 * Build the best checker depending on the options.
 */
private void prepareChecker(){
  if (!structuredOptions.shouldMatchDistinctMetamodels()) {
    checker=new DistinctEcoreSimilarityChecker(filter);
  }
 else {
    checker=new StatisticBasedSimilarityChecker(filter);
  }
  if (!structuredOptions.isIgnoringID()) {
    checker=new EcoreIDSimilarityChecker(filter);
  }
  if (!structuredOptions.isIgnoringXMIID()) {
    checker=new XMIIDSimilarityChecker(filter);
  }
}
Program: 93689
Project: 93689
Buggy source:
/** 
 * This will iterate through all the features stored via   {@link #processEObject(EObject)} and populatesthe  {@link #unusedFeatures unused features list}.
 */
private void buildUnusedFeatures(){
  unusedFeatures=new ArrayList<EStructuralFeature>();
  final Iterator<String> it=featuresToInformation.keySet().iterator();
  while (it.hasNext()) {
    final String feat=it.next();
    if (featuresToInformation.get(feat).hasUniqueValue())     unusedFeatures.add(featuresToInformation.get(feat).getFeature());
  }
}

Fixed version (ground truth):
/** 
 * This will iterate through all the features stored via   {@link #processEObject(EObject)} and populatesthe  {@link #unusedFeatures unused features list}.
 */
private void buildUnusedFeatures(){
  unusedFeatures=new ArrayList<EStructuralFeature>();
  final Iterator<EStructuralFeature> it=featuresToInformation.keySet().iterator();
  while (it.hasNext()) {
    final EStructuralFeature feat=it.next();
    if (featuresToInformation.get(feat).hasUniqueValue())     unusedFeatures.add(featuresToInformation.get(feat).getFeature());
  }
}
Program: 93690
Project: 93690
Buggy source:
/** 
 * Iterates through all the   {@link EStructuralFeature features} of a given {@link EObject} and populatesthe  {@link #featuresToInformation known features list} for later use.
 * @param eObj {@link EObject} we need to parse for feature information.
 */
private void processEObject(EObject eObj){
  final Iterator<EStructuralFeature> featIt=eObj.eClass().getEAllStructuralFeatures().iterator();
  while (featIt.hasNext()) {
    final EStructuralFeature feat=featIt.next();
    final StringBuilder key=new StringBuilder();
    key.append(feat.hashCode());
    key.append(eObj.eClass().getName());
    if (!featuresToInformation.containsKey(key.toString())) {
      featuresToInformation.put(key.toString(),new FeatureInformation(feat));
    }
    try {
      if (EFactory.eGet(eObj,feat.getName()) != null) {
        featuresToInformation.get(key.toString()).processValue(eObj.eGet(feat).toString());
      }
 else {
        featuresToInformation.get(key.toString()).processValue("String_Node_Str");
      }
    }
 catch (    FactoryException e) {
      EMFComparePlugin.log(e.getMessage(),false);
    }
  }
}

Fixed version (ground truth):
/** 
 * Iterates through all the   {@link EStructuralFeature features} of a given {@link EObject} and populatesthe  {@link #featuresToInformation known features list} for later use.
 * @param eObj {@link EObject} we need to parse for feature information.
 */
private void processEObject(EObject eObj){
  final Iterator<EStructuralFeature> featIt=eObj.eClass().getEAllStructuralFeatures().iterator();
  while (featIt.hasNext()) {
    final EStructuralFeature feat=featIt.next();
    if (!feat.isDerived()) {
      if (!featuresToInformation.containsKey(feat)) {
        featuresToInformation.put(feat,new FeatureInformation(feat));
      }
      final Object value=eObj.eGet(feat);
      final FeatureInformation featureInformation=featuresToInformation.get(feat);
      if (feat instanceof EReference) {
        if (feat.isMany()) {
          final Collection<EObject> values=(Collection)value;
          if (values.size() == 0) {
            featureInformation.processValue("String_Node_Str");
          }
        }
 else {
          if (value == null) {
            featureInformation.processValue("String_Node_Str");
          }
        }
      }
 else {
        if (value != null) {
          featureInformation.processValue(value.toString());
        }
 else {
          featureInformation.processValue("String_Node_Str");
        }
      }
    }
  }
}
Program: 93691
Project: 93691
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.compare.contentmergeviewer.IMergeViewerContentProvider#getLeftContent(java.lang.Object)
 */
public Object getLeftContent(Object element){
  Object content=null;
  if (element instanceof ModelCompareInput) {
    final Resource res=((ModelCompareInput)element).getLeftResource();
    if (res != null && res.getResourceSet() != null)     content=res.getResourceSet();
 else     content=res;
  }
 else   if (element instanceof ICompareInput)   content=((ICompareInput)element).getLeft();
  return content;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.compare.contentmergeviewer.IMergeViewerContentProvider#getLeftContent(java.lang.Object)
 */
public Object getLeftContent(Object element){
  Object content=null;
  if (element instanceof ModelCompareInput) {
    content=((ModelCompareInput)element).getLeftResource();
  }
 else   if (element instanceof ICompareInput)   content=((ICompareInput)element).getLeft();
  return content;
}
Program: 93692
Project: 93692
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.compare.contentmergeviewer.IMergeViewerContentProvider#getRightContent(java.lang.Object)
 */
public Object getRightContent(Object element){
  Object content=null;
  if (element instanceof ModelCompareInput) {
    final Resource res=((ModelCompareInput)element).getRightResource();
    if (res != null && res.getResourceSet() != null)     content=res.getResourceSet();
 else     content=res;
  }
 else   if (element instanceof ICompareInput)   content=((ICompareInput)element).getRight();
  return content;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.compare.contentmergeviewer.IMergeViewerContentProvider#getRightContent(java.lang.Object)
 */
public Object getRightContent(Object element){
  Object content=null;
  if (element instanceof ModelCompareInput) {
    content=((ModelCompareInput)element).getRightResource();
  }
 else   if (element instanceof ICompareInput)   content=((ICompareInput)element).getRight();
  return content;
}