nus-yam/ex-repair huggingface dataset:
Program: 35046
Project: 35046
Buggy source:
private void setUpTextView(Context context,AttributeSet attrs){
  TypedArray ta=context.obtainStyledAttributes(attrs,R.styleable.DynamicText,0,0);
  try {
    mMinTextSize=ta.getDimension(R.styleable.DynamicText_minimumTextSize,getTextSize());
  }
  finally {
    ta.recycle();
  }
  mStartingTextSize=getTextSize();
  Log.d("String_Node_Str","String_Node_Str" + mStartingTextSize);
}

Fixed version (ground truth):
private void setUpTextView(Context context,AttributeSet attrs){
  TypedArray ta=context.obtainStyledAttributes(attrs,R.styleable.DynamicText,0,0);
  try {
    mMinTextSize=ta.getDimension(R.styleable.DynamicText_minimumTextSize,getTextSize());
  }
  finally {
    ta.recycle();
  }
  Log.d("String_Node_Str","String_Node_Str" + getTextSize());
}
Program: 35047
Project: 35047
Buggy source:
/** 
 * Helper method to size text
 */
private void layoutText(){
  if (getText().equals("String_Node_Str"))   return;
  Paint paint=getPaint();
  if (mTextSize != 0f)   paint.setTextSize(mTextSize);
  if (mMinTextSize == getTextSize())   return;
  float textWidth=paint.measureText(getText().toString());
  float boxWidth=getWidth() - getPaddingLeft() - getPaddingRight();
  ;
  float textSize=getTextSize();
  if (textWidth > boxWidth) {
    float scaled=textSize * boxWidth / textWidth;
    if (scaled < mMinTextSize)     scaled=mMinTextSize;
    paint.setTextSize(scaled);
    mTextSize=textSize;
  }
}

Fixed version (ground truth):
/** 
 * Helper method to size text dynamically depending on the text size in relation to the width of the text view
 */
private void layoutText(){
  if (getText().equals("String_Node_Str"))   return;
  Paint paint=getPaint();
  if (mTextSize != 0f)   paint.setTextSize(mTextSize);
  if (mMinTextSize == getTextSize())   return;
  float textWidth=paint.measureText(getText().toString());
  float boxWidth=getWidth() - getPaddingLeft() - getPaddingRight();
  if (boxWidth <= 0f)   return;
  float textSize=getTextSize();
  if (textWidth > boxWidth) {
    float scaled=textSize * boxWidth / textWidth;
    if (scaled < mMinTextSize)     scaled=mMinTextSize;
    paint.setTextSize(scaled);
    mTextSize=textSize;
  }
}
Program: 35048
Project: 35048
Buggy source:
/** 
 * Helper method used to set the main display with HTML formatting, without highlighting
 * @param expStr is the main expression to update
 */
private void setTextHtml(String expStr){
  setText(Html.fromHtml("String_Node_Str" + mTextPrefix + "String_Node_Str"+ expStr+ "String_Node_Str"+ mTextSuffix+ "String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Helper method used to set the main display with HTML formatting, without highlighting
 * @param expStr is the main expression to update
 */
private void setTextHtml(String expStr){
  setText(ViewUtils.fromHtml("String_Node_Str" + mTextPrefix + "String_Node_Str"+ expStr+ "String_Node_Str"+ mTextSuffix+ "String_Node_Str"));
}
Program: 35053
Project: 35053
Buggy source:
@Override public boolean onTouch(View view,MotionEvent event){
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
    mView=view;
  mInc=0;
if (mColorHoldHandler != null) return true;
mColorHoldHandler=new Handler();
mColorHoldHandler.postDelayed(mBackspaceColor,10);
if (mResetHandler != null) return true;
mResetHandler=new Handler();
mResetHandler.postDelayed(mBackspaceReset,RESET_HOLD_TIME);
break;
case MotionEvent.ACTION_UP:
if (mColorHoldHandler == null) return true;
if (mResetHandler == null) return true;
numButtonPressed("String_Node_Str");
ContextCompat.getColor(mAppContext,R.color.op_button_normal);
mColorHoldHandler.removeCallbacks(mBackspaceColor);
mColorHoldHandler=null;
mResetHandler.removeCallbacks(mBackspaceReset);
mResetHandler=null;
break;
}
return false;
}

Fixed version (ground truth):
@Override public boolean onTouch(View view,MotionEvent event){
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
    mView=view;
  mInc=0;
if (mColorHoldHandler != null) return true;
mColorHoldHandler=new Handler();
mColorHoldHandler.postDelayed(mBackspaceColor,10);
if (mResetHandler != null) return true;
mResetHandler=new Handler();
mResetHandler.postDelayed(mBackspaceReset,RESET_HOLD_TIME);
break;
case MotionEvent.ACTION_UP:
if (mColorHoldHandler == null) return true;
if (mResetHandler == null) return true;
numButtonPressed("String_Node_Str");
view.setBackgroundColor(ContextCompat.getColor(mAppContext,R.color.op_button_normal));
mColorHoldHandler.removeCallbacks(mBackspaceColor);
mColorHoldHandler=null;
mResetHandler.removeCallbacks(mBackspaceReset);
mResetHandler=null;
break;
}
return false;
}
Program: 35055
Project: 35055
Buggy source:
@Override public void onExtraLongClick(View view){
  int buttonId=view.getId();
  if (buttonId == R.id.percent_button) {
    String main=mCalc.mPreferences.getPercentButMain();
    String sec=mCalc.mPreferences.getPercentButSec();
    mCalc.mPreferences.setPercentButMain(sec);
    mCalc.mPreferences.setPercentButSec(main);
    ViewUtils.toastLong("String_Node_Str" + sec,mAppContext);
  }
}

Fixed version (ground truth):
@Override public void onExtraLongClick(View view){
  int buttonId=view.getId();
  if (buttonId == R.id.percent_button) {
    String main=mCalc.mPreferences.getPercentButMain();
    String sec=mCalc.mPreferences.getPercentButSec();
    mCalc.mPreferences.setPercentButMain(sec);
    mCalc.mPreferences.setPercentButSec(main);
    ViewUtils.toastLong("String_Node_Str" + sec,mAppContext);
    ahb.setPrimaryText(sec);
    ahb.setSecondaryText(main);
    ahb.invalidate();
  }
}
Program: 35056
Project: 35056
Buggy source:
@Override protected void onSelectionChanged(int selStart,int selEnd){
  if (mCalc != null) {
    int fixedSelStart=mSepHandler.makeIndexValid(selStart);
    int fixedSelEnd=mSepHandler.makeIndexValid((selEnd));
    if (fixedSelStart != selStart || fixedSelEnd != selEnd) {
      setSelection(fixedSelStart,fixedSelEnd);
      return;
    }
    int preLen=mTextPrefex.length();
    int expLen=mExpressionText.length();
    if (selEnd > expLen + preLen) {
      setSelection(selStart,expLen + preLen);
      return;
    }
    if (selStart > expLen + preLen) {
      setSelection(expLen + preLen,selEnd);
      return;
    }
    if (selEnd < preLen) {
      setSelection(selStart,preLen);
      return;
    }
    if (selStart < preLen) {
      setSelection(preLen,selEnd);
      return;
    }
    mCalc.setSelection(mSepHandler.translateFromSepIndex(selStart - preLen),mSepHandler.translateFromSepIndex(selEnd - preLen));
    setCursorVisible(true);
  }
}

Fixed version (ground truth):
@Override protected void onSelectionChanged(int selStart,int selEnd){
  if (mCalc != null) {
    int preLen=mTextPrefex.length();
    int expLen=mExpressionText.length();
    int fixedSelStart=mSepHandler.makeIndexValid(selStart - preLen) + preLen;
    int fixedSelEnd=mSepHandler.makeIndexValid((selEnd - preLen)) + preLen;
    if (fixedSelStart != selStart || fixedSelEnd != selEnd) {
      setSelection(fixedSelStart,fixedSelEnd);
      return;
    }
    if (selEnd > expLen + preLen) {
      setSelection(selStart,expLen + preLen);
      return;
    }
    if (selStart > expLen + preLen) {
      setSelection(expLen + preLen,selEnd);
      return;
    }
    if (selEnd < preLen) {
      setSelection(selStart,preLen);
      return;
    }
    if (selStart < preLen) {
      setSelection(preLen,selEnd);
      return;
    }
    mCalc.setSelection(mSepHandler.translateFromSepIndex(selStart - preLen),mSepHandler.translateFromSepIndex(selEnd - preLen));
    setCursorVisible(true);
  }
}
Program: 35057
Project: 35057
Buggy source:
/** 
 * Updates the current expression and result list
 * @param updateResult whether or not to update result
 */
public void updateScreen(boolean updateResult){
  updateScreenWithInstaScrollOption(updateResult,false);
  if (!mCalc.isUnitIsSet())   clearConvKeyForFragPos(mConvKeysViewPager.getCurrentItem());
}

Fixed version (ground truth):
/** 
 * Updates the current expression and result list
 * @param updateResult whether or not to update result
 */
public void updateScreen(boolean updateResult){
  updateScreenWithInstaScrollOption(updateResult,false);
  if (!mCalc.isUnitSelected())   clearConvKeyForFragPos(mConvKeysViewPager.getCurrentItem());
}
Program: 35058
Project: 35058
Buggy source:
/** 
 * Called when any non convert key is pressed
 * @param keyPressed ASCII representation of the key pressed ("1", "=" "*", etc)
 */
public void numButtonPressed(String keyPressed){
  mCalc.parseKeyPressed(keyPressed);
  updateScreen(keyPressed.equals("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Called when any non convert key is pressed
 * @param keyPressed ASCII representation of the key pressed ("1", "=" "*", etc)
 */
public void numButtonPressed(String keyPressed){
  if (keyPressed.equals("String_Node_Str") && mCalc.isUnitSelected() && !mCalc.isSolved()) {
    new AlertDialog.Builder(this).setMessage("String_Node_Str").setPositiveButton(android.R.string.yes,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
      }
    }
).show();
  }
  mCalc.parseKeyPressed(keyPressed);
  updateScreen(keyPressed.equals("String_Node_Str"));
}
Program: 35059
Project: 35059
Buggy source:
/** 
 * Passed a key from calculator (num/op/back/clear/eq) and distributes it to its proper function
 * @param sKey is either single character (but still a String) or a string from result list
 */
public void parseKeyPressed(String sKey){
  if (isExpressionInvalid())   mExpression.clearExpression();
  if (isSolved() && isUnitIsSet())   clearSelectedUnit();
  if (sKey.equals("String_Node_Str")) {
    solveAndLoadIntoResultList();
  }
 else   if (sKey.equals("String_Node_Str"))   backspace();
 else   if (sKey.equals("String_Node_Str")) {
    clear();
  }
 else {
    if (mExpression.isSolved() && sKey.matches("String_Node_Str"))     clearSelectedUnit();
    mExpression.keyPresses(sKey);
  }
}

Fixed version (ground truth):
/** 
 * Passed a key from calculator (num/op/back/clear/eq) and distributes it to its proper function
 * @param sKey is either single character (but still a String) or a string from result list
 */
public void parseKeyPressed(String sKey){
  if (isExpressionInvalid())   mExpression.clearExpression();
  if (isSolved() && isUnitSelected())   clearSelectedUnit();
  if (sKey.equals("String_Node_Str")) {
    if (isUnitSelected()) {
      return;
    }
    solveAndLoadIntoResultList();
  }
 else   if (sKey.equals("String_Node_Str"))   backspace();
 else   if (sKey.equals("String_Node_Str")) {
    clear();
  }
 else {
    if (mExpression.isSolved() && sKey.matches("String_Node_Str"))     clearSelectedUnit();
    mExpression.keyPresses(sKey);
  }
}
Program: 35060
Project: 35060
Buggy source:
/** 
 * Method turns calculator class into a singleton class  (one instance allowed)
 */
private Calculator(Context appContext){
  mAppContext=appContext;
  mResultList=new ArrayList<Result>();
  mExpression=new Expression(intDisplayPrecision);
  mUnitTypePos=UNIT_TYPE_DEFAULT_POS;
  mHints=new Hints();
  mSolver=new Solver(intCalcPrecision);
  mUnitTypeArray=new ArrayList<UnitType>();
  initiateUnits();
  try {
    loadState();
  }
 catch (  Exception e) {
  }
}

Fixed version (ground truth):
/** 
 * Method turns calculator class into a singleton class  (one instance allowed)
 */
private Calculator(Context appContext){
  mAppContext=appContext;
  mResultList=new ArrayList<Result>();
  mExpression=new Expression(intDisplayPrecision);
  mUnitTypePos=UNIT_TYPE_DEFAULT_POS;
  mHints=new Hints();
  mSolver=new Solver(intCalcPrecision);
  mUnitTypeArray=new ArrayList<UnitType>();
  initiateUnits();
  try {
    loadState();
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str");
    System.out.println("String_Node_Str");
    System.out.println(e.toString());
    System.out.println("String_Node_Str");
  }
}
Program: 35061
Project: 35061
Buggy source:
/** 
 * Function that is called after user hits the "=" key Called by calculator for solving current expression
 * @param exp
 * @return solved expression
 */
private boolean solveAndLoadIntoResultList(){
  Result result=mSolver.solve(mExpression);
  if (result != null) {
    mResultList.add(result);
    if (mResultList.size() > RESULT_LIST_MAX_SIZE)     mResultList.remove(0);
    if (Expression.isInvalid(result.getAnswer()))     return false;
    if (isUnitIsSet()) {
      Unit toUnit=getCurrUnitType().getCurrUnit();
      mResultList.get(mResultList.size() - 1).setResultUnit(toUnit,toUnit,mUnitTypePos);
    }
    return true;
  }
 else   return false;
}

Fixed version (ground truth):
/** 
 * Function that is called after user hits the "=" key Called by calculator for solving current expression
 * @param exp
 * @return solved expression
 */
private boolean solveAndLoadIntoResultList(){
  Result result=mSolver.solve(mExpression);
  if (result != null) {
    mResultList.add(result);
    if (mResultList.size() > RESULT_LIST_MAX_SIZE)     mResultList.remove(0);
    if (Expression.isInvalid(result.getAnswer()))     return false;
    if (isUnitSelected()) {
      Unit toUnit=getCurrUnitType().getCurrUnit();
      mResultList.get(mResultList.size() - 1).setResultUnit(toUnit,toUnit,mUnitTypePos);
    }
    return true;
  }
 else   return false;
}
Program: 35062
Project: 35062
Buggy source:
/** 
 * Updates the text with current value from calc Preserves calc's cursor selections
 */
public void updateTextFromCalc(){
  int selStart=mCalc.getSelectionStart();
  int selEnd=mCalc.getSelectionEnd();
  mTextPrefex="String_Node_Str";
  mExpressionText=mCalc.toString();
  mTextSuffix="String_Node_Str";
  if (!mCalc.isExpressionInvalid() && !mCalc.isExpressionEmpty() && mCalc.getCurrUnitType().isUnitSelected()) {
    mTextSuffix="String_Node_Str" + mCalc.getCurrUnitType().getCurrUnit().toString();
    if (!mCalc.isSolved()) {
      mTextPrefex=getResources().getString(R.string.word_Convert) + "String_Node_Str";
      mTextSuffix=mTextSuffix + "String_Node_Str" + getResources().getString(R.string.word_to)+ "String_Node_Str";
    }
  }
  setText(mTextPrefex + mExpressionText + mTextSuffix);
  selStart=selStart + mTextPrefex.length();
  selEnd=selEnd + mTextPrefex.length();
  setSelection(selStart,selEnd);
  if (mCalc.isSolved())   setCursorVisible(false);
 else   setCursorVisible(true);
}

Fixed version (ground truth):
/** 
 * Updates the text with current value from calc Preserves calc's cursor selections
 */
public void updateTextFromCalc(){
  int selStart=mCalc.getSelectionStart();
  int selEnd=mCalc.getSelectionEnd();
  mTextPrefex="String_Node_Str";
  mExpressionText=mCalc.toString();
  mTextSuffix="String_Node_Str";
  if (!mCalc.isExpressionInvalid() && !mCalc.isExpressionEmpty() && mCalc.isUnitSelected()) {
    mTextSuffix="String_Node_Str" + mCalc.getCurrUnitType().getCurrUnit().toString();
    if (!mCalc.isSolved()) {
      mTextPrefex=getResources().getString(R.string.word_Convert) + "String_Node_Str";
      mTextSuffix=mTextSuffix + "String_Node_Str" + getResources().getString(R.string.word_to)+ "String_Node_Str";
    }
  }
  setText(mTextPrefex + mExpressionText + mTextSuffix);
  selStart=selStart + mTextPrefex.length();
  selEnd=selEnd + mTextPrefex.length();
  setSelection(selStart,selEnd);
  if (mCalc.isSolved())   setCursorVisible(false);
 else   setCursorVisible(true);
}
Program: 35063
Project: 35063
Buggy source:
public JSONObject toJSON() throws JSONException {
  JSONObject json=new JSONObject();
  json.put(JSON_QUERY,getQuerry());
  json.put(JSON_ANSWER,getAnswer());
  json.put(JSON_QUERY_UNIT,mQueryUnit.toJSON());
  json.put(JSON_ANSWER_UNIT,mAnswerUnit.toJSON());
  json.put(JSON_UNIT_TYPE_POS,getUnitTypePos());
  json.put(JSON_CONTAINS_UNITS,containsUnits());
  json.put(JSON_TIMESTAMP,getTimestamp());
  return json;
}

Fixed version (ground truth):
public JSONObject toJSON() throws JSONException {
  JSONObject json=new JSONObject();
  json.put(JSON_QUERY,getQuerry());
  json.put(JSON_ANSWER,getAnswer());
  json.put(JSON_QUERY_UNIT,mQueryUnit.toJSON());
  json.put(JSON_ANSWER_UNIT,mAnswerUnit.toJSON());
  json.put(JSON_UNIT_TYPE_POS,getUnitTypePos());
  json.put(JSON_CONTAINS_UNITS,containsUnits());
  json.put(JSON_TIMESTAMP,mTimestamp);
  return json;
}
Program: 35064
Project: 35064
Buggy source:
@Override public void onClick(View view){
  int position=getListView().getPositionForView((View)view.getParent());
  Calculator calc=Calculator.getCalculator(getActivity());
  Result thisResult=mResultArray.get(position);
  String textPassBack="String_Node_Str";
  int viewID=view.getId();
  if (viewID == R.id.list_item_result_textPrevQuery)   textPassBack=thisResult.getQuerry();
  if (viewID == R.id.list_item_result_textPrevAnswer)   textPassBack=thisResult.getAnswer();
  if (!calc.isUnitIsSet() && thisResult.containsUnits()) {
    Unit unitPassBack;
    if (viewID == R.id.list_item_result_textPrevQuery)     unitPassBack=thisResult.getQuerryUnit();
 else     unitPassBack=thisResult.getAnswerUnit();
    mCallback.selectUnit(unitPassBack,thisResult.getUnitTypePos());
  }
  calc.parseKeyPressed(textPassBack);
  mCallback.updateScreen(false);
}

Fixed version (ground truth):
@Override public void onClick(View view){
  int position=getListView().getPositionForView((View)view.getParent());
  Calculator calc=Calculator.getCalculator(getActivity());
  Result thisResult=mResultArray.get(position);
  String textPassBack="String_Node_Str";
  int viewID=view.getId();
  if (viewID == R.id.list_item_result_textPrevQuery)   textPassBack=thisResult.getQuerry();
  if (viewID == R.id.list_item_result_textPrevAnswer)   textPassBack=thisResult.getAnswer();
  if (!calc.isUnitSelected() && thisResult.containsUnits()) {
    Unit unitPassBack;
    if (viewID == R.id.list_item_result_textPrevQuery)     unitPassBack=thisResult.getQuerryUnit();
 else     unitPassBack=thisResult.getAnswerUnit();
    mCallback.selectUnit(unitPassBack,thisResult.getUnitTypePos());
  }
  calc.parseKeyPressed(textPassBack);
  mCallback.updateScreen(false);
}
Program: 35066
Project: 35066
Buggy source:
private void highlightMatchingPara(String sKey){
  String open="String_Node_Str";
  String close="String_Node_Str";
  int associatedIndex=-1;
  if (sKey.equals(close)) {
    associatedIndex=findMatchingOpenPara(expresssionToSelection(),expresssionToSelection().lastIndexOf(close));
  }
 else   if (sKey.equals(open)) {
    associatedIndex=findMatchingClosePara(expresssionAfterSelectionStart(),expresssionAfterSelectionStart().indexOf(open));
  }
 else   return;
  if (associatedIndex != -1)   markHighlighted(getSelectionStart() - 1,associatedIndex);
}

Fixed version (ground truth):
private void highlightMatchingPara(String sKey){
  String open="String_Node_Str";
  String close="String_Node_Str";
  int associatedIndex=-1;
  if (sKey.equals(close)) {
    associatedIndex=findMatchingOpenPara(expresssionToSelection(),expresssionToSelection().lastIndexOf(close));
  }
 else   if (sKey.equals(open) || sKey.equals("String_Node_Str" + open)) {
    associatedIndex=findMatchingClosePara(getExpression(),getSelectionStart() - 1);
  }
 else   return;
  if (associatedIndex != -1)   markHighlighted(getSelectionStart() - 1,associatedIndex);
}
Program: 35067
Project: 35067
Buggy source:
@Override public void onAnimationUpdate(ValueAnimator animator){
  ArrayList<Integer> highlist=mCalc.getHighlighted();
  mHighlightIndex1=highlist.get(0);
  mHighlightIndex2=highlist.get(1);
  String coloredExp=mExpressionText;
  if (mHighlightIndex1 == -1 || mHighlightIndex2 == -1)   animator.cancel();
 else {
    int color=(Integer)animator.getAnimatedValue();
    coloredExp=mExpressionText.substring(0,mHighlightIndex1) + "String_Node_Str" + color+ "String_Node_Str"+ mExpressionText.substring(mHighlightIndex1,mHighlightIndex1 + 1)+ "String_Node_Str"+ mExpressionText.substring(mHighlightIndex1 + 1,mHighlightIndex2)+ "String_Node_Str"+ color+ "String_Node_Str"+ mExpressionText.substring(mHighlightIndex2,mHighlightIndex2 + 1)+ "String_Node_Str"+ mExpressionText.substring(mHighlightIndex2 + 1,mExpressionText.length());
  }
  setText(Html.fromHtml("String_Node_Str" + mTextPrefex + "String_Node_Str"+ coloredExp+ "String_Node_Str"+ mTextSuffix+ "String_Node_Str"));
  setSelection(mSelStart,mSelEnd);
}

Fixed version (ground truth):
@Override public void onAnimationUpdate(ValueAnimator animator){
  ArrayList<Integer> highlist=mCalc.getHighlighted();
  mHighlightIndex1=highlist.get(0);
  mHighlightIndex2=highlist.get(1);
  String coloredExp=mExpressionText;
  if (mHighlightIndex1 == -1)   animator.cancel();
 else {
    int color=(Integer)animator.getAnimatedValue();
    for (int i=0; i < 2; i++) {
    }
    coloredExp=mExpressionText.substring(0,mHighlightIndex1) + "String_Node_Str" + color+ "String_Node_Str"+ mExpressionText.substring(mHighlightIndex1,mHighlightIndex1 + 1)+ "String_Node_Str"+ mExpressionText.substring(mHighlightIndex1 + 1,mHighlightIndex2)+ "String_Node_Str"+ color+ "String_Node_Str"+ mExpressionText.substring(mHighlightIndex2,mHighlightIndex2 + 1)+ "String_Node_Str"+ mExpressionText.substring(mHighlightIndex2 + 1,mExpressionText.length());
  }
  setText(Html.fromHtml("String_Node_Str" + mTextPrefex + "String_Node_Str"+ coloredExp+ "String_Node_Str"+ mTextSuffix+ "String_Node_Str"));
  setSelection(mSelStart,mSelEnd);
}
Program: 35069
Project: 35069
Buggy source:
public int getReversedYearIndex(){
  return mHistoricalValues.size() - mYearIndex;
}

Fixed version (ground truth):
public int getReversedYearIndex(){
  return mHistoricalValues.size() - 1 - mYearIndex;
}
Program: 35070
Project: 35070
Buggy source:
/** 
 * Index value 0 corresponds to 2014, 1 to 2013 etc
 * @param reversedIndex
 */
public void setYearIndexReversed(int reversedIndex){
  setYearIndex(mHistoricalValues.size() - reversedIndex);
}

Fixed version (ground truth):
/** 
 * Index value 0 corresponds to 2014, 1 to 2013 etc
 * @param reversedIndex
 */
public void setYearIndexReversed(int reversedIndex){
  setYearIndex(mHistoricalValues.size() - 1 - reversedIndex);
}
Program: 35071
Project: 35071
Buggy source:
/** 
 * @return an array of all years in decrementing order (2014, 2013,... etc)
 */
public CharSequence[] getPossibleYearsReversed(){
  int arraySize=mHistoricalValues.size();
  CharSequence[] cs=new CharSequence[arraySize];
  for (int i=0; i < arraySize; i++)   cs[i]=String.valueOf(mIndexStartYearOffset + arraySize - i);
  return cs;
}

Fixed version (ground truth):
/** 
 * @return an array of all years in decrementing order (2014, 2013,... etc)
 */
public CharSequence[] getPossibleYearsReversed(){
  int arraySize=mHistoricalValues.size();
  CharSequence[] cs=new CharSequence[arraySize];
  for (int i=0; i < arraySize; i++)   cs[i]=String.valueOf(mIndexStartYearOffset + arraySize - 1 - i);
  return cs;
}
Program: 35072
Project: 35072
Buggy source:
public void backspaceAtSelection(){
  int selStart=getSelectionStart();
  int selEnd=getSelectionEnd();
  if (isEmpty() || selEnd == 0)   return;
  if (selStart != selEnd)   insertAtSelection("String_Node_Str");
 else {
    setExpression(getExpression().substring(0,selStart - 1) + getExpression().substring(selStart,getExpressionLength()));
    setSelection(selStart - 1,selStart - 1);
  }
}

Fixed version (ground truth):
public void backspaceAtSelection(){
  int selStart=getSelectionStart();
  int selEnd=getSelectionEnd();
  if (isEmpty() || selEnd == 0)   return;
  if (selStart != selEnd)   insertAtSelection("String_Node_Str");
 else {
    setExpression(getExpression().substring(0,selStart - 1) + expresssionAfterSelectionStart());
    setSelection(selStart - 1,selStart - 1);
  }
}
Program: 35074
Project: 35074
Buggy source:
/** 
 * Replaces % operators their respective operators 
 */
public void replacePercentOps(){
  String str=getExpression();
  String subStr="String_Node_Str";
  for (int i=0; i < str.length(); i++) {
    if (str.charAt(i) == '%') {
      subStr=str.substring(0,i);
      String lastNum=getLastNumb(subStr);
      subStr=subStr.substring(0,subStr.length() - lastNum.length());
      if (!subStr.equals("String_Node_Str")) {
        String lastOp=subStr.substring(subStr.length() - 1,subStr.length());
        subStr=subStr.substring(0,subStr.length() - 1);
        if (lastOp.matches(regexGroupedAddSub) && !subStr.equals("String_Node_Str"))         subStr="String_Node_Str" + subStr + "String_Node_Str"+ lastOp+ lastNum+ "String_Node_Str";
 else         subStr=subStr + lastOp + "String_Node_Str"+ lastNum+ "String_Node_Str";
      }
 else       subStr="String_Node_Str" + lastNum + "String_Node_Str";
      str=subStr + str.substring(i + 1,str.length());
      i=subStr.length();
    }
  }
  replaceExpression(str);
}

Fixed version (ground truth):
/** 
 * Replaces % operators their respective operators 
 */
public void replacePercentOps(){
  String str=getExpression();
  String subStr="String_Node_Str";
  String strAfter="String_Node_Str";
  for (int i=0; i < str.length(); i++) {
    if (str.charAt(i) == '%') {
      subStr=str.substring(0,i);
      String lastNum=getLastNumb(subStr);
      subStr=subStr.substring(0,subStr.length() - lastNum.length());
      strAfter=str.substring(i + 1,str.length());
      if (!subStr.equals("String_Node_Str")) {
        String lastOp=subStr.substring(subStr.length() - 1,subStr.length());
        subStr=subStr.substring(0,subStr.length() - 1);
        if (lastOp.matches(regexGroupedAddSub) && !subStr.equals("String_Node_Str") && (strAfter.equals("String_Node_Str") || strAfter.matches(regexGroupedAddSub + "String_Node_Str")))         subStr="String_Node_Str" + subStr + "String_Node_Str"+ lastOp+ lastNum+ "String_Node_Str";
 else         subStr=subStr + lastOp + "String_Node_Str"+ lastNum+ "String_Node_Str";
      }
 else       subStr="String_Node_Str" + lastNum + "String_Node_Str";
      str=subStr + strAfter;
      i=subStr.length();
    }
  }
  replaceExpression(str);
}
Program: 35075
Project: 35075
Buggy source:
/** 
 * Updates the text with current value from calc Preserves calc's cursor selections
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void updateTextFromCalc(){
  int selStart=mCalc.getSelectionStart();
  int selEnd=mCalc.getSelectionEnd();
  mTextPrefex="String_Node_Str";
  mExpressionText=mCalc.toString();
  mTextSuffix="String_Node_Str";
  if (!mCalc.isExpressionInvalid() && !mCalc.isExpressionEmpty() && mCalc.isUnitSelected()) {
    mTextSuffix="String_Node_Str" + mCalc.getCurrUnitType().getCurrUnit().toString();
    if (!mCalc.isSolved()) {
      mTextPrefex=getResources().getString(R.string.word_Convert) + "String_Node_Str";
      mTextSuffix=mTextSuffix + "String_Node_Str" + getResources().getString(R.string.word_to)+ "String_Node_Str";
      selStart=selStart + mTextPrefex.length();
      selEnd=selEnd + mTextPrefex.length();
    }
  }
  setText(Html.fromHtml("String_Node_Str" + mTextPrefex + "String_Node_Str"+ mExpressionText+ "String_Node_Str"+ mTextSuffix+ "String_Node_Str"));
  setSelection(selStart,selEnd);
  setCursorVisible(!mCalc.isSolved());
}

Fixed version (ground truth):
/** 
 * Updates the text with current value from calc Preserves calc's cursor selections
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void updateTextFromCalc(){
  int selStart=mCalc.getSelectionStart();
  int selEnd=mCalc.getSelectionEnd();
  mTextPrefex="String_Node_Str";
  mExpressionText=mCalc.toString();
  mTextSuffix="String_Node_Str";
  if (!mCalc.isExpressionInvalid() && !mCalc.isExpressionEmpty() && mCalc.isUnitSelected()) {
    mTextSuffix="String_Node_Str" + mCalc.getCurrUnitType().getCurrUnit().toString();
    if (!mCalc.isSolved()) {
      mTextPrefex=getResources().getString(R.string.word_Convert) + "String_Node_Str";
      mTextSuffix=mTextSuffix + "String_Node_Str" + getResources().getString(R.string.word_to)+ "String_Node_Str";
      selStart=selStart + mTextPrefex.length();
      selEnd=selEnd + mTextPrefex.length();
    }
  }
  setText(Html.fromHtml("String_Node_Str" + mTextPrefex + "String_Node_Str"+ mExpressionText+ "String_Node_Str"+ mTextSuffix+ "String_Node_Str"));
  if (mCalc.getHighlighted().get(0) != -1) {
    Integer colorFrom=Color.RED;
    Integer colorTo=Color.WHITE;
    ValueAnimator colorAnimation=ValueAnimator.ofObject(new ArgbEvaluator(),colorFrom,colorTo);
    colorAnimation.addUpdateListener(new AnimatorUpdateListener(){
      @Override public void onAnimationUpdate(      ValueAnimator animator){
        setTextColor((Integer)animator.getAnimatedValue());
      }
    }
);
    colorAnimation.addListener(new AnimatorListenerAdapter(){
      @Override public void onAnimationEnd(      Animator animation){
        System.out.println("String_Node_Str");
        mCalc.clearHighlighted();
      }
    }
);
    colorAnimation.setDuration(600 * 2);
    colorAnimation.start();
  }
  setSelection(selStart,selEnd);
  setCursorVisible(!mCalc.isSolved());
}
Program: 35076
Project: 35076
Buggy source:
@Override public View getView(int position,View convertView,ViewGroup parent){
  if (convertView == null)   convertView=getActivity().getLayoutInflater().inflate(R.layout.list_item_result,null);
  Result result=getItem(position);
  TextView textViewUnitDesc=(TextView)convertView.findViewById(R.id.list_item_result_convertUnitDesc);
  if (result.containsUnits()) {
    String text=getResources().getString(R.string.word_Converting) + "String_Node_Str" + result.getQuerryUnit().getLowercaseLongName()+ "String_Node_Str"+ getResources().getString(R.string.word_to)+ "String_Node_Str"+ result.getAnswerUnit().getLowercaseLongName()+ "String_Node_Str";
    textViewUnitDesc.setText(text);
  }
 else   textViewUnitDesc.setVisibility(View.GONE);
  TextView textViewQuerry=(TextView)convertView.findViewById(R.id.list_item_result_textPrevQuery);
  setUpResultTextView(textViewQuerry,result.getTextQuerry());
  TextView textViewAnswer=(TextView)convertView.findViewById(R.id.list_item_result_textPrevAnswer);
  setUpResultTextView(textViewAnswer,result.getTextAnswer());
  return convertView;
}

Fixed version (ground truth):
@Override public View getView(int position,View convertView,ViewGroup parent){
  if (convertView == null)   convertView=getActivity().getLayoutInflater().inflate(R.layout.list_item_result,null);
  Result result=getItem(position);
  TextView textViewUnitDesc=(TextView)convertView.findViewById(R.id.list_item_result_convertUnitDesc);
  if (result.containsUnits()) {
    String text=getResources().getString(R.string.word_Converting) + "String_Node_Str" + result.getQuerryUnit().getLowercaseLongName()+ "String_Node_Str"+ getResources().getString(R.string.word_to)+ "String_Node_Str"+ result.getAnswerUnit().getLowercaseLongName()+ "String_Node_Str";
    textViewUnitDesc.setText(text);
    textViewUnitDesc.setVisibility(View.VISIBLE);
  }
 else   textViewUnitDesc.setVisibility(View.GONE);
  TextView textViewQuerry=(TextView)convertView.findViewById(R.id.list_item_result_textPrevQuery);
  setUpResultTextView(textViewQuerry,result.getTextQuerry());
  TextView textViewAnswer=(TextView)convertView.findViewById(R.id.list_item_result_textPrevAnswer);
  setUpResultTextView(textViewAnswer,result.getTextAnswer());
  return convertView;
}
Program: 35077
Project: 35077
Buggy source:
/** 
 * Method turns calculator class into a singleton class (one instance allowed)
 */
private Calculator(Context appContext){
  mAppContext=appContext;
  try {
    loadState();
  }
 catch (  Exception e) {
    mResultList=new ArrayList<Result>();
    mExpression=new Expression(intDisplayPrecision);
    mUnitTypePos=2;
  }
  mMcOperate=new MathContext(intCalcPrecision);
  initiateUnits();
}

Fixed version (ground truth):
/** 
 * Method turns calculator class into a singleton class (one instance allowed)
 */
private Calculator(Context appContext){
  mAppContext=appContext;
  mResultList=new ArrayList<Result>();
  mExpression=new Expression(intDisplayPrecision);
  mUnitTypePos=2;
  mMcOperate=new MathContext(intCalcPrecision);
  try {
    loadState();
  }
 catch (  Exception e) {
  }
  initiateUnits();
}
Program: 35078
Project: 35078
Buggy source:
/** 
 * Try to paste the current clipboard text into this EditText 
 */
@SuppressWarnings("String_Node_Str") @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void onTextPaste(){
  String textToPaste;
  int currentapiVersion=android.os.Build.VERSION.SDK_INT;
  if (currentapiVersion >= android.os.Build.VERSION_CODES.HONEYCOMB) {
    ClipboardManager clipboard=(ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip=clipboard.getPrimaryClip();
    textToPaste=clip.getItemAt(0).coerceToText(getContext()).toString();
  }
 else {
    ClipboardManager clipboard=(ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    if (clipboard.hasText())     textToPaste=clipboard.getText().toString();
 else     return;
  }
  Toast.makeText(context,"String_Node_Str" + textToPaste,Toast.LENGTH_SHORT).show();
  mCalc.pasteIntoExpression(textToPaste);
}

Fixed version (ground truth):
/** 
 * Try to paste the current clipboard text into this EditText 
 */
@SuppressWarnings("String_Node_Str") @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void onTextPaste(){
  String textToPaste;
  int currentapiVersion=android.os.Build.VERSION.SDK_INT;
  if (currentapiVersion >= android.os.Build.VERSION_CODES.HONEYCOMB) {
    ClipboardManager clipboard=(ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip=clipboard.getPrimaryClip();
    textToPaste=clip.getItemAt(0).coerceToText(getContext()).toString();
  }
 else {
    ClipboardManager clipboard=(ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    if (clipboard.hasText())     textToPaste=clipboard.getText().toString();
 else     return;
  }
  Toast.makeText(context,"String_Node_Str" + textToPaste + "String_Node_Str",Toast.LENGTH_SHORT).show();
  mCalc.pasteIntoExpression(textToPaste);
}
Program: 35079
Project: 35079
Buggy source:
/** 
 * Try to cut the current clipboard text 
 */
@SuppressWarnings("String_Node_Str") @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void onTextCut(){
  int selStart=getSelectionStart();
  int selEnd=getSelectionEnd();
  CharSequence copiedText=getText().subSequence(selStart,selEnd);
  int currentapiVersion=android.os.Build.VERSION.SDK_INT;
  if (currentapiVersion >= android.os.Build.VERSION_CODES.HONEYCOMB) {
    ClipboardManager clipboard=(ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    clipboard.setPrimaryClip(ClipData.newPlainText(null,copiedText));
  }
 else {
    ClipboardManager clipboard=(ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    clipboard.setText(copiedText);
  }
  mCalc.parseKeyPressed("String_Node_Str");
  LAST_CUT_OR_COPY_TIME=SystemClock.uptimeMillis();
  Toast.makeText(context,"String_Node_Str",Toast.LENGTH_SHORT).show();
}

Fixed version (ground truth):
/** 
 * Try to cut the current clipboard text 
 */
@SuppressWarnings("String_Node_Str") @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void onTextCut(){
  int selStart=getSelectionStart();
  int selEnd=getSelectionEnd();
  CharSequence copiedText=getText().subSequence(selStart,selEnd);
  int currentapiVersion=android.os.Build.VERSION.SDK_INT;
  if (currentapiVersion >= android.os.Build.VERSION_CODES.HONEYCOMB) {
    ClipboardManager clipboard=(ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    clipboard.setPrimaryClip(ClipData.newPlainText(null,copiedText));
  }
 else {
    ClipboardManager clipboard=(ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    clipboard.setText(copiedText);
  }
  mCalc.parseKeyPressed("String_Node_Str");
  LAST_CUT_OR_COPY_TIME=SystemClock.uptimeMillis();
  Toast.makeText(context,"String_Node_Str" + copiedText + "String_Node_Str",Toast.LENGTH_SHORT).show();
}
Program: 35080
Project: 35080
Buggy source:
@Override protected void onSelectionChanged(int selStart,int selEnd){
  if (mCalc != null) {
    if (mCalc.toString().equals("String_Node_Str"))     return;
    mCalc.setSelection(selStart,selEnd);
    setCursorVisible(true);
  }
}

Fixed version (ground truth):
@Override protected void onSelectionChanged(int selStart,int selEnd){
  if (mCalc != null) {
    if (mCalc.toString().equals("String_Node_Str"))     return;
    int expLen=mCalc.toString().length();
    if (selEnd > expLen) {
      setSelection(selStart,expLen);
      return;
    }
    if (selStart > expLen) {
      setSelection(expLen,selEnd);
      return;
    }
    mCalc.setSelection(selStart,selEnd);
    setCursorVisible(true);
  }
}
Program: 35081
Project: 35081
Buggy source:
/** 
 * Updates the text with current value from calc. Preserves calc's cursor selections
 */
public void updateTextFromCalc(){
  int selStart=mCalc.getSelectionStart();
  int selEnd=mCalc.getSelectionEnd();
  setText(mCalc.toString());
  setSelection(selStart,selEnd);
  if (selStart == mCalc.toString().length())   setCursorVisible(false);
 else   setCursorVisible(true);
}

Fixed version (ground truth):
/** 
 * Updates the text with current value from calc. Preserves calc's cursor selections
 */
public void updateTextFromCalc(){
  int selStart=mCalc.getSelectionStart();
  int selEnd=mCalc.getSelectionEnd();
  String text=mCalc.toString();
  if (mCalc.getCurrUnitType().isUnitSelected())   text=text + "String_Node_Str" + mCalc.getCurrUnitType().getSelectedUnit().toString();
  setText(text);
  setSelection(selStart,selEnd);
  if (selStart == mCalc.toString().length())   setCursorVisible(false);
 else   setCursorVisible(true);
}
Program: 35082
Project: 35082
Buggy source:
/** 
 * Adds parenthesis around power operations 
 */
public void groupPowerOperand(){
  String str=mExpression.toString();
  for (int i=1; i < str.length(); i++) {
    if (str.charAt(i) == '^') {
      int openPareIndex=0;
      int closePareIndex=0;
      if (str.charAt(i - 1) == ')') {
        for (int k=i - 2; k > 0; k--) {
          if (numOpenPara(str.substring(k,i)) == 0) {
            openPareIndex=k;
            break;
          }
        }
      }
 else {
        String lastNumb=getLastNumb(str.substring(0,i));
        openPareIndex=i - lastNumb.length();
      }
      if (str.charAt(i + 1) == '(') {
        for (int k=i + 2; k <= str.length(); k++) {
          if (numOpenPara(str.substring(i,k)) == 0) {
            closePareIndex=k;
            break;
          }
        }
      }
 else {
        String firstNum=getFirstNumb(str.substring(i + 1,str.length()));
        closePareIndex=i + 1 + firstNum.length();
      }
      str=str.substring(0,openPareIndex) + "String_Node_Str" + str.substring(openPareIndex,closePareIndex)+ "String_Node_Str"+ str.substring(closePareIndex,str.length());
      i=closePareIndex;
    }
  }
  replaceExpression(str);
}

Fixed version (ground truth):
/** 
 * Adds parenthesis around power operations 
 */
public void groupPowerOperand(){
  String str=mExpression.toString();
  for (int i=1; i < str.length(); i++) {
    if (str.charAt(i) == '^') {
      int openPareIndex=0;
      int closePareIndex=0;
      if (str.charAt(i - 1) == ')') {
        for (int k=i - 2; k > 0; k--) {
          if (numOpenPara(str.substring(k,i)) == 0) {
            openPareIndex=k;
            break;
          }
        }
      }
 else {
        String lastNumb=getLastNumb(str.substring(0,i));
        lastNumb=lastNumb.replaceAll("String_Node_Str","String_Node_Str");
        openPareIndex=i - lastNumb.length();
      }
      if (str.charAt(i + 1) == '(') {
        for (int k=i + 2; k <= str.length(); k++) {
          if (numOpenPara(str.substring(i,k)) == 0) {
            closePareIndex=k;
            break;
          }
        }
      }
 else {
        System.out.println("String_Node_Str");
        String firstNum=getFirstNumb(str.substring(i + 1,str.length()));
        closePareIndex=i + 1 + firstNum.length();
      }
      str=str.substring(0,openPareIndex) + "String_Node_Str" + str.substring(openPareIndex,closePareIndex)+ "String_Node_Str"+ str.substring(closePareIndex,str.length());
      i=closePareIndex;
    }
  }
  System.out.println("String_Node_Str" + str);
  replaceExpression(str);
}
Program: 35083
Project: 35083
Buggy source:
/** 
 * Gets the last double (returned as a String) for input string
 * @param String expression to find last number of
 * @return anything after last valid operator, or "" if expression empty, or entire expression if doesn't contain regexAnyValidOperator. Note if expression is "1+-5" it will return "-5"
 */
private String getLastNumb(String expStr){
  String[] strA=expStr.split(regexAnyValidOperator);
  if (strA.length == 0)   return "String_Node_Str";
 else {
    if (expStr.matches("String_Node_Str" + regexAnyValidOperator + regexAnyValidOperator+ regexGroupedNumber))     return expStr.replaceAll("String_Node_Str" + regexAnyValidOperator + regexGroupedNumber+ "String_Node_Str","String_Node_Str");
    return strA[strA.length - 1];
  }
}

Fixed version (ground truth):
/** 
 * Gets the last number (returned as a String) for input string
 * @param String expression to find last number of
 * @return Last valid number in expression, "" if expression empty, or entire expression if doesn't contain regexAnyValidOperator. Note if expression is "1+-5" it will return "-5"
 */
private String getLastNumb(String expStr){
  if (expStr.matches("String_Node_Str" + regexGroupedNonNegNumber))   return expStr.replaceAll("String_Node_Str" + regexGroupedNonNegNumber + "String_Node_Str","String_Node_Str");
  return "String_Node_Str";
}
Program: 35086
Project: 35086
Buggy source:
/** 
 * Recursively loop over all parentheses, invoke other operators in results found within
 * @param str is the String to loop the parentheses solving over
 */
private String collapsePara(String str){
  int firstPara=str.indexOf("String_Node_Str");
  if (firstPara != -1) {
    int paraCount=0;
    int matchingPara=-1;
    for (int i=firstPara; i < str.length(); i++) {
      if (str.charAt(i) == '(')       paraCount++;
 else       if (str.charAt(i) == ')') {
        paraCount--;
        if (paraCount == 0) {
          matchingPara=i;
          break;
        }
      }
    }
    if (matchingPara == -1) {
      str=strSyntaxError;
      return str;
    }
 else {
      String firstSection=str.substring(0,firstPara);
      String middleSection=collapsePara(str.substring(firstPara + 1,matchingPara));
      String endSection=str.substring(matchingPara + 1,str.length());
      str=collapsePara(firstSection + middleSection + endSection);
    }
  }
  System.out.println("String_Node_Str" + str);
  str=collapseOps(Expression.regexGroupedExponent,str);
  str=collapseOps(Expression.regexGroupedMultDiv,str);
  str=collapseOps(Expression.regexGroupedAddSub,str);
  return str;
}

Fixed version (ground truth):
/** 
 * Recursively loop over all parentheses, invoke other operators in results found within
 * @param str is the String to loop the parentheses solving over
 */
private String collapsePara(String str){
  int firstPara=str.indexOf("String_Node_Str");
  if (firstPara != -1) {
    int paraCount=0;
    int matchingPara=-1;
    for (int i=firstPara; i < str.length(); i++) {
      if (str.charAt(i) == '(')       paraCount++;
 else       if (str.charAt(i) == ')') {
        paraCount--;
        if (paraCount == 0) {
          matchingPara=i;
          break;
        }
      }
    }
    if (matchingPara == -1) {
      str=strSyntaxError;
      return str;
    }
 else {
      String firstSection=str.substring(0,firstPara);
      String middleSection=collapsePara(str.substring(firstPara + 1,matchingPara));
      String endSection=str.substring(matchingPara + 1,str.length());
      str=collapsePara(firstSection + middleSection + endSection);
    }
  }
  str=collapseOps(Expression.regexGroupedExponent,str);
  str=collapseOps(Expression.regexGroupedMultDiv,str);
  str=collapseOps(Expression.regexGroupedAddSub,str);
  return str;
}
Program: 35087
Project: 35087
Buggy source:
/** 
 * Gets the last double (returned as a String) for input string
 * @param String expression to find last number of
 * @return anything after last valid operator, or "" if expression empty, or entire expression if doesn't contain regexAnyValidOperator. Note if expression is "1+-5" it will return "-5"
 */
private String getLastNumb(String expStr){
  String[] strA=expStr.split(regexAnyValidOperator);
  if (strA.length == 0)   return "String_Node_Str";
 else {
    if (expStr.matches("String_Node_Str" + regexAnyValidOperator + regexAnyValidOperator+ regexGroupedNumber))     return expStr.replaceAll("String_Node_Str" + regexAnyValidOperator + regexGroupedNumber,"String_Node_Str");
    return strA[strA.length - 1];
  }
}

Fixed version (ground truth):
/** 
 * Gets the last double (returned as a String) for input string
 * @param String expression to find last number of
 * @return anything after last valid operator, or "" if expression empty, or entire expression if doesn't contain regexAnyValidOperator. Note if expression is "1+-5" it will return "-5"
 */
private String getLastNumb(String expStr){
  String[] strA=expStr.split(regexAnyValidOperator);
  if (strA.length == 0)   return "String_Node_Str";
 else {
    if (expStr.matches("String_Node_Str" + regexAnyValidOperator + regexAnyValidOperator+ regexGroupedNumber))     return expStr.replaceAll("String_Node_Str" + regexAnyValidOperator + regexGroupedNumber+ "String_Node_Str","String_Node_Str");
    return strA[strA.length - 1];
  }
}
Program: 35090
Project: 35090
Buggy source:
private void addTab(int index,CharSequence text,int iconResId){
  final TabView tabView=new TabView(getContext());
  tabView.mIndex=index;
  tabView.setFocusable(true);
  tabView.setOnClickListener(mTabClickListener);
  tabView.setText(text);
  if (iconResId != 0) {
    tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId,0,0,0);
  }
  mTabLayout.addView(tabView,new LinearLayout.LayoutParams(0,MATCH_PARENT,1));
}

Fixed version (ground truth):
private void addTab(int index,CharSequence text,int iconResId){
  final TabView tabView=new TabView(getContext());
  tabView.mIndex=index;
  tabView.setFocusable(true);
  tabView.setOnClickListener(mTabClickListener);
  tabView.setText(text);
  if (iconResId != 0) {
    tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId,0,0,0);
  }
  mTabLayout.addView(tabView,new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,MATCH_PARENT,1));
}
Program: 35091
Project: 35091
Buggy source:
/** 
 * Counts the number of open vs number of closed parentheses in the given 
 * @return 0 if equal num of open/close para, positive # if more open, neg # if more close
 */
private int numOpenPara(){
  int numOpen=0;
  int numClose=0;
  for (int i=0; i < expresssionToSelection().length(); i++) {
    if (expresssionToSelection().charAt(i) == '(')     numOpen++;
    if (expresssionToSelection().charAt(i) == ')')     numClose++;
  }
  return numOpen - numClose;
}

Fixed version (ground truth):
/** 
 * Counts the number of open vs. number of closed parentheses in the given string
 * @param String containing parenthesis to count 
 * @return 0 if equal num of open/close para, positive # if more open, neg # if more close
 */
private int numOpenPara(String str){
  int numOpen=0;
  int numClose=0;
  for (int i=0; i < str.length(); i++) {
    if (str.charAt(i) == '(')     numOpen++;
    if (str.charAt(i) == ')')     numClose++;
  }
  return numOpen - numClose;
}
Program: 35092
Project: 35092
Buggy source:
/** 
 * Gets the first number (returned as a String) at selection in current expression
 * @return anything before the first valid operator, or "" if expression empty, or entire expression if doesn't contain regexAnyValidOperator
 */
private String getFirstNumb(){
  String[] strA=expresssionToSelection().split(regexAnyValidOperator);
  return strA[0];
}

Fixed version (ground truth):
/** 
 * Gets the first number (returned as a String) at selection in current expression
 * @return anything before the first valid operator, or "" if expression empty, or entire expression if doesn't contain regexAnyValidOperator
 */
private String getFirstNumb(){
  return getFirstNumb(expresssionToSelection());
}