nus-yam/ex-repair huggingface dataset:
Program: 93506
Project: 93506
Buggy source:
/** 
 * @param receiverName The variable name if it could be extracted from the context.
 * @param receiverType The type of the variable on which completion is requested.
 * @param context The context holding information about the completion request.
 * @param needsConstructor True, if the completion is invoked while a new variable is defined, e.g. <code>Button b<^Space></code>.
 * @return The {@link CompletionTargetVariable} representing the variable onwhich the request was invoked or which shall be constructed in case it was invoked while defining a new variable.
 */
private static CompletionTargetVariable createInvokedVariable(final String receiverName,final ITypeName receiverType,final IIntelligentCompletionContext context,final boolean needsConstructor){
  CompletionTargetVariable completionTargetVariable=null;
  if (receiverType != null) {
    int documentOffset;
    int variableNameLength=0;
    if (!needsConstructor && receiverName.length() > 0) {
      variableNameLength=receiverName.length() + 1;
    }
    if (needsConstructor) {
      documentOffset=context.getReplacementRegion().getOffset();
    }
 else {
      documentOffset=context.getInvocationOffset() - variableNameLength;
    }
    final int replacementLength=context.getReplacementRegion().getLength() + variableNameLength;
    completionTargetVariable=new CompletionTargetVariable(receiverName,receiverType,new Region(documentOffset,replacementLength),needsConstructor);
  }
  return completionTargetVariable;
}

Fixed version (ground truth):
/** 
 * @param receiverName The variable name if it could be extracted from the context.
 * @param receiverType The type of the variable on which completion is requested.
 * @param context The context holding information about the completion request.
 * @param needsConstructor True, if the completion is invoked while a new variable is defined, e.g. <code>Button b<^Space></code>.
 * @return The {@link CompletionTargetVariable} representing the variable onwhich the request was invoked or which shall be constructed in case it was invoked while defining a new variable.
 */
private static CompletionTargetVariable createInvokedVariable(final String receiverName,final ITypeName receiverType,final IIntelligentCompletionContext context,final boolean needsConstructor){
  CompletionTargetVariable completionTargetVariable=null;
  if (receiverType != null) {
    int variableNameLength=0;
    if (!needsConstructor && receiverName.length() > 0) {
      variableNameLength=receiverName.length() + 1;
    }
    final int documentOffset=context.getReplacementRegion().getOffset() - variableNameLength;
    final int replacementLength=context.getReplacementRegion().getLength() + variableNameLength;
    completionTargetVariable=new CompletionTargetVariable(receiverName,receiverType,new Region(documentOffset,replacementLength),needsConstructor);
  }
  return completionTargetVariable;
}
Program: 93507
Project: 93507
Buggy source:
/** 
 * @param methodCall {@link MethodCall} holding information about the method callto format and on which variable it is invoked.
 * @return The name of the new variable created from the method's returnedtype.
 */
private static String getNewVariableName(final MethodCall methodCall){
  final IMethodName invokedMethod=methodCall.getInvokedMethod();
  String variableName=null;
  if (invokedMethod.isInit()) {
    variableName=methodCall.getCompletionTargetVariable().getName();
  }
  if (variableName == null) {
    variableName=getNewVariableNameFromMethod(invokedMethod);
  }
  return variableName;
}

Fixed version (ground truth):
/** 
 * @param methodCall {@link MethodCall} holding information about the method callto format and on which variable it is invoked.
 * @return The name of the new variable created from the method's returnedtype.
 */
private static String getNewVariableName(final MethodCall methodCall){
  String variableName=null;
  if (methodCall.getInvokedMethod().isInit()) {
    variableName=methodCall.getCompletionTargetVariable().getName();
  }
  if (variableName == null || variableName.isEmpty()) {
    variableName=getNewVariableNameFromMethod(methodCall);
  }
  return variableName;
}
Program: 93508
Project: 93508
Buggy source:
/** 
 * @param methodName A method which returns a type other than void.
 * @return A variable name from the given method's name (e.g. "<code>getText</code>" to "<code>text</code>") or its return type (e.g. "<code>someMethod : String</code>" to "<code>string</code> ").
 */
private static String getNewVariableNameFromMethod(final IMethodName methodName){
  String variableName;
  if (methodName.getName().startsWith("String_Node_Str")) {
    variableName=methodName.getName().substring(3);
  }
 else {
    variableName=methodName.getReturnType().getClassName();
  }
  return StringUtils.uncapitalize(variableName);
}

Fixed version (ground truth):
/** 
 * @param methodCall {@link MethodCall} holding information about the method callto format and on which variable it is invoked.
 * @return A variable name from the given method's name (e.g. "<code>getText</code>" to "<code>text</code>") or its return type (e.g. "<code>someMethod : String</code>" to "<code>string</code> ").
 */
private static String getNewVariableNameFromMethod(final MethodCall methodCall){
  String variableName;
  final IMethodName methodName=methodCall.getInvokedMethod();
  if (methodName.isInit()) {
    final String type=Names.vm2srcTypeName(methodCall.getCompletionTargetVariable().getType().getIdentifier());
    variableName=String.format("String_Node_Str",type);
  }
 else   if (methodName.getName().startsWith("String_Node_Str")) {
    variableName=StringUtils.uncapitalize(methodName.getName().substring(3));
    if (variableName.equals(methodCall.getCompletionTargetVariable().getName())) {
      final String type=Names.vm2srcTypeName(methodName.getReturnType().getIdentifier());
      variableName=String.format("String_Node_Str",type);
    }
  }
 else {
    variableName=StringUtils.uncapitalize(methodName.getReturnType().getClassName());
  }
  return variableName;
}
Program: 93509
Project: 93509
Buggy source:
/** 
 * @param methodCall {@link MethodCall} holding information about the method callto format and on which variable it is invoked.
 * @return A string representation of the whole expression, i.e. thedefinition of a new variable if something is returned and the variable with the invoked method, e.g. " <code>String text = button.getText()</code>".
 * @throws JavaModelException When the method could not be resolved by JDT.
 */
String format(final MethodCall methodCall) throws JavaModelException {
  String invocationPrefix;
  final IMethodName invokedMethod=methodCall.getInvokedMethod();
  if (invokedMethod.isInit()) {
    invocationPrefix="String_Node_Str";
  }
 else {
    final String variableName=methodCall.getCompletionTargetVariable().getName();
    invocationPrefix=String.format("String_Node_Str",variableName == null ? "String_Node_Str" : variableName);
  }
  return String.format("String_Node_Str",getNewVariableString(methodCall),invocationPrefix,methodFormatter.format(invokedMethod));
}

Fixed version (ground truth):
/** 
 * @param methodCall {@link MethodCall} holding information about the method callto format and on which variable it is invoked.
 * @return A string representation of the whole expression, i.e. thedefinition of a new variable if something is returned and the variable with the invoked method, e.g. " <code>String text = button.getText()</code>".
 * @throws JavaModelException When the method could not be resolved by JDT.
 */
String format(final MethodCall methodCall) throws JavaModelException {
  String invocationPrefix;
  final IMethodName invokedMethod=methodCall.getInvokedMethod();
  if (invokedMethod.isInit()) {
    invocationPrefix="String_Node_Str";
  }
 else {
    String variableName=methodCall.getCompletionTargetVariable().getName();
    if (variableName == null || variableName.isEmpty()) {
      variableName="String_Node_Str";
    }
    invocationPrefix=String.format("String_Node_Str",variableName);
  }
  return String.format("String_Node_Str",getNewVariableString(methodCall),invocationPrefix,methodFormatter.format(invokedMethod));
}
Program: 93510
Project: 93510
Buggy source:
/** 
 * @param methodName The method for which to get the parameter names.
 * @return The method's parameters as template code, e.g.<code>${string}, ${selected:link(false, true)}</code>.
 * @throws JavaModelException When the method could not be resolved by JDT.
 */
String getParametersString(final IMethodName methodName) throws JavaModelException {
  final StringBuilder parameters=new StringBuilder(32);
  final IMethod jdtMethod=elementResolver.toJdtMethod(methodName);
  final String[] parameterNames=jdtMethod.getParameterNames();
  final String[] parameterTypes=jdtMethod.getParameterTypes();
  for (int i=0; i < parameterNames.length; ++i) {
    parameters.append(getParameterString(parameterNames[i],parameterTypes[i]));
    parameters.append("String_Node_Str");
  }
  return StringUtils.chomp(parameters.toString(),"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @param methodName The method for which to get the parameter names.
 * @return The method's parameters as template code, e.g.<code>${string}, ${selected:link(false, true)}</code>.
 * @throws JavaModelException When the method could not be resolved by JDT.
 */
private String getParametersString(final IMethodName methodName) throws JavaModelException {
  final StringBuilder parameters=new StringBuilder(32);
  final IMethod jdtMethod=elementResolver.toJdtMethod(methodName);
  final String[] parameterNames=jdtMethod.getParameterNames();
  final String[] parameterTypes=jdtMethod.getParameterTypes();
  for (int i=0; i < parameterNames.length; ++i) {
    parameters.append(getParameterString(parameterNames[i],parameterTypes[i]));
    parameters.append("String_Node_Str");
  }
  return StringUtils.chomp(parameters.toString(),"String_Node_Str");
}
Program: 93511
Project: 93511
Buggy source:
@Override public void analyzeMethod(final Entrypoint entrypoint,final MethodDeclaration method){
  this.methodDecl=method;
  setEntrypointMethod(entrypoint);
  buildCallGraph(entrypoint);
  createHeapHelper();
  createInstanceKeyMappings();
  invokeCallgraphAnalyzers();
}

Fixed version (ground truth):
@Override public void analyzeMethod(final Entrypoint entrypoint,final MethodDeclaration method,final IProgressMonitor monitor){
  if (monitor.isCanceled()) {
    return;
  }
  this.methodDecl=method;
  setEntrypointMethod(entrypoint);
  buildCallGraph(entrypoint);
  createHeapHelper();
  createInstanceKeyMappings();
  invokeCallgraphAnalyzers();
}
Program: 93512
Project: 93512
Buggy source:
void finalizeClass(CompilationUnit compilationUnit,IClass exampleClass);

Fixed version (ground truth):
void finalizeClass(CompilationUnit compilationUnit,IClass exampleClass,IProgressMonitor monitor);
Program: 93513
Project: 93513
Buggy source:
@Override public void analyzeMethod(final Entrypoint entrypoint,final MethodDeclaration methodDecl){
  final IMethod method=entrypoint.getMethod();
  if (!method.isInit()) {
    return;
  }
  final IClass declaringClass=method.getDeclaringClass();
  final IClass superclass=declaringClass.getSuperclass();
  if (superclass != null) {
    final ITypeName typeName=WalaNameUtils.wala2recTypeName(superclass);
    final IMethodName methodName=VmMethodName.get(typeName.getIdentifier(),"String_Node_Str");
    methodDecl.firstDeclaration=methodName;
    methodDecl.superDeclaration=methodName;
  }
}

Fixed version (ground truth):
@Override public void analyzeMethod(final Entrypoint entrypoint,final MethodDeclaration methodDecl,final IProgressMonitor monitor){
  final IMethod method=entrypoint.getMethod();
  if (!method.isInit()) {
    return;
  }
  final IClass declaringClass=method.getDeclaringClass();
  final IClass superclass=declaringClass.getSuperclass();
  if (superclass != null) {
    final ITypeName typeName=WalaNameUtils.wala2recTypeName(superclass);
    final IMethodName methodName=VmMethodName.get(typeName.getIdentifier(),"String_Node_Str");
    methodDecl.firstDeclaration=methodName;
    methodDecl.superDeclaration=methodName;
  }
}
Program: 93514
Project: 93514
Buggy source:
@Override public void analyzeClass(final IClass exampleClass,final TypeDeclaration type){
  for (  final IField field : exampleClass.getDeclaredInstanceFields()) {
    final TypeReference fieldType=field.getFieldTypeReference();
    final ITypeName typeName=WalaNameUtils.wala2recTypeName(fieldType);
    type.fields.add(typeName);
  }
}

Fixed version (ground truth):
@Override public void analyzeClass(final IClass exampleClass,final TypeDeclaration type,final IProgressMonitor monitor){
  for (  final IField field : exampleClass.getDeclaredInstanceFields()) {
    final TypeReference fieldType=field.getFieldTypeReference();
    final ITypeName typeName=WalaNameUtils.wala2recTypeName(fieldType);
    type.fields.add(typeName);
  }
}
Program: 93515
Project: 93515
Buggy source:
@Override public void analyzeClass(final IClass exampleClass,final TypeDeclaration type){
  for (  final IClass interface_ : exampleClass.getDirectInterfaces()) {
    final ITypeName name=WalaNameUtils.wala2recTypeName(interface_);
    type.interfaces.add(name);
  }
}

Fixed version (ground truth):
@Override public void analyzeClass(final IClass exampleClass,final TypeDeclaration type,final IProgressMonitor monitor){
  for (  final IClass interface_ : exampleClass.getDirectInterfaces()) {
    final ITypeName name=WalaNameUtils.wala2recTypeName(interface_);
    type.interfaces.add(name);
  }
}
Program: 93516
Project: 93516
Buggy source:
@Override public void analyzeClass(final IClass exampleClass,final TypeDeclaration type){
  final IClass superclass=exampleClass.getSuperclass();
  if (superclass != null) {
    type.superclass=WalaNameUtils.wala2recTypeName(superclass);
  }
}

Fixed version (ground truth):
@Override public void analyzeClass(final IClass exampleClass,final TypeDeclaration type,final IProgressMonitor monitor){
  final IClass superclass=exampleClass.getSuperclass();
  if (superclass != null) {
    type.superclass=WalaNameUtils.wala2recTypeName(superclass);
  }
}
Program: 93517
Project: 93517
Buggy source:
@Override public void finalizeClass(final CompilationUnit compilationUnit,final IClass exampleClass){
  setCompilationUnitFingerprint(compilationUnit,exampleClass);
  final IClassHierarchy cha=exampleClass.getClassHierarchy();
  for (  final ITypeName recType : findAllUsedTypes(compilationUnit)) {
    final TypeReference walaType=WalaNameUtils.rec2walaType(recType);
    final IClass clazz=ClassUtils.findClass(walaType,cha);
    if (clazz != null) {
      addTypeToUsedTypes(compilationUnit,recType,clazz);
    }
  }
}

Fixed version (ground truth):
@Override public void finalizeClass(final CompilationUnit compilationUnit,final IClass exampleClass,final IProgressMonitor monitor){
  setCompilationUnitFingerprint(compilationUnit,exampleClass);
  final IClassHierarchy cha=exampleClass.getClassHierarchy();
  for (  final ITypeName recType : findAllUsedTypes(compilationUnit)) {
    final TypeReference walaType=WalaNameUtils.rec2walaType(recType);
    final IClass clazz=ClassUtils.findClass(walaType,cha);
    if (clazz != null) {
      addTypeToUsedTypes(compilationUnit,recType,clazz);
    }
  }
}
Program: 93518
Project: 93518
Buggy source:
private void addTypeToUsedTypes(final CompilationUnit compilationUnit,final ITypeName recType,final IClass clazz){
  String fingerprint=fingerprint(clazz);
  final org.eclipse.recommenders.internal.commons.analysis.codeelements.TypeReference recTypeRef=org.eclipse.recommenders.internal.commons.analysis.codeelements.TypeReference.create(recType,fingerprint);
  compilationUnit.imports.add(recTypeRef);
}

Fixed version (ground truth):
private void addTypeToUsedTypes(final CompilationUnit compilationUnit,final ITypeName recType,final IClass clazz){
  final String fingerprint=fingerprint(clazz);
  final org.eclipse.recommenders.internal.commons.analysis.codeelements.TypeReference recTypeRef=org.eclipse.recommenders.internal.commons.analysis.codeelements.TypeReference.create(recType,fingerprint);
  compilationUnit.imports.add(recTypeRef);
}
Program: 93519
Project: 93519
Buggy source:
@Override public void analyzeMethod(final Entrypoint entrypoint,final MethodDeclaration methodDecl){
  final IMethod method=entrypoint.getMethod();
  if (!MethodUtils.mayHaveSuperDeclaration(method)) {
    return;
  }
  final IMethod firstDeclaration=MethodUtils.findRootDeclaration(method);
  if (firstDeclaration != null && !sameMethods(method,firstDeclaration)) {
    methodDecl.firstDeclaration=WalaNameUtils.wala2recMethodName(firstDeclaration);
  }
}

Fixed version (ground truth):
@Override public void analyzeMethod(final Entrypoint entrypoint,final MethodDeclaration methodDecl,final IProgressMonitor monitor){
  final IMethod method=entrypoint.getMethod();
  if (!MethodUtils.mayHaveSuperDeclaration(method)) {
    return;
  }
  final IMethod firstDeclaration=MethodUtils.findRootDeclaration(method);
  if (firstDeclaration != null && !sameMethods(method,firstDeclaration)) {
    methodDecl.firstDeclaration=WalaNameUtils.wala2recMethodName(firstDeclaration);
  }
}
Program: 93520
Project: 93520
Buggy source:
void analyzeClass(IClass exampleClass,TypeDeclaration type);

Fixed version (ground truth):
void analyzeClass(IClass exampleClass,TypeDeclaration type,IProgressMonitor monitor);
Program: 93521
Project: 93521
Buggy source:
void analyzeMethod(Entrypoint entrypoint,MethodDeclaration method);

Fixed version (ground truth):
void analyzeMethod(Entrypoint entrypoint,MethodDeclaration method,IProgressMonitor monitor);
Program: 93522
Project: 93522
Buggy source:
@Override public void finalizeClass(final CompilationUnit compilationUnit,final IClass exampleClass){
  recursiveRemoveWalaExceptions(compilationUnit.primaryType);
}

Fixed version (ground truth):
@Override public void finalizeClass(final CompilationUnit compilationUnit,final IClass exampleClass,final IProgressMonitor monitor){
  recursiveRemoveWalaExceptions(compilationUnit.primaryType);
}
Program: 93523
Project: 93523
Buggy source:
@Override public void analyzeMethod(final Entrypoint entrypoint,final MethodDeclaration methodDecl){
  final IMethod method=entrypoint.getMethod();
  methodDecl.line=method.getLineNumber(0);
}

Fixed version (ground truth):
@Override public void analyzeMethod(final Entrypoint entrypoint,final MethodDeclaration methodDecl,final IProgressMonitor monitor){
  final IMethod method=entrypoint.getMethod();
  methodDecl.line=method.getLineNumber(0);
}
Program: 93524
Project: 93524
Buggy source:
@Override public void analyzeClass(final IClass exampleClass,final TypeDeclaration type){
  type.modifiers=exampleClass.getModifiers();
}

Fixed version (ground truth):
@Override public void analyzeClass(final IClass exampleClass,final TypeDeclaration type,final IProgressMonitor monitor){
  type.modifiers=exampleClass.getModifiers();
}
Program: 93525
Project: 93525
Buggy source:
@Override public void analyzeMethod(final Entrypoint entrypoint,final MethodDeclaration methodDecl){
  final IMethod method=entrypoint.getMethod();
  int modifiers=0;
  if (method.isPrivate()) {
    modifiers|=Modifier.PRIVATE;
  }
  if (method.isProtected()) {
    modifiers|=Modifier.PROTECTED;
  }
  if (method.isPublic()) {
    modifiers|=Modifier.PUBLIC;
  }
  if (method.isAbstract()) {
    modifiers|=Modifier.ABSTRACT;
  }
  if (method.isFinal()) {
    modifiers|=Modifier.FINAL;
  }
  if (method.isStatic()) {
    modifiers|=Modifier.STATIC;
  }
  if (method.isSynchronized()) {
    modifiers|=Modifier.SYNCHRONIZED;
  }
  if (method.isVolatile()) {
    modifiers|=Modifier.VOLATILE;
  }
  if (method.isNative()) {
    modifiers|=Modifier.NATIVE;
  }
  methodDecl.modifiers=modifiers;
}

Fixed version (ground truth):
@Override public void analyzeMethod(final Entrypoint entrypoint,final MethodDeclaration methodDecl,final IProgressMonitor monitor){
  final IMethod method=entrypoint.getMethod();
  int modifiers=0;
  if (method.isPrivate()) {
    modifiers|=Modifier.PRIVATE;
  }
  if (method.isProtected()) {
    modifiers|=Modifier.PROTECTED;
  }
  if (method.isPublic()) {
    modifiers|=Modifier.PUBLIC;
  }
  if (method.isAbstract()) {
    modifiers|=Modifier.ABSTRACT;
  }
  if (method.isFinal()) {
    modifiers|=Modifier.FINAL;
  }
  if (method.isStatic()) {
    modifiers|=Modifier.STATIC;
  }
  if (method.isSynchronized()) {
    modifiers|=Modifier.SYNCHRONIZED;
  }
  if (method.isVolatile()) {
    modifiers|=Modifier.VOLATILE;
  }
  if (method.isNative()) {
    modifiers|=Modifier.NATIVE;
  }
  methodDecl.modifiers=modifiers;
}
Program: 93526
Project: 93526
Buggy source:
@Override public void analyzeClass(final IClass exampleClass,final TypeDeclaration type){
  final ITypeName name=WalaNameUtils.wala2recTypeName(exampleClass);
  type.name=name;
}

Fixed version (ground truth):
@Override public void analyzeClass(final IClass exampleClass,final TypeDeclaration type,final IProgressMonitor monitor){
  final ITypeName name=WalaNameUtils.wala2recTypeName(exampleClass);
  type.name=name;
}
Program: 93527
Project: 93527
Buggy source:
@Override public void analyzeMethod(final Entrypoint entrypoint,final MethodDeclaration methodDecl){
  final IMethod method=entrypoint.getMethod();
  methodDecl.name=WalaNameUtils.wala2recMethodName(method);
}

Fixed version (ground truth):
@Override public void analyzeMethod(final Entrypoint entrypoint,final MethodDeclaration methodDecl,final IProgressMonitor monitor){
  final IMethod method=entrypoint.getMethod();
  methodDecl.name=WalaNameUtils.wala2recMethodName(method);
}
Program: 93528
Project: 93528
Buggy source:
@Override public void analyzeMethod(final Entrypoint entrypoint,final MethodDeclaration methodDecl){
  final IMethod method=entrypoint.getMethod();
  if (method.isInit()) {
    return;
  }
  final IMethod superDeclaration=MethodUtils.findSuperDeclaration(method);
  if (superDeclaration != null) {
    methodDecl.superDeclaration=WalaNameUtils.wala2recMethodName(superDeclaration);
  }
}

Fixed version (ground truth):
@Override public void analyzeMethod(final Entrypoint entrypoint,final MethodDeclaration methodDecl,final IProgressMonitor monitor){
  final IMethod method=entrypoint.getMethod();
  if (method.isInit()) {
    return;
  }
  final IMethod superDeclaration=MethodUtils.findSuperDeclaration(method);
  if (superDeclaration != null) {
    methodDecl.superDeclaration=WalaNameUtils.wala2recMethodName(superDeclaration);
  }
}
Program: 93529
Project: 93529
Buggy source:
@Override public void finalizeClass(final CompilationUnit compilationUnit,final IClass exampleClass){
  recursiveRemoveWalaExceptions(compilationUnit.primaryType);
}

Fixed version (ground truth):
@Override public void finalizeClass(final CompilationUnit compilationUnit,final IClass exampleClass,final IProgressMonitor monitor){
  recursiveRemoveWalaExceptions(compilationUnit.primaryType);
}
Program: 93530
Project: 93530
Buggy source:
@Override public void finalizeClass(final CompilationUnit compilationUnit,final IClass exampleClass){
  recursiveRemoveWalaExceptions(compilationUnit.primaryType);
}

Fixed version (ground truth):
@Override public void finalizeClass(final CompilationUnit compilationUnit,final IClass exampleClass,final IProgressMonitor monitor){
  recursiveRemoveWalaExceptions(compilationUnit.primaryType);
}
Program: 93531
Project: 93531
Buggy source:
@Override @Before public void setUp() throws Exception {
  super.setUp();
  Activator.getDefault().getRepositoryCache().clear();
  final MockSystemReader mockSystemReader=new MockSystemReader();
  SystemReader.setInstance(mockSystemReader);
  mockSystemReader.setProperty(Constants.GIT_CEILING_DIRECTORIES_KEY,ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getParentFile().getAbsoluteFile().toString());
  final IWorkspaceRoot workspaceRoot=project.getProject().getWorkspace().getRoot();
  gitDir=new File(workspaceRoot.getRawLocation().toFile(),Constants.DOT_GIT);
  repository=new GitTestRepository(gitDir);
  repository.connect(project.getProject());
  repository.ignore(workspaceRoot.getRawLocation().append("String_Node_Str").toFile());
}

Fixed version (ground truth):
@Override @Before public void setUp() throws Exception {
  super.setUp();
  Activator.getDefault().getRepositoryCache().clear();
  final MockSystemReader mockSystemReader=new MockSystemReader();
  SystemReader.setInstance(mockSystemReader);
  mockSystemReader.setProperty(Constants.GIT_CEILING_DIRECTORIES_KEY,ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getParentFile().getAbsoluteFile().toString());
  final IWorkspaceRoot workspaceRoot=project.getProject().getWorkspace().getRoot();
  gitDir=new File(workspaceRoot.getRawLocation().toFile(),Constants.DOT_GIT);
  repository=new GitTestRepository(gitDir);
  repository.connect(project.getProject());
  File gitIgnoreFile=workspaceRoot.getRawLocation().append("String_Node_Str").toFile();
  Path gitIgnorePath=gitIgnoreFile.toPath();
  Files.write(gitIgnorePath,Collections.singleton("String_Node_Str"),Charset.forName("String_Node_Str"),StandardOpenOption.CREATE);
}
Program: 93532
Project: 93532
Buggy source:
private static void copyDirectoryContents(File rootDirectory,final File workingDirectory) throws IOException {
  for (  String child : rootDirectory.list()) {
    copyDirectory(new File(rootDirectory,child),new File(workingDirectory,child));
  }
}

Fixed version (ground truth):
private static void copyDirectoryContents(File rootDirectory,final File workingDirectory) throws IOException {
  String[] list=rootDirectory.list();
  if (list != null) {
    for (    String child : list) {
      copyDirectory(new File(rootDirectory,child),new File(workingDirectory,child));
    }
  }
}
Program: 93533
Project: 93533
Buggy source:
private Iterable<File> getAllContainedFiles(File workingDirectory){
  final Builder<File> builder=ImmutableList.builder();
  for (  File containedFile : workingDirectory.listFiles()) {
    if (containedFile.isFile()) {
      builder.add(containedFile);
    }
 else     if (containedFile.isDirectory()) {
      builder.addAll(getAllContainedFiles(containedFile));
    }
  }
  return builder.build();
}

Fixed version (ground truth):
private Iterable<File> getAllContainedFiles(File workingDirectory){
  final Builder<File> builder=ImmutableList.builder();
  File[] listFiles=workingDirectory.listFiles();
  if (listFiles != null) {
    for (    File containedFile : listFiles) {
      if (containedFile.isFile()) {
        builder.add(containedFile);
      }
 else       if (containedFile.isDirectory()) {
        builder.addAll(getAllContainedFiles(containedFile));
      }
    }
  }
  return builder.build();
}
Program: 93534
Project: 93534
Buggy source:
private static void copyDirectory(File source,File destination) throws IOException {
  if (source.isDirectory()) {
    if (!destination.exists()) {
      destination.mkdir();
    }
    for (    String child : source.list()) {
      copyDirectory(new File(source,child),new File(destination,child));
    }
  }
 else {
    copyFile(source,destination);
  }
}

Fixed version (ground truth):
private static void copyDirectory(File source,File destination) throws IOException {
  if (source != null && source.isDirectory()) {
    if (destination != null && !destination.exists()) {
      destination.mkdir();
    }
    String[] list=source.list();
    if (list != null) {
      for (      String child : list) {
        copyDirectory(new File(source,child),new File(destination,child));
      }
    }
  }
 else {
    copyFile(source,destination);
  }
}
Program: 93535
Project: 93535
Buggy source:
/** 
 * Import the Eclipse projects contained in the given file.
 * @param file The folder to look inside
 * @throws InvocationTargetException Thrown if an error happen during the import of the project
 * @throws InterruptedException Thrown if the import operation is interrupted
 * @throws CoreException Thrown if the project cannot be created in the workspace
 */
private void importProjects(File file) throws InvocationTargetException, InterruptedException, CoreException {
  for (  File child : file.listFiles()) {
    if (child.isDirectory() && !child.getName().equals(METADATA_FOLDER) && !child.getName().equals("String_Node_Str")) {
      importProjects(child);
    }
 else     if (child.getName().equals("String_Node_Str")) {
      importProject(child);
    }
  }
}

Fixed version (ground truth):
/** 
 * Import the Eclipse projects contained in the given file.
 * @param file The folder to look inside
 * @throws InvocationTargetException Thrown if an error happen during the import of the project
 * @throws InterruptedException Thrown if the import operation is interrupted
 * @throws CoreException Thrown if the project cannot be created in the workspace
 */
private void importProjects(File file) throws InvocationTargetException, InterruptedException, CoreException {
  File[] listFiles=file.listFiles();
  if (listFiles != null) {
    for (    File child : listFiles) {
      if (child.isDirectory() && !child.getName().equals(METADATA_FOLDER) && !child.getName().equals("String_Node_Str")) {
        importProjects(child);
      }
 else       if (child.getName().equals("String_Node_Str")) {
        importProject(child);
      }
    }
  }
}
Program: 93536
Project: 93536
Buggy source:
/** 
 * Clean all possibly remaining elements to start the test in a clean state.
 * @throws CoreException Thrown if a project cannot be deleted
 * @throws IOException Thrown if a file cannot be deleted
 */
protected void setup() throws CoreException, IOException {
  final IWorkspaceRoot workspaceRoot=ResourcesPlugin.getWorkspace().getRoot();
  IProject[] unknownProjects=workspaceRoot.getProjects();
  if (unknownProjects != null && unknownProjects.length > 0) {
    for (    IProject iProject : unknownProjects) {
      iProject.delete(true,new NullProgressMonitor());
    }
  }
  Activator.getDefault().getRepositoryCache().clear();
  File file=new File(workspaceRoot.getLocation().toOSString());
  for (  File child : file.listFiles()) {
    if (!child.getName().equals(METADATA_FOLDER)) {
      FileUtils.delete(child,FileUtils.RECURSIVE | FileUtils.RETRY);
    }
  }
}

Fixed version (ground truth):
/** 
 * Clean all possibly remaining elements to start the test in a clean state.
 * @throws CoreException Thrown if a project cannot be deleted
 * @throws IOException Thrown if a file cannot be deleted
 */
protected void setup() throws CoreException, IOException {
  final IWorkspaceRoot workspaceRoot=ResourcesPlugin.getWorkspace().getRoot();
  IProject[] unknownProjects=workspaceRoot.getProjects();
  if (unknownProjects != null && unknownProjects.length > 0) {
    for (    IProject iProject : unknownProjects) {
      iProject.delete(true,new NullProgressMonitor());
    }
  }
  Activator.getDefault().getRepositoryCache().clear();
  File file=new File(workspaceRoot.getLocation().toOSString());
  File[] listFiles=file.listFiles();
  if (listFiles != null) {
    for (    File child : listFiles) {
      if (!child.getName().equals(METADATA_FOLDER)) {
        FileUtils.delete(child,FileUtils.RECURSIVE | FileUtils.RETRY);
      }
    }
  }
}
Program: 93537
Project: 93537
Buggy source:
/** 
 * Find the ".git" folder in the repository.
 * @param file The path of the root of the unziped files
 * @return The path to the .git folder
 */
private File findGitDir(File file){
  for (  File child : file.listFiles()) {
    if (child.isDirectory() && child.getName().equals("String_Node_Str")) {
      return child;
    }
 else     if (child.isDirectory()) {
      File findGitDir=findGitDir(child);
      if (findGitDir != null) {
        return findGitDir;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Find the ".git" folder in the repository.
 * @param file The path of the root of the unziped files
 * @return The path to the .git folder
 */
private File findGitDir(File file){
  File[] listFiles=file.listFiles();
  if (listFiles != null) {
    for (    File child : listFiles) {
      if (child.isDirectory() && child.getName().equals("String_Node_Str")) {
        return child;
      }
 else       if (child.isDirectory()) {
        File findGitDir=findGitDir(child);
        if (findGitDir != null) {
          return findGitDir;
        }
      }
    }
  }
  return null;
}
Program: 93538
Project: 93538
Buggy source:
/** 
 * Clear workspace and repository for next tests.
 * @throws CoreException Thrown if a project cannot be deleted
 * @throws IOException Thrown if a file cannot be deleted
 */
protected void tearDown() throws CoreException, IOException {
  if (repository != null) {
    repository.close();
    repository=null;
  }
  if (disposers != null) {
    for (    Runnable disposer : disposers) {
      disposer.run();
    }
    disposers.clear();
  }
  Activator.getDefault().getRepositoryCache().clear();
  if (projects != null) {
    new DisconnectProviderOperation(Arrays.asList(projects)).execute(null);
    for (    IProject iProject : projects) {
      iProject.delete(true,new NullProgressMonitor());
    }
  }
  File file=new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
  for (  File child : file.listFiles()) {
    if (!child.getName().equals(METADATA_FOLDER)) {
      FileUtils.delete(child,FileUtils.RECURSIVE | FileUtils.RETRY);
    }
  }
}

Fixed version (ground truth):
/** 
 * Clear workspace and repository for next tests.
 * @throws CoreException Thrown if a project cannot be deleted
 * @throws IOException Thrown if a file cannot be deleted
 */
protected void tearDown() throws CoreException, IOException {
  if (repository != null) {
    repository.close();
    repository=null;
  }
  if (disposers != null) {
    for (    Runnable disposer : disposers) {
      disposer.run();
    }
    disposers.clear();
  }
  Activator.getDefault().getRepositoryCache().clear();
  if (projects != null) {
    new DisconnectProviderOperation(Arrays.asList(projects)).execute(null);
    for (    IProject iProject : projects) {
      iProject.delete(true,new NullProgressMonitor());
    }
  }
  File file=new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
  File[] listFiles=file.listFiles();
  if (listFiles != null) {
    for (    File child : listFiles) {
      if (!child.getName().equals(METADATA_FOLDER)) {
        FileUtils.delete(child,FileUtils.RECURSIVE | FileUtils.RETRY);
      }
    }
  }
}
Program: 93539
Project: 93539
Buggy source:
/** 
 * Make sure that and RAC:DELETE is not in conflict with a change on its EObject if this EObject had an eContainer in the ancestor (i.e. when there is a ReferenceChange:DLETE of a containment reference to conflict with)
 */
@Test public void testDanglingRACTest() throws Exception {
  ResourceSet rsAncestor=input.getRACDanglingConflictAncestorModel();
  ResourceSet rsLeft=input.getRACDanglingConflictLeftModel();
  ResourceSet rsRight=input.getRACDanglingConflictRightModel();
  IComparisonScope scope=new DefaultComparisonScope(rsLeft,rsRight,rsAncestor);
  Comparison comparison=EMFCompare.builder().build().compare(scope);
  List<Diff> differences=comparison.getDifferences();
  List<Conflict> conflicts=comparison.getConflicts();
  assertEquals(5,differences.size());
  assertEquals(2,conflicts.size());
  assertEquals(4,Iterables.size(Iterables.filter(differences,hasConflict(REAL))));
  Iterable<Diff> nonConflictingDiffs=Iterables.filter(differences,not(hasConflict(REAL,PSEUDO)));
  assertEquals(1,Iterables.size(nonConflictingDiffs));
  Diff nonConflictingDiff=nonConflictingDiffs.iterator().next();
  assertTrue(nonConflictingDiff instanceof ResourceAttachmentChange);
  assertEquals(DifferenceSource.RIGHT,nonConflictingDiff.getSource());
  assertTrue(((ResourceAttachmentChange)nonConflictingDiff).getResourceURI().endsWith("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Make sure that and RAC:DELETE is not in conflict with a change on its EObject if this EObject had an eContainer in the ancestor (i.e. when there is a ReferenceChange:DLETE of a containment reference to conflict with)
 */
@Test public void testDanglingRACTest() throws Exception {
  ResourceSet rsAncestor=input.getRACDanglingConflictAncestorModel();
  ResourceSet rsLeft=input.getRACDanglingConflictLeftModel();
  ResourceSet rsRight=input.getRACDanglingConflictRightModel();
  IComparisonScope scope=new DefaultComparisonScope(rsLeft,rsRight,rsAncestor);
  Comparison comparison=EMFCompare.builder().build().compare(scope);
  List<Diff> differences=comparison.getDifferences();
  List<Conflict> conflicts=comparison.getConflicts();
  assertEquals(5,differences.size());
  assertEquals(2,conflicts.size());
  assertEquals(4,size(filter(differences,hasConflict(REAL))));
  Iterable<Diff> nonConflictingDiffs=filter(differences,not(hasConflict(REAL,PSEUDO)));
  assertEquals(1,size(nonConflictingDiffs));
  Diff nonConflictingDiff=nonConflictingDiffs.iterator().next();
  assertTrue(nonConflictingDiff instanceof ResourceAttachmentChange);
  assertEquals(DifferenceSource.RIGHT,nonConflictingDiff.getSource());
  assertTrue(((ResourceAttachmentChange)nonConflictingDiff).getResourceURI().endsWith("String_Node_Str"));
}
Program: 93540
Project: 93540
Buggy source:
@Test public void testK1UseCase() throws IOException {
  final Resource left=input.getK1Left();
  final Resource origin=input.getK1Origin();
  final Resource right=input.getK1Right();
  final IComparisonScope scope=new DefaultComparisonScope(left,right,origin);
  final Comparison comparison=EMFCompare.builder().build().compare(scope);
  final List<Diff> differences=comparison.getDifferences();
  final List<Conflict> conflicts=comparison.getConflicts();
  assertEquals(6,differences.size());
  assertEquals(2,conflicts.size());
  for (  Conflict conflict : conflicts) {
    assertSame(REAL,conflict.getKind());
  }
}

Fixed version (ground truth):
@Test public void testK1UseCase() throws IOException {
  final Resource left=input.getK1Left();
  final Resource origin=input.getK1Origin();
  final Resource right=input.getK1Right();
  final IComparisonScope scope=new DefaultComparisonScope(left,right,origin);
  final Comparison comparison=EMFCompare.builder().build().compare(scope);
  final List<Diff> differences=comparison.getDifferences();
  final List<Conflict> conflicts=comparison.getConflicts();
  assertEquals(6,differences.size());
  assertEquals(2,conflicts.size());
  Iterable<Conflict> realConflicts=filter(conflicts,containsConflictOfTypes(REAL));
  Iterable<Conflict> pseudoConflicts=filter(conflicts,containsConflictOfTypes(PSEUDO));
  assertEquals(1,size(realConflicts));
  assertEquals(1,size(pseudoConflicts));
}
Program: 93541
Project: 93541
Buggy source:
@Test public void testK3UseCase() throws IOException {
  final Resource left=input.getK3Left();
  final Resource origin=input.getK3Origin();
  final Resource right=input.getK3Right();
  final IComparisonScope scope=new DefaultComparisonScope(left,right,origin);
  final Comparison comparison=EMFCompare.builder().build().compare(scope);
  final List<Diff> differences=comparison.getDifferences();
  final List<Conflict> conflicts=comparison.getConflicts();
  assertEquals(6,differences.size());
  assertEquals(3,conflicts.size());
  for (  Conflict conflict : conflicts) {
    assertSame(REAL,conflict.getKind());
  }
}

Fixed version (ground truth):
@Test public void testK3UseCase() throws IOException {
  final Resource left=input.getK3Left();
  final Resource origin=input.getK3Origin();
  final Resource right=input.getK3Right();
  final IComparisonScope scope=new DefaultComparisonScope(left,right,origin);
  final Comparison comparison=EMFCompare.builder().build().compare(scope);
  final List<Diff> differences=comparison.getDifferences();
  final List<Conflict> conflicts=comparison.getConflicts();
  assertEquals(6,differences.size());
  assertEquals(3,conflicts.size());
  Iterable<Conflict> realConflicts=filter(conflicts,containsConflictOfTypes(REAL));
  Iterable<Conflict> pseudoConflicts=filter(conflicts,containsConflictOfTypes(PSEUDO));
  assertEquals(1,size(realConflicts));
  assertEquals(2,size(pseudoConflicts));
}
Program: 93542
Project: 93542
Buggy source:
@Test public void testK2UseCase() throws IOException {
  final Resource left=input.getK2Left();
  final Resource origin=input.getK2Origin();
  final Resource right=input.getK2Right();
  final IComparisonScope scope=new DefaultComparisonScope(left,right,origin);
  final Comparison comparison=EMFCompare.builder().build().compare(scope);
  final List<Diff> differences=comparison.getDifferences();
  final List<Conflict> conflicts=comparison.getConflicts();
  assertEquals(8,differences.size());
  assertEquals(3,conflicts.size());
  for (  Conflict conflict : conflicts) {
    assertSame(REAL,conflict.getKind());
  }
}

Fixed version (ground truth):
@Test public void testK2UseCase() throws IOException {
  final Resource left=input.getK2Left();
  final Resource origin=input.getK2Origin();
  final Resource right=input.getK2Right();
  final IComparisonScope scope=new DefaultComparisonScope(left,right,origin);
  final Comparison comparison=EMFCompare.builder().build().compare(scope);
  final List<Diff> differences=comparison.getDifferences();
  final List<Conflict> conflicts=comparison.getConflicts();
  assertEquals(8,differences.size());
  assertEquals(3,conflicts.size());
  Iterable<Conflict> realConflicts=filter(conflicts,containsConflictOfTypes(REAL));
  Iterable<Conflict> pseudoConflicts=filter(conflicts,containsConflictOfTypes(PSEUDO));
  assertEquals(1,size(realConflicts));
  assertEquals(2,size(pseudoConflicts));
}
Program: 93544
Project: 93544
Buggy source:
/** 
 * Assert that the rejection of the deletion of PackageY (right to left) will not lead to unwanted dependencies dues to the presence of a pseudo conflicts (with dependencies) on a child element of packageY. <pre> The ancestor model: - PackageA - ClassB - PackageX - PackageY - ClassZ -> ClassB The left model:  - PackageX  The right model:  - PackageA2 - ClassB2 - PackageX - PackageY </pre> The comparison on those models leads to a pseudo-conflict (deletion of ClassZ -> ClassB) and two conflicts (renaming of PackageA and ClassB).
 * @throws IOException
 */
@Test public void testImplicationBetweenConflicts() throws IOException {
  Diff deletePackageY=setupImplicationBetweenConflicts();
  MergeDependenciesChecker checker=getChecker(deletePackageY);
  checker.rightToLeft().implies(1).rejects(0).check();
  checker.leftToRight().implies(5).rejects(0).check();
}

Fixed version (ground truth):
/** 
 * Assert that the rejection of the deletion of PackageY (right to left) will not lead to unwanted dependencies dues to the presence of a pseudo conflicts (with dependencies) on a child element of packageY. <pre> The ancestor model: - PackageA - ClassB - PackageX - PackageY - ClassZ -> ClassB The left model:  - PackageX  The right model:  - PackageA2 - ClassB2 - PackageX - PackageY </pre> The comparison on those models leads to a pseudo-conflict (deletion of ClassZ -> ClassB) and two conflicts (renaming of PackageA and ClassB).
 * @throws IOException
 */
@Test public void testImplicationBetweenConflicts() throws IOException {
  Diff deletePackageY=setupImplicationBetweenConflicts();
  MergeDependenciesChecker checker=getChecker(deletePackageY);
  checker.rightToLeft().implies(1).rejects(0).check();
  checker.leftToRight().implies(1).rejects(0).check();
}
Program: 93549
Project: 93549
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.emf.compare.conflict.IConflictDetector#detect(org.eclipse.emf.compare.Comparison,org.eclipse.emf.common.util.Monitor)
 */
public void detect(Comparison comparison,Monitor monitor){
  long start=System.currentTimeMillis();
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("String_Node_Str");
  }
  final List<Diff> differences=comparison.getDifferences();
  final int diffCount=differences.size();
  for (int i=0; i < diffCount; i++) {
    if (i % 100 == 0) {
      monitor.subTask(EMFCompareMessages.getString("String_Node_Str",Integer.valueOf(i + 1),Integer.valueOf(diffCount)));
    }
    if (monitor.isCanceled()) {
      throw new ComparisonCanceledException();
    }
    final Diff diff=differences.get(i);
    checkConflict(comparison,diff,Iterables.filter(differences,possiblyConflictingWith(diff)));
  }
  handlePseudoUnderRealAdd(comparison);
  if (LOGGER.isInfoEnabled()) {
    LOGGER.info(String.format("String_Node_Str",Long.valueOf(System.currentTimeMillis() - start)));
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.emf.compare.conflict.IConflictDetector#detect(org.eclipse.emf.compare.Comparison,org.eclipse.emf.common.util.Monitor)
 */
public void detect(Comparison comparison,Monitor monitor){
  long start=System.currentTimeMillis();
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("String_Node_Str");
  }
  final List<Diff> differences=comparison.getDifferences();
  final int diffCount=differences.size();
  for (int i=0; i < diffCount; i++) {
    if (i % 100 == 0) {
      monitor.subTask(EMFCompareMessages.getString("String_Node_Str",Integer.valueOf(i + 1),Integer.valueOf(diffCount)));
    }
    if (monitor.isCanceled()) {
      throw new ComparisonCanceledException();
    }
    final Diff diff=differences.get(i);
    checkConflict(comparison,diff,Iterables.filter(differences,possiblyConflictingWith(diff)));
  }
  if (LOGGER.isInfoEnabled()) {
    LOGGER.info(String.format("String_Node_Str",Long.valueOf(System.currentTimeMillis() - start)));
  }
}
Program: 93550
Project: 93550
Buggy source:
/** 
 * {@inheritDoc}
 * @see org.eclipse.emf.compare.conflict.IConflictDetector#detect(org.eclipse.emf.compare.Comparison,org.eclipse.emf.common.util.Monitor)
 */
public void detect(Comparison comparison,Monitor monitor){
  long start=System.currentTimeMillis();
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("String_Node_Str");
  }
  final List<Diff> differences=comparison.getDifferences();
  final int diffCount=differences.size();
  ConflictSearchFactory conflictSearchFactory=new ConflictSearchFactory(comparison,monitor);
  for (int i=0; i < diffCount; i++) {
    if (i % 100 == 0) {
      monitor.subTask(EMFCompareMessages.getString("String_Node_Str",Integer.valueOf(i + 1),Integer.valueOf(diffCount)));
    }
    if (monitor.isCanceled()) {
      throw new ComparisonCanceledException();
    }
    final Diff diff=differences.get(i);
    AbstractConflictSearch<? extends Diff> search=conflictSearchFactory.doSwitch(diff);
    search.detectConflicts();
  }
  handlePseudoUnderRealAdd(comparison);
  if (LOGGER.isInfoEnabled()) {
    LOGGER.info(String.format("String_Node_Str",Long.valueOf(System.currentTimeMillis() - start)));
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see org.eclipse.emf.compare.conflict.IConflictDetector#detect(org.eclipse.emf.compare.Comparison,org.eclipse.emf.common.util.Monitor)
 */
public void detect(Comparison comparison,Monitor monitor){
  long start=System.currentTimeMillis();
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("String_Node_Str");
  }
  final List<Diff> differences=comparison.getDifferences();
  final int diffCount=differences.size();
  ConflictSearchFactory conflictSearchFactory=new ConflictSearchFactory(comparison,monitor);
  for (int i=0; i < diffCount; i++) {
    if (i % 100 == 0) {
      monitor.subTask(EMFCompareMessages.getString("String_Node_Str",Integer.valueOf(i + 1),Integer.valueOf(diffCount)));
    }
    if (monitor.isCanceled()) {
      throw new ComparisonCanceledException();
    }
    final Diff diff=differences.get(i);
    AbstractConflictSearch<? extends Diff> search=conflictSearchFactory.doSwitch(diff);
    search.detectConflicts();
  }
  if (LOGGER.isInfoEnabled()) {
    LOGGER.info(String.format("String_Node_Str",Long.valueOf(System.currentTimeMillis() - start)));
  }
}