Program: 88646
Project: 88646
Buggy source:
public Section parseView(Element view){
  Element viewpoint=GeneratorUtils.findStereotypedRelationship(view,conforms);
  if (viewpoint == null)   viewpoint=GeneratorUtils.findStereotypedRelationship(view,sysml14conforms);
  Section viewSection=new Section();
  viewSection.setView(true);
  if (StereotypesHelper.hasStereotype(view,DocGen3Profile.appendixViewStereotype))   viewSection.isAppendix(true);
  if (viewpoint != null && viewpoint instanceof Class) {
    if (!(view instanceof Diagram)) {
      String viewDoc=ModelHelper.getComment(view);
      if (viewDoc != null) {
        Paragraph para=new Paragraph(viewDoc);
        para.setDgElement(view);
        para.setFrom(From.DOCUMENTATION);
        viewSection.addElement(para);
      }
    }
    Collection<Behavior> viewpointBehavior=((Class)viewpoint).getOwnedBehavior();
    Behavior b=null;
    if (viewpointBehavior.size() > 0)     b=viewpointBehavior.iterator().next();
 else {
      Class now=(Class)viewpoint;
      while (now != null) {
        if (!now.getSuperClass().isEmpty()) {
          now=now.getSuperClass().iterator().next();
          if (now.getOwnedBehavior().size() > 0) {
            b=now.getOwnedBehavior().iterator().next();
            break;
          }
        }
 else {
          now=null;
        }
      }
    }
    if (b != null) {
      Boolean addVPElements=(Boolean)GeneratorUtils.getObjectProperty(b,DocGen3Profile.methodStereotype,"String_Node_Str",false);
      ;
      List<Element> elementImports=Utils.collectDirectedRelatedElementsByRelationshipJavaClass(view,ElementImport.class,1,1);
      List<Element> packageImports=Utils.collectDirectedRelatedElementsByRelationshipJavaClass(view,PackageImport.class,1,1);
      List<Element> expose=Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(view,DocGen3Profile.queriesStereotype,1,false,1);
      List<Element> queries=Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(view,DocGen3Profile.oldQueriesStereotype,1,false,1);
      if (elementImports == null)       elementImports=new ArrayList<Element>();
      if (packageImports != null)       elementImports.addAll(packageImports);
      if (expose != null)       elementImports.addAll(expose);
      if (queries != null)       elementImports.addAll(queries);
      if (view instanceof Class) {
        for (        TypedElement te : ((Class)view).get_typedElementOfType()) {
          if (te instanceof Property && ((Property)te).getAggregation() == AggregationKindEnum.COMPOSITE) {
            elementImports.addAll(Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(te,DocGen3Profile.queriesStereotype,1,false,1));
          }
        }
      }
      if (elementImports.isEmpty())       elementImports.add(view);
      if (addVPElements) {
        elementImports.add(viewpoint);
        elementImports.addAll(Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(viewpoint,"String_Node_Str",1,false,1));
        elementImports.addAll(Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(viewpoint,"String_Node_Str",1,false,1));
        elementImports.add(b);
        elementImports.add(view);
      }
      context.pushTargets(Utils2.asList(Utils.removeDuplicates(elementImports),Object.class));
      if (b instanceof Activity) {
        parseActivityOrStructuredNode(b,viewSection);
      }
      context.popTargets();
    }
  }
 else {
    List<Element> expose=Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(view,DocGen3Profile.queriesStereotype,1,false,1);
    if (view instanceof Class) {
      for (      TypedElement te : ((Class)view).get_typedElementOfType()) {
        if (te instanceof Property && ((Property)te).getAggregation() == AggregationKindEnum.COMPOSITE) {
          expose.addAll(Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(te,DocGen3Profile.queriesStereotype,1,false,1));
        }
      }
    }
    if (view instanceof Class && expose.size() == 1 && StereotypesHelper.hasStereotypeOrDerived(expose.get(0),sysmlview)) {
      return parseView(expose.get(0));
    }
    if (view instanceof Diagram) {
      Image image=new Image();
      List<Object> images=new ArrayList<Object>();
      images.add(view);
      image.setTargets(images);
      String caption=(String)StereotypesHelper.getStereotypePropertyFirst(view,DocGen3Profile.dgviewStereotype,"String_Node_Str");
      if (caption == null)       caption=(String)StereotypesHelper.getStereotypePropertyFirst(view,DocGen3Profile.oldDgviewStereotype,"String_Node_Str");
      List<String> captions=new ArrayList<String>();
      captions.add(caption);
      image.setCaptions(captions);
      image.setShowCaptions(true);
      viewSection.addElement(image);
    }
 else {
      String viewDoc=ModelHelper.getComment(view);
      if (viewDoc != null) {
        Paragraph para=new Paragraph(viewDoc);
        if ((Boolean)GeneratorUtils.getObjectProperty(view,DocGen3Profile.editableChoosable,"String_Node_Str",true)) {
          para.setDgElement(view);
          para.setFrom(From.DOCUMENTATION);
        }
        viewSection.addElement(para);
      }
    }
  }
  viewSection.setDgElement(view);
  viewSection.setId(view.getID());
  viewSection.setTitle(((NamedElement)view).getName());
  return viewSection;
}

Fixed version (ground truth):
public Section parseView(Element view){
  Element viewpoint=GeneratorUtils.findStereotypedRelationship(view,conforms);
  if (viewpoint == null)   viewpoint=GeneratorUtils.findStereotypedRelationship(view,sysml14conforms);
  Section viewSection=new Section();
  viewSection.setView(true);
  if (StereotypesHelper.hasStereotype(view,DocGen3Profile.appendixViewStereotype))   viewSection.isAppendix(true);
  if (viewpoint != null && viewpoint instanceof Class) {
    if (!(view instanceof Diagram)) {
      String viewDoc=ModelHelper.getComment(view);
      if (viewDoc != null) {
        Paragraph para=new Paragraph(viewDoc);
        para.setDgElement(view);
        para.setFrom(From.DOCUMENTATION);
        viewSection.addElement(para);
      }
    }
    Collection<Behavior> viewpointBehavior=((Class)viewpoint).getOwnedBehavior();
    Behavior b=null;
    if (viewpointBehavior.size() > 0)     b=viewpointBehavior.iterator().next();
 else {
      Class now=(Class)viewpoint;
      while (now != null) {
        if (!now.getSuperClass().isEmpty()) {
          now=now.getSuperClass().iterator().next();
          if (now.getOwnedBehavior().size() > 0) {
            b=now.getOwnedBehavior().iterator().next();
            break;
          }
        }
 else {
          now=null;
        }
      }
    }
    if (b != null) {
      Boolean addVPElements=(Boolean)GeneratorUtils.getObjectProperty(b,DocGen3Profile.methodStereotype,"String_Node_Str",false);
      ;
      List<Element> elementImports=Utils.collectDirectedRelatedElementsByRelationshipJavaClass(view,ElementImport.class,1,1);
      List<Element> packageImports=Utils.collectDirectedRelatedElementsByRelationshipJavaClass(view,PackageImport.class,1,1);
      List<Element> expose=Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(view,DocGen3Profile.queriesStereotype,1,false,1);
      List<Element> queries=Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(view,DocGen3Profile.oldQueriesStereotype,1,false,1);
      if (elementImports == null)       elementImports=new ArrayList<Element>();
      if (packageImports != null)       elementImports.addAll(packageImports);
      if (expose != null)       elementImports.addAll(expose);
      if (queries != null)       elementImports.addAll(queries);
      if (view instanceof Class) {
        for (        TypedElement te : ((Class)view).get_typedElementOfType()) {
          if (te instanceof Property && ((Property)te).getAggregation() == AggregationKindEnum.COMPOSITE) {
            elementImports.addAll(Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(te,DocGen3Profile.queriesStereotype,1,false,1));
          }
        }
      }
      if (elementImports.isEmpty())       elementImports.add(view);
      if (addVPElements) {
        elementImports.add(viewpoint);
        elementImports.addAll(Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(viewpoint,"String_Node_Str",1,false,1));
        elementImports.addAll(Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(viewpoint,"String_Node_Str",1,false,1));
        elementImports.add(b);
        elementImports.add(view);
      }
      context.pushTargets(Utils2.asList(Utils.removeDuplicates(elementImports),Object.class));
      if (b instanceof Activity) {
        parseActivityOrStructuredNode(b,viewSection);
      }
      context.popTargets();
    }
  }
 else {
    List<Element> expose=Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(view,DocGen3Profile.queriesStereotype,1,false,1);
    if (view instanceof Class) {
      for (      TypedElement te : ((Class)view).get_typedElementOfType()) {
        if (te instanceof Property && ((Property)te).getAggregation() == AggregationKindEnum.COMPOSITE) {
          expose.addAll(Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(te,DocGen3Profile.queriesStereotype,1,false,1));
        }
      }
    }
    if (view instanceof Class && expose.size() == 1 && StereotypesHelper.hasStereotypeOrDerived(expose.get(0),sysmlview)) {
      return parseView(expose.get(0));
    }
    if (view instanceof Diagram) {
      Image image=new Image();
      List<Object> images=new ArrayList<Object>();
      images.add(view);
      image.setTargets(images);
      String caption=(String)StereotypesHelper.getStereotypePropertyFirst(view,DocGen3Profile.dgviewStereotype,"String_Node_Str");
      if (caption == null)       caption=(String)StereotypesHelper.getStereotypePropertyFirst(view,DocGen3Profile.oldDgviewStereotype,"String_Node_Str");
      List<String> captions=new ArrayList<String>();
      captions.add(caption);
      image.setCaptions(captions);
      image.setShowCaptions(true);
      viewSection.addElement(image);
    }
 else {
      String viewDoc=ModelHelper.getComment(view);
      if (viewDoc != null) {
        Paragraph para=new Paragraph(viewDoc);
        para.setDgElement(view);
        para.setFrom(From.DOCUMENTATION);
        viewSection.addElement(para);
      }
    }
  }
  viewSection.setDgElement(view);
  viewSection.setId(view.getID());
  viewSection.setTitle(((NamedElement)view).getName());
  return viewSection;
}