nus-yam/ex-repair huggingface dataset:
Program: 93620
Project: 93620
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.jface.action.Action#run()
 */
@Override public void run(){
  Shell parent=configuration.getContainer().getWorkbenchPart().getSite().getShell();
  FileDialog fileDialog=new FileDialog(parent,SWT.SAVE);
  File file=new File(fileDialog.open());
  if (file.exists()) {
    MessageDialog messageDialog=new MessageDialog(parent,"String_Node_Str",null,"String_Node_Str" + file.toString() + "String_Node_Str",MessageDialog.WARNING,DIALOG_BUTTON_LABELS.toArray(new String[0]),1);
    int open=messageDialog.open();
    if (open == DIALOG_BUTTON_LABELS.indexOf("String_Node_Str")) {
      saveComparison(file);
    }
  }
 else {
    saveComparison(file);
  }
  super.run();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.jface.action.Action#run()
 */
@Override public void run(){
  Shell parent=configuration.getContainer().getWorkbenchPart().getSite().getShell();
  FileDialog fileDialog=new FileDialog(parent,SWT.SAVE);
  String filePath=fileDialog.open();
  if (filePath != null) {
    File file=new File(filePath);
    if (file.exists()) {
      MessageDialog messageDialog=new MessageDialog(parent,"String_Node_Str",null,"String_Node_Str" + file.toString() + "String_Node_Str",MessageDialog.WARNING,DIALOG_BUTTON_LABELS.toArray(new String[0]),1);
      int open=messageDialog.open();
      if (open == DIALOG_BUTTON_LABELS.indexOf("String_Node_Str")) {
        saveComparison(file);
      }
    }
 else {
      saveComparison(file);
    }
  }
  super.run();
}
Program: 93622
Project: 93622
Buggy source:
/** 
 * Check whether we have all the required information to search for this object matches.
 * @param inProgress the Comparison which is being matched.
 * @param fastCheck the Object we are trying to match.
 * @return true if we have all the required information, false otherwise.
 */
private boolean readyForThisTest(Comparison inProgress,EObject fastCheck){
  if (fastCheck.eContainer() != null) {
    return inProgress.getMatch(fastCheck.eContainer()) != null || scope.isInScope(fastCheck.eContainer());
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Check whether we have all the required information to search for this object matches.
 * @param inProgress the Comparison which is being matched.
 * @param fastCheck the Object we are trying to match.
 * @return true if we have all the required information, false otherwise.
 */
private boolean readyForThisTest(Comparison inProgress,EObject fastCheck){
  if (fastCheck.eContainer() != null && scope.isInScope(fastCheck.eContainer())) {
    return inProgress.getMatch(fastCheck.eContainer()) != null;
  }
  return true;
}
Program: 93623
Project: 93623
Buggy source:
/** 
 * Look for a perfect match (identic content) in the given list of candidates.
 * @param inProgress the comparison being matched.
 * @param eObj the object
 * @param candidates the list of possible matches.
 * @return a candidate instance wrapping the found match Object (if found)
 */
private Candidate findIdenticMatch(Comparison inProgress,final EObject eObj,List<EObject> candidates){
  Iterator<EObject> it=candidates.iterator();
  Candidate best=new Candidate();
  while (it.hasNext() && !best.some()) {
    EObject fastCheck=it.next();
    if (!readyForThisTest(inProgress,fastCheck)) {
      stats.backtrack();
      best.eObject=BACKTRACK;
    }
 else {
      stats.identicCompare();
      if (meter.areIdentic(inProgress,eObj,fastCheck)) {
        stats.identicSuccess();
        best.eObject=fastCheck;
        best.distance=0;
      }
    }
  }
  return best;
}

Fixed version (ground truth):
/** 
 * Look for a perfect match (identic content) in the given list of candidates.
 * @param inProgress the comparison being matched.
 * @param eObj the object
 * @param candidates the list of possible matches.
 * @return a candidate instance wrapping the found match Object (if found)
 */
private Candidate findIdenticMatch(Comparison inProgress,final EObject eObj,List<EObject> candidates){
  Iterator<EObject> it=candidates.iterator();
  Candidate best=new Candidate();
  while (it.hasNext() && !best.some()) {
    EObject fastCheck=it.next();
    if (!readyForThisTest(inProgress,fastCheck)) {
      stats.backtrack();
    }
 else {
      stats.identicCompare();
      if (meter.areIdentic(inProgress,eObj,fastCheck)) {
        stats.identicSuccess();
        best.eObject=fastCheck;
        best.distance=0;
      }
    }
  }
  return best;
}
Program: 93624
Project: 93624
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.jface.action.Action#run()
 */
@Override public void run(){
  Shell parent=configuration.getContainer().getWorkbenchPart().getSite().getShell();
  FileDialog fileDialog=new FileDialog(parent,SWT.SAVE);
  File file=new File(fileDialog.open());
  if (file.exists()) {
    MessageDialog messageDialog=new MessageDialog(parent,"String_Node_Str",null,"String_Node_Str" + file.toString() + "String_Node_Str",MessageDialog.WARNING,DIALOG_BUTTON_LABELS.toArray(new String[0]),1);
    int open=messageDialog.open();
    if (open == DIALOG_BUTTON_LABELS.indexOf("String_Node_Str")) {
      saveComparison(file);
    }
  }
 else {
    saveComparison(file);
  }
  super.run();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.jface.action.Action#run()
 */
@Override public void run(){
  Shell parent=configuration.getContainer().getWorkbenchPart().getSite().getShell();
  FileDialog fileDialog=new FileDialog(parent,SWT.SAVE);
  String filePath=fileDialog.open();
  if (filePath != null) {
    File file=new File(filePath);
    if (file.exists()) {
      MessageDialog messageDialog=new MessageDialog(parent,"String_Node_Str",null,"String_Node_Str" + file.toString() + "String_Node_Str",MessageDialog.WARNING,DIALOG_BUTTON_LABELS.toArray(new String[0]),1);
      int open=messageDialog.open();
      if (open == DIALOG_BUTTON_LABELS.indexOf("String_Node_Str")) {
        saveComparison(file);
      }
    }
 else {
      saveComparison(file);
    }
  }
  super.run();
}
Program: 93626
Project: 93626
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.compare.structuremergeviewer.ICompareInput#getAncestor()
 */
public ITypedElement getAncestor(){
  IAccessorFactory accessorFactory=getAccessorFactoryForTarget();
  if (accessorFactory != null) {
    return AccessorAdapter.adapt(accessorFactory.createAncestor(getAdapterFactory(),getTarget()));
  }
  return null;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.compare.structuremergeviewer.ICompareInput#getAncestor()
 */
public ITypedElement getAncestor(){
  final ITypedElement ret;
  IAccessorFactory accessorFactory=getAccessorFactoryForTarget();
  if (accessorFactory != null) {
    org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.legacy.ITypedElement typedElement=accessorFactory.createAncestor(getAdapterFactory(),getTarget());
    if (typedElement != null) {
      ret=AccessorAdapter.adapt(typedElement);
    }
 else {
      ret=null;
    }
  }
 else {
    ret=null;
  }
  return ret;
}
Program: 93627
Project: 93627
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.compare.structuremergeviewer.ICompareInput#getRight()
 */
public ITypedElement getRight(){
  IAccessorFactory accessorFactory=getAccessorFactoryForTarget();
  if (accessorFactory != null) {
    return AccessorAdapter.adapt(accessorFactory.createRight(getAdapterFactory(),getTarget()));
  }
  return null;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.compare.structuremergeviewer.ICompareInput#getRight()
 */
public ITypedElement getRight(){
  final ITypedElement ret;
  IAccessorFactory accessorFactory=getAccessorFactoryForTarget();
  if (accessorFactory != null) {
    org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.legacy.ITypedElement typedElement=accessorFactory.createRight(getAdapterFactory(),getTarget());
    if (typedElement != null) {
      ret=AccessorAdapter.adapt(typedElement);
    }
 else {
      ret=null;
    }
  }
 else {
    ret=null;
  }
  return ret;
}
Program: 93628
Project: 93628
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.compare.structuremergeviewer.ICompareInput#getLeft()
 */
public ITypedElement getLeft(){
  IAccessorFactory accessorFactory=getAccessorFactoryForTarget();
  if (accessorFactory != null) {
    return AccessorAdapter.adapt(accessorFactory.createLeft(getAdapterFactory(),getTarget()));
  }
  return null;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.compare.structuremergeviewer.ICompareInput#getLeft()
 */
public ITypedElement getLeft(){
  final ITypedElement ret;
  IAccessorFactory accessorFactory=getAccessorFactoryForTarget();
  if (accessorFactory != null) {
    org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.legacy.ITypedElement typedElement=accessorFactory.createLeft(getAdapterFactory(),getTarget());
    if (typedElement != null) {
      ret=AccessorAdapter.adapt(typedElement);
    }
 else {
      ret=null;
    }
  }
 else {
    ret=null;
  }
  return ret;
}
Program: 93629
Project: 93629
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.emf.compare.diagram.ide.ui.internal.contentmergeviewer.diagram.DiagramContentMergeViewer.AbstractDecoratorManager#getReferenceViews(org.eclipse.emf.compare.diagram.DiagramDiff)
 */
@Override protected List<View> getReferenceViews(DiagramDiff difference){
  List<View> result=new ArrayList<View>();
  Match matchValue=getComparison().getMatch(difference.getView());
  if (matchValue.getLeft() != null) {
    result.add((View)matchValue.getLeft());
  }
  if (matchValue.getRight() != null) {
    result.add((View)matchValue.getRight());
  }
  if (getComparison().isThreeWay()) {
switch (difference.getKind()) {
case DELETE:
case CHANGE:
case MOVE:
      result.add((View)matchValue.getOrigin());
    break;
default :
  break;
}
}
return result;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.emf.compare.diagram.ide.ui.internal.contentmergeviewer.diagram.DiagramContentMergeViewer.AbstractDecoratorManager#getReferenceViews(org.eclipse.emf.compare.diagram.DiagramDiff)
 */
@Override protected List<View> getReferenceViews(DiagramDiff difference){
  List<View> result=new ArrayList<View>();
  Match matchValue=getComparison().getMatch(difference.getView());
  if (matchValue != null) {
    if (matchValue.getLeft() != null) {
      result.add((View)matchValue.getLeft());
    }
    if (matchValue.getRight() != null) {
      result.add((View)matchValue.getRight());
    }
    if (getComparison().isThreeWay()) {
switch (difference.getKind()) {
case DELETE:
case CHANGE:
case MOVE:
        result.add((View)matchValue.getOrigin());
      break;
default :
    break;
}
}
}
return result;
}
Program: 93630
Project: 93630
Buggy source:
/** 
 * From the given view, get or create the related phantoms.
 * @param referenceView The given view.
 * @return The list of phantoms.
 */
private List<Phantom> getOrCreateRelatedDecorators(EObject referenceView){
  List<Phantom> result=new ArrayList<Phantom>();
  Collection<Diff> changes=Collections2.filter(getComparison().getDifferences(referenceView),goodCandidate());
  for (  Diff change : changes) {
    Phantom phantom=fPhantomRegistry.get(change);
    if (phantom == null) {
      phantom=createAndRegisterDecorator(change,(View)referenceView,PhantomManager.this.getFigure((View)referenceView),fSide);
    }
    result.add(phantom);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * From the given view, get or create the related phantoms.
 * @param referenceView The given view.
 * @return The list of phantoms.
 */
private List<Phantom> getOrCreateRelatedDecorators(EObject referenceView){
  List<Phantom> result=new ArrayList<Phantom>();
  Collection<Diff> changes=Collections2.filter(getComparison().getDifferences(referenceView),goodCandidate());
  for (  Diff change : changes) {
    Phantom phantom=fPhantomRegistry.get(change);
    if (phantom == null) {
      IFigure referenceFigure=PhantomManager.this.getFigure((View)referenceView);
      if (referenceFigure != null) {
        phantom=createAndRegisterDecorator(change,(View)referenceView,referenceFigure,fSide);
      }
    }
    if (phantom != null) {
      result.add(phantom);
    }
  }
  return result;
}
Program: 93631
Project: 93631
Buggy source:
/** 
 * Get the figure related to the given view.
 * @param view The view.
 * @return the figure.
 */
protected IFigure getFigure(View view){
  MergeViewerSide side=getSide(view);
  GraphicalEditPart originEditPart=(GraphicalEditPart)getViewer(side).getEditPart(view);
  return originEditPart.getFigure();
}

Fixed version (ground truth):
/** 
 * Get the figure related to the given view.
 * @param view The view.
 * @return the figure.
 */
protected IFigure getFigure(View view){
  MergeViewerSide side=getSide(view);
  GraphicalEditPart originEditPart=(GraphicalEditPart)getViewer(side).getEditPart(view);
  if (originEditPart != null) {
    return originEditPart.getFigure();
  }
  return null;
}
Program: 93633
Project: 93633
Buggy source:
/** 
 * @param parent
 * @param configuration
 */
public EMFCompareStructureMergeViewer(Composite parent,CompareConfiguration configuration){
  super(parent,configuration);
  fAdapterFactory=new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
  fAdapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
  fAdapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
  setLabelProvider(new DelegatingStyledCellLabelProvider(new EMFCompareStructureMergeViewerLabelProvider(fAdapterFactory,this)));
  setContentProvider(new EMFCompareStructureMergeViewerContentProvider(fAdapterFactory,structureMergeViewerGrouper));
  if (parent instanceof CompareViewerSwitchingPane) {
    fParent=(CompareViewerSwitchingPane)parent;
  }
 else {
    fParent=null;
  }
  fCompareInputChangeListener=new ICompareInputChangeListener(){
    public void compareInputChanged(    ICompareInput input){
      EMFCompareStructureMergeViewer.this.compareInputChanged(input);
    }
  }
;
  setComparer(new DiffNodeComparer(super.getComparer()));
  if (eventBus == null) {
    eventBus=new EventBus();
    eventBus.register(this);
  }
}

Fixed version (ground truth):
/** 
 * @param parent
 * @param configuration
 */
public EMFCompareStructureMergeViewer(Composite parent,CompareConfiguration configuration){
  super(parent,configuration);
  fAdapterFactory=new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
  fAdapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
  fAdapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
  structureMergeViewerComparator=new EMFCompareStructureMergeViewerComparator();
  setLabelProvider(new DelegatingStyledCellLabelProvider(new EMFCompareStructureMergeViewerLabelProvider(fAdapterFactory,this)));
  setContentProvider(new EMFCompareStructureMergeViewerContentProvider(fAdapterFactory,structureMergeViewerGrouper));
  if (parent instanceof CompareViewerSwitchingPane) {
    fParent=(CompareViewerSwitchingPane)parent;
  }
 else {
    fParent=null;
  }
  fCompareInputChangeListener=new ICompareInputChangeListener(){
    public void compareInputChanged(    ICompareInput input){
      EMFCompareStructureMergeViewer.this.compareInputChanged(input);
    }
  }
;
  setComparer(new DiffNodeComparer(super.getComparer()));
  if (eventBus == null) {
    eventBus=new EventBus();
    eventBus.register(this);
  }
}
Program: 93634
Project: 93634
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.compare.contentmergeviewer.ContentMergeViewer#copy(boolean)
 */
@Override protected void copy(boolean leftToRight){
  EList<Diff> differences=getComparison().getDifferences();
  final Command copyCommand=getEditingDomain().createCopyAllNonConflictingCommand(differences,leftToRight);
  getEditingDomain().getCommandStack().execute(copyCommand);
  if (leftToRight) {
    setRightDirty(true);
  }
 else {
    setLeftDirty(true);
  }
  refresh();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.compare.contentmergeviewer.ContentMergeViewer#copy(boolean)
 */
@Override protected void copy(boolean leftToRight){
  EList<Diff> differences=getComparison().getDifferences();
  final Command copyCommand=getEditingDomain().createCopyAllNonConflictingCommand(differences,leftToRight,EMFCompareIDEPlugin.getDefault().getMergerRegistry());
  getEditingDomain().getCommandStack().execute(copyCommand);
  if (leftToRight) {
    setRightDirty(true);
  }
 else {
    setLeftDirty(true);
  }
  refresh();
}
Program: 93635
Project: 93635
Buggy source:
/** 
 * @param style
 * @param bundle
 * @param cc
 */
protected EMFCompareContentMergeViewer(int style,ResourceBundle bundle,CompareConfiguration cc){
  super(style,bundle,cc);
  fDynamicObject=new DynamicObject(this);
  fComparison=((ComparisonNode)cc.getProperty(EMFCompareConstants.COMPARE_RESULT)).getTarget();
  fEditingDomain=(EMFCompareEditingDomain)getCompareConfiguration().getProperty(EMFCompareConstants.EDITING_DOMAIN);
}

Fixed version (ground truth):
/** 
 * @param style
 * @param bundle
 * @param cc
 */
protected EMFCompareContentMergeViewer(int style,ResourceBundle bundle,CompareConfiguration cc){
  super(style,bundle,cc);
  fDynamicObject=new DynamicObject(this);
  fComparison=(Comparison)cc.getProperty(EMFCompareConstants.COMPARE_RESULT);
  fEditingDomain=(EMFCompareEditingDomain)getCompareConfiguration().getProperty(EMFCompareConstants.EDITING_DOMAIN);
}
Program: 93636
Project: 93636
Buggy source:
public void widgetDisposed(DisposeEvent e){
  fControl=null;
}

Fixed version (ground truth):
public void widgetDisposed(DisposeEvent e){
  ret.removePaintListener(paintListener);
}
Program: 93637
Project: 93637
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.compare.contentmergeviewer.ContentMergeViewer#createCenterControl(org.eclipse.swt.widgets.Composite)
 */
@Override protected Control createCenterControl(Composite parent){
  final Control ret=super.createCenterControl(parent);
  final PaintListener paintListener=new PaintListener(){
    public void paintControl(    PaintEvent e){
      paintCenter(e.gc);
    }
  }
;
  ret.addPaintListener(paintListener);
  ret.addDisposeListener(new DisposeListener(){
    public void widgetDisposed(    DisposeEvent e){
      ret.removePaintListener(paintListener);
    }
  }
);
  new Resizer(ret);
  return ret;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.compare.contentmergeviewer.ContentMergeViewer#createCenterControl(org.eclipse.swt.widgets.Composite)
 */
@Override protected Control createCenterControl(Composite parent){
  final Control ret=super.createCenterControl(parent);
  final PaintListener paintListener=new PaintListener(){
    public void paintControl(    PaintEvent e){
      paintCenter(e.gc);
    }
  }
;
  ret.addPaintListener(paintListener);
  ret.addDisposeListener(new DisposeListener(){
    public void widgetDisposed(    DisposeEvent e){
      ret.removePaintListener(paintListener);
    }
  }
);
  return ret;
}
Program: 93638
Project: 93638
Buggy source:
void compareInputChanged(final Comparison comparison){
  fRoot=fAdapterFactory.adapt(comparison,IDiffElement.class);
  getCompareConfiguration().setProperty(EMFCompareConstants.COMPARE_RESULT,fRoot);
  getCompareConfiguration().getContainer().runAsynchronously(new IRunnableWithProgress(){
    public void run(    IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
      String message=null;
      if (comparison.getDifferences().isEmpty()) {
        message="String_Node_Str";
      }
      if (Display.getCurrent() != null) {
        refreshAfterDiff(message,fRoot);
      }
 else {
        final String theMessage=message;
        Display.getDefault().asyncExec(new Runnable(){
          public void run(){
            refreshAfterDiff(theMessage,fRoot);
          }
        }
);
      }
    }
  }
);
}

Fixed version (ground truth):
void compareInputChanged(final Comparison comparison){
  getCompareConfiguration().setProperty(EMFCompareConstants.COMPARE_RESULT,comparison);
  fRoot=fAdapterFactory.adapt(comparison,IDiffElement.class);
  getCompareConfiguration().getContainer().runAsynchronously(new IRunnableWithProgress(){
    public void run(    IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
      String message=null;
      if (comparison.getDifferences().isEmpty()) {
        message="String_Node_Str";
      }
      if (Display.getCurrent() != null) {
        refreshAfterDiff(message,fRoot);
      }
 else {
        final String theMessage=message;
        Display.getDefault().asyncExec(new Runnable(){
          public void run(){
            refreshAfterDiff(theMessage,fRoot);
          }
        }
);
      }
    }
  }
);
}
Program: 93639
Project: 93639
Buggy source:
/** 
 * Checks the potential equivalence from the given <code>difference</code>.
 * @param comparison The comparison this engine is expected to complete.
 * @param referenceChange The difference that is to be checked
 */
protected void checkForEquivalences(Comparison comparison,ReferenceChange referenceChange){
  Equivalence equivalence=referenceChange.getEquivalence();
  if (equivalence == null) {
    equivalence=CompareFactory.eINSTANCE.createEquivalence();
    comparison.getEquivalences().add(equivalence);
    equivalence.getDifferences().add(referenceChange);
    EObject container=MatchUtil.getContainer(comparison,referenceChange);
    if (container != null) {
      for (      ReferenceChange diff : filter(comparison.getDifferences(container),ReferenceChange.class)) {
        EReference reference=diff.getReference();
        EReference eOpposite=reference.getEOpposite();
        EObject referenceChangeContainer=MatchUtil.getContainer(comparison,diff);
        EObject value=referenceChange.getValue();
        if (eOpposite != null && eOpposite.equals(referenceChange.getReference()) && value.equals(referenceChangeContainer)) {
          equivalence.getDifferences().add(diff);
          break;
        }
      }
    }
  }
}

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 referenceChange The difference that is to be checked
 */
protected void checkForEquivalences(Comparison comparison,ReferenceChange referenceChange){
  Equivalence equivalence=referenceChange.getEquivalence();
  if (equivalence == null) {
    equivalence=CompareFactory.eINSTANCE.createEquivalence();
    comparison.getEquivalences().add(equivalence);
    equivalence.getDifferences().add(referenceChange);
    EObject container=MatchUtil.getContainer(comparison,referenceChange);
    if (container != null) {
      for (      ReferenceChange diff : filter(comparison.getDifferences(container),ReferenceChange.class)) {
        EReference reference=diff.getReference();
        EReference eOpposite=reference.getEOpposite();
        EObject referenceChangeContainer=MatchUtil.getContainer(comparison,diff);
        EObject value=referenceChange.getValue();
        if (eOpposite != null && eOpposite.equals(referenceChange.getReference()) && value.equals(referenceChangeContainer)) {
          equivalence.getDifferences().add(diff);
          break;
        }
      }
      addChangesFromOrigin(comparison,referenceChange,equivalence);
    }
  }
}
Program: 93640
Project: 93640
Buggy source:
/** 
 * Add to the given <code>equivalence</code> potential changes based on the same reference as the given <code>diff</code>.
 * @param comparison The comparison which enable to know from which side come the business model objects owning the differences.
 * @param diff The current difference.
 * @param equivalence The current equivalence attached to the difference.
 */
private void addChangesFromOrigin(Comparison comparison,ReferenceChange diff,Equivalence equivalence){
  if (!diff.getReference().isMany()) {
    final EObject originContainer=MatchUtil.getOriginContainer(comparison,diff);
    if (originContainer != null) {
      for (      Diff referenceChange : comparison.getDifferences(originContainer)) {
        if (referenceChange instanceof ReferenceChange && MatchUtil.getContainer(comparison,referenceChange).equals(ReferenceUtil.safeEGet(originContainer,diff.getReference()))) {
          equivalence.getDifferences().add(referenceChange);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Add to the given <code>equivalence</code> potential changes based on the same reference as the given <code>diff</code>.
 * @param comparison The comparison which enable to know from which side come the business model objects owning the differences.
 * @param diff The current difference.
 * @param equivalence The current equivalence attached to the difference.
 */
private void addChangesFromOrigin(Comparison comparison,ReferenceChange diff,Equivalence equivalence){
  if (!diff.getReference().isMany()) {
    final EObject originContainer=MatchUtil.getOriginContainer(comparison,diff);
    if (originContainer != null) {
      for (      Diff referenceChange : comparison.getDifferences(originContainer)) {
        if (referenceChange instanceof ReferenceChange && diff.getReference().equals(((ReferenceChange)referenceChange).getReference().getEOpposite())) {
          equivalence.getDifferences().add(referenceChange);
        }
      }
    }
  }
}
Program: 93641
Project: 93641
Buggy source:
/** 
 * Add to the given <code>equivalence</code> potential changes based on the same reference as the given <code>diff</code>.
 * @param comparison The comparison which enable to know from which side come the business model objects owning the differences.
 * @param diff The current difference.
 * @param equivalence The current equivalence attached to the difference.
 */
private void addChangesFromOrigin(Comparison comparison,ReferenceChange diff,Equivalence equivalence){
  if (!diff.getReference().isMany()) {
    final EObject originContainer=MatchUtil.getOriginContainer(comparison,diff);
    if (originContainer != null) {
      for (      Diff referenceChange : comparison.getDifferences(originContainer)) {
        if (referenceChange instanceof ReferenceChange && MatchUtil.getContainer(comparison,referenceChange).equals(originContainer.eGet(diff.getReference(),false))) {
          equivalence.getDifferences().add(referenceChange);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Add to the given <code>equivalence</code> potential changes based on the same reference as the given <code>diff</code>.
 * @param comparison The comparison which enable to know from which side come the business model objects owning the differences.
 * @param diff The current difference.
 * @param equivalence The current equivalence attached to the difference.
 */
private void addChangesFromOrigin(Comparison comparison,ReferenceChange diff,Equivalence equivalence){
  if (!diff.getReference().isMany()) {
    final EObject originContainer=MatchUtil.getOriginContainer(comparison,diff);
    if (originContainer != null) {
      for (      Diff referenceChange : comparison.getDifferences(originContainer)) {
        if (referenceChange instanceof ReferenceChange && MatchUtil.getContainer(comparison,referenceChange).equals(ReferenceUtil.safeEGet(originContainer,diff.getReference()))) {
          equivalence.getDifferences().add(referenceChange);
        }
      }
    }
  }
}
Program: 93642
Project: 93642
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>();
  EReference reference=sourceDifference.getReference();
  if (!reference.isMany()) {
    EObject originContainer=MatchUtil.getOriginContainer(comparison,sourceDifference);
    if (originContainer != null) {
      Object originValue=originContainer.eGet(reference,false);
      if (originValue instanceof EObject) {
        result=getDifferenceOnGivenObject(comparison,(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>();
  EReference reference=sourceDifference.getReference();
  if (!reference.isMany()) {
    EObject originContainer=MatchUtil.getOriginContainer(comparison,sourceDifference);
    if (originContainer != null) {
      Object originValue=ReferenceUtil.safeEGet(originContainer,reference);
      if (originValue instanceof EObject) {
        result=getDifferenceOnGivenObject(comparison,(EObject)originValue,DifferenceKind.DELETE);
      }
    }
  }
  return result;
}
Program: 93643
Project: 93643
Buggy source:
/** 
 * Check if the given <code>difference</code> is a CHANGE to a null value on a mono-valued reference.
 * @param difference The given difference.
 * @return True if it is a CHANGE to a null value.
 */
private static boolean isChangeDelete(ReferenceChange difference){
  boolean result=false;
  EReference reference=difference.getReference();
  if (!reference.isMany() && !reference.isContainment()) {
    Match match=difference.getMatch();
    if (difference.getSource() == DifferenceSource.LEFT) {
      final EObject left=match.getLeft();
      result=left == null || left.eGet(reference,false) == null;
    }
 else {
      final EObject right=match.getRight();
      result=right == null || right.eGet(reference,false) == null;
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Check if the given <code>difference</code> is a CHANGE to a null value on a mono-valued reference.
 * @param difference The given difference.
 * @return True if it is a CHANGE to a null value.
 */
private static boolean isChangeDelete(ReferenceChange difference){
  boolean result=false;
  EReference reference=difference.getReference();
  if (!reference.isMany() && !reference.isContainment()) {
    Match match=difference.getMatch();
    if (difference.getSource() == DifferenceSource.LEFT) {
      final EObject left=match.getLeft();
      result=left == null || ReferenceUtil.safeEGet(left,reference) == null;
    }
 else {
      final EObject right=match.getRight();
      result=right == null || ReferenceUtil.safeEGet(right,reference) == null;
    }
  }
  return result;
}
Program: 93644
Project: 93644
Buggy source:
/** 
 * Check if the given <code>difference</code> is a CHANGE from a null value on a mono-valued reference.
 * @param comparison The comparison this engine is expected to complete.
 * @param difference The given difference.
 * @return True if it is a CHANGE from a null value.
 */
private static boolean isChangeAdd(Comparison comparison,ReferenceChange difference){
  boolean result=false;
  EReference reference=difference.getReference();
  if (!reference.isMany() && !reference.isContainment()) {
    Match match=difference.getMatch();
    if (comparison.isThreeWay()) {
      final EObject origin=match.getOrigin();
      result=origin == null || origin.eGet(reference,false) == null;
    }
 else {
      final EObject right=match.getRight();
      result=right == null || right.eGet(reference,false) == null;
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Check if the given <code>difference</code> is a CHANGE from a null value on a mono-valued reference.
 * @param comparison The comparison this engine is expected to complete.
 * @param difference The given difference.
 * @return True if it is a CHANGE from a null value.
 */
private static boolean isChangeAdd(Comparison comparison,ReferenceChange difference){
  boolean result=false;
  EReference reference=difference.getReference();
  if (!reference.isMany() && !reference.isContainment()) {
    Match match=difference.getMatch();
    if (comparison.isThreeWay()) {
      final EObject origin=match.getOrigin();
      result=origin == null || ReferenceUtil.safeEGet(origin,reference) == null;
    }
 else {
      final EObject right=match.getRight();
      result=right == null || ReferenceUtil.safeEGet(right,reference) == null;
    }
  }
  return result;
}
Program: 93645
Project: 93645
Buggy source:
/** 
 * This predicate can be used in order to check that a particular Diff describes either a  {@link ReferenceChange} or {@link AttributeChange} for the given {@code expectedValue}. <p> For example, this could be used to check that the given value has indeed been added to a reference or attribute, though such checks are more easily performed through   {@link #addedIn(EObject,EObject)} or{@link #removedFrom(EObject,EObject)}. </p>
 * @param expectedValue The value which we expect to have changed and detected through a Diff.
 * @return The created predicate.
 */
public static Predicate<? super Diff> valueIs(final Object expectedValue){
  return new Predicate<Diff>(){
    public boolean apply(    Diff input){
      final Object value;
      if (input instanceof ReferenceChange) {
        value=((ReferenceChange)input).getValue();
      }
 else       if (input instanceof AttributeChange) {
        value=((AttributeChange)input).getValue();
      }
 else {
        return false;
      }
      return value == expectedValue;
    }
  }
;
}

Fixed version (ground truth):
/** 
 * This predicate can be used in order to check that a particular Diff describes either a  {@link ReferenceChange} or {@link AttributeChange} for the given {@code expectedValue}. <p> For example, this could be used to check that the given value has indeed been added to a reference or attribute, though such checks are more easily performed through   {@link #addedIn(EObject,EObject)} or{@link #removedFrom(EObject,EObject)}. </p>
 * @param expectedValue The value which we expect to have changed and detected through a Diff.
 * @return The created predicate.
 */
public static Predicate<? super Diff> valueIs(final Object expectedValue){
  return new Predicate<Diff>(){
    public boolean apply(    Diff input){
      final Object value;
      if (input instanceof ReferenceChange) {
        value=((ReferenceChange)input).getValue();
      }
 else       if (input instanceof AttributeChange) {
        value=((AttributeChange)input).getValue();
      }
 else {
        return false;
      }
      if (value == null) {
        return expectedValue == null;
      }
 else {
        return value.equals(expectedValue);
      }
    }
  }
;
}
Program: 93646
Project: 93646
Buggy source:
/** 
 * From a given mono-valued reference change, get the origin value.
 * @param comparison The comparison.
 * @param difference The given reference change.
 * @return The origin value.
 */
public static EObject getOriginValue(Comparison comparison,ReferenceChange difference){
  if (!difference.getReference().isContainment() && !difference.getReference().isMany() && difference.getKind().equals(DifferenceKind.CHANGE)) {
    EObject originContainer=getOriginContainer(comparison,difference);
    if (originContainer != null) {
      Object originValue=originContainer.eGet(difference.getReference());
      if (originValue instanceof EObject) {
        return (EObject)originValue;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * From a given mono-valued reference change, get the origin value.
 * @param comparison The comparison.
 * @param difference The given reference change.
 * @return The origin value.
 */
public static EObject getOriginValue(Comparison comparison,ReferenceChange difference){
  if (!difference.getReference().isContainment() && !difference.getReference().isMany() && difference.getKind().equals(DifferenceKind.CHANGE)) {
    EObject originContainer=getOriginContainer(comparison,difference);
    if (originContainer != null) {
      Object originValue=ReferenceUtil.safeEGet(originContainer,difference.getReference());
      if (originValue instanceof EObject) {
        return (EObject)originValue;
      }
    }
  }
  return null;
}
Program: 93652
Project: 93652
Buggy source:
/** 
 * Checks the potential equivalence from the given <code>difference</code>.
 * @param comparison The comparison this engine is expected to complete.
 * @param referenceChange The difference that is to be checked
 */
protected void checkForEquivalences(Comparison comparison,ReferenceChange referenceChange){
  Equivalence equivalence=referenceChange.getEquivalence();
  if (equivalence == null) {
    equivalence=CompareFactory.eINSTANCE.createEquivalence();
    comparison.getEquivalences().add(equivalence);
    equivalence.getDifferences().add(referenceChange);
    EObject container=MatchUtil.getContainer(comparison,referenceChange);
    if (container != null) {
      for (      ReferenceChange diff : filter(comparison.getDifferences(container),ReferenceChange.class)) {
        EReference reference=diff.getReference();
        EReference eOpposite=reference.getEOpposite();
        EObject referenceChangeContainer=MatchUtil.getContainer(comparison,diff);
        EObject value=referenceChange.getValue();
        if (eOpposite != null && eOpposite.equals(referenceChange.getReference()) && value.equals(referenceChangeContainer)) {
          equivalence.getDifferences().add(diff);
          break;
        }
      }
      addChangesFromOrigin(comparison,referenceChange,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 referenceChange The difference that is to be checked
 */
protected void checkForEquivalences(Comparison comparison,ReferenceChange referenceChange){
  Equivalence equivalence=referenceChange.getEquivalence();
  if (equivalence == null) {
    equivalence=CompareFactory.eINSTANCE.createEquivalence();
    comparison.getEquivalences().add(equivalence);
    equivalence.getDifferences().add(referenceChange);
    EObject container=MatchUtil.getContainer(comparison,referenceChange);
    if (container != null) {
      for (      ReferenceChange diff : filter(comparison.getDifferences(container),ReferenceChange.class)) {
        EReference reference=diff.getReference();
        EReference eOpposite=reference.getEOpposite();
        EObject referenceChangeContainer=MatchUtil.getContainer(comparison,diff);
        EObject value=referenceChange.getValue();
        if (eOpposite != null && eOpposite.equals(referenceChange.getReference()) && value.equals(referenceChangeContainer)) {
          equivalence.getDifferences().add(diff);
          break;
        }
      }
    }
  }
}
Program: 93653
Project: 93653
Buggy source:
@Override public Match getParentMatch(Diff input){
  if (getRelatedExtensionKind(input) == DifferenceKind.CHANGE) {
    Match match=input.getMatch().getComparison().getMatch(getDiscriminantFromDiff(input));
    if (match.eContainer() instanceof Match) {
      return (Match)match.eContainer();
    }
 else {
      return match;
    }
  }
  return super.getParentMatch(input);
}

Fixed version (ground truth):
@Override public Match getParentMatch(Diff input){
  if (getRelatedExtensionKind(input) == DifferenceKind.CHANGE) {
    final EObject discriminant=getDiscriminantFromDiff(input);
    if (discriminant != null) {
      final Match match=input.getMatch().getComparison().getMatch(discriminant);
      if (match.eContainer() instanceof Match) {
        return (Match)match.eContainer();
      }
 else {
        return match;
      }
    }
 else {
      return input.getMatch();
    }
  }
  return super.getParentMatch(input);
}
Program: 93655
Project: 93655
Buggy source:
public void handleEvent(Event event){
  if (event.item == fLastWidget && event.height == fLastHeight) {
    return;
  }
  fLastWidget=event.item;
  fLastHeight=event.height;
  int newHeight=(int)(event.gc.getFontMetrics().getHeight() * 1.33d);
  if (newHeight % 2 == 1) {
    newHeight+=1;
  }
  event.height=newHeight;
}

Fixed version (ground truth):
public void handleEvent(Event event){
  if (event.item == fLastWidget && event.height == fLastHeight) {
    return;
  }
  fLastWidget=event.item;
  fLastHeight=event.height;
  int newHeight=(int)(event.gc.getFontMetrics().getHeight() * 1.33d);
  if ((newHeight & 1) == 1) {
    newHeight+=1;
  }
  event.height=newHeight;
}
Program: 93656
Project: 93656
Buggy source:
TableMergeViewer(Composite parent,EMFCompareContentMergeViewer contentMergeViewer,MergeViewerSide side){
  super(parent,side);
  fContentMergeViewer=contentMergeViewer;
  getStructuredViewer().getTable().addListener(SWT.EraseItem,new Listener(){
    public void handleEvent(    Event event){
      TableMergeViewer.this.handleEraseItemEvent(event);
    }
  }
);
  getStructuredViewer().getTable().addListener(SWT.MeasureItem,new Listener(){
    private Widget fLastWidget;
    private int fLastHeight;
    public void handleEvent(    Event event){
      if (event.item == fLastWidget && event.height == fLastHeight) {
        return;
      }
      fLastWidget=event.item;
      fLastHeight=event.height;
      int newHeight=(int)(event.gc.getFontMetrics().getHeight() * 1.33d);
      if (newHeight % 2 == 1) {
        newHeight+=1;
      }
      event.height=newHeight;
    }
  }
);
}

Fixed version (ground truth):
TableMergeViewer(Composite parent,EMFCompareContentMergeViewer contentMergeViewer,MergeViewerSide side){
  super(parent,side);
  fContentMergeViewer=contentMergeViewer;
  getStructuredViewer().getTable().addListener(SWT.EraseItem,new Listener(){
    public void handleEvent(    Event event){
      TableMergeViewer.this.handleEraseItemEvent(event);
    }
  }
);
  getStructuredViewer().getTable().addListener(SWT.MeasureItem,new Listener(){
    private Widget fLastWidget;
    private int fLastHeight;
    public void handleEvent(    Event event){
      if (event.item == fLastWidget && event.height == fLastHeight) {
        return;
      }
      fLastWidget=event.item;
      fLastHeight=event.height;
      int newHeight=(int)(event.gc.getFontMetrics().getHeight() * 1.33d);
      if ((newHeight & 1) == 1) {
        newHeight+=1;
      }
      event.height=newHeight;
    }
  }
);
}
Program: 93657
Project: 93657
Buggy source:
/** 
 * Process all the matches and re-attache them to their parent if one is found.
 */
private void restructureMatchModel(){
  Iterator<Match> it=matches.iterator();
  while (it.hasNext()) {
    Match cur=it.next();
    EObject possibleContainer=null;
    if (cur.getLeft() != null) {
      possibleContainer=cur.getLeft().eContainer();
    }
    if (possibleContainer != null && cur.getRight() != null) {
      possibleContainer=cur.getRight().eContainer();
    }
    if (possibleContainer != null && cur.getOrigin() != null) {
      possibleContainer=cur.getOrigin().eContainer();
    }
    Match possibleContainerMatch=eObjectsToMatch.get(possibleContainer);
    if (possibleContainerMatch != null) {
      ((BasicEList)possibleContainerMatch.getSubmatches()).addUnique(cur);
      it.remove();
    }
  }
  Iterator<Match> it2=matches.iterator();
  if (it2.hasNext()) {
    Match root=it2.next();
    while (it2.hasNext()) {
      ((BasicEList)root.getSubmatches()).addUnique(it2.next());
      it2.remove();
    }
  }
}

Fixed version (ground truth):
/** 
 * Process all the matches and re-attache them to their parent if one is found.
 */
private void restructureMatchModel(){
  Iterator<Match> it=matches.iterator();
  while (it.hasNext()) {
    Match cur=it.next();
    EObject possibleContainer=null;
    if (cur.getLeft() != null) {
      possibleContainer=cur.getLeft().eContainer();
    }
    if (possibleContainer != null && cur.getRight() != null) {
      possibleContainer=cur.getRight().eContainer();
    }
    if (possibleContainer != null && cur.getOrigin() != null) {
      possibleContainer=cur.getOrigin().eContainer();
    }
    Match possibleContainerMatch=eObjectsToMatch.get(possibleContainer);
    if (possibleContainerMatch != null) {
      ((BasicEList<Match>)possibleContainerMatch.getSubmatches()).addUnique(cur);
      it.remove();
    }
  }
  Iterator<Match> it2=matches.iterator();
  if (it2.hasNext()) {
    Match root=it2.next();
    while (it2.hasNext()) {
      ((BasicEList<Match>)root.getSubmatches()).addUnique(it2.next());
      it2.remove();
    }
  }
}
Program: 93658
Project: 93658
Buggy source:
private void addInsertionPoints(final List<Object> values){
  ImmutableMap.Builder<Match,DiffInsertionPoint> insertionsPoints=ImmutableMap.builder();
  for (  ReferenceChange diff : filter(fInput.getDiffFromTheOtherSide().reverse(),ReferenceChange.class)) {
    if (diff.getState() == DifferenceState.UNRESOLVED) {
      boolean rightToLeft=(getSide() == MergeViewerSide.LEFT);
      EObject value=diff.getValue();
      if (value != null) {
        Match match=diff.getMatch();
        Match matchOfDiffValue=match.getComparison().getMatch(value);
        if (matchOfDiffValue != null) {
          DiffInsertionPoint insertionPoint=new DiffInsertionPoint(diff);
          final int insertionIndex;
          if (diff.getReference().isMany()) {
            insertionIndex=DiffUtil.findInsertionIndex(match.getComparison(),diff,rightToLeft);
          }
 else {
            insertionIndex=0;
          }
          values.add(insertionIndex,insertionPoint);
          insertionsPoints.put(matchOfDiffValue,insertionPoint);
        }
      }
    }
  }
  fInsertionPoints=insertionsPoints.build();
}

Fixed version (ground truth):
private void addInsertionPoints(final List<Object> values){
  ImmutableMap.Builder<Match,DiffInsertionPoint> insertionsPoints=ImmutableMap.builder();
  for (  ReferenceChange diff : filter(fInput.getDiffFromTheOtherSide().reverse(),ReferenceChange.class)) {
    if (diff.getState() == DifferenceState.UNRESOLVED) {
      boolean rightToLeft=(getSide() == MergeViewerSide.LEFT);
      EObject value=diff.getValue();
      if (value != null) {
        Match match=diff.getMatch();
        Match matchOfDiffValue=match.getComparison().getMatch(value);
        if (matchOfDiffValue != null) {
          DiffInsertionPoint insertionPoint=new DiffInsertionPoint(diff);
          final int insertionIndex;
          if (diff.getReference().isMany()) {
            insertionIndex=DiffUtil.findInsertionIndex(match.getComparison(),diff,rightToLeft);
          }
 else {
            insertionIndex=0;
          }
          int nbInsertionPointBefore=size(filter(values.subList(0,insertionIndex),DiffInsertionPoint.class));
          values.add(insertionIndex + nbInsertionPointBefore,insertionPoint);
          insertionsPoints.put(matchOfDiffValue,insertionPoint);
        }
      }
    }
  }
  fInsertionPoints=insertionsPoints.build();
}
Program: 93659
Project: 93659
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.AbstractMergeViewer#createStructuredViewer()
 */
@Override protected final TableViewer createStructuredViewer(Composite parent){
  return new TableViewer(parent);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.AbstractMergeViewer#createStructuredViewer()
 */
@Override protected final TableViewer createStructuredViewer(Composite parent){
  return new TableViewer(parent,SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL| SWT.BORDER| SWT.FULL_SELECTION);
}
Program: 93660
Project: 93660
Buggy source:
private static Rectangle getBoundsForInsertionPoint(TableItem tableItem){
  Rectangle fill=getBounds(tableItem);
  fill.y=fill.y + 6;
  fill.height=fill.height - 12;
  return fill;
}

Fixed version (ground truth):
private static Rectangle getBoundsForInsertionPoint(Event event){
  Rectangle fill=getBounds(event);
  fill.y=fill.y + 6;
  fill.height=fill.height - 12;
  return fill;
}