Program: 135980
Project: 135980
Buggy source:
/** 
 * Computes the regions that will be hidden when the fold at this position is collapsed. The following is from an email from Leslie. It starts by explaining how comments should be used and folded in proofs and ends by describing the folding rule. In proofs, there are two ways I can think of for using comments: - At the beginning of a proof to explain the proof.  For example: <2>3. x > 0 (********************************************************************) (* We prove y >0 and x \geq y by using Finagle's theorem and step   *) (* <1>3.                                                            *) (********************************************************************) <3>1. ... - As an informal leaf proof.  For example: <2>3. x > 0 (*********************************************************************) (* This follows by simple algebra from <2>1 and <1>3, but I'm not    *) (* going to bother trying to convince this stupid prover that it     *) (* does.                                                             *) (*********************************************************************) <2>4. ... In this case, I will also want to add a PROOF OMITTED to tell the prover that I didn't just forget about this proof step. We can handle both these cases by the following rule, where the PROOF OMITTED follows the comment in the second case: When hiding a proof, hide everything from the (line following the) end of the statement being proved to the end of the proof.
 */
public IRegion[] computeProjectionRegions(IDocument document) throws BadLocationException {
  int firstLine=document.getLineOfOffset(positionOfStatement.getOffset() + positionOfStatement.getLength()) + 1;
  int lastLine=document.getLineOfOffset(positionOfProof.getOffset() + positionOfProof.getLength());
  if (firstLine > lastLine) {
    return null;
  }
  int firstLineOffset=document.getLineOffset(firstLine);
  IRegion lastLineInfo=document.getLineInformation(lastLine);
  IRegion toFold=alignRegion(new Region(firstLineOffset,lastLineInfo.getOffset() + lastLineInfo.getLength() - firstLineOffset),document);
  if (toFold != null) {
    return new IRegion[]{toFold};
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Computes the regions that will be hidden when the fold at this position is collapsed. The following is from an email from Leslie. It starts by explaining how comments should be used and folded in proofs and ends by describing the folding rule. In proofs, there are two ways I can think of for using comments: - At the beginning of a proof to explain the proof.  For example: <2>3. x > 0 (********************************************************************) (* We prove y >0 and x \geq y by using Finagle's theorem and step   *) (* <1>3.                                                            *) (********************************************************************) <3>1. ... - As an informal leaf proof.  For example: <2>3. x > 0 (*********************************************************************) (* This follows by simple algebra from <2>1 and <1>3, but I'm not    *) (* going to bother trying to convince this stupid prover that it     *) (* does.                                                             *) (*********************************************************************) <2>4. ... In this case, I will also want to add a PROOF OMITTED to tell the prover that I didn't just forget about this proof step. We can handle both these cases by the following rule, where the PROOF OMITTED follows the comment in the second case: When hiding a proof, hide everything from the (line following the) end of the statement being proved to the end of the proof.
 */
public IRegion[] computeProjectionRegions(IDocument document) throws BadLocationException {
  int firstLine=document.getLineOfOffset(positionOfStatement.getOffset() + positionOfStatement.getLength()) + 1;
  int lastLine=document.getLineOfOffset(positionOfProof.getOffset() + positionOfProof.getLength());
  if (firstLine > lastLine) {
    return null;
  }
  int firstLineOffset=document.getLineOffset(firstLine);
  IRegion lastLineInfo=document.getLineInformation(lastLine);
  IRegion toFold=alignRegion(new Region(firstLineOffset,lastLineInfo.getOffset() + lastLineInfo.getLength() - firstLineOffset),document);
  length=toFold.getOffset() + toFold.getLength() - offset;
  if (toFold != null) {
    return new IRegion[]{toFold};
  }
  return null;
}