nus-yam/ex-repair huggingface dataset:
Program: 93420
Project: 93420
Buggy source:
@Override public void run(final Composite composite){
  disposeChildren(composite);
  SwtFactory.createStyledText(composite,text,SWT.COLOR_BLACK,true);
  final Composite templates=SwtFactory.createGridComposite(composite,1,0,12,0,0);
  for (int i=0; i < Math.min(patterns.length,3); ++i) {
    final MethodPattern pattern=patterns[i];
    final int patternProbability=(int)(pattern.getNumberOfObservations() / numberOfSubclasses.doubleValue() * 100);
    String text2=String.format("String_Node_Str",i + 1,patternProbability,pattern.getNumberOfObservations());
    new TextAndFeaturesLine(templates,text2,ratings);
    final TableListing table=new TableListing(composite,4);
    final List<Entry<IMethodName,Double>> entries=getRecommendedMethodOverridesSortedByLikelihood(pattern);
    for (    final Entry<IMethodName,Double> entry : entries) {
      table.startNewRow();
      final IMethodName method=entry.getKey();
      text2="String_Node_Str" + method.getDeclaringType().getClassName() + "String_Node_Str"+ Names.vm2srcSimpleMethod(method);
      table.addLabelItem(text2,false,true,SWT.COLOR_BLACK);
      table.addLabelItem("String_Node_Str",false,false,SWT.COLOR_BLACK);
      table.addLabelItem(String.format("String_Node_Str",entry.getValue() * 100),false,false,SWT.COLOR_BLUE);
    }
  }
  ratings.loadCommentsComposite(composite);
}

Fixed version (ground truth):
@Override public void run(final Composite composite){
  disposeChildren(composite);
  SwtFactory.createStyledText(composite,text,SWT.COLOR_BLACK,true);
  final Composite templates=SwtFactory.createGridComposite(composite,1,0,12,0,0);
  for (int i=0; i < Math.min(patterns.length,3); ++i) {
    final MethodPattern pattern=patterns[i];
    final int patternProbability=(int)(pattern.getNumberOfObservations() / numberOfSubclasses.doubleValue() * 100);
    String text2=String.format("String_Node_Str",i + 1,patternProbability,pattern.getNumberOfObservations());
    new TextAndFeaturesLine(templates,text2,ratings);
    final TableListing table=new TableListing(templates,4);
    final List<Entry<IMethodName,Double>> entries=getRecommendedMethodOverridesSortedByLikelihood(pattern);
    for (    final Entry<IMethodName,Double> entry : entries) {
      table.startNewRow();
      final IMethodName method=entry.getKey();
      text2="String_Node_Str" + method.getDeclaringType().getClassName() + "String_Node_Str"+ Names.vm2srcSimpleMethod(method);
      table.addCell(text2,false,true,SWT.COLOR_BLACK);
      table.addCell("String_Node_Str",false,false,SWT.COLOR_BLACK);
      table.addCell(String.format("String_Node_Str",entry.getValue() * 100),false,false,SWT.COLOR_BLUE);
    }
  }
  ratings.loadCommentsComposite(composite);
}
Program: 93421
Project: 93421
Buggy source:
private void checkProvider(final TableItem tableItem,final Control control){
  final IJavaElementSelection lastSelection=table.getLastSelection();
  final String preferenceId=ProvidersTable.getPreferenceId((IProvider)control.getData(),lastSelection.getElementLocation());
  table.setChecked(preferenceId,tableItem.getChecked());
  if (tableItem.getGrayed()) {
    if (tableItem.getChecked()) {
      new ProviderUpdateJob(table,tableItem,lastSelection).schedule();
    }
  }
 else {
    table.setContentVisible(tableItem,tableItem.getChecked());
  }
}

Fixed version (ground truth):
private void checkProvider(final TableItem tableItem,final Control control){
  final IJavaElementSelection lastSelection=table.getLastSelection();
  final String preferenceId=ProvidersTable.getPreferenceId((IProvider)control.getData(),lastSelection.getElementLocation());
  table.setChecked(preferenceId,tableItem.getChecked());
  if (tableItem.getGrayed()) {
    if (tableItem.getChecked()) {
      new ProviderUpdateJob(table,tableItem,lastSelection).schedule();
    }
  }
 else {
    table.setContentVisible(tableItem,tableItem.getChecked(),true);
  }
}
Program: 93422
Project: 93422
Buggy source:
@Test public void testProvidersTable(){
  table.addProvider(mockProviderControl(),"String_Node_Str",null,true);
  Assert.assertEquals(1,table.getItems().length);
  table.setContext(ExtDocUtils.getSelection());
  final IJavaElementSelection lastSelection=table.getLastSelection();
  Assert.assertEquals(ExtDocUtils.getSelection(),lastSelection);
  for (  final TableItem item : table.getItems()) {
    table.setContentVisible(item,true);
  }
}

Fixed version (ground truth):
@Test public void testProvidersTable(){
  table.addProvider(mockProviderControl(),"String_Node_Str",null,true);
  Assert.assertEquals(1,table.getItems().length);
  table.setContext(ExtDocUtils.getSelection());
  final IJavaElementSelection lastSelection=table.getLastSelection();
  Assert.assertEquals(ExtDocUtils.getSelection(),lastSelection);
  for (  final TableItem item : table.getItems()) {
    table.setContentVisible(item,true,true);
  }
}
Program: 93423
Project: 93423
Buggy source:
@Override public IStatus runInUIThread(final IProgressMonitor monitor){
  if (!composite.isDisposed()) {
    disposeChildren(composite);
    final TextAndFeaturesLine line=new TextAndFeaturesLine(composite,text,ratings);
    line.createStyleRange(15,elementName.length(),SWT.NORMAL,false,true);
    displayProposals(proposals,calledMethods);
    comments.createContents(composite);
    composite.layout(true);
  }
  return Status.OK_STATUS;
}

Fixed version (ground truth):
@Override public IStatus runInUIThread(final IProgressMonitor monitor){
  if (!composite.isDisposed()) {
    disposeChildren(composite);
    final TextAndFeaturesLine line=new TextAndFeaturesLine(composite,text,ratings);
    line.createStyleRange(15,elementName.length(),SWT.NORMAL,false,true);
    displayProposals(proposals,calledMethods);
    composite.layout(true);
  }
  return Status.OK_STATUS;
}
Program: 93424
Project: 93424
Buggy source:
private void displayProposalsForAllMethods(final IJavaElementSelection selection,final IField field){
  try {
    final ITypeName fieldType=context.getVariable().type;
    for (    final IMethod method : field.getDeclaringType().getMethods()) {
      if (false) {
        context=new MockedIntelligentCompletionContext(selection){
          @Override public Variable getVariable(){
            return Variable.create(field.getElementName(),fieldType,ElementResolver.toRecMethod(method));
          }
        }
;
        displayProposalsForMethod(method);
      }
    }
  }
 catch (  final JavaModelException e) {
    throw new IllegalStateException(e);
  }
}

Fixed version (ground truth):
private void displayProposalsForAllMethods(final IJavaElementSelection selection,final IField field){
  try {
    final ITypeName fieldType=context.getVariable().type;
    for (    final IMethod method : field.getDeclaringType().getMethods()) {
      context=new MockedIntelligentCompletionContext(selection){
        @Override public Variable getVariable(){
          return Variable.create(field.getElementName(),fieldType,ElementResolver.toRecMethod(method));
        }
      }
;
      displayProposalsForMethod(method);
    }
  }
 catch (  final JavaModelException e) {
    throw new IllegalStateException(e);
  }
}
Program: 93425
Project: 93425
Buggy source:
private boolean displayContentForMethod(final IMethodName method,final IMethodName firstDeclaration){
  final MethodSelfcallDirectives selfcalls=server.getMethodSelfcallDirectives(firstDeclaration);
  if (selfcalls == null || method == null) {
    return false;
  }
  final int definitions=selfcalls.getNumberOfDefinitions();
  final StarsRatingComposite ratings=new StarsRatingComposite(method,this,server);
  new UIJob("String_Node_Str"){
    @Override public IStatus runInUIThread(    final IProgressMonitor monitor){
      if (!composite.isDisposed()) {
        final String text=String.format("String_Node_Str",definitions,method.getName());
        disposeChildren(composite);
        displayMethodOverrideInformation(firstDeclaration.getDeclaringType().getClassName(),92,25);
        final TextAndFeaturesLine line=new TextAndFeaturesLine(composite,text,ratings);
        line.createStyleRange(29 + getLength(definitions),method.getName().length(),SWT.NORMAL,false,true);
        displayDirectives(selfcalls.getCalls(),"String_Node_Str",definitions);
        composite.layout(true);
      }
      return Status.OK_STATUS;
    }
  }
.schedule();
  return true;
}

Fixed version (ground truth):
private boolean displayContentForMethod(final IMethodName method,final IMethodName firstDeclaration){
  final MethodSelfcallDirectives selfcalls=server.getMethodSelfcallDirectives(firstDeclaration);
  if (selfcalls == null || method == null) {
    return false;
  }
  final int definitions=selfcalls.getNumberOfDefinitions();
  final StarsRatingComposite ratings=new StarsRatingComposite(method,this,server);
  final CommentsComposite comments=CommentsComposite.create(method,this,server);
  new UIJob("String_Node_Str"){
    @Override public IStatus runInUIThread(    final IProgressMonitor monitor){
      if (!composite.isDisposed()) {
        disposeChildren(composite);
        final String text=String.format("String_Node_Str",definitions,method.getName());
        final TextAndFeaturesLine line=new TextAndFeaturesLine(composite,text,ratings);
        line.createStyleRange(29 + getLength(definitions),method.getName().length(),SWT.NORMAL,false,true);
        displayDirectives(selfcalls.getCalls(),"String_Node_Str",definitions);
        comments.createContents(composite);
        composite.layout(true);
      }
      return Status.OK_STATUS;
    }
  }
.schedule();
  return true;
}
Program: 93426
Project: 93426
Buggy source:
private boolean displayContentForType(final ITypeName type){
  final ClassOverrideDirectives overrides=server.getClassOverrideDirectives(type);
  if (overrides == null) {
    return false;
  }
  final String elementName=type.getClassName();
  final int subclasses=overrides.getNumberOfSubclasses();
  final String text="String_Node_Str" + subclasses + "String_Node_Str"+ elementName+ "String_Node_Str";
  final String text2="String_Node_Str";
  final ClassSelfcallDirectives calls=server.getClassSelfcallDirectives(type);
  final StarsRatingComposite ratings=new StarsRatingComposite(type,this,server);
  new UIJob("String_Node_Str"){
    @Override public IStatus runInUIThread(    final IProgressMonitor monitor){
      if (!composite.isDisposed()) {
        disposeChildren(composite);
        final TextAndFeaturesLine line=new TextAndFeaturesLine(composite,text,ratings);
        line.createStyleRange(31 + getLength(subclasses),elementName.length(),SWT.NORMAL,false,true);
        displayDirectives(overrides.getOverrides(),"String_Node_Str",subclasses);
        if (calls != null) {
          new TextAndFeaturesLine(composite,text2,ratings);
          displayDirectives(calls.getCalls(),"String_Node_Str",calls.getNumberOfSubclasses());
        }
        composite.layout(true);
      }
      return Status.OK_STATUS;
    }
  }
.schedule();
  return true;
}

Fixed version (ground truth):
private boolean displayContentForType(final ITypeName type){
  final ClassOverrideDirectives overrides=server.getClassOverrideDirectives(type);
  if (overrides == null) {
    return false;
  }
  final String elementName=type.getClassName();
  final int subclasses=overrides.getNumberOfSubclasses();
  final String text="String_Node_Str" + subclasses + "String_Node_Str"+ elementName+ "String_Node_Str";
  final String text2="String_Node_Str";
  final ClassSelfcallDirectives calls=server.getClassSelfcallDirectives(type);
  final StarsRatingComposite ratings=new StarsRatingComposite(type,this,server);
  final CommentsComposite comments=CommentsComposite.create(type,this,server);
  new UIJob("String_Node_Str"){
    @Override public IStatus runInUIThread(    final IProgressMonitor monitor){
      if (!composite.isDisposed()) {
        disposeChildren(composite);
        final TextAndFeaturesLine line=new TextAndFeaturesLine(composite,text,ratings);
        line.createStyleRange(31 + getLength(subclasses),elementName.length(),SWT.NORMAL,false,true);
        displayDirectives(overrides.getOverrides(),"String_Node_Str",subclasses);
        if (calls != null) {
          new TextAndFeaturesLine(composite,text2,ratings);
          displayDirectives(calls.getCalls(),"String_Node_Str",calls.getNumberOfSubclasses());
        }
        comments.createContents(composite);
        composite.layout(true);
      }
      return Status.OK_STATUS;
    }
  }
.schedule();
  return true;
}
Program: 93427
Project: 93427
Buggy source:
@Override public IStatus runInUIThread(final IProgressMonitor monitor){
  if (!composite.isDisposed()) {
    final String text=String.format("String_Node_Str",definitions,method.getName());
    disposeChildren(composite);
    displayMethodOverrideInformation(firstDeclaration.getDeclaringType().getClassName(),92,25);
    final TextAndFeaturesLine line=new TextAndFeaturesLine(composite,text,ratings);
    line.createStyleRange(29 + getLength(definitions),method.getName().length(),SWT.NORMAL,false,true);
    displayDirectives(selfcalls.getCalls(),"String_Node_Str",definitions);
    composite.layout(true);
  }
  return Status.OK_STATUS;
}

Fixed version (ground truth):
@Override public IStatus runInUIThread(final IProgressMonitor monitor){
  if (!composite.isDisposed()) {
    disposeChildren(composite);
    final String text=String.format("String_Node_Str",definitions,method.getName());
    final TextAndFeaturesLine line=new TextAndFeaturesLine(composite,text,ratings);
    line.createStyleRange(29 + getLength(definitions),method.getName().length(),SWT.NORMAL,false,true);
    displayDirectives(selfcalls.getCalls(),"String_Node_Str",definitions);
    comments.createContents(composite);
    composite.layout(true);
  }
  return Status.OK_STATUS;
}
Program: 93429
Project: 93429
Buggy source:
@Override public IStatus runInUIThread(final IProgressMonitor monitor){
  if (!composite.isDisposed()) {
    disposeChildren(composite);
    SwtFactory.createStyledText(composite,text);
    final Composite templates=SwtFactory.createGridComposite(composite,1,0,12,0,0);
    for (int i=0; i < Math.min(patterns.length,3); ++i) {
      final MethodPattern pattern=patterns[i];
      final double patternProbability=pattern.getNumberOfObservations() / numberOfSubclasses.doubleValue();
      String text2=String.format("String_Node_Str",i + 1,patternProbability,pattern.getNumberOfObservations());
      new TextAndFeaturesLine(templates,text2,ratings);
      final Composite template=SwtFactory.createGridComposite(templates,4,12,2,12,0);
      final List<Entry<IMethodName,Double>> entries=getRecommendedMethodOverridesSortedByLikelihood(pattern);
      for (      final Entry<IMethodName,Double> entry : entries) {
        SwtFactory.createSquare(template);
        final IMethodName method=entry.getKey();
        text2="String_Node_Str" + method.getDeclaringType().getClassName() + "String_Node_Str"+ Names.vm2srcSimpleMethod(method);
        SwtFactory.createLabel(template,text2,false,true,SWT.COLOR_BLACK);
        SwtFactory.createLabel(template,"String_Node_Str");
        SwtFactory.createLabel(template,String.format("String_Node_Str",entry.getValue() * 100),false,false,SWT.COLOR_BLUE);
      }
    }
    composite.layout(true);
  }
  return Status.OK_STATUS;
}

Fixed version (ground truth):
@Override public IStatus runInUIThread(final IProgressMonitor monitor){
  if (!composite.isDisposed()) {
    disposeChildren(composite);
    SwtFactory.createStyledText(composite,text);
    final Composite templates=SwtFactory.createGridComposite(composite,1,0,12,0,0);
    for (int i=0; i < Math.min(patterns.length,3); ++i) {
      final MethodPattern pattern=patterns[i];
      final int patternProbability=(int)(pattern.getNumberOfObservations() / numberOfSubclasses.doubleValue() * 100);
      String text2=String.format("String_Node_Str",i + 1,patternProbability,pattern.getNumberOfObservations());
      new TextAndFeaturesLine(templates,text2,ratings);
      final Composite template=SwtFactory.createGridComposite(templates,4,12,2,12,0);
      final List<Entry<IMethodName,Double>> entries=getRecommendedMethodOverridesSortedByLikelihood(pattern);
      for (      final Entry<IMethodName,Double> entry : entries) {
        SwtFactory.createSquare(template);
        final IMethodName method=entry.getKey();
        text2="String_Node_Str" + method.getDeclaringType().getClassName() + "String_Node_Str"+ Names.vm2srcSimpleMethod(method);
        SwtFactory.createLabel(template,text2,false,true,SWT.COLOR_BLACK);
        SwtFactory.createLabel(template,"String_Node_Str");
        SwtFactory.createLabel(template,String.format("String_Node_Str",entry.getValue() * 100),false,false,SWT.COLOR_BLUE);
      }
    }
    comments.createContents(composite);
    composite.layout(true);
  }
  return Status.OK_STATUS;
}
Program: 93430
Project: 93430
Buggy source:
@Override public IStatus run(final IProgressMonitor monitor){
  try {
    monitor.beginTask("String_Node_Str",1);
    updateProvider();
    return Status.OK_STATUS;
  }
  finally {
    monitor.done();
    active.remove(this);
  }
}

Fixed version (ground truth):
@Override public IStatus run(final IProgressMonitor monitor){
  try {
    monitor.beginTask("String_Node_Str",1);
    try {
      updateProvider();
    }
 catch (    final Exception e) {
      e.printStackTrace();
    }
    return Status.OK_STATUS;
  }
  finally {
    monitor.done();
    active.remove(this);
  }
}
Program: 93431
Project: 93431
Buggy source:
@Override public void setMethodContext(IMethodName newActiveMethodContext){
  if (newActiveMethodContext == null) {
    newActiveMethodContext=NetworkUtils.CTX_NULL;
  }
  junctionTree.addEvidence(contextNode,newActiveMethodContext.getIdentifier());
}

Fixed version (ground truth):
@Override public void setMethodContext(IMethodName newActiveMethodContext){
  if (newActiveMethodContext == null) {
    newActiveMethodContext=NetworkUtils.CTX_NULL;
  }
  final String identifier=newActiveMethodContext.getIdentifier();
  if (contextNode.getOutcomes().contains(identifier)) {
    junctionTree.addEvidence(contextNode,identifier);
  }
}
Program: 93432
Project: 93432
Buggy source:
public void invalidateManifest(final IPackageFragmentRoot packageFragmentRoot){
  resource2manifestId.remove(packageFragmentRoot);
}

Fixed version (ground truth):
public void invalidateManifest(final IPackageFragmentRoot packageFragmentRoot){
  final File file=getLocation(packageFragmentRoot);
  resource2manifestId.remove(file);
}
Program: 93433
Project: 93433
Buggy source:
public static IPackageFragmentRoot getPackageFragmentRoot(final IPackageFragment packageFragment){
  IJavaElement currentElement=packageFragment;
  while (!(currentElement instanceof IPackageFragmentRoot)) {
    currentElement=currentElement.getParent();
  }
  return (IPackageFragmentRoot)currentElement;
}

Fixed version (ground truth):
public static IPackageFragmentRoot getPackageFragmentRoot(final IPackageFragment packageFragment){
  return (IPackageFragmentRoot)packageFragment.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
}
Program: 93434
Project: 93434
Buggy source:
public static AbstractJavaCompletionProposal createFromJDTProposal(final SubwordsProposalContext subwordsContext){
  final IJavaCompletionProposal jdtProposal=subwordsContext.getJdtProposal();
  if (jdtProposal instanceof JavaMethodCompletionProposal) {
    return SubwordsJavaMethodCompletionProposal.create(subwordsContext);
  }
 else   if (jdtProposal instanceof JavaCompletionProposal) {
    return SubwordsJavaCompletionProposal.create(subwordsContext);
  }
 else   if (jdtProposal instanceof LazyJavaTypeCompletionProposal) {
    return SubwordsJavaTypeCompletionProposal.create(subwordsContext);
  }
 else   if (jdtProposal instanceof JavaFieldWithCastedReceiverCompletionProposal) {
    return SubwordsFieldCastedCompletionProposal.create(subwordsContext);
  }
 else   if (jdtProposal instanceof OverrideCompletionProposal) {
    return SubwordsOverrideCompletionProposal.create(subwordsContext);
  }
 else   if (jdtProposal instanceof AnonymousTypeCompletionProposal) {
    try {
      return SubwordsAnonymousCompletionProposal.create(subwordsContext);
    }
 catch (    final CoreException e) {
      throw new RuntimeException(e);
    }
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public static AbstractJavaCompletionProposal createFromJDTProposal(final SubwordsProposalContext subwordsContext){
  final IJavaCompletionProposal jdtProposal=subwordsContext.getJdtProposal();
  if (jdtProposal instanceof JavaMethodCompletionProposal) {
    return SubwordsJavaMethodCompletionProposal.create(subwordsContext);
  }
 else   if (jdtProposal instanceof JavaFieldWithCastedReceiverCompletionProposal) {
    return SubwordsFieldCastedCompletionProposal.create(subwordsContext);
  }
 else   if (jdtProposal instanceof OverrideCompletionProposal) {
    return SubwordsOverrideCompletionProposal.create(subwordsContext);
  }
 else   if (jdtProposal instanceof AnonymousTypeCompletionProposal) {
    try {
      return SubwordsAnonymousCompletionProposal.create(subwordsContext);
    }
 catch (    final CoreException e) {
      throw new RuntimeException(e);
    }
  }
 else   if (jdtProposal instanceof JavaCompletionProposal) {
    return SubwordsJavaCompletionProposal.create(subwordsContext);
  }
 else   if (jdtProposal instanceof LazyJavaTypeCompletionProposal) {
    return SubwordsJavaTypeCompletionProposal.create(subwordsContext);
  }
 else {
    return null;
  }
}
Program: 93435
Project: 93435
Buggy source:
@Before public void before(){
  sut=createJavaCompletionProposal();
}

Fixed version (ground truth):
@Before public void before() throws JavaModelException {
  sut=createJavaCompletionProposal();
}
Program: 93436
Project: 93436
Buggy source:
private SubwordsJavaMethodCompletionProposal createJavaCompletionProposal(){
  final CompletionProposal dummyProposal=mockCompletionProposal(CompletionProposal.METHOD_REF,c1);
  final JavaContentAssistInvocationContext dummyInvocationContext=mockInvocationContext();
  final SubwordsProposalContext subwordsContext=new SubwordsProposalContext("String_Node_Str",dummyProposal,mockJdtCompletion(c1),dummyInvocationContext);
  final SubwordsJavaMethodCompletionProposal someSubwordsProposal=SubwordsJavaMethodCompletionProposal.create(subwordsContext);
  return someSubwordsProposal;
}

Fixed version (ground truth):
private SubwordsJavaMethodCompletionProposal createJavaCompletionProposal() throws JavaModelException {
  final CompletionProposal dummyProposal=mockCompletionProposal(CompletionProposal.METHOD_REF,c1);
  final JavaContentAssistInvocationContext dummyInvocationContext=mockInvocationContext();
  final SubwordsProposalContext subwordsContext=new SubwordsProposalContext("String_Node_Str",dummyProposal,mockJdtCompletion(c1),dummyInvocationContext);
  final SubwordsJavaMethodCompletionProposal someSubwordsProposal=SubwordsJavaMethodCompletionProposal.create(subwordsContext);
  return someSubwordsProposal;
}
Program: 93437
Project: 93437
Buggy source:
@Test public void testHappyPath(){
  final CompletionProposal proposal=mockCompletionProposal(METHOD_REF,"String_Node_Str");
  final SubwordsCompletionRequestor sut=createSut("String_Node_Str");
  sut.accept(proposal);
  assertNumberOfAcceptedProposals(1,sut);
}

Fixed version (ground truth):
@Test public void testHappyPath() throws JavaModelException {
  final CompletionProposal proposal=mockCompletionProposal(METHOD_REF,"String_Node_Str");
  final SubwordsCompletionRequestor sut=createSut("String_Node_Str");
  sut.accept(proposal);
  assertNumberOfAcceptedProposals(1,sut);
}
Program: 93438
Project: 93438
Buggy source:
@Test public void testCompletionMatchButWrongProposalKind(){
  final CompletionProposal proposal=mockCompletionProposal(JAVADOC_BLOCK_TAG,"String_Node_Str");
  final SubwordsCompletionRequestor sut=createSut("String_Node_Str");
  sut.accept(proposal);
  assertNumberOfAcceptedProposals(0,sut);
}

Fixed version (ground truth):
@Test public void testCompletionMatchButWrongProposalKind() throws JavaModelException {
  final CompletionProposal proposal=mockCompletionProposal(JAVADOC_BLOCK_TAG,"String_Node_Str");
  final SubwordsCompletionRequestor sut=createSut("String_Node_Str");
  sut.accept(proposal);
  assertNumberOfAcceptedProposals(0,sut);
}
Program: 93439
Project: 93439
Buggy source:
private SubwordsCompletionRequestor createSut(final String token){
  return new SubwordsCompletionRequestor(token,mockInvocationContext());
}

Fixed version (ground truth):
private SubwordsCompletionRequestor createSut(final String token) throws JavaModelException {
  return new SubwordsCompletionRequestor(token,mockInvocationContext());
}
Program: 93440
Project: 93440
Buggy source:
@Test public void testRightProposalKindButNoCompletionMatch(){
  final CompletionProposal proposal=mockCompletionProposal(METHOD_REF,"String_Node_Str");
  final SubwordsCompletionRequestor sut=createSut("String_Node_Str");
  sut.accept(proposal);
  assertNumberOfAcceptedProposals(0,sut);
}

Fixed version (ground truth):
@Test public void testRightProposalKindButNoCompletionMatch() throws JavaModelException {
  final CompletionProposal proposal=mockCompletionProposal(METHOD_REF,"String_Node_Str");
  final SubwordsCompletionRequestor sut=createSut("String_Node_Str");
  sut.accept(proposal);
  assertNumberOfAcceptedProposals(0,sut);
}
Program: 93441
Project: 93441
Buggy source:
public static CompletionProposal mockCompletionProposal(final int proposalKind,final String completion){
  final CompletionProposal mock=mockCompletionProposal();
  when(mock.getKind()).thenReturn(proposalKind);
  when(mock.getCompletion()).thenReturn(completion.toCharArray());
  when(mock.getName()).thenReturn(completion.toCharArray());
  when(mock.getSignature()).thenReturn("String_Node_Str".toCharArray());
  return mock;
}

Fixed version (ground truth):
public static CompletionProposal mockCompletionProposal(final int proposalKind,final String completion){
  final CompletionProposal mock=mockCompletionProposal();
  when(mock.getKind()).thenReturn(proposalKind);
  when(mock.getCompletion()).thenReturn(completion.toCharArray());
  when(mock.getName()).thenReturn(completion.toCharArray());
  when(mock.getSignature()).thenReturn("String_Node_Str".toCharArray());
  when(mock.getDeclarationKey()).thenReturn(new char[0]);
  when(mock.getDeclarationSignature()).thenReturn("String_Node_Str".toCharArray());
  return mock;
}
Program: 93442
Project: 93442
Buggy source:
public static JavaContentAssistInvocationContext mockInvocationContext(final String token){
  final JavaContentAssistInvocationContext javaContext=mockInvocationContext();
  final CompletionContext coreContext=javaContext.getCoreContext();
  when(coreContext.getToken()).thenReturn(token.toCharArray());
  return javaContext;
}

Fixed version (ground truth):
public static JavaContentAssistInvocationContext mockInvocationContext(final String token) throws JavaModelException {
  final JavaContentAssistInvocationContext javaContext=mockInvocationContext();
  final CompletionContext coreContext=javaContext.getCoreContext();
  when(coreContext.getToken()).thenReturn(token.toCharArray());
  return javaContext;
}
Program: 93443
Project: 93443
Buggy source:
public static ICompilationUnit mockICompilationUnit(){
  return mock(ICompilationUnit.class);
}

Fixed version (ground truth):
public static ICompilationUnit mockICompilationUnit() throws JavaModelException {
  final ICompilationUnit cu=mock(ICompilationUnit.class);
  final IJavaProject javaProject=mockJavaProject();
  when(cu.getJavaProject()).thenReturn(javaProject);
  return cu;
}
Program: 93444
Project: 93444
Buggy source:
private int calculateDistance(final String completion){
  return SubwordsNGramsDistance.calculateRelevanceDistance(token,completion,2);
}

Fixed version (ground truth):
private int calculateDistance(final String completion){
  return SubwordsRelevanceCalculator.calculateRelevance(token,completion);
}
Program: 93445
Project: 93445
Buggy source:
private SubwordsJavaMethodCompletionProposal createJavaCompletionProposal(){
  final CompletionProposal dummyProposal=mockCompletionProposal(CompletionProposal.METHOD_REF,c1);
  final JavaContentAssistInvocationContext dummyInvocationContext=mockInvocationContext();
  final SubwordsProposalContext subwordsContext=new SubwordsProposalContext("String_Node_Str",dummyProposal,mockJdtCompletion(),dummyInvocationContext);
  final SubwordsJavaMethodCompletionProposal someSubwordsProposal=SubwordsJavaMethodCompletionProposal.create(subwordsContext);
  return someSubwordsProposal;
}

Fixed version (ground truth):
private SubwordsJavaMethodCompletionProposal createJavaCompletionProposal(){
  final CompletionProposal dummyProposal=mockCompletionProposal(CompletionProposal.METHOD_REF,c1);
  final JavaContentAssistInvocationContext dummyInvocationContext=mockInvocationContext();
  final SubwordsProposalContext subwordsContext=new SubwordsProposalContext("String_Node_Str",dummyProposal,mockJdtCompletion(c1),dummyInvocationContext);
  final SubwordsJavaMethodCompletionProposal someSubwordsProposal=SubwordsJavaMethodCompletionProposal.create(subwordsContext);
  return someSubwordsProposal;
}
Program: 93446
Project: 93446
Buggy source:
@Test public void testHappyPath(){
  final CompletionProposal proposal=mockCompletionProposal(METHOD_REF,"String_Node_Str");
  final SubwordsCompletionRequestor sut=createSut("String_Node_Str");
  sut.accept(proposal);
  assertNumberOfAcceptedProposals(1,sut);
}

Fixed version (ground truth):
@Test @Ignore public void testHappyPath(){
  final CompletionProposal proposal=mockCompletionProposal(METHOD_REF,"String_Node_Str");
  final SubwordsCompletionRequestor sut=createSut("String_Node_Str");
  sut.accept(proposal);
  assertNumberOfAcceptedProposals(1,sut);
}
Program: 93447
Project: 93447
Buggy source:
public static CompletionProposal mockCompletionProposal(final int proposalKind,final String completion){
  final CompletionProposal mock=mockCompletionProposal();
  when(mock.getKind()).thenReturn(proposalKind);
  when(mock.getCompletion()).thenReturn(completion.toCharArray());
  return mock;
}

Fixed version (ground truth):
public static CompletionProposal mockCompletionProposal(final int proposalKind,final String completion){
  final CompletionProposal mock=mockCompletionProposal();
  when(mock.getKind()).thenReturn(proposalKind);
  when(mock.getCompletion()).thenReturn(completion.toCharArray());
  when(mock.getName()).thenReturn(completion.toCharArray());
  return mock;
}
Program: 93448
Project: 93448
Buggy source:
public static JavaCompletionProposal mockJdtCompletion(){
  return mock(JavaCompletionProposal.class);
}

Fixed version (ground truth):
public static JavaCompletionProposal mockJdtCompletion(final String proposalDisplayString){
  final JavaCompletionProposal mock=mock(JavaCompletionProposal.class);
  when(mock.getDisplayString()).thenReturn(proposalDisplayString);
  return mock;
}
Program: 93449
Project: 93449
Buggy source:
@Override public boolean selectionChanged(final IJavaElementSelection context){
  if (context.getJavaElement() != null) {
    javadoc.setInput(context.getJavaElement());
    final Browser browser=(Browser)javadoc.getControl();
    browser.setSize(browser.getSize().x,5);
  }
  return context.getJavaElement() != null;
}

Fixed version (ground truth):
@Override public boolean selectionChanged(final IJavaElementSelection context){
  if (context.getJavaElement() != null) {
    javadoc.setInput(context.getJavaElement());
    setBrowserSizeLayoutDataAndTriggerLayout(20);
  }
  return context.getJavaElement() != null;
}
Program: 93450
Project: 93450
Buggy source:
@Override public void run(){
  final Browser browser=(Browser)javadoc.getControl();
  final Object result=browser.evaluate("String_Node_Str");
  browser.setSize(browser.getSize().x,(int)Math.ceil((Double)result));
  browser.getParent().layout(true);
}

Fixed version (ground truth):
@Override public void run(){
  final Browser browser=(Browser)javadoc.getControl();
  final Object result=browser.evaluate("String_Node_Str");
  final int height=(int)Math.ceil((Double)result);
  setBrowserSizeLayoutDataAndTriggerLayout(height);
}
Program: 93451
Project: 93451
Buggy source:
@Override public void completed(final ProgressEvent event){
  Display.getCurrent().asyncExec(new Runnable(){
    @Override public void run(){
      final Browser browser=(Browser)javadoc.getControl();
      final Object result=browser.evaluate("String_Node_Str");
      browser.setSize(browser.getSize().x,(int)Math.ceil((Double)result));
      browser.getParent().layout(true);
    }
  }
);
}

Fixed version (ground truth):
@Override public void completed(final ProgressEvent event){
  Display.getCurrent().asyncExec(new Runnable(){
    @Override public void run(){
      final Browser browser=(Browser)javadoc.getControl();
      final Object result=browser.evaluate("String_Node_Str");
      final int height=(int)Math.ceil((Double)result);
      setBrowserSizeLayoutDataAndTriggerLayout(height);
    }
  }
);
}
Program: 93452
Project: 93452
Buggy source:
@Override public Control createControl(final Composite parent,final IWorkbenchPartSite partSite){
  javadoc=new ExtendedJavadocView(parent,partSite);
  javadoc.getControl().setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,false,1,1));
  javadoc.getControl().setSize(-1,250);
  final Browser browser=(Browser)javadoc.getControl();
  browser.addProgressListener(this);
  browser.setJavascriptEnabled(true);
  return javadoc.getControl();
}

Fixed version (ground truth):
@Override public Control createControl(final Composite parent,final IWorkbenchPartSite partSite){
  javadoc=new ExtendedJavadocView(parent,partSite);
  setBrowserSizeLayoutDataAndTriggerLayout(20);
  final Browser browser=(Browser)javadoc.getControl();
  browser.addProgressListener(this);
  browser.setJavascriptEnabled(true);
  return javadoc.getControl();
}
Program: 93453
Project: 93453
Buggy source:
/** 
 * @param locationNodeType The type of the AST node indicating the element's location.
 * @param javaElement The Java element to identify the location for.
 * @return The {@link JavaElementLocation} for the given Java element andits location node type.
 */
private static JavaElementLocation getLocationForNodeType(final int locationNodeType,final IJavaElement javaElement){
switch (locationNodeType) {
case ASTNode.BLOCK:
case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
    return JavaElementLocation.BLOCK;
case ASTNode.METHOD_DECLARATION:
  return JavaElementLocation.METHOD_DECLARATION;
case ASTNode.SINGLE_VARIABLE_DECLARATION:
return JavaElementLocation.METHOD_DECLARATION_PARAMETER;
case ASTNode.FIELD_DECLARATION:
return JavaElementLocation.FIELD_DECLARATION;
case ASTNode.TYPE_DECLARATION:
return getTypeDeclarationLocation(javaElement);
case ASTNode.IMPORT_DECLARATION:
return JavaElementLocation.IMPORT_DECLARATION;
case ASTNode.PACKAGE_DECLARATION:
return JavaElementLocation.PACKAGE_DECLARATION;
default :
throw new IllegalArgumentException("String_Node_Str" + locationNodeType);
}
}

Fixed version (ground truth):
/** 
 * @param locationNodeType The type of the AST node indicating the element's location.
 * @param javaElement The Java element to identify the location for.
 * @return The {@link JavaElementLocation} for the given Java element andits location node type.
 */
private static JavaElementLocation getLocationForNodeType(final int locationNodeType,final IJavaElement javaElement){
switch (locationNodeType) {
case ASTNode.BLOCK:
case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
case ASTNode.CAST_EXPRESSION:
    return JavaElementLocation.BLOCK;
case ASTNode.METHOD_DECLARATION:
  return JavaElementLocation.METHOD_DECLARATION;
case ASTNode.SINGLE_VARIABLE_DECLARATION:
return JavaElementLocation.METHOD_DECLARATION_PARAMETER;
case ASTNode.FIELD_DECLARATION:
return JavaElementLocation.FIELD_DECLARATION;
case ASTNode.TYPE_DECLARATION:
return getTypeDeclarationLocation(javaElement);
case ASTNode.IMPORT_DECLARATION:
return JavaElementLocation.IMPORT_DECLARATION;
case ASTNode.PACKAGE_DECLARATION:
return JavaElementLocation.PACKAGE_DECLARATION;
default :
throw new IllegalArgumentException("String_Node_Str" + locationNodeType);
}
}
Program: 93454
Project: 93454
Buggy source:
private boolean displayContentForMethod(final IMethod element){
  try {
    disposeContainerChildren();
    final IMethod overriddenMethod=SuperTypeHierarchyCache.getMethodOverrideTester(element.getDeclaringType()).findOverriddenMethod(element,true);
    if (overriddenMethod == null) {
      return false;
    }
    final CodeExamples codeExamples=server.getOverridenMethodCodeExamples(overriddenMethod);
    final CodeSnippet[] snippets=codeExamples.getExamples();
    for (int i=0; i < snippets.length; i++) {
      createSnippetVisualization(i,element,snippets[i]);
    }
    container.layout(true);
  }
 catch (  final JavaModelException e) {
    e.printStackTrace();
  }
  return true;
}

Fixed version (ground truth):
private boolean displayContentForMethod(final IMethod element){
  try {
    disposeContainerChildren();
    final IMethod overriddenMethod=SuperTypeHierarchyCache.getMethodOverrideTester(element.getDeclaringType()).findOverriddenMethod(element,true);
    if (overriddenMethod == null) {
      return false;
    }
    final CodeExamples codeExamples=server.getOverridenMethodCodeExamples(overriddenMethod);
    if (codeExamples == null) {
      return false;
    }
    final CodeSnippet[] snippets=codeExamples.getExamples();
    for (int i=0; i < snippets.length; i++) {
      createSnippetVisualization(i,element,snippets[i]);
    }
    container.layout(true);
  }
 catch (  final JavaModelException e) {
    e.printStackTrace();
  }
  return true;
}
Program: 93455
Project: 93455
Buggy source:
private void displayDirectives(final Map<IMethodName,Integer> directives,final String actionKeyword,final int definitions){
  final Composite directiveComposite=SwtFactory.createGridComposite(composite,4,12,3,15,0);
  final Map<IMethodName,Integer> orderedMap=new TreeMap<IMethodName,Integer>(new Comparator<IMethodName>(){
    @Override public int compare(    final IMethodName o1,    final IMethodName o2){
      return directives.get(o2).compareTo(directives.get(o1));
    }
  }
);
  orderedMap.putAll(directives);
  for (  final Entry<IMethodName,Integer> directive : orderedMap.entrySet()) {
    final int percent=(int)Math.round(directive.getValue() * 100.0 / definitions);
    SwtFactory.createSquare(directiveComposite);
    SwtFactory.createLabel(directiveComposite,getLabel(percent),true,false,false);
    SwtFactory.createLabel(directiveComposite,actionKeyword + "String_Node_Str" + Names.vm2srcSimpleMethod(directive.getKey()),false,false,true);
    final StyledText txt=SwtFactory.createStyledText(directiveComposite,"String_Node_Str" + directive.getValue() + "String_Node_Str"+ percent+ "String_Node_Str");
    SwtFactory.createStyleRange(txt,10 + getLength(directive.getValue()),getLength(percent) + 1,SWT.NORMAL,true,false);
  }
}

Fixed version (ground truth):
private void displayDirectives(final Map<IMethodName,Integer> directives,final String actionKeyword,final int definitions){
  final Composite directiveComposite=SwtFactory.createGridComposite(composite,4,12,2,15,0);
  final Map<IMethodName,Integer> orderedMap=new TreeMap<IMethodName,Integer>(new Comparator<IMethodName>(){
    @Override public int compare(    final IMethodName o1,    final IMethodName o2){
      return directives.get(o2).compareTo(directives.get(o1));
    }
  }
);
  orderedMap.putAll(directives);
  for (  final Entry<IMethodName,Integer> directive : orderedMap.entrySet()) {
    final int percent=(int)Math.round(directive.getValue() * 100.0 / definitions);
    SwtFactory.createSquare(directiveComposite);
    SwtFactory.createLabel(directiveComposite,getLabel(percent),true,false,false);
    SwtFactory.createLabel(directiveComposite,actionKeyword + "String_Node_Str" + Names.vm2srcSimpleMethod(directive.getKey()),false,false,true);
    final StyledText txt=SwtFactory.createStyledText(directiveComposite,"String_Node_Str" + directive.getValue() + "String_Node_Str"+ percent+ "String_Node_Str");
    SwtFactory.createStyleRange(txt,10 + getLength(directive.getValue()),getLength(percent) + 1,SWT.NORMAL,true,false);
  }
}
Program: 93456
Project: 93456
Buggy source:
private void printProposals(final IJavaElement element){
  final int subclasses=123;
  styledText.setText("String_Node_Str" + subclasses + "String_Node_Str");
  if (templates != null) {
    templates.dispose();
  }
  templates=SwtFactory.createGridComposite(composite,1,0,12,0,0);
  for (int i=0; i < 2; ++i) {
    final String text="String_Node_Str";
    final TextAndFeaturesLine line=new TextAndFeaturesLine(templates,text,element,element.getElementName(),this,server,new TemplateEditDialog(getShell()));
    line.createStyleRange(0,16,SWT.BOLD,false,false);
    line.createStyleRange(40,3,SWT.NORMAL,true,false);
    final Composite template=SwtFactory.createGridComposite(templates,5,12,3,12,0);
    for (int j=0; j < 3; ++j) {
      SwtFactory.createSquare(template);
      SwtFactory.createLabel(template,"String_Node_Str",true,false,false);
      SwtFactory.createLabel(template,"String_Node_Str",false,false,true);
      SwtFactory.createLabel(template,"String_Node_Str",false,false,false);
      SwtFactory.createLabel(template,"String_Node_Str",false,true,false);
    }
  }
  composite.layout(true);
}

Fixed version (ground truth):
private void printProposals(final IJavaElement element){
  final int subclasses=123;
  styledText.setText("String_Node_Str" + subclasses + "String_Node_Str");
  if (templates != null) {
    templates.dispose();
  }
  templates=SwtFactory.createGridComposite(composite,1,0,12,0,0);
  for (int i=0; i < 2; ++i) {
    final String text="String_Node_Str";
    final TextAndFeaturesLine line=new TextAndFeaturesLine(templates,text,element,element.getElementName(),this,server,new TemplateEditDialog(getShell()));
    line.createStyleRange(0,16,SWT.BOLD,false,false);
    line.createStyleRange(40,3,SWT.NORMAL,true,false);
    final Composite template=SwtFactory.createGridComposite(templates,5,12,2,12,0);
    for (int j=0; j < 3; ++j) {
      SwtFactory.createSquare(template);
      SwtFactory.createLabel(template,"String_Node_Str",true,false,false);
      SwtFactory.createLabel(template,"String_Node_Str",false,false,true);
      SwtFactory.createLabel(template,"String_Node_Str",false,false,false);
      SwtFactory.createLabel(template,"String_Node_Str",false,true,false);
    }
  }
  composite.layout(true);
}
Program: 93457
Project: 93457
Buggy source:
@Override protected boolean updateContent(final IJavaElementSelection selection){
  final IJavaElement element=selection.getJavaElement();
  String markup=null;
  if (element != null) {
    markup=server.getText(element);
  }
  if (composite != null) {
    composite.dispose();
  }
  composite=SwtFactory.createGridComposite(parentComposite,1,0,11,0,0);
  if (markup == null) {
    displayNoText(element);
  }
 else {
    displayText(element,markup);
  }
  parentComposite.layout(true);
  return true;
}

Fixed version (ground truth):
@Override protected boolean updateContent(final IJavaElementSelection selection){
  final IJavaElement element=selection.getJavaElement();
  if (element == null || element instanceof ILocalVariable) {
    return false;
  }
  if (composite != null) {
    composite.dispose();
  }
  composite=SwtFactory.createGridComposite(parentComposite,1,0,11,0,0);
  final String markup=server.getText(element);
  if (markup == null) {
    displayNoText(element);
  }
 else {
    displayText(element,markup);
  }
  parentComposite.layout(true);
  return true;
}
Program: 93458
Project: 93458
Buggy source:
@Override public void stop(final BundleContext context) throws Exception {
  preferences.flush();
  preferences=null;
  plugin=null;
  super.stop(context);
}

Fixed version (ground truth):
@Override public void stop(final BundleContext context) throws Exception {
  preferences=null;
  plugin=null;
  super.stop(context);
}
Program: 93459
Project: 93459
Buggy source:
@Override public void start(final BundleContext context) throws Exception {
  super.start(context);
  plugin=this;
  preferences=new InstanceScope().getNode(getBundle().getSymbolicName());
  preferences.sync();
}

Fixed version (ground truth):
@Override public void start(final BundleContext context) throws Exception {
  super.start(context);
  plugin=this;
  preferences=new InstanceScope().getNode(getBundle().getSymbolicName());
}
Program: 93460
Project: 93460
Buggy source:
public void update(final IJavaElementSelection selection){
  if (selection != null && table != null) {
    table.setContext(selection.getElementLocation());
    for (    final TableItem item : table.getItems()) {
      if (item.getChecked()) {
        new UIJob("String_Node_Str"){
          @Override public IStatus runInUIThread(          final IProgressMonitor monitor){
            final IProvider provider=(IProvider)((Control)item.getData()).getData();
            final boolean hasContent=provider.selectionChanged(selection);
            table.setGrayed(item,!hasContent);
            return Status.OK_STATUS;
          }
        }
.schedule();
      }
    }
    new UIJob("String_Node_Str"){
      @Override public IStatus runInUIThread(      final IProgressMonitor monitor){
        providersComposite.layout(true);
        scrolled.layout(true);
        scrolled.setMinHeight(providersComposite.computeSize(SWT.DEFAULT,SWT.DEFAULT,true).y);
        return Status.OK_STATUS;
      }
    }
.schedule();
  }
}

Fixed version (ground truth):
public void update(final IJavaElementSelection selection){
  if (selection != null && table != null) {
    table.setContext(selection.getElementLocation());
    for (    final TableItem item : table.getItems()) {
      if (item.getChecked()) {
        new UIJob("String_Node_Str"){
          @Override public IStatus runInUIThread(          final IProgressMonitor monitor){
            final IProvider provider=(IProvider)((Control)item.getData()).getData();
            final boolean hasContent=provider.selectionChanged(selection);
            table.setGrayed(item,!hasContent);
            return Status.OK_STATUS;
          }
        }
.schedule();
      }
    }
    new UIJob("String_Node_Str"){
      @Override public IStatus runInUIThread(      final IProgressMonitor monitor){
        providersComposite.layout(true);
        scrolled.layout(true);
        scrolled.setMinHeight(providersComposite.computeSize(SWT.DEFAULT,SWT.DEFAULT,true).y);
        return Status.OK_STATUS;
      }
    }
.schedule(500);
  }
}
Program: 93461
Project: 93461
Buggy source:
public void setContext(final JavaElementLocation location){
  if (lastLocation != location) {
    preferencePrefix=location.name();
    for (    final TableItem item : table.getItems()) {
      final IProvider provider=(IProvider)((Control)item.getData()).getData();
      boolean selectProvider=false;
      if (preferences.getBoolean(preferencePrefix + provider.getProviderName(),true)) {
        selectProvider=provider.isAvailableForLocation(location);
      }
      setChecked(item,selectProvider);
      setGrayed(item,!selectProvider);
    }
    lastLocation=location;
  }
}

Fixed version (ground truth):
public void setContext(final JavaElementLocation location){
  if (lastLocation != location) {
    preferencePrefix=location == null ? "String_Node_Str" : location.name();
    for (    final TableItem item : table.getItems()) {
      final IProvider provider=(IProvider)((Control)item.getData()).getData();
      boolean selectProvider=false;
      if (preferences.getBoolean(preferencePrefix + provider.getProviderName(),true)) {
        selectProvider=provider.isAvailableForLocation(location);
      }
      setChecked(item,selectProvider);
      setGrayed(item,!selectProvider);
    }
    lastLocation=location;
  }
}