Program: 12148
Project: 12148
Buggy source:
private Set<ITypeBinding> generateRequiredImportDeclarationsBasedOnBranch(ArrayList<Statement> statements){
  List<ITypeBinding> typeBindings=new ArrayList<ITypeBinding>();
  for (  Statement statement : statements) {
    ExpressionExtractor expressionExtractor=new ExpressionExtractor();
    List<Expression> variableInstructions=expressionExtractor.getVariableInstructions(statement);
    for (    Expression variableInstruction : variableInstructions) {
      SimpleName simpleName=(SimpleName)variableInstruction;
      IBinding binding=simpleName.resolveBinding();
      if (binding.getKind() == IBinding.VARIABLE) {
        IVariableBinding variableBinding=(IVariableBinding)binding;
        ITypeBinding variableTypeBinding=variableBinding.getType();
        if (!typeBindings.contains(variableTypeBinding))         typeBindings.add(variableTypeBinding);
        ITypeBinding declaringClassTypeBinding=variableBinding.getDeclaringClass();
        if (declaringClassTypeBinding != null && !typeBindings.contains(declaringClassTypeBinding))         typeBindings.add(declaringClassTypeBinding);
      }
    }
    List<Expression> methodInvocations=expressionExtractor.getMethodInvocations(statement);
    for (    Expression expression : methodInvocations) {
      if (expression instanceof MethodInvocation) {
        MethodInvocation methodInvocation=(MethodInvocation)expression;
        IMethodBinding methodBinding=methodInvocation.resolveMethodBinding();
        ITypeBinding declaringClassTypeBinding=methodBinding.getDeclaringClass();
        if (declaringClassTypeBinding != null && !typeBindings.contains(declaringClassTypeBinding))         typeBindings.add(declaringClassTypeBinding);
      }
    }
    List<Expression> classInstanceCreations=expressionExtractor.getClassInstanceCreations(statement);
    for (    Expression expression : classInstanceCreations) {
      ClassInstanceCreation classInstanceCreation=(ClassInstanceCreation)expression;
      Type classInstanceCreationType=classInstanceCreation.getType();
      ITypeBinding classInstanceCreationTypeBinding=classInstanceCreationType.resolveBinding();
      if (!typeBindings.contains(classInstanceCreationTypeBinding))       typeBindings.add(classInstanceCreationTypeBinding);
    }
    List<Expression> typeLiterals=expressionExtractor.getTypeLiterals(statement);
    for (    Expression expression : typeLiterals) {
      TypeLiteral typeLiteral=(TypeLiteral)expression;
      Type typeLiteralType=typeLiteral.getType();
      ITypeBinding typeLiteralTypeBinding=typeLiteralType.resolveBinding();
      if (!typeBindings.contains(typeLiteralTypeBinding))       typeBindings.add(typeLiteralTypeBinding);
    }
    List<Expression> castExpressions=expressionExtractor.getCastExpressions(statement);
    for (    Expression expression : castExpressions) {
      CastExpression castExpression=(CastExpression)expression;
      Type castExpressionType=castExpression.getType();
      ITypeBinding typeLiteralTypeBinding=castExpressionType.resolveBinding();
      if (!typeBindings.contains(typeLiteralTypeBinding))       typeBindings.add(typeLiteralTypeBinding);
    }
  }
  Set<ITypeBinding> finalTypeBindings=new LinkedHashSet<ITypeBinding>();
  getSimpleTypeBindings(typeBindings,finalTypeBindings);
  return finalTypeBindings;
}

Fixed version (ground truth):
private Set<ITypeBinding> generateRequiredImportDeclarationsBasedOnBranch(ArrayList<Statement> statements){
  List<ITypeBinding> typeBindings=new ArrayList<ITypeBinding>();
  for (  Statement statement : statements) {
    ExpressionExtractor expressionExtractor=new ExpressionExtractor();
    List<Expression> variableInstructions=expressionExtractor.getVariableInstructions(statement);
    for (    Expression variableInstruction : variableInstructions) {
      SimpleName simpleName=(SimpleName)variableInstruction;
      IBinding binding=simpleName.resolveBinding();
      if (binding.getKind() == IBinding.VARIABLE) {
        IVariableBinding variableBinding=(IVariableBinding)binding;
        ITypeBinding variableTypeBinding=variableBinding.getType();
        if (!typeBindings.contains(variableTypeBinding))         typeBindings.add(variableTypeBinding);
        ITypeBinding declaringClassTypeBinding=variableBinding.getDeclaringClass();
        if (declaringClassTypeBinding != null && !typeBindings.contains(declaringClassTypeBinding))         typeBindings.add(declaringClassTypeBinding);
      }
    }
    List<Expression> methodInvocations=expressionExtractor.getMethodInvocations(statement);
    for (    Expression expression : methodInvocations) {
      if (expression instanceof MethodInvocation) {
        MethodInvocation methodInvocation=(MethodInvocation)expression;
        IMethodBinding methodBinding=methodInvocation.resolveMethodBinding();
        ITypeBinding declaringClassTypeBinding=methodBinding.getDeclaringClass();
        if (declaringClassTypeBinding != null && !typeBindings.contains(declaringClassTypeBinding))         typeBindings.add(declaringClassTypeBinding);
      }
    }
    List<Expression> classInstanceCreations=expressionExtractor.getClassInstanceCreations(statement);
    for (    Expression expression : classInstanceCreations) {
      ClassInstanceCreation classInstanceCreation=(ClassInstanceCreation)expression;
      Type classInstanceCreationType=classInstanceCreation.getType();
      ITypeBinding classInstanceCreationTypeBinding=classInstanceCreationType.resolveBinding();
      if (!typeBindings.contains(classInstanceCreationTypeBinding))       typeBindings.add(classInstanceCreationTypeBinding);
    }
    List<Expression> typeLiterals=expressionExtractor.getTypeLiterals(statement);
    for (    Expression expression : typeLiterals) {
      TypeLiteral typeLiteral=(TypeLiteral)expression;
      Type typeLiteralType=typeLiteral.getType();
      ITypeBinding typeLiteralTypeBinding=typeLiteralType.resolveBinding();
      if (!typeBindings.contains(typeLiteralTypeBinding))       typeBindings.add(typeLiteralTypeBinding);
    }
    List<Expression> castExpressions=expressionExtractor.getCastExpressions(statement);
    for (    Expression expression : castExpressions) {
      CastExpression castExpression=(CastExpression)expression;
      Type castExpressionType=castExpression.getType();
      ITypeBinding castExpressionTypeBinding=castExpressionType.resolveBinding();
      if (!typeBindings.contains(castExpressionTypeBinding))       typeBindings.add(castExpressionTypeBinding);
    }
    List<Expression> instanceofExpressions=expressionExtractor.getInstanceofExpressions(statement);
    for (    Expression expression : instanceofExpressions) {
      InstanceofExpression instanceofExpression=(InstanceofExpression)expression;
      Type instanceofType=instanceofExpression.getRightOperand();
      ITypeBinding instanceofTypeBinding=instanceofType.resolveBinding();
      if (!typeBindings.contains(instanceofTypeBinding))       typeBindings.add(instanceofTypeBinding);
    }
  }
  Set<ITypeBinding> finalTypeBindings=new LinkedHashSet<ITypeBinding>();
  getSimpleTypeBindings(typeBindings,finalTypeBindings);
  return finalTypeBindings;
}