Program: 23966
Project: 23966
Buggy source:
private void genElement(String defPath,HierarchicalTableGenerator gen,List<Row> rows,ElementDefinition element,List<ElementDefinition> all,List<StructureDefinition> profiles,boolean showMissing,String profileBaseFileName,Boolean extensions,boolean snapshot,String corePath) throws IOException {
  StructureDefinition profile=profiles == null ? null : profiles.get(profiles.size() - 1);
  String s=tail(element.getPath());
  List<ElementDefinition> children=getChildren(all,element);
  boolean isExtension=(s.equals("String_Node_Str") || s.equals("String_Node_Str"));
  if (!snapshot && extensions != null && extensions != isExtension)   return;
  if (!onlyInformationIsMapping(all,element)) {
    Row row=gen.new Row();
    row.setAnchor(element.getPath());
    row.setColor(getRowColor(element));
    boolean hasDef=element != null;
    boolean ext=false;
    if (s.equals("String_Node_Str") || s.equals("String_Node_Str")) {
      if (element.hasType() && element.getType().get(0).hasProfile() && extensionIsComplex(element.getType().get(0).getProfile().get(0).getValue()))       row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX);
 else       row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
      ext=true;
    }
 else     if (!hasDef || element.getType().size() == 0)     row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_ELEMENT);
 else     if (hasDef && element.getType().size() > 1) {
      if (allTypesAre(element.getType(),"String_Node_Str"))       row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_REFERENCE);
 else       row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_CHOICE);
    }
 else     if (hasDef && element.getType().get(0).getCode() != null && element.getType().get(0).getCode().startsWith("String_Node_Str"))     row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_REUSE);
 else     if (hasDef && isPrimitive(element.getType().get(0).getCode()))     row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_PRIMITIVE);
 else     if (hasDef && isReference(element.getType().get(0).getCode()))     row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_REFERENCE);
 else     if (hasDef && isDataType(element.getType().get(0).getCode()))     row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_DATATYPE);
 else     row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_RESOURCE);
    String ref=defPath == null ? null : defPath + makePathLink(element);
    UnusedTracker used=new UnusedTracker();
    used.used=true;
    Cell left=gen.new Cell(null,ref,s,!hasDef ? null : element.getDefinition(),null);
    row.getCells().add(left);
    Cell gc=gen.new Cell();
    row.getCells().add(gc);
    if (element != null && element.getIsModifier())     checkForNoChange(element.getIsModifierElement(),gc.addImage(corePath + "String_Node_Str","String_Node_Str","String_Node_Str"));
    if (element != null && element.getMustSupport())     checkForNoChange(element.getMustSupportElement(),gc.addImage(corePath + "String_Node_Str","String_Node_Str","String_Node_Str"));
    if (element != null && element.getIsSummary())     checkForNoChange(element.getIsSummaryElement(),gc.addImage(corePath + "String_Node_Str","String_Node_Str","String_Node_Str"));
    if (element != null && (!element.getConstraint().isEmpty() || !element.getCondition().isEmpty()))     gc.addImage(corePath + "String_Node_Str","String_Node_Str","String_Node_Str");
    ExtensionContext extDefn=null;
    if (ext) {
      if (element != null && element.getType().size() == 1 && element.getType().get(0).hasProfile()) {
        extDefn=locateExtension(StructureDefinition.class,element.getType().get(0).getProfile().get(0).getValue());
        if (extDefn == null) {
          genCardinality(gen,element,row,hasDef,used,null);
          row.getCells().add(gen.new Cell(null,null,"String_Node_Str" + element.getType().get(0).getProfile(),null,null));
          generateDescription(gen,row,element,null,used.used,profile.getUrl(),element.getType().get(0).getProfile().get(0).getValue(),profile,corePath);
        }
 else {
          String name=urltail(element.getType().get(0).getProfile().get(0).getValue());
          left.getPieces().get(0).setText(name);
          left.getPieces().get(0).setHint("String_Node_Str" + extDefn.getUrl());
          genCardinality(gen,element,row,hasDef,used,extDefn.getElement());
          ElementDefinition valueDefn=extDefn.getExtensionValueDefinition();
          if (valueDefn != null && !"String_Node_Str".equals(valueDefn.getMax()))           genTypes(gen,row,valueDefn,profileBaseFileName,profile,corePath);
 else           row.getCells().add(gen.new Cell(null,null,"String_Node_Str",null,null));
          generateDescription(gen,row,element,extDefn.getElement(),used.used,null,extDefn.getUrl(),profile,corePath);
        }
      }
 else {
        genCardinality(gen,element,row,hasDef,used,null);
        if ("String_Node_Str".equals(element.getMax()))         row.getCells().add(gen.new Cell());
 else         genTypes(gen,row,element,profileBaseFileName,profile,corePath);
        generateDescription(gen,row,element,null,used.used,null,null,profile,corePath);
      }
    }
 else {
      genCardinality(gen,element,row,hasDef,used,null);
      if (hasDef && !"String_Node_Str".equals(element.getMax()))       genTypes(gen,row,element,profileBaseFileName,profile,corePath);
 else       row.getCells().add(gen.new Cell());
      generateDescription(gen,row,element,null,used.used,null,null,profile,corePath);
    }
    if (element.hasSlicing()) {
      if (standardExtensionSlicing(element)) {
        used.used=element.hasType() && element.getType().get(0).hasProfile();
        showMissing=false;
      }
 else {
        row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_SLICE);
        row.getCells().get(2).getPieces().clear();
        for (        Cell cell : row.getCells())         for (        Piece p : cell.getPieces()) {
          p.addStyle("String_Node_Str");
        }
      }
    }
    if (used.used || showMissing)     rows.add(row);
    if (!used.used && !element.hasSlicing()) {
      for (      Cell cell : row.getCells())       for (      Piece p : cell.getPieces()) {
        p.setStyle("String_Node_Str");
        p.setReference(null);
      }
    }
 else {
      for (      ElementDefinition child : children)       if (!child.getPath().endsWith("String_Node_Str"))       genElement(defPath,gen,row.getSubRows(),child,all,profiles,showMissing,profileBaseFileName,isExtension,snapshot,corePath);
      if (!snapshot && (extensions == null || !extensions))       for (      ElementDefinition child : children)       if (child.getPath().endsWith("String_Node_Str"))       genElement(defPath,gen,row.getSubRows(),child,all,profiles,showMissing,profileBaseFileName,true,false,corePath);
    }
  }
}

Fixed version (ground truth):
private void genElement(String defPath,HierarchicalTableGenerator gen,List<Row> rows,ElementDefinition element,List<ElementDefinition> all,List<StructureDefinition> profiles,boolean showMissing,String profileBaseFileName,Boolean extensions,boolean snapshot,String corePath) throws IOException {
  StructureDefinition profile=profiles == null ? null : profiles.get(profiles.size() - 1);
  String s=tail(element.getPath());
  List<ElementDefinition> children=getChildren(all,element);
  boolean isExtension=(s.equals("String_Node_Str") || s.equals("String_Node_Str"));
  if (!snapshot && extensions != null && extensions != isExtension)   return;
  if (!onlyInformationIsMapping(all,element)) {
    Row row=gen.new Row();
    row.setAnchor(element.getPath());
    row.setColor(getRowColor(element));
    boolean hasDef=element != null;
    boolean ext=false;
    if (s.equals("String_Node_Str") || s.equals("String_Node_Str")) {
      if (element.hasType() && element.getType().get(0).hasProfile() && extensionIsComplex(element.getType().get(0).getProfile().get(0).getValue()))       row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_EXTENSION_COMPLEX);
 else       row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_EXTENSION_SIMPLE);
      ext=true;
    }
 else     if (!hasDef || element.getType().size() == 0)     row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_ELEMENT);
 else     if (hasDef && element.getType().size() > 1) {
      if (allTypesAre(element.getType(),"String_Node_Str"))       row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_REFERENCE);
 else       row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_CHOICE);
    }
 else     if (hasDef && element.getType().get(0).getCode() != null && element.getType().get(0).getCode().startsWith("String_Node_Str"))     row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_REUSE);
 else     if (hasDef && isPrimitive(element.getType().get(0).getCode()))     row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_PRIMITIVE);
 else     if (hasDef && isReference(element.getType().get(0).getCode()))     row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_REFERENCE);
 else     if (hasDef && isDataType(element.getType().get(0).getCode()))     row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_DATATYPE);
 else     row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_RESOURCE);
    String ref=defPath == null ? null : defPath + makePathLink(element);
    UnusedTracker used=new UnusedTracker();
    used.used=true;
    Cell left=gen.new Cell(null,ref,s,!hasDef ? null : element.getDefinition(),null);
    row.getCells().add(left);
    Cell gc=gen.new Cell();
    row.getCells().add(gc);
    if (element != null && element.getIsModifier())     checkForNoChange(element.getIsModifierElement(),gc.addImage(corePath + "String_Node_Str","String_Node_Str","String_Node_Str",null,null));
    if (element != null && element.getMustSupport())     checkForNoChange(element.getMustSupportElement(),gc.addImage(corePath + "String_Node_Str","String_Node_Str","String_Node_Str",null,null));
    if (element != null && element.getIsSummary())     checkForNoChange(element.getIsSummaryElement(),gc.addImage(corePath + "String_Node_Str","String_Node_Str","String_Node_Str",null,null));
    if (element != null && (!element.getConstraint().isEmpty() || !element.getCondition().isEmpty()))     gc.addImage(corePath + "String_Node_Str","String_Node_Str","String_Node_Str",null,null);
    ExtensionContext extDefn=null;
    if (ext) {
      if (element != null && element.getType().size() == 1 && element.getType().get(0).hasProfile()) {
        extDefn=locateExtension(StructureDefinition.class,element.getType().get(0).getProfile().get(0).getValue());
        if (extDefn == null) {
          genCardinality(gen,element,row,hasDef,used,null);
          row.getCells().add(gen.new Cell(null,null,"String_Node_Str" + element.getType().get(0).getProfile(),null,null));
          generateDescription(gen,row,element,null,used.used,profile.getUrl(),element.getType().get(0).getProfile().get(0).getValue(),profile,corePath);
        }
 else {
          String name=urltail(element.getType().get(0).getProfile().get(0).getValue());
          left.getPieces().get(0).setText(name);
          left.getPieces().get(0).setHint("String_Node_Str" + extDefn.getUrl());
          genCardinality(gen,element,row,hasDef,used,extDefn.getElement());
          ElementDefinition valueDefn=extDefn.getExtensionValueDefinition();
          if (valueDefn != null && !"String_Node_Str".equals(valueDefn.getMax()))           genTypes(gen,row,valueDefn,profileBaseFileName,profile,corePath);
 else           row.getCells().add(gen.new Cell(null,null,"String_Node_Str",null,null));
          generateDescription(gen,row,element,extDefn.getElement(),used.used,null,extDefn.getUrl(),profile,corePath);
        }
      }
 else {
        genCardinality(gen,element,row,hasDef,used,null);
        if ("String_Node_Str".equals(element.getMax()))         row.getCells().add(gen.new Cell());
 else         genTypes(gen,row,element,profileBaseFileName,profile,corePath);
        generateDescription(gen,row,element,null,used.used,null,null,profile,corePath);
      }
    }
 else {
      genCardinality(gen,element,row,hasDef,used,null);
      if (hasDef && !"String_Node_Str".equals(element.getMax()))       genTypes(gen,row,element,profileBaseFileName,profile,corePath);
 else       row.getCells().add(gen.new Cell());
      generateDescription(gen,row,element,null,used.used,null,null,profile,corePath);
    }
    if (element.hasSlicing()) {
      if (standardExtensionSlicing(element)) {
        used.used=element.hasType() && element.getType().get(0).hasProfile();
        showMissing=false;
      }
 else {
        row.setIcon("String_Node_Str",HierarchicalTableGenerator.TEXT_ICON_SLICE);
        row.getCells().get(2).getPieces().clear();
        for (        Cell cell : row.getCells())         for (        Piece p : cell.getPieces()) {
          p.addStyle("String_Node_Str");
        }
      }
    }
    if (used.used || showMissing)     rows.add(row);
    if (!used.used && !element.hasSlicing()) {
      for (      Cell cell : row.getCells())       for (      Piece p : cell.getPieces()) {
        p.setStyle("String_Node_Str");
        p.setReference(null);
      }
    }
 else {
      for (      ElementDefinition child : children)       if (!child.getPath().endsWith("String_Node_Str"))       genElement(defPath,gen,row.getSubRows(),child,all,profiles,showMissing,profileBaseFileName,isExtension,snapshot,corePath);
      if (!snapshot && (extensions == null || !extensions))       for (      ElementDefinition child : children)       if (child.getPath().endsWith("String_Node_Str"))       genElement(defPath,gen,row.getSubRows(),child,all,profiles,showMissing,profileBaseFileName,true,false,corePath);
    }
  }
}