Program: 135949
Project: 135949
Buggy source:
/** 
 * Creates a SANY marker for levelNode if it is a   {@link TheoremNode} or a {@link UseOrHideNode}. If it has a proof, this method recursively calls it self on all children. The SANY location attribute for these markers is a string representation of the location of the node if it is a   {@link UseOrHideNode} and the string representation of the location of the node{@link TheoremNode#getTheorem()} if it is a {@link TheoremNode}. The methods   {@link #locToString(Location)} and {@link #stringToLoc(String)} convert from{@link Location} to Strings and back.See  {@link ProverHelper#SANY_MARKER} for a description ofthese markers. Creates and returns the  {@link StepTuple} for levelNode if levelNode is an instance of{@link UseOrHideNode} or {@link TheoremNode}. Sets the marker for this tuple. Returns null otherwise. If levelNode is a   {@link TheoremNode} then it sets levelNodeas the parent of all non-null  {@link StepTuple}s returned by calling this method on its children. The proverJob is the instance of   {@link ProverJob} used to launch the proverand passed to listeners of TLAPM output for that launch. It provides access to information about launch parameters and other useful data structures.
 * @param theoremNode
 * @throws CoreException 
 */
public static StepTuple prepareTreeForProverLaunch(LevelNode levelNode,IResource module,ProverJob proverJob) throws CoreException {
  if (levelNode == null) {
    return null;
  }
  if (levelNode instanceof UseOrHideNode || levelNode instanceof TheoremNode) {
    IMarker marker=module.createMarker(SANY_MARKER);
    Location locForAttr;
    if (levelNode instanceof UseOrHideNode) {
      locForAttr=levelNode.getLocation();
    }
 else {
      TheoremNode theoremNode=(TheoremNode)levelNode;
      Location beginLoc=theoremNode.getLocation();
      Location statementLoc=theoremNode.getTheorem().getLocation();
      locForAttr=new Location(UniqueString.uniqueStringOf(statementLoc.source()),beginLoc.beginLine(),beginLoc.beginColumn(),statementLoc.endLine(),statementLoc.endColumn());
    }
    marker.setAttribute(SANY_LOC_ATR,locToString(locForAttr));
    IRegion locRegion=AdapterFactory.locationToRegion(locForAttr);
    marker.setAttribute(IMarker.CHAR_START,locRegion.getOffset());
    marker.setAttribute(IMarker.CHAR_END,locRegion.getOffset() + locRegion.getLength());
    StepTuple stepTuple=new StepTuple(proverJob);
    stepTuple.setSanyMarker(marker);
    if (levelNode instanceof TheoremNode) {
      TheoremNode theoremNode=(TheoremNode)levelNode;
      ProofNode proof=theoremNode.getProof();
      if (proof != null) {
        if (proof instanceof NonLeafProofNode) {
          NonLeafProofNode nonLeafProof=(NonLeafProofNode)proof;
          LevelNode[] steps=nonLeafProof.getSteps();
          marker.setAttribute(SANY_IS_LEAF_ATR,steps.length == 0);
          for (int i=0; i < steps.length; i++) {
            StepTuple childTuple=prepareTreeForProverLaunch(steps[i],module,proverJob);
            if (childTuple != null) {
              childTuple.setParent(stepTuple);
              stepTuple.addChild(childTuple);
            }
          }
        }
 else {
          marker.setAttribute(SANY_IS_LEAF_ATR,true);
          LeafProofNode leafProof=(LeafProofNode)proof;
          if (leafProof.getOmitted()) {
            stepTuple.addChild(new ObligationStatus(stepTuple,createObligationMarker(-1,theoremNode.getLocation()),ColorPredicate.NUMBER_OF_OMITTED_STATE,theoremNode.getLocation(),0));
          }
        }
      }
 else {
        marker.setAttribute(SANY_IS_LEAF_ATR,true);
        LevelNode assertion=theoremNode.getTheorem();
        boolean shouldHaveProof=true;
        if (assertion instanceof OpApplNode) {
          OpApplNode opApplAss=(OpApplNode)assertion;
          String name=opApplAss.getOperator().getName().toString();
          if (name.equals("String_Node_Str") || name.equals("String_Node_Str") || name.equals("String_Node_Str"))           shouldHaveProof=false;
        }
        if (shouldHaveProof) {
          stepTuple.addChild(new ObligationStatus(stepTuple,createObligationMarker(-1,theoremNode.getLocation()),ColorPredicate.NUMBER_OF_MISSING_STATE,theoremNode.getLocation(),0));
        }
      }
    }
 else {
      marker.setAttribute(SANY_IS_LEAF_ATR,true);
    }
    if (marker.getAttribute(SANY_IS_LEAF_ATR,false)) {
      proverJob.getLeafStepMap().put(new Integer(locForAttr.beginLine()),stepTuple);
    }
    return stepTuple;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Creates a SANY marker for levelNode if it is a   {@link TheoremNode} or a {@link UseOrHideNode}. If it has a proof, this method recursively calls it self on all children. The SANY location attribute for these markers is a string representation of the location of the node if it is a   {@link UseOrHideNode} and the string representation of the location of the node{@link TheoremNode#getTheorem()} if it is a {@link TheoremNode}. The methods   {@link #locToString(Location)} and {@link #stringToLoc(String)} convert from{@link Location} to Strings and back.See  {@link ProverHelper#SANY_MARKER} for a description ofthese markers. Creates and returns the  {@link StepTuple} for levelNode if levelNode is an instance of{@link UseOrHideNode} or {@link TheoremNode}. Sets the marker for this tuple. Returns null otherwise. If levelNode is a   {@link TheoremNode} then it sets levelNodeas the parent of all non-null  {@link StepTuple}s returned by calling this method on its children. The proverJob is the instance of   {@link ProverJob} used to launch the proverand passed to listeners of TLAPM output for that launch. It provides access to information about launch parameters and other useful data structures.
 * @param theoremNode
 * @throws CoreException 
 */
public static StepTuple prepareTreeForProverLaunch(LevelNode levelNode,IResource module,ProverJob proverJob) throws CoreException {
  if (levelNode == null) {
    return null;
  }
  if (levelNode instanceof UseOrHideNode || levelNode instanceof TheoremNode) {
    IMarker marker=module.createMarker(SANY_MARKER);
    Location locForAttr;
    if (levelNode instanceof UseOrHideNode) {
      locForAttr=levelNode.getLocation();
    }
 else {
      TheoremNode theoremNode=(TheoremNode)levelNode;
      Location beginLoc=theoremNode.getLocation();
      Location statementLoc=theoremNode.getTheorem().getLocation();
      locForAttr=new Location(UniqueString.uniqueStringOf(statementLoc.source()),beginLoc.beginLine(),beginLoc.beginColumn(),statementLoc.endLine(),statementLoc.endColumn());
    }
    marker.setAttribute(SANY_LOC_ATR,locToString(locForAttr));
    IRegion locRegion=AdapterFactory.locationToRegion(locForAttr);
    marker.setAttribute(IMarker.CHAR_START,locRegion.getOffset());
    marker.setAttribute(IMarker.CHAR_END,locRegion.getOffset() + locRegion.getLength());
    StepTuple stepTuple=new StepTuple(proverJob);
    stepTuple.setSanyMarker(marker);
    if (levelNode instanceof TheoremNode) {
      TheoremNode theoremNode=(TheoremNode)levelNode;
      ProofNode proof=theoremNode.getProof();
      if (proof != null) {
        if (proof instanceof NonLeafProofNode) {
          NonLeafProofNode nonLeafProof=(NonLeafProofNode)proof;
          LevelNode[] steps=nonLeafProof.getSteps();
          marker.setAttribute(SANY_IS_LEAF_ATR,steps.length == 0);
          for (int i=0; i < steps.length; i++) {
            StepTuple childTuple=prepareTreeForProverLaunch(steps[i],module,proverJob);
            if (childTuple != null) {
              childTuple.setParent(stepTuple);
              stepTuple.addChild(childTuple);
            }
          }
        }
 else {
          marker.setAttribute(SANY_IS_LEAF_ATR,true);
          LeafProofNode leafProof=(LeafProofNode)proof;
          if (leafProof.getOmitted()) {
            stepTuple.addChild(new ObligationStatus(stepTuple,createObligationMarker(-1,theoremNode.getLocation()),ColorPredicate.NUMBER_OF_OMITTED_STATE,theoremNode.getLocation(),-1));
          }
        }
      }
 else {
        marker.setAttribute(SANY_IS_LEAF_ATR,true);
        LevelNode assertion=theoremNode.getTheorem();
        boolean shouldHaveProof=true;
        if (assertion instanceof OpApplNode) {
          OpApplNode opApplAss=(OpApplNode)assertion;
          String name=opApplAss.getOperator().getName().toString();
          if (name.equals("String_Node_Str") || name.equals("String_Node_Str") || name.equals("String_Node_Str"))           shouldHaveProof=false;
        }
        if (shouldHaveProof) {
          stepTuple.addChild(new ObligationStatus(stepTuple,createObligationMarker(-1,theoremNode.getLocation()),ColorPredicate.NUMBER_OF_MISSING_STATE,theoremNode.getLocation(),-1));
        }
      }
    }
 else {
      marker.setAttribute(SANY_IS_LEAF_ATR,true);
    }
    if (marker.getAttribute(SANY_IS_LEAF_ATR,false)) {
      proverJob.getLeafStepMap().put(new Integer(locForAttr.beginLine()),stepTuple);
    }
    return stepTuple;
  }
  return null;
}