Program: 88621
Project: 88621
Buggy source:
/** 
 * Create DocBook paragraph(s) for this Paragraph.
 * @param forViewEditor
 * @param outputDir
 * @return Return one or more DBParagraphs for docgen or the view editorbased on properties of the Paragraph UML stereotype. <p> <code> O=tryOcl && T=gotText && R=gotTargets && S=gotStereotypeProperties && D=don't care <br><br> 1 &nbsp;D && !T && !R &&  D: return nothing <br> 2     !O && !T &&  R && !S: return a paragraph of documentation for each target <br> 3     !O && !T &&  R &&  S: return a paragraph for each target-property pair  <br> 4     !O &&  T &&  D &&  D: return a paragraph of the text, tied to the "body" slot of dgElement <br>  <br> 5 &nbsp;O && !T &&  R && !S: return a paragraph of the evaluation of the documentation of each target as OCL on dgElement <br> 6 &nbsp;O && !T &&  R &&  S: return a paragraph of the evaluation of each target-property as OCL on dgElement <br> 7 &nbsp;O &&  T && !R &&  D: return a paragraph of the evaluation of the text as OCL on dgElement <br> 8 &nbsp;O &&  T &&  R && !S: return a paragraph of the evaluation of the text as OCL on each target <br> 9 &nbsp;O &&  T &&  R &&  S: return a paragraph of the evaluation of the text as OCL on each target-property pair <br> </code> <p>
 * @see gov.nasa.jpl.mbee.model.Query#visit(boolean,java.lang.String)
 */
@Override public List<DocumentElement> visit(boolean forViewEditor,String outputDir){
  Debug.outln("String_Node_Str" + forViewEditor + "String_Node_Str"+ outputDir+ "String_Node_Str");
  List<DocumentElement> res=new ArrayList<DocumentElement>();
  List<Reference> refs=new ArrayList<Reference>();
  if (getIgnore())   return res;
  boolean gotText=getText() != null;
  boolean gotTargets=getTargets() != null && !getTargets().isEmpty();
  boolean gotStereotypeProperties=!Utils2.isNullOrEmpty(getStereotypeProperties());
  boolean allTargetsAreProperties=false;
  Debug.outln("String_Node_Str" + gotText + "String_Node_Str"+ getText());
  Debug.outln("String_Node_Str" + gotTargets + "String_Node_Str"+ MoreToString.Helper.toLongString(getTargets()));
  Debug.outln("String_Node_Str" + gotStereotypeProperties + "String_Node_Str"+ getStereotypeProperties());
  Debug.outln("String_Node_Str" + attribute);
  if (gotText && !tryOcl) {
    Debug.outln("String_Node_Str");
    if (forViewEditor || !getText().trim().equals("String_Node_Str")) {
      Stereotype paragraphStereotype=Utils.getStereotype(DocGen3Profile.paragraphStereotype);
      Slot s=Utils.getSlot(getDgElement(),Utils.getStereotypePropertyByName(paragraphStereotype,"String_Node_Str"));
      if (s != null) {
        res.add(new DBParagraph(getText(),s,From.DVALUE));
      }
 else {
        if (getDgElement() != null && getFrom() != null) {
          res.add(new DBParagraph(getText(),getDgElement(),getFrom()));
        }
 else         if (getDgElement() != null) {
          res.add(new DBParagraph(getText(),getDgElement(),From.DOCUMENTATION));
        }
 else {
          res.add(new DBParagraph(getText()));
        }
      }
    }
  }
 else   if (gotText && !gotTargets) {
    Debug.outln("String_Node_Str");
    addOclParagraph(res,getText(),dgElement);
  }
 else   if (gotTargets) {
    allTargetsAreProperties=true;
    for (    Object o : targets) {
      if (o != null && !(o instanceof Property)) {
        if (!(o instanceof Slot)) {
          allTargetsAreProperties=false;
          break;
        }
      }
    }
    for (    Object o : targets) {
      Element e=null;
      if (o instanceof Element) {
        e=(Element)o;
      }
 else       if (!tryOcl)       continue;
      Reference ref=null;
      if (gotStereotypeProperties) {
        Debug.outln("String_Node_Str" + o);
        for (        Property p : getStereotypeProperties()) {
          ref=Reference.getPropertyReference(e,p);
          refs.add(ref);
        }
      }
 else {
        if (tryOcl && gotText) {
          Debug.outln("String_Node_Str" + Utils.getName(o));
          ref=new Reference(o);
        }
 else {
          Debug.outln("String_Node_Str");
          if (allTargetsAreProperties && tryOcl) {
            Object v=Utils.getElementAttribute(e,AvailableAttribute.Value);
            ref=new Reference(e,From.DVALUE,v);
          }
 else {
            ref=new Reference(e,From.DOCUMENTATION,ModelHelper.getComment(e));
          }
        }
        refs.add(ref);
      }
    }
    if (tryOcl && !iterate && gotText) {
      Debug.outln("String_Node_Str");
      ArrayList<Object> results=new ArrayList<Object>();
      for (      Reference r : refs) {
        results.add(r.getResult());
      }
      addOclParagraph(res,getText(),results);
    }
 else {
      if (!iterate) {
        Debug.error(false,"String_Node_Str" + dgElement);
      }
      for (      Reference r : refs) {
        if (!tryOcl) {
          Debug.outln("String_Node_Str" + r);
          res.addAll(Common.getReferenceAsDocumentElements(r));
        }
 else {
          if (gotText) {
            Debug.outln("String_Node_Str" + r);
            addOclParagraph(res,getText(),r.getResult());
          }
 else {
            Debug.outln("String_Node_Str" + r);
            addOclParagraph(res,r.getResult(),dgElement);
          }
        }
      }
    }
  }
  Debug.outln("String_Node_Str" + forViewEditor + "String_Node_Str"+ outputDir+ "String_Node_Str"+ res);
  return res;
}

Fixed version (ground truth):
/** 
 * Create DocBook paragraph(s) for this Paragraph.
 * @param forViewEditor
 * @param outputDir
 * @return Return one or more DBParagraphs for docgen or the view editorbased on properties of the Paragraph UML stereotype. <p> <code> O=tryOcl && T=gotText && R=gotTargets && S=gotStereotypeProperties && D=don't care <br><br> 1 &nbsp;D && !T && !R &&  D: return nothing <br> 2     !O && !T &&  R && !S: return a paragraph of documentation for each target <br> 3     !O && !T &&  R &&  S: return a paragraph for each target-property pair  <br> 4     !O &&  T &&  D &&  D: return a paragraph of the text, tied to the "body" slot of dgElement <br>  <br> 5 &nbsp;O && !T &&  R && !S: return a paragraph of the evaluation of the documentation of each target as OCL on dgElement <br> 6 &nbsp;O && !T &&  R &&  S: return a paragraph of the evaluation of each target-property as OCL on dgElement <br> 7 &nbsp;O &&  T && !R &&  D: return a paragraph of the evaluation of the text as OCL on dgElement <br> 8 &nbsp;O &&  T &&  R && !S: return a paragraph of the evaluation of the text as OCL on each target <br> 9 &nbsp;O &&  T &&  R &&  S: return a paragraph of the evaluation of the text as OCL on each target-property pair <br> </code> <p>
 * @see gov.nasa.jpl.mbee.model.Query#visit(boolean,java.lang.String)
 */
@Override public List<DocumentElement> visit(boolean forViewEditor,String outputDir){
  Debug.outln("String_Node_Str" + forViewEditor + "String_Node_Str"+ outputDir+ "String_Node_Str");
  List<DocumentElement> res=new ArrayList<DocumentElement>();
  List<Reference> refs=new ArrayList<Reference>();
  if (getIgnore())   return res;
  boolean gotText=getText() != null;
  boolean gotTargets=getTargets() != null && !getTargets().isEmpty();
  boolean gotStereotypeProperties=!Utils2.isNullOrEmpty(getStereotypeProperties());
  boolean allTargetsAreProperties=false;
  Debug.outln("String_Node_Str" + gotText + "String_Node_Str"+ getText());
  Debug.outln("String_Node_Str" + gotTargets + "String_Node_Str"+ MoreToString.Helper.toLongString(getTargets()));
  Debug.outln("String_Node_Str" + gotStereotypeProperties + "String_Node_Str"+ getStereotypeProperties());
  Debug.outln("String_Node_Str" + attribute);
  if (gotText && !tryOcl) {
    Debug.outln("String_Node_Str");
    if (forViewEditor || !getText().trim().equals("String_Node_Str")) {
      Stereotype paragraphStereotype=Utils.getStereotype(DocGen3Profile.paragraphStereotype);
      Slot s=Utils.getSlot(getDgElement(),Utils.getStereotypePropertyByName(paragraphStereotype,"String_Node_Str"));
      if (s != null) {
        res.add(new DBParagraph(getText(),s,From.DVALUE));
      }
 else {
        if (getDgElement() != null && getFrom() != null) {
          res.add(new DBParagraph(getText(),getDgElement(),getFrom()));
        }
 else         if (getDgElement() != null) {
          res.add(new DBParagraph(getText(),getDgElement(),From.DOCUMENTATION));
        }
 else {
          res.add(new DBParagraph(getText()));
        }
      }
    }
  }
 else   if (gotText && !gotTargets) {
    Debug.outln("String_Node_Str");
    addOclParagraph(res,getText(),new ArrayList<Object>());
  }
 else   if (gotTargets) {
    allTargetsAreProperties=true;
    for (    Object o : targets) {
      if (o != null && !(o instanceof Property)) {
        if (!(o instanceof Slot)) {
          allTargetsAreProperties=false;
          break;
        }
      }
    }
    for (    Object o : targets) {
      Element e=null;
      if (o instanceof Element) {
        e=(Element)o;
      }
 else       if (!tryOcl)       continue;
      Reference ref=null;
      if (gotStereotypeProperties) {
        Debug.outln("String_Node_Str" + o);
        for (        Property p : getStereotypeProperties()) {
          ref=Reference.getPropertyReference(e,p);
          refs.add(ref);
        }
      }
 else {
        if (tryOcl && gotText) {
          Debug.outln("String_Node_Str" + Utils.getName(o));
          ref=new Reference(o);
        }
 else {
          Debug.outln("String_Node_Str");
          if (allTargetsAreProperties && tryOcl) {
            Object v=Utils.getElementAttribute(e,AvailableAttribute.Value);
            ref=new Reference(e,From.DVALUE,v);
          }
 else {
            ref=new Reference(e,From.DOCUMENTATION,ModelHelper.getComment(e));
          }
        }
        refs.add(ref);
      }
    }
    if (tryOcl && !iterate && gotText) {
      Debug.outln("String_Node_Str");
      ArrayList<Object> results=new ArrayList<Object>();
      for (      Reference r : refs) {
        results.add(r.getResult());
      }
      addOclParagraph(res,getText(),results);
    }
 else {
      if (!iterate) {
        Debug.error(false,"String_Node_Str" + dgElement);
      }
      for (      Reference r : refs) {
        if (!tryOcl) {
          Debug.outln("String_Node_Str" + r);
          res.addAll(Common.getReferenceAsDocumentElements(r));
        }
 else {
          if (gotText) {
            Debug.outln("String_Node_Str" + r);
            addOclParagraph(res,getText(),r.getResult());
          }
 else {
            Debug.outln("String_Node_Str" + r);
            addOclParagraph(res,r.getResult(),new ArrayList<Object>());
          }
        }
      }
    }
  }
  Debug.outln("String_Node_Str" + forViewEditor + "String_Node_Str"+ outputDir+ "String_Node_Str"+ res);
  return res;
}