Program: 135872
Project: 135872
Buggy source:
/** 
 * Creates the proof, which is a Suffices Only proof if sufficesONly = true, and otherwise is an and-split proof if * isAndProof is true, and a case-split proof otherwise.
 * @param nodeRep
 * @param isAndProof
 * @param sufficesOnly
 */
void makeProof(NodeRepresentation nodeRep,boolean isAndProof,boolean sufficesOnly){
  int proofIndent=PROOF_INDENT;
  String proofIndentString=StringHelper.copyString("String_Node_Str",proofIndent);
  String[] assumptionsText=createdAssumptions();
  String[] proofText=null;
  if (this.proof != null) {
    proofText=this.stepRep.subNodeText(this.proof).nodeText;
    proofText=prependToStringArray(proofText,proofIndentString);
    try {
      IRegion proofRegion=EditorUtil.getRegionOf(this.doc,((SyntaxTreeNode)this.proof.stn).getLocation());
      this.doc.replace(proofRegion.getOffset(),proofRegion.getLength(),"String_Node_Str");
    }
 catch (    BadLocationException e) {
      MessageDialog.openError(UIHelper.getShellProvider().getShell(),"String_Node_Str","String_Node_Str" + "String_Node_Str");
      e.printStackTrace();
    }
  }
  boolean addStepNumber=(stepNumber != null) && this.needsStepNumber;
  String[] sufficesStep=null;
  boolean hasSufficesStep=useSufficesButton.getSelection() && (assumptionsText.length != 0);
  if (hasSufficesStep || sufficesOnly) {
    String sufficesProof=null;
    String[] suffices=prependToStringArray(concatStringArrays(prependToStringArray(assumptionsText,"String_Node_Str"),prependToStringArray(this.goalRep.primedNodeText(),"String_Node_Str")),proofLevelString + "String_Node_Str");
    if (goalDefinitions.isEmpty() && !addStepNumber) {
      if (OBVIOUS_HAS_PROOF) {
        sufficesProof="String_Node_Str";
      }
 else {
        sufficesProof="String_Node_Str";
      }
    }
 else {
      sufficesProof="String_Node_Str";
      if (addStepNumber) {
        sufficesProof=sufficesProof + this.stepNumber + "String_Node_Str";
      }
      if (!goalDefinitions.isEmpty()) {
        sufficesProof=sufficesProof + "String_Node_Str" + setOfStringsToList(goalDefinitions);
      }
    }
    sufficesStep=concatStringArrays(suffices,new String[]{proofIndentString + sufficesProof});
  }
  String[][] mainProofSteps=null;
  int numberOfSteps=0;
  String proofDef=null;
  if (!sufficesOnly) {
    if (isAndProof) {
      Decomposition decomp=nodeRep.decomposition;
      numberOfSteps=decomp.children.size();
      mainProofSteps=new String[numberOfSteps][];
      proofDef=decomp.definedOp;
      for (int i=0; i < numberOfSteps; i++) {
        NodeRepresentation stepGoalRep=decompositionChildToNodeRep(nodeRep,i,null,null);
        String[] goalArray=stepGoalRep.primedNodeText();
        String[] step;
        if ((sufficesStep == null)) {
          step=concatStringArrays(prependToStringArray(assumptionsText,"String_Node_Str"),prependToStringArray(goalArray,"String_Node_Str"));
        }
 else {
          step=goalArray;
        }
        step=prependToStringArray(step,proofLevelString + (i + 1) + STEP_NUMBER_PUNCTUATION+ "String_Node_Str");
        if (proofText != null) {
          step=concatStringArrays(step,proofText);
        }
        mainProofSteps[i]=step;
      }
    }
 else {
      Vector<String[]> pfStepVec=new Vector<String[]>();
      for (int i=0; i < nodeRep.children.size(); i++) {
        Vector<NodeRepresentation> childVec=nodeRep.children.elementAt(i);
        String[] assumpArray;
        if (!hasSufficesStep) {
          assumpArray=new String[assumptionsText.length];
          for (int j=0; j < assumptionsText.length; j++) {
            assumpArray[j]=assumptionsText[j];
          }
        }
 else {
          assumpArray=new String[0];
        }
        addCaseProofs(pfStepVec,childVec,assumpArray,proofText);
      }
      mainProofSteps=new String[pfStepVec.size()][];
      for (int i=0; i < mainProofSteps.length; i++) {
        mainProofSteps[i]=pfStepVec.elementAt(i);
      }
      numberOfSteps=mainProofSteps.length;
    }
  }
  String[] qedStep=new String[2];
  qedStep[0]=proofLevelString;
  if (NUMBER_QED_STEP && (numberOfSteps != 0)) {
    qedStep[0]=qedStep[0] + (numberOfSteps + 1) + STEP_NUMBER_PUNCTUATION;
  }
  qedStep[0]=qedStep[0] + "String_Node_Str";
  qedStep[1]=proofIndentString + "String_Node_Str" + ((numberOfSteps > 0) ? (proofLevelString + 1) : "String_Node_Str");
  for (int i=2; i <= numberOfSteps; i++) {
    qedStep[1]=qedStep[1] + "String_Node_Str" + proofLevelString+ i;
  }
  if ((sufficesStep == null) && needsStepNumber) {
    qedStep[1]=qedStep[1] + "String_Node_Str" + this.stepNumber;
  }
  boolean hasGoalDefs=(!this.goalDefinitions.isEmpty()) && (sufficesStep == null);
  boolean hasAssumeDefs=!this.assumeDefinitions.isEmpty();
  String goalAndAssumeDefs=(hasGoalDefs ? setOfStringsToList(this.goalDefinitions) : "String_Node_Str") + ((hasGoalDefs && hasAssumeDefs) ? "String_Node_Str" : "String_Node_Str") + (hasAssumeDefs ? setOfStringsToList(this.assumeDefinitions) : "String_Node_Str");
  if (sufficesOnly) {
    if (this.proof != null) {
      qedStep=concatStringArrays(new String[]{qedStep[0]},prependToStringArray(proofText,proofIndentString));
    }
 else {
      qedStep[1]="String_Node_Str";
    }
  }
 else {
    boolean hasDEF=false;
    if (hasGoalDefs || hasAssumeDefs) {
      hasDEF=true;
      qedStep[1]=qedStep[1] + "String_Node_Str" + goalAndAssumeDefs;
    }
    if (proofDef != null) {
      if (hasDEF) {
        qedStep[1]=qedStep[1] + "String_Node_Str" + proofDef;
      }
 else {
        qedStep[1]=qedStep[1] + "String_Node_Str" + proofDef;
      }
    }
  }
  String[] blankLine=new String[]{"String_Node_Str"};
  String[] completeProof=new String[0];
  if (sufficesStep != null) {
    if (this.BLANK_LINE_BETWEEN_STEPS) {
      completeProof=concatStringArrays(sufficesStep,blankLine);
    }
 else {
      completeProof=sufficesStep;
    }
  }
  if (mainProofSteps != null) {
    completeProof=concatStringArrays(completeProof,mainProofSteps[0]);
    for (int i=1; i < mainProofSteps.length; i++) {
      if (this.BLANK_LINE_BETWEEN_STEPS) {
        completeProof=concatStringArrays(completeProof,concatStringArrays(blankLine,mainProofSteps[i]));
      }
 else {
        completeProof=concatStringArrays(completeProof,mainProofSteps[i]);
      }
    }
    if (this.BLANK_LINE_BETWEEN_STEPS) {
      completeProof=concatStringArrays(completeProof,blankLine);
    }
  }
  completeProof=concatStringArrays(completeProof,qedStep);
  completeProof=prependToStringArray(completeProof,StringHelper.copyString("String_Node_Str",this.step.getLocation().beginColumn() - 1 + proofIndent));
  try {
    int nextLineOffset=doc.getLineInformation(this.step.getTheorem().getLocation().endLine()).getOffset();
    this.doc.replace(nextLineOffset,0,stringArrayToString(completeProof) + "String_Node_Str");
  }
 catch (  BadLocationException e) {
    MessageDialog.openError(UIHelper.getShellProvider().getShell(),"String_Node_Str","String_Node_Str" + "String_Node_Str");
    e.printStackTrace();
  }
  this.windowShell.dispose();
  return;
}

Fixed version (ground truth):
/** 
 * Creates the proof, which is a Suffices Only proof if sufficesONly = true, and otherwise is an and-split proof if * isAndProof is true, and a case-split proof otherwise.
 * @param nodeRep
 * @param isAndProof
 * @param sufficesOnly
 */
void makeProof(NodeRepresentation nodeRep,boolean isAndProof,boolean sufficesOnly){
  int proofIndent=PROOF_INDENT;
  String proofIndentString=StringHelper.copyString("String_Node_Str",proofIndent);
  String[] assumptionsText=createdAssumptions();
  String[] proofText=null;
  if (this.proof != null) {
    proofText=this.stepRep.subNodeText(this.proof).nodeText;
    proofText=prependToStringArray(proofText,proofIndentString);
    try {
      IRegion proofRegion=EditorUtil.getRegionOf(this.doc,((SyntaxTreeNode)this.proof.stn).getLocation());
      this.doc.replace(proofRegion.getOffset(),proofRegion.getLength(),"String_Node_Str");
    }
 catch (    BadLocationException e) {
      MessageDialog.openError(UIHelper.getShellProvider().getShell(),"String_Node_Str","String_Node_Str" + "String_Node_Str");
      e.printStackTrace();
    }
  }
  boolean addStepNumber=(stepNumber != null) && this.needsStepNumber;
  String[] sufficesStep=null;
  boolean hasSufficesStep=useSufficesButton.getSelection() && (assumptionsText.length != 0);
  if (hasSufficesStep || sufficesOnly) {
    String sufficesProof=null;
    String[] suffices=prependToStringArray(concatStringArrays(prependToStringArray(assumptionsText,"String_Node_Str"),prependToStringArray(this.goalRep.primedNodeText(),"String_Node_Str")),proofLevelString + "String_Node_Str");
    if (goalDefinitions.isEmpty() && !addStepNumber) {
      if (OBVIOUS_HAS_PROOF) {
        sufficesProof="String_Node_Str";
      }
 else {
        sufficesProof="String_Node_Str";
      }
    }
 else {
      sufficesProof="String_Node_Str";
      if (addStepNumber) {
        sufficesProof=sufficesProof + this.stepNumber + "String_Node_Str";
      }
      if (!goalDefinitions.isEmpty()) {
        sufficesProof=sufficesProof + "String_Node_Str" + setOfStringsToList(goalDefinitions);
      }
    }
    sufficesStep=concatStringArrays(suffices,new String[]{proofIndentString + sufficesProof});
  }
  String[][] mainProofSteps=null;
  int numberOfSteps=0;
  String proofDef=null;
  if (!sufficesOnly) {
    if (isAndProof) {
      Decomposition decomp=nodeRep.decomposition;
      numberOfSteps=decomp.children.size();
      mainProofSteps=new String[numberOfSteps][];
      proofDef=decomp.definedOp;
      for (int i=0; i < numberOfSteps; i++) {
        NodeRepresentation stepGoalRep=decompositionChildToNodeRep(nodeRep,i,null,null);
        String[] goalArray=stepGoalRep.primedNodeText();
        String[] step;
        if ((sufficesStep == null || assumptionsText == null && assumptionsText.length == 0)) {
          step=concatStringArrays(prependToStringArray(assumptionsText,"String_Node_Str"),prependToStringArray(goalArray,"String_Node_Str"));
        }
 else {
          step=goalArray;
        }
        step=prependToStringArray(step,proofLevelString + (i + 1) + STEP_NUMBER_PUNCTUATION+ "String_Node_Str");
        if (proofText != null) {
          step=concatStringArrays(step,proofText);
        }
        mainProofSteps[i]=step;
      }
    }
 else {
      Vector<String[]> pfStepVec=new Vector<String[]>();
      for (int i=0; i < nodeRep.children.size(); i++) {
        Vector<NodeRepresentation> childVec=nodeRep.children.elementAt(i);
        String[] assumpArray;
        if (!hasSufficesStep) {
          assumpArray=new String[assumptionsText.length];
          for (int j=0; j < assumptionsText.length; j++) {
            assumpArray[j]=assumptionsText[j];
          }
        }
 else {
          assumpArray=new String[0];
        }
        addCaseProofs(pfStepVec,childVec,assumpArray,proofText);
      }
      mainProofSteps=new String[pfStepVec.size()][];
      for (int i=0; i < mainProofSteps.length; i++) {
        mainProofSteps[i]=pfStepVec.elementAt(i);
      }
      numberOfSteps=mainProofSteps.length;
    }
  }
  String[] qedStep=new String[2];
  qedStep[0]=proofLevelString;
  if (NUMBER_QED_STEP && (numberOfSteps != 0)) {
    qedStep[0]=qedStep[0] + (numberOfSteps + 1) + STEP_NUMBER_PUNCTUATION;
  }
  qedStep[0]=qedStep[0] + "String_Node_Str";
  qedStep[1]=proofIndentString + "String_Node_Str" + ((numberOfSteps > 0) ? (proofLevelString + 1) : "String_Node_Str");
  for (int i=2; i <= numberOfSteps; i++) {
    qedStep[1]=qedStep[1] + "String_Node_Str" + proofLevelString+ i;
  }
  if ((sufficesStep == null) && needsStepNumber) {
    qedStep[1]=qedStep[1] + "String_Node_Str" + this.stepNumber;
  }
  boolean hasGoalDefs=(!this.goalDefinitions.isEmpty()) && (sufficesStep == null);
  boolean hasAssumeDefs=!this.assumeDefinitions.isEmpty();
  String goalAndAssumeDefs=(hasGoalDefs ? setOfStringsToList(this.goalDefinitions) : "String_Node_Str") + ((hasGoalDefs && hasAssumeDefs) ? "String_Node_Str" : "String_Node_Str") + (hasAssumeDefs ? setOfStringsToList(this.assumeDefinitions) : "String_Node_Str");
  if (sufficesOnly) {
    if (this.proof != null) {
      qedStep=concatStringArrays(new String[]{qedStep[0]},prependToStringArray(proofText,proofIndentString));
    }
 else {
      qedStep[1]="String_Node_Str";
    }
  }
 else {
    boolean hasDEF=false;
    if (hasGoalDefs || hasAssumeDefs) {
      hasDEF=true;
      qedStep[1]=qedStep[1] + "String_Node_Str" + goalAndAssumeDefs;
    }
    if (proofDef != null) {
      if (hasDEF) {
        qedStep[1]=qedStep[1] + "String_Node_Str" + proofDef;
      }
 else {
        qedStep[1]=qedStep[1] + "String_Node_Str" + proofDef;
      }
    }
  }
  String[] blankLine=new String[]{"String_Node_Str"};
  String[] completeProof=new String[0];
  if (sufficesStep != null) {
    if (this.BLANK_LINE_BETWEEN_STEPS) {
      completeProof=concatStringArrays(sufficesStep,blankLine);
    }
 else {
      completeProof=sufficesStep;
    }
  }
  if (mainProofSteps != null) {
    completeProof=concatStringArrays(completeProof,mainProofSteps[0]);
    for (int i=1; i < mainProofSteps.length; i++) {
      if (this.BLANK_LINE_BETWEEN_STEPS) {
        completeProof=concatStringArrays(completeProof,concatStringArrays(blankLine,mainProofSteps[i]));
      }
 else {
        completeProof=concatStringArrays(completeProof,mainProofSteps[i]);
      }
    }
    if (this.BLANK_LINE_BETWEEN_STEPS) {
      completeProof=concatStringArrays(completeProof,blankLine);
    }
  }
  completeProof=concatStringArrays(completeProof,qedStep);
  completeProof=prependToStringArray(completeProof,StringHelper.copyString("String_Node_Str",this.step.getLocation().beginColumn() - 1 + proofIndent));
  try {
    int nextLineOffset=doc.getLineInformation(this.step.getTheorem().getLocation().endLine()).getOffset();
    this.doc.replace(nextLineOffset,0,stringArrayToString(completeProof) + "String_Node_Str");
  }
 catch (  BadLocationException e) {
    MessageDialog.openError(UIHelper.getShellProvider().getShell(),"String_Node_Str","String_Node_Str" + "String_Node_Str");
    e.printStackTrace();
  }
  this.windowShell.dispose();
  return;
}