Program: 12085
Project: 12085
Buggy source:
private ASTNode processASTNodeWithDifferences(AST ast,ASTRewrite sourceRewriter,ASTNode oldASTNode,List<ASTNodeDifference> differences){
  if (differences.isEmpty()) {
    return oldASTNode;
  }
 else {
    Set<String> parameterBindingKeys=originalPassedParameters.keySet();
    Set<String> declaredLocalVariableBindingKeys=mapper.getDeclaredLocalVariablesInMappedNodes().keySet();
    ExpressionExtractor expressionExtractor=new ExpressionExtractor();
    ASTNode newASTNode=ASTNode.copySubtree(ast,oldASTNode);
    for (    ASTNodeDifference difference : differences) {
      Expression oldExpression=difference.getExpression1().getExpression();
      boolean isCommonParameter=false;
      if (isMethodName(oldExpression)) {
        SimpleName oldSimpleName=(SimpleName)oldExpression;
        IBinding binding=oldSimpleName.resolveBinding();
        oldExpression=(Expression)oldExpression.getParent();
        if (parameterBindingKeys.contains(binding.getKey()) || declaredLocalVariableBindingKeys.contains(binding.getKey()))         isCommonParameter=true;
      }
 else       if (oldExpression instanceof SimpleName) {
        SimpleName oldSimpleName=(SimpleName)oldExpression;
        IBinding binding=oldSimpleName.resolveBinding();
        if (parameterBindingKeys.contains(binding.getKey()) || declaredLocalVariableBindingKeys.contains(binding.getKey()))         isCommonParameter=true;
      }
 else       if (oldExpression instanceof QualifiedName) {
        QualifiedName oldQualifiedName=(QualifiedName)oldExpression;
        SimpleName oldSimpleName=oldQualifiedName.getName();
        IBinding binding=oldSimpleName.resolveBinding();
        if (parameterBindingKeys.contains(binding.getKey()) || declaredLocalVariableBindingKeys.contains(binding.getKey()))         isCommonParameter=true;
      }
      if (!isCommonParameter) {
        if (oldExpression.getParent() instanceof Type) {
          Type oldType=(Type)oldExpression.getParent();
          if (difference.containsDifferenceType(DifferenceType.SUBCLASS_TYPE_MISMATCH)) {
            ITypeBinding typeBinding1=difference.getExpression1().getExpression().resolveTypeBinding();
            ITypeBinding typeBinding2=difference.getExpression2().getExpression().resolveTypeBinding();
            ITypeBinding commonSuperTypeBinding=commonSuperType(typeBinding1,typeBinding2);
            if (commonSuperTypeBinding != null) {
              Type arg=generateTypeFromTypeBinding(commonSuperTypeBinding,ast,sourceRewriter);
              TypeVisitor oldTypeVisitor=new TypeVisitor();
              oldASTNode.accept(oldTypeVisitor);
              List<Type> oldTypes=oldTypeVisitor.getTypes();
              TypeVisitor newTypeVisitor=new TypeVisitor();
              newASTNode.accept(newTypeVisitor);
              List<Type> newTypes=newTypeVisitor.getTypes();
              int j=0;
              for (              Type type : oldTypes) {
                Type newType=newTypes.get(j);
                if (type.equals(oldType)) {
                  sourceRewriter.replace(newType,arg,null);
                  break;
                }
                j++;
              }
            }
          }
        }
 else {
          SimpleName argument;
          Set<VariableDeclaration> fields=fieldDeclarationsToBePulledUp.get(0);
          BindingSignature bindingSignature1=difference.getBindingSignaturePair().getSignature1();
          boolean variableIsFieldToBePulledUp=false;
          for (          VariableDeclaration field : fields) {
            if (bindingSignature1.containsBinding(field.resolveBinding().getKey())) {
              variableIsFieldToBePulledUp=true;
              break;
            }
          }
          if (!variableIsFieldToBePulledUp) {
            if (parameterizedDifferenceMap.containsKey(difference.getBindingSignaturePair())) {
              List<BindingSignaturePair> list=new ArrayList<BindingSignaturePair>(parameterizedDifferenceMap.keySet());
              int index=list.indexOf(difference.getBindingSignaturePair());
              argument=ast.newSimpleName("String_Node_Str" + index);
            }
 else {
              argument=ast.newSimpleName("String_Node_Str" + parameterizedDifferenceMap.size());
              parameterizedDifferenceMap.put(difference.getBindingSignaturePair(),difference);
            }
            int j=0;
            List<Expression> oldExpressions=expressionExtractor.getAllExpressions(oldASTNode);
            List<Expression> newExpressions=expressionExtractor.getAllExpressions(newASTNode);
            for (            Expression expression : oldExpressions) {
              Expression newExpression=newExpressions.get(j);
              if (expression.equals(oldExpression)) {
                sourceRewriter.replace(newExpression,argument,null);
                break;
              }
              if (oldExpression instanceof QualifiedName) {
                QualifiedName oldQualifiedName=(QualifiedName)oldExpression;
                if (expression.equals(oldQualifiedName.getName())) {
                  sourceRewriter.replace(newExpression.getParent(),argument,null);
                  break;
                }
              }
              j++;
            }
          }
        }
      }
    }
    return newASTNode;
  }
}

Fixed version (ground truth):
private ASTNode processASTNodeWithDifferences(AST ast,ASTRewrite sourceRewriter,ASTNode oldASTNode,List<ASTNodeDifference> differences){
  if (differences.isEmpty()) {
    return oldASTNode;
  }
 else {
    Set<String> parameterBindingKeys=originalPassedParameters.keySet();
    Set<String> declaredLocalVariableBindingKeys=mapper.getDeclaredLocalVariablesInMappedNodes().keySet();
    ExpressionExtractor expressionExtractor=new ExpressionExtractor();
    ASTNode newASTNode=ASTNode.copySubtree(ast,oldASTNode);
    for (    ASTNodeDifference difference : differences) {
      Expression oldExpression=difference.getExpression1().getExpression();
      boolean isCommonParameter=false;
      if (isMethodName(oldExpression)) {
        SimpleName oldSimpleName=(SimpleName)oldExpression;
        IBinding binding=oldSimpleName.resolveBinding();
        oldExpression=(Expression)oldExpression.getParent();
        if (parameterBindingKeys.contains(binding.getKey()) || declaredLocalVariableBindingKeys.contains(binding.getKey()))         isCommonParameter=true;
      }
 else       if (oldExpression instanceof SimpleName) {
        SimpleName oldSimpleName=(SimpleName)oldExpression;
        IBinding binding=oldSimpleName.resolveBinding();
        if (parameterBindingKeys.contains(binding.getKey()) || declaredLocalVariableBindingKeys.contains(binding.getKey()))         isCommonParameter=true;
      }
 else       if (oldExpression instanceof QualifiedName) {
        QualifiedName oldQualifiedName=(QualifiedName)oldExpression;
        SimpleName oldSimpleName=oldQualifiedName.getName();
        IBinding binding=oldSimpleName.resolveBinding();
        if (parameterBindingKeys.contains(binding.getKey()) || declaredLocalVariableBindingKeys.contains(binding.getKey()))         isCommonParameter=true;
      }
      if (!isCommonParameter) {
        if (oldExpression.getParent() instanceof Type) {
          Type oldType=(Type)oldExpression.getParent();
          if (difference.containsDifferenceType(DifferenceType.SUBCLASS_TYPE_MISMATCH)) {
            ITypeBinding typeBinding1=difference.getExpression1().getExpression().resolveTypeBinding();
            ITypeBinding typeBinding2=difference.getExpression2().getExpression().resolveTypeBinding();
            ITypeBinding commonSuperTypeBinding=commonSuperType(typeBinding1,typeBinding2);
            if (commonSuperTypeBinding != null) {
              Type arg=generateTypeFromTypeBinding(commonSuperTypeBinding,ast,sourceRewriter);
              TypeVisitor oldTypeVisitor=new TypeVisitor();
              oldASTNode.accept(oldTypeVisitor);
              List<Type> oldTypes=oldTypeVisitor.getTypes();
              TypeVisitor newTypeVisitor=new TypeVisitor();
              newASTNode.accept(newTypeVisitor);
              List<Type> newTypes=newTypeVisitor.getTypes();
              int j=0;
              for (              Type type : oldTypes) {
                Type newType=newTypes.get(j);
                if (type.equals(oldType)) {
                  sourceRewriter.replace(newType,arg,null);
                  break;
                }
                j++;
              }
            }
          }
        }
 else {
          Set<VariableDeclaration> fields1=fieldDeclarationsToBePulledUp.get(0);
          BindingSignature bindingSignature1=difference.getBindingSignaturePair().getSignature1();
          boolean expression1IsFieldToBePulledUp=false;
          for (          VariableDeclaration field : fields1) {
            if (bindingSignature1.containsOnlyBinding(field.resolveBinding().getKey())) {
              expression1IsFieldToBePulledUp=true;
              break;
            }
          }
          Set<VariableDeclaration> fields2=fieldDeclarationsToBePulledUp.get(1);
          BindingSignature bindingSignature2=difference.getBindingSignaturePair().getSignature2();
          boolean expression2IsFieldToBePulledUp=false;
          for (          VariableDeclaration field : fields2) {
            if (bindingSignature2.containsOnlyBinding(field.resolveBinding().getKey())) {
              expression2IsFieldToBePulledUp=true;
              break;
            }
          }
          boolean expressionIsFieldToBePulledUp=expression1IsFieldToBePulledUp && expression2IsFieldToBePulledUp;
          if (!expressionIsFieldToBePulledUp) {
            SimpleName argument;
            if (parameterizedDifferenceMap.containsKey(difference.getBindingSignaturePair())) {
              List<BindingSignaturePair> list=new ArrayList<BindingSignaturePair>(parameterizedDifferenceMap.keySet());
              int index=list.indexOf(difference.getBindingSignaturePair());
              argument=ast.newSimpleName("String_Node_Str" + index);
            }
 else {
              argument=ast.newSimpleName("String_Node_Str" + parameterizedDifferenceMap.size());
              parameterizedDifferenceMap.put(difference.getBindingSignaturePair(),difference);
            }
            int j=0;
            List<Expression> oldExpressions=expressionExtractor.getAllExpressions(oldASTNode);
            List<Expression> newExpressions=expressionExtractor.getAllExpressions(newASTNode);
            for (            Expression expression : oldExpressions) {
              Expression newExpression=newExpressions.get(j);
              if (expression.equals(oldExpression)) {
                sourceRewriter.replace(newExpression,argument,null);
                break;
              }
              if (oldExpression instanceof QualifiedName) {
                QualifiedName oldQualifiedName=(QualifiedName)oldExpression;
                if (expression.equals(oldQualifiedName.getName())) {
                  sourceRewriter.replace(newExpression.getParent(),argument,null);
                  break;
                }
              }
              j++;
            }
          }
        }
      }
    }
    return newASTNode;
  }
}