Program: 23299
Project: 23299
Buggy source:
private int processExtension(ElementDefn extensions,Sheet sheet,int row,Definitions definitions,String uri,Profile ap,List<ValidationMessage> issues,Map<String,Invariant> invariants) throws Exception {
  StructureDefinition ex=new StructureDefinition();
  ex.setUserData(ToolResourceUtilities.NAME_RES_IG,ig == null ? "String_Node_Str" : ig.getCode());
  ex.setUserData("String_Node_Str",ap);
  ex.setKind(StructureDefinitionKind.COMPLEXTYPE);
  ex.setType("String_Node_Str");
  ex.setBaseDefinition("String_Node_Str");
  ex.setDerivation(TypeDerivationRule.CONSTRAINT);
  ex.setAbstract(false);
  ex.setFhirVersion(version);
  if (ap.hasMetadata("String_Node_Str"))   ToolingExtensions.addIntegerExtension(ex,ToolingExtensions.EXT_FMM_LEVEL,Integer.parseInt(ap.getFmmLevel()));
  if (ap.hasMetadata("String_Node_Str"))   ToolingExtensions.setCodeExtension(ex,ToolingExtensions.EXT_WORKGROUP,ap.getWg());
  ToolResourceUtilities.updateUsage(ex,ap.getCategory());
  String name=sheet.getColumn(row,"String_Node_Str");
  String context=null;
  if (Utilities.noString(name))   throw new Exception("String_Node_Str" + getLocation(row));
  if (name.contains("String_Node_Str"))   throw new Exception("String_Node_Str" + name + "String_Node_Str"+ getLocation(row));
  ex.setUrl(uri + name);
  ex.setId(tail(ex.getUrl()));
  ap.getExtensions().add(ex);
  if (context == null) {
    ex.setContextType(readContextType(sheet.getColumn(row,"String_Node_Str"),row));
    if (sheet.hasColumn("String_Node_Str"))     for (    String s : sheet.getColumn(row,"String_Node_Str").split("String_Node_Str"))     ex.addContextInvariant(s);
    String cc=sheet.getColumn(row,"String_Node_Str");
    if (!Utilities.noString(cc))     for (    String c : cc.split("String_Node_Str")) {
      if (definitions != null)       definitions.checkContextValid(ex.getContextType(),c,this.name);
      ex.addContext(c);
    }
  }
  ex.setTitle(sheet.getColumn(row,"String_Node_Str"));
  ElementDefn exe=new ElementDefn();
  exe.setName(sheet.getColumn(row,"String_Node_Str"));
  ElementDefn exu=new ElementDefn();
  exu.setName("String_Node_Str");
  exe.getElements().add(exu);
  exu.setFixed(new UriType(ex.getUrl()));
  exu.getTypes().add(new TypeRef().setName("String_Node_Str"));
  if (invariants != null) {
    for (    Invariant inv : invariants.values()) {
      if (inv.getContext().equals(name))       exe.getInvariants().put(inv.getId(),inv);
    }
  }
  parseExtensionElement(sheet,row,definitions,exe,false);
  String sl=exe.getShortDefn();
  ex.setName(sheet.getColumn(row,"String_Node_Str"));
  if (!ex.hasName())   ex.setName(ex.getTitle());
  if (!Utilities.noString(sl) && (!sl.contains("String_Node_Str") || !ex.hasName()))   ex.setName(sl);
  if (!ex.hasName())   throw new Exception("String_Node_Str" + ex.getUrl() + "String_Node_Str"+ getLocation(row));
  ex.setDescription(preProcessMarkdown(exe.getDefinition(),"String_Node_Str"));
  ex.setPublisher(ap.metadata("String_Node_Str"));
  if (ap.hasMetadata("String_Node_Str"))   ex.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL,ap.metadata("String_Node_Str")));
  if (ap.hasMetadata("String_Node_Str"))   ex.setDateElement(Factory.newDateTime(ap.metadata("String_Node_Str").substring(0,10)));
 else   ex.setDate(genDate.getTime());
  if (ap.hasMetadata("String_Node_Str"))   ex.setStatus(PublicationStatus.fromCode(ap.metadata("String_Node_Str")));
  row++;
  if (ig == null || ig.isCore()) {
    if (!ex.getUrl().startsWith("String_Node_Str"))     throw new Exception("String_Node_Str" + ex.getUrl() + "String_Node_Str");
  }
 else {
    if (!ex.getUrl().startsWith("String_Node_Str" + ig.getCode() + "String_Node_Str"))     throw new Exception("String_Node_Str" + ex.getUrl() + "String_Node_Str"+ ig.getCode()+ "String_Node_Str");
  }
  while (row < sheet.getRows().size() && sheet.getColumn(row,"String_Node_Str").startsWith(name + "String_Node_Str")) {
    String n=sheet.getColumn(row,"String_Node_Str");
    ElementDefn p=findContext(exe,n.substring(0,n.lastIndexOf("String_Node_Str")),"String_Node_Str" + name);
    ElementDefn child=new ElementDefn();
    p.getElements().add(child);
    child.setName(n.substring(n.lastIndexOf("String_Node_Str") + 1));
    parseExtensionElement(sheet,row,definitions,child,true);
    if (invariants != null) {
      for (      Invariant inv : invariants.values()) {
        if (inv.getContext().equals(n))         child.getInvariants().put(inv.getId(),inv);
      }
    }
    row++;
  }
  ProfileGenerator gen=new ProfileGenerator(definitions,null,pkp,null,null,null,fpUsages);
  ProfileUtilities utils=new ProfileUtilities(this.context,issues,pkp);
  gen.convertElements(exe,ex,null);
  ex.getDifferential().getElementFirstRep().getType().clear();
  utils.setIds(ex,false);
  StructureDefinition base=definitions != null ? definitions.getSnapShotForType("String_Node_Str") : this.context.getProfiles().get("String_Node_Str");
  List<String> errors=new ArrayList<String>();
  utils.sortDifferential(base,ex,"String_Node_Str" + ex.getUrl(),errors);
  assert(errors.size() == 0);
  utils.generateSnapshot(base,ex,ex.getUrl(),ex.getName());
  utils.setIds(ex,true);
  this.context.seeExtensionDefinition("String_Node_Str",ex);
  return row;
}

Fixed version (ground truth):
private int processExtension(ElementDefn extensions,Sheet sheet,int row,Definitions definitions,String uri,Profile ap,List<ValidationMessage> issues,Map<String,Invariant> invariants) throws Exception {
  StructureDefinition ex=new StructureDefinition();
  ex.setUserData(ToolResourceUtilities.NAME_RES_IG,ig == null ? "String_Node_Str" : ig.getCode());
  ex.setUserData("String_Node_Str",ap);
  ex.setKind(StructureDefinitionKind.COMPLEXTYPE);
  ex.setType("String_Node_Str");
  ex.setBaseDefinition("String_Node_Str");
  ex.setDerivation(TypeDerivationRule.CONSTRAINT);
  ex.setAbstract(false);
  ex.setFhirVersion(version);
  if (ap.hasMetadata("String_Node_Str"))   ToolingExtensions.addIntegerExtension(ex,ToolingExtensions.EXT_FMM_LEVEL,Integer.parseInt(ap.getFmmLevel()));
  if (ap.hasMetadata("String_Node_Str"))   ToolingExtensions.setCodeExtension(ex,ToolingExtensions.EXT_WORKGROUP,ap.getWg());
  ToolResourceUtilities.updateUsage(ex,ap.getCategory());
  String name=sheet.getColumn(row,"String_Node_Str");
  String context=null;
  if (Utilities.noString(name))   throw new Exception("String_Node_Str" + getLocation(row));
  if (name.contains("String_Node_Str"))   throw new Exception("String_Node_Str" + name + "String_Node_Str"+ getLocation(row));
  ex.setUrl(uri + name);
  ex.setId(tail(ex.getUrl()));
  ap.getExtensions().add(ex);
  if (context == null) {
    ex.setContextType(readContextType(sheet.getColumn(row,"String_Node_Str"),row));
    if (sheet.hasColumn("String_Node_Str"))     for (    String s : sheet.getColumn(row,"String_Node_Str").split("String_Node_Str"))     ex.addContextInvariant(s);
    String cc=sheet.getColumn(row,"String_Node_Str");
    if (!Utilities.noString(cc))     for (    String c : cc.split("String_Node_Str")) {
      if (definitions != null)       definitions.checkContextValid(ex.getContextType(),c.trim(),this.name);
      ex.addContext(c.trim());
    }
  }
  ex.setTitle(sheet.getColumn(row,"String_Node_Str"));
  ElementDefn exe=new ElementDefn();
  exe.setName(sheet.getColumn(row,"String_Node_Str"));
  ElementDefn exu=new ElementDefn();
  exu.setName("String_Node_Str");
  exe.getElements().add(exu);
  exu.setFixed(new UriType(ex.getUrl()));
  exu.getTypes().add(new TypeRef().setName("String_Node_Str"));
  if (invariants != null) {
    for (    Invariant inv : invariants.values()) {
      if (inv.getContext().equals(name))       exe.getInvariants().put(inv.getId(),inv);
    }
  }
  parseExtensionElement(sheet,row,definitions,exe,false);
  String sl=exe.getShortDefn();
  ex.setName(sheet.getColumn(row,"String_Node_Str"));
  if (!ex.hasName())   ex.setName(ex.getTitle());
  if (!Utilities.noString(sl) && (!sl.contains("String_Node_Str") || !ex.hasName()))   ex.setName(sl);
  if (!ex.hasName())   throw new Exception("String_Node_Str" + ex.getUrl() + "String_Node_Str"+ getLocation(row));
  ex.setDescription(preProcessMarkdown(exe.getDefinition(),"String_Node_Str"));
  ex.setPublisher(ap.metadata("String_Node_Str"));
  if (ap.hasMetadata("String_Node_Str"))   ex.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL,ap.metadata("String_Node_Str")));
  if (ap.hasMetadata("String_Node_Str"))   ex.setDateElement(Factory.newDateTime(ap.metadata("String_Node_Str").substring(0,10)));
 else   ex.setDate(genDate.getTime());
  if (ap.hasMetadata("String_Node_Str"))   ex.setStatus(PublicationStatus.fromCode(ap.metadata("String_Node_Str")));
  row++;
  if (ig == null || ig.isCore()) {
    if (!ex.getUrl().startsWith("String_Node_Str"))     throw new Exception("String_Node_Str" + ex.getUrl() + "String_Node_Str");
  }
 else {
    if (!ex.getUrl().startsWith("String_Node_Str" + ig.getCode() + "String_Node_Str"))     throw new Exception("String_Node_Str" + ex.getUrl() + "String_Node_Str"+ ig.getCode()+ "String_Node_Str");
  }
  while (row < sheet.getRows().size() && sheet.getColumn(row,"String_Node_Str").startsWith(name + "String_Node_Str")) {
    String n=sheet.getColumn(row,"String_Node_Str");
    ElementDefn p=findContext(exe,n.substring(0,n.lastIndexOf("String_Node_Str")),"String_Node_Str" + name);
    ElementDefn child=new ElementDefn();
    p.getElements().add(child);
    child.setName(n.substring(n.lastIndexOf("String_Node_Str") + 1));
    parseExtensionElement(sheet,row,definitions,child,true);
    if (invariants != null) {
      for (      Invariant inv : invariants.values()) {
        if (inv.getContext().equals(n))         child.getInvariants().put(inv.getId(),inv);
      }
    }
    row++;
  }
  ProfileGenerator gen=new ProfileGenerator(definitions,null,pkp,null,null,null,fpUsages);
  ProfileUtilities utils=new ProfileUtilities(this.context,issues,pkp);
  gen.convertElements(exe,ex,null);
  ex.getDifferential().getElementFirstRep().getType().clear();
  utils.setIds(ex,false);
  StructureDefinition base=definitions != null ? definitions.getSnapShotForType("String_Node_Str") : this.context.getProfiles().get("String_Node_Str");
  List<String> errors=new ArrayList<String>();
  utils.sortDifferential(base,ex,"String_Node_Str" + ex.getUrl(),errors);
  assert(errors.size() == 0);
  utils.generateSnapshot(base,ex,ex.getUrl(),ex.getName());
  utils.setIds(ex,true);
  this.context.seeExtensionDefinition("String_Node_Str",ex);
  return row;
}