Program: 135995
Project: 135995
Buggy source:
/** 
 * For all   {@link TheoremNode} in the tree rooted at theoremNode,this returns the  {@link TheoremNode} that is first on the linecontaining the caret, or null if none satisfy that criteria.
 * @param theoremNode
 * @return
 */
public static TheoremNode getStepWithCaret(TheoremNode theoremNode,int caretOffset,IDocument document){
  try {
    Location stepLoc=theoremNode.getTheorem().getLocation();
    int caretLine=document.getLineOfOffset(caretOffset) + 1;
    if (stepLoc.beginLine() <= caretLine && stepLoc.endLine() >= caretLine) {
      return theoremNode;
    }
    ThmOrAssumpDefNode defNode=theoremNode.getDef();
    if (defNode != null) {
    }
    ProofNode proof=theoremNode.getProof();
    if (proof != null) {
      Location proofLoc=proof.getLocation();
      if (caretLine >= proofLoc.beginColumn() && caretLine <= proofLoc.endLine()) {
        if (proof instanceof NonLeafProofNode) {
          NonLeafProofNode nonLeafProof=(NonLeafProofNode)proof;
          LevelNode[] steps=nonLeafProof.getSteps();
          for (int i=0; i < steps.length; i++) {
            if (steps[i] instanceof TheoremNode) {
              TheoremNode node=getStepWithCaret((TheoremNode)steps[i],caretOffset,document);
              if (node != null) {
                return node;
              }
            }
          }
        }
      }
    }
  }
 catch (  BadLocationException e) {
    Activator.logError("String_Node_Str",e);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * For all   {@link TheoremNode} in the tree rooted at theoremNode,this returns the  {@link TheoremNode} that is first on the linecontaining the caret, or null if none satisfy that criteria.
 * @param theoremNode
 * @return
 */
public static TheoremNode getStepWithCaret(TheoremNode theoremNode,int caretOffset,IDocument document){
  try {
    int nodeBeginLine;
    int nodeEndLine;
    if (theoremNode.getDef() != null) {
      nodeBeginLine=theoremNode.getDef().getLocation().beginLine();
    }
 else {
      nodeBeginLine=theoremNode.getTheorem().getLocation().beginLine();
    }
    nodeEndLine=theoremNode.getTheorem().getLocation().endLine();
    int caretLine=document.getLineOfOffset(caretOffset) + 1;
    if (nodeBeginLine <= caretLine && nodeEndLine >= caretLine) {
      return theoremNode;
    }
    ThmOrAssumpDefNode defNode=theoremNode.getDef();
    if (defNode != null) {
    }
    ProofNode proof=theoremNode.getProof();
    if (proof != null) {
      Location proofLoc=proof.getLocation();
      if (caretLine >= proofLoc.beginColumn() && caretLine <= proofLoc.endLine()) {
        if (proof instanceof NonLeafProofNode) {
          NonLeafProofNode nonLeafProof=(NonLeafProofNode)proof;
          LevelNode[] steps=nonLeafProof.getSteps();
          for (int i=0; i < steps.length; i++) {
            if (steps[i] instanceof TheoremNode) {
              TheoremNode node=getStepWithCaret((TheoremNode)steps[i],caretOffset,document);
              if (node != null) {
                return node;
              }
            }
          }
        }
      }
    }
  }
 catch (  BadLocationException e) {
    Activator.logError("String_Node_Str",e);
  }
  return null;
}