Program: 88743
Project: 88743
Buggy source:
/** 
 * parses activity/structured node - these usually indicate a new context of target elements
 * @param a
 * @param parent
 * @return the output of parsing the activity
 */
@SuppressWarnings("String_Node_Str") public Object parseActivityOrStructuredNode(Element a,Container parent){
  Debug.outln("String_Node_Str" + a.getHumanName() + "String_Node_Str"+ a.getID()+ "String_Node_Str"+ parent.getStringIfEmpty()+ "String_Node_Str");
  InitialNode in=GeneratorUtils.findInitialNode(a);
  if (in == null)   return null;
  Collection<ActivityEdge> outs=in.getOutgoing();
  int pushed=0;
  ActivityNode next2=in;
  Object lastResults=null;
  Object parseResults=null;
  while (outs != null && outs.size() == 1) {
    parseResults=null;
    ActivityNode next=outs.iterator().next().getTarget();
    Debug.outln("String_Node_Str" + next.getHumanName() + "String_Node_Str"+ next.getID());
    next2=null;
    if (next instanceof CallBehaviorAction || next instanceof StructuredActivityNode && StereotypesHelper.hasStereotypeOrDerived(next,DocGen3Profile.tableStructureStereotype)) {
      Behavior b=(next instanceof CallBehaviorAction) ? ((CallBehaviorAction)next).getBehavior() : null;
      if (StereotypesHelper.hasStereotypeOrDerived(next,DocGen3Profile.sectionStereotype) || b != null && StereotypesHelper.hasStereotypeOrDerived(b,DocGen3Profile.sectionStereotype)) {
        parseResults=parseSection((CallBehaviorAction)next,parent);
        next2=next;
      }
 else       if (StereotypesHelper.hasStereotypeOrDerived(next,DocGen3Profile.templateStereotype) || b != null && StereotypesHelper.hasStereotypeOrDerived(b,DocGen3Profile.templateStereotype)) {
        parseResults=parseQuery(next,parent);
        next2=next;
      }
 else       if (StereotypesHelper.hasStereotypeOrDerived(next,DocGen3Profile.collectFilterStereotype) || b != null && StereotypesHelper.hasStereotypeOrDerived(b,DocGen3Profile.collectFilterStereotype)) {
        CollectFilterParser.setContext(context);
        List<Element> results=CollectFilterParser.startCollectAndFilterSequence(next,null);
        parseResults=results;
        this.context.pushTargets(results);
        pushed++;
        next2=context.getCurrentNode();
      }
    }
 else     if (next instanceof StructuredActivityNode) {
      Boolean loop=(Boolean)GeneratorUtils.getObjectProperty(next,DocGen3Profile.templateStereotype,"String_Node_Str",false);
      Boolean ignore=(Boolean)GeneratorUtils.getObjectProperty(next,DocGen3Profile.templateStereotype,"String_Node_Str",false);
      Boolean createSections=(Boolean)GeneratorUtils.getObjectProperty(next,DocGen3Profile.structuredQueryStereotype,"String_Node_Str",false);
      Boolean useContextNameAsTitle=(Boolean)GeneratorUtils.getObjectProperty(next,DocGen3Profile.templateStereotype,"String_Node_Str",false);
      String titlePrefix=(String)StereotypesHelper.getStereotypePropertyFirst(a,DocGen3Profile.templateStereotype,"String_Node_Str");
      String titleSuffix=(String)StereotypesHelper.getStereotypePropertyFirst(a,DocGen3Profile.templateStereotype,"String_Node_Str");
      List<String> titles=(List<String>)StereotypesHelper.getStereotypePropertyValue(next,DocGen3Profile.templateStereotype,"String_Node_Str");
      if (titles == null)       titles=new ArrayList<String>();
      List<Element> targets=getTargets(next,this.context);
      if (!ignore) {
        if (loop) {
          int count=0;
          for (          Element e : targets) {
            List<Element> target=new ArrayList<Element>();
            target.add(e);
            this.context.pushTargets(target);
            Container con=parent;
            if (createSections) {
              Section sec=new Section();
              if (titles != null && titles.size() > count)               sec.setTitle(titles.get(count));
 else               if (e instanceof NamedElement)               sec.setTitle(((NamedElement)e).getName());
              sec.setTitlePrefix(titlePrefix);
              sec.setTitleSuffix(titleSuffix);
              sec.setDgElement(next);
              parent.addElement(sec);
              con=sec;
            }
            parseResults=parseActivityOrStructuredNode(next,con);
            this.context.popTargets();
            count++;
          }
        }
 else {
          this.context.pushTargets(targets);
          Container con=parent;
          if (createSections) {
            Section sec=new Section();
            if (titles != null && titles.size() > 0)             sec.setTitle(titles.get(0));
 else             if (!next.getName().equals("String_Node_Str"))             sec.setTitle(next.getName());
            sec.setUseContextNameAsTitle(useContextNameAsTitle);
            sec.setDgElement(next);
            sec.setTitlePrefix(titlePrefix);
            sec.setTitleSuffix(titleSuffix);
            parent.addElement(sec);
            con=sec;
          }
          parseResults=parseActivityOrStructuredNode(next,con);
          this.context.popTargets();
        }
      }
      next2=next;
    }
 else     if (next instanceof ForkNode && StereotypesHelper.hasStereotype(next,DocGen3Profile.parallel)) {
      CollectFilterParser.setContext(context);
      List<Element> results=CollectFilterParser.startCollectAndFilterSequence(next,null);
      parseResults=results;
      this.context.pushTargets(results);
      pushed++;
      next2=context.getCurrentNode();
    }
    if (next2 == null) {
      next2=next;
    }
    if (parseResults == null)     parseResults=this.context.peekTargets();
    if (parseResults != null)     lastResults=parseResults;
    DocumentValidator.evaluateConstraints(next,parseResults,context);
    outs=next2.getOutgoing();
    Debug.outln("String_Node_Str" + MoreToString.Helper.toLongString(outs) + "String_Node_Str"+ next2.getHumanName()+ "String_Node_Str"+ next2.getID());
  }
  while (pushed > 0) {
    this.context.popTargets();
    pushed--;
  }
  return lastResults;
}

Fixed version (ground truth):
/** 
 * parses activity/structured node - these usually indicate a new context of target elements
 * @param a
 * @param parent
 * @return the output of parsing the activity
 */
@SuppressWarnings("String_Node_Str") public Object parseActivityOrStructuredNode(Element a,Container parent){
  Debug.outln("String_Node_Str" + a.getHumanName() + "String_Node_Str"+ a.getID()+ "String_Node_Str"+ parent.getStringIfEmpty()+ "String_Node_Str");
  InitialNode in=GeneratorUtils.findInitialNode(a);
  if (in == null)   return null;
  Collection<ActivityEdge> outs=in.getOutgoing();
  int pushed=0;
  ActivityNode next2=in;
  Object lastResults=null;
  Object parseResults=null;
  while (outs != null && outs.size() == 1) {
    parseResults=null;
    ActivityNode next=outs.iterator().next().getTarget();
    Debug.outln("String_Node_Str" + next.getHumanName() + "String_Node_Str"+ next.getID());
    next2=null;
    boolean evaluatedConstraintsForNext=false;
    if (next instanceof CallBehaviorAction || next instanceof StructuredActivityNode && StereotypesHelper.hasStereotypeOrDerived(next,DocGen3Profile.tableStructureStereotype)) {
      Behavior b=(next instanceof CallBehaviorAction) ? ((CallBehaviorAction)next).getBehavior() : null;
      if (StereotypesHelper.hasStereotypeOrDerived(next,DocGen3Profile.sectionStereotype) || b != null && StereotypesHelper.hasStereotypeOrDerived(b,DocGen3Profile.sectionStereotype)) {
        parseResults=parseSection((CallBehaviorAction)next,parent);
        next2=next;
      }
 else       if (StereotypesHelper.hasStereotypeOrDerived(next,DocGen3Profile.templateStereotype) || b != null && StereotypesHelper.hasStereotypeOrDerived(b,DocGen3Profile.templateStereotype)) {
        parseResults=parseQuery(next,parent);
        next2=next;
      }
 else       if (StereotypesHelper.hasStereotypeOrDerived(next,DocGen3Profile.collectFilterStereotype) || b != null && StereotypesHelper.hasStereotypeOrDerived(b,DocGen3Profile.collectFilterStereotype)) {
        CollectFilterParser.setContext(context);
        List<Element> results=CollectFilterParser.startCollectAndFilterSequence(next,null);
        parseResults=results;
        this.context.pushTargets(results);
        pushed++;
        next2=context.getCurrentNode();
        evaluatedConstraintsForNext=true;
      }
    }
 else     if (next instanceof StructuredActivityNode) {
      Boolean loop=(Boolean)GeneratorUtils.getObjectProperty(next,DocGen3Profile.templateStereotype,"String_Node_Str",false);
      Boolean ignore=(Boolean)GeneratorUtils.getObjectProperty(next,DocGen3Profile.templateStereotype,"String_Node_Str",false);
      Boolean createSections=(Boolean)GeneratorUtils.getObjectProperty(next,DocGen3Profile.structuredQueryStereotype,"String_Node_Str",false);
      Boolean useContextNameAsTitle=(Boolean)GeneratorUtils.getObjectProperty(next,DocGen3Profile.templateStereotype,"String_Node_Str",false);
      String titlePrefix=(String)StereotypesHelper.getStereotypePropertyFirst(a,DocGen3Profile.templateStereotype,"String_Node_Str");
      String titleSuffix=(String)StereotypesHelper.getStereotypePropertyFirst(a,DocGen3Profile.templateStereotype,"String_Node_Str");
      List<String> titles=(List<String>)StereotypesHelper.getStereotypePropertyValue(next,DocGen3Profile.templateStereotype,"String_Node_Str");
      if (titles == null)       titles=new ArrayList<String>();
      List<Element> targets=getTargets(next,this.context);
      if (!ignore) {
        if (loop) {
          int count=0;
          for (          Element e : targets) {
            List<Element> target=new ArrayList<Element>();
            target.add(e);
            this.context.pushTargets(target);
            Container con=parent;
            if (createSections) {
              Section sec=new Section();
              if (titles != null && titles.size() > count)               sec.setTitle(titles.get(count));
 else               if (e instanceof NamedElement)               sec.setTitle(((NamedElement)e).getName());
              sec.setTitlePrefix(titlePrefix);
              sec.setTitleSuffix(titleSuffix);
              sec.setDgElement(next);
              parent.addElement(sec);
              con=sec;
            }
            parseResults=parseActivityOrStructuredNode(next,con);
            this.context.popTargets();
            count++;
          }
        }
 else {
          this.context.pushTargets(targets);
          Container con=parent;
          if (createSections) {
            Section sec=new Section();
            if (titles != null && titles.size() > 0)             sec.setTitle(titles.get(0));
 else             if (!next.getName().equals("String_Node_Str"))             sec.setTitle(next.getName());
            sec.setUseContextNameAsTitle(useContextNameAsTitle);
            sec.setDgElement(next);
            sec.setTitlePrefix(titlePrefix);
            sec.setTitleSuffix(titleSuffix);
            parent.addElement(sec);
            con=sec;
          }
          parseResults=parseActivityOrStructuredNode(next,con);
          this.context.popTargets();
        }
      }
      next2=next;
    }
 else     if (next instanceof ForkNode && StereotypesHelper.hasStereotype(next,DocGen3Profile.parallel)) {
      CollectFilterParser.setContext(context);
      List<Element> results=CollectFilterParser.startCollectAndFilterSequence(next,null);
      parseResults=results;
      this.context.pushTargets(results);
      pushed++;
      next2=context.getCurrentNode();
    }
    if (next2 == null) {
      next2=next;
    }
    if (parseResults == null)     parseResults=this.context.peekTargets();
    if (parseResults != null)     lastResults=parseResults;
    if (!evaluatedConstraintsForNext) {
      DocumentValidator.evaluateConstraints(next,parseResults,context);
    }
    outs=next2.getOutgoing();
    Debug.outln("String_Node_Str" + MoreToString.Helper.toLongString(outs) + "String_Node_Str"+ next2.getHumanName()+ "String_Node_Str"+ next2.getID());
  }
  while (pushed > 0) {
    this.context.popTargets();
    pushed--;
  }
  return lastResults;
}