Program: 128582
Project: 128582
Buggy source:
private void addParticleDetail(XSDSchema xsdSchema,XSDParticle xsdParticle,ATreeNode parentNode,String currentPath) throws OdaException, IllegalAccessException, InvocationTargetException {
  XSDTerm xsdTerm=xsdParticle.getTerm();
  if (xsdTerm instanceof XSDElementDeclaration) {
    XSDElementDeclaration xsdElementDeclarationParticle=(XSDElementDeclaration)xsdTerm;
    ATreeNode partNode=new ATreeNode();
    String elementName=xsdElementDeclarationParticle.getName();
    String prefix=null;
    String namespace=xsdElementDeclarationParticle.getTargetNamespace();
    XSDTypeDefinition typeDef=xsdElementDeclarationParticle.getTypeDefinition();
    if (namespace != null) {
      prefix=namespaceToPrefix.get(namespace);
      if (prefix == null) {
        prefix=((XSDElementDeclaration)xsdTerm).getQName().contains("String_Node_Str") ? ((XSDElementDeclaration)xsdTerm).getQName().split("String_Node_Str")[0] : "String_Node_Str";
        if (isEnableGeneratePrefix() && (prefix == null || prefix.isEmpty())) {
          prefix="String_Node_Str" + prefixNumberGenerated;
          prefixNumberGenerated++;
        }
        if (namespaceToPrefix.containsValue(prefix)) {
          prefix=prefix + prefixNumberGenerated;
          prefixNumberGenerated++;
        }
        if (prefix != null && !prefix.isEmpty()) {
          namespaceToPrefix.put(namespace,prefix);
        }
 else {
          ATreeNode namespaceNode=new ATreeNode();
          namespaceNode.setDataType("String_Node_Str");
          namespaceNode.setType(ATreeNode.NAMESPACE_TYPE);
          namespaceNode.setValue(namespace);
          partNode.addChild(namespaceNode);
        }
      }
    }
    partNode.setCurrentNamespace(namespace);
    if (prefix != null && !prefix.isEmpty()) {
      elementName=prefix + "String_Node_Str" + elementName;
    }
    partNode.setValue(elementName);
    partNode.setType(ATreeNode.ELEMENT_TYPE);
    partNode.setDataType(xsdElementDeclarationParticle.getName());
    parentNode.addChild(partNode);
    boolean resolvedAsComplex=false;
    if (typeDef instanceof XSDComplexTypeDefinition) {
      if (!currentPath.contains("String_Node_Str" + elementName + "String_Node_Str")) {
        String path=currentPath + elementName + "String_Node_Str";
        XSDTypeDefinition xsdTypeDefinition=xsdElementDeclarationParticle.getTypeDefinition();
        if (xsdTypeDefinition == null) {
          XSDComplexTypeDefinition generalType=xsdSchema.resolveComplexTypeDefinitionURI(xsdElementDeclarationParticle.getURI());
          if (generalType.getContainer() != null) {
            xsdTypeDefinition=generalType;
          }
        }
        if (xsdTypeDefinition != null && xsdTypeDefinition.getName() != null) {
          partNode.setDataType(xsdTypeDefinition.getQName());
        }
        addComplexTypeDetails(xsdSchema,partNode,xsdTypeDefinition,prefix,namespace,path);
      }
      resolvedAsComplex=true;
    }
 else     if (typeDef.getTargetNamespace() != null) {
      resolvedAsComplex=true;
      if (!currentPath.contains("String_Node_Str" + elementName + "String_Node_Str")) {
        String path=currentPath + elementName + "String_Node_Str";
        XSDComplexTypeDefinition generalType=xsdSchema.resolveComplexTypeDefinition(typeDef.getQName());
        XSDTypeDefinition xsdTypeDefinition=xsdElementDeclarationParticle.getTypeDefinition();
        if (generalType.getContainer() != null) {
          xsdTypeDefinition=generalType;
        }
        if (xsdTypeDefinition != null && xsdTypeDefinition.getName() != null) {
          partNode.setDataType(xsdTypeDefinition.getName());
        }
        if (xsdTypeDefinition instanceof XSDComplexTypeDefinition) {
          addComplexTypeDetails(xsdSchema,partNode,xsdTypeDefinition,prefix,namespace,path);
        }
 else {
          resolvedAsComplex=false;
        }
      }
    }
    if (!resolvedAsComplex) {
      String dataType=xsdElementDeclarationParticle.getTypeDefinition().getQName();
      if (xsdElementDeclarationParticle.getTypeDefinition().getBaseType() != null) {
        if (!"String_Node_Str".equals(xsdElementDeclarationParticle.getTypeDefinition().getBaseType().getQName())) {
          dataType=xsdElementDeclarationParticle.getTypeDefinition().getBaseType().getQName();
        }
      }
      partNode.setDataType(dataType);
    }
    handleOptionalAttribute(partNode,xsdParticle);
    addSubstitutionDetails(xsdSchema,partNode,xsdElementDeclarationParticle,null);
  }
 else   if (xsdTerm instanceof XSDModelGroup) {
    XSDModelGroup xsdModelGroup=(XSDModelGroup)xsdTerm;
    ATreeNode node=addChoiceDetails(parentNode,xsdModelGroup);
    handleOptionalAttribute(node,xsdParticle);
    for (Iterator j=xsdModelGroup.getParticles().iterator(); j.hasNext(); ) {
      XSDParticle childParticle=(XSDParticle)j.next();
      addParticleDetail(xsdSchema,childParticle,node,currentPath);
    }
  }
}

Fixed version (ground truth):
private void addParticleDetail(XSDSchema xsdSchema,XSDParticle xsdParticle,ATreeNode parentNode,String currentPath) throws OdaException, IllegalAccessException, InvocationTargetException {
  XSDTerm xsdTerm=xsdParticle.getTerm();
  if (xsdTerm instanceof XSDElementDeclaration) {
    XSDElementDeclaration xsdElementDeclarationParticle=(XSDElementDeclaration)xsdTerm;
    ATreeNode partNode=new ATreeNode();
    String elementName=xsdElementDeclarationParticle.getName();
    String prefix=null;
    String namespace=xsdElementDeclarationParticle.getTargetNamespace();
    XSDTypeDefinition typeDef=xsdElementDeclarationParticle.getTypeDefinition();
    if (typeDef == null) {
      XSDSchema schemaFromNamespace=getXSDSchemaFromNamespace(namespace);
      if (schemaFromNamespace == null) {
        schemaFromNamespace=xsdSchema;
      }
      xsdElementDeclarationParticle=schemaFromNamespace.resolveElementDeclarationURI(xsdElementDeclarationParticle.getURI());
      typeDef=xsdElementDeclarationParticle.getType();
    }
    if (namespace != null) {
      prefix=namespaceToPrefix.get(namespace);
      if (prefix == null) {
        prefix=((XSDElementDeclaration)xsdTerm).getQName().contains("String_Node_Str") ? ((XSDElementDeclaration)xsdTerm).getQName().split("String_Node_Str")[0] : "String_Node_Str";
        if (isEnableGeneratePrefix() && (prefix == null || prefix.isEmpty())) {
          prefix="String_Node_Str" + prefixNumberGenerated;
          prefixNumberGenerated++;
        }
        if (namespaceToPrefix.containsValue(prefix)) {
          prefix=prefix + prefixNumberGenerated;
          prefixNumberGenerated++;
        }
        if (prefix != null && !prefix.isEmpty()) {
          namespaceToPrefix.put(namespace,prefix);
        }
 else {
          ATreeNode namespaceNode=new ATreeNode();
          namespaceNode.setDataType("String_Node_Str");
          namespaceNode.setType(ATreeNode.NAMESPACE_TYPE);
          namespaceNode.setValue(namespace);
          partNode.addChild(namespaceNode);
        }
      }
    }
    partNode.setCurrentNamespace(namespace);
    if (prefix != null && !prefix.isEmpty()) {
      elementName=prefix + "String_Node_Str" + elementName;
    }
    partNode.setValue(elementName);
    partNode.setType(ATreeNode.ELEMENT_TYPE);
    partNode.setDataType(xsdElementDeclarationParticle.getName());
    parentNode.addChild(partNode);
    boolean resolvedAsComplex=false;
    if (typeDef instanceof XSDComplexTypeDefinition) {
      if (!currentPath.contains("String_Node_Str" + elementName + "String_Node_Str")) {
        String path=currentPath + elementName + "String_Node_Str";
        XSDTypeDefinition xsdTypeDefinition=xsdElementDeclarationParticle.getTypeDefinition();
        if (xsdTypeDefinition == null) {
          XSDComplexTypeDefinition generalType=xsdSchema.resolveComplexTypeDefinitionURI(xsdElementDeclarationParticle.getURI());
          if (generalType.getContainer() != null) {
            xsdTypeDefinition=generalType;
          }
        }
        if (xsdTypeDefinition != null && xsdTypeDefinition.getName() != null) {
          partNode.setDataType(xsdTypeDefinition.getQName());
        }
        addComplexTypeDetails(xsdSchema,partNode,xsdTypeDefinition,prefix,namespace,path);
      }
      resolvedAsComplex=true;
    }
 else     if (typeDef.getTargetNamespace() != null) {
      resolvedAsComplex=true;
      if (!currentPath.contains("String_Node_Str" + elementName + "String_Node_Str")) {
        String path=currentPath + elementName + "String_Node_Str";
        XSDComplexTypeDefinition generalType=xsdSchema.resolveComplexTypeDefinition(typeDef.getQName());
        XSDTypeDefinition xsdTypeDefinition=xsdElementDeclarationParticle.getTypeDefinition();
        if (generalType.getContainer() != null) {
          xsdTypeDefinition=generalType;
        }
        if (xsdTypeDefinition != null && xsdTypeDefinition.getName() != null) {
          partNode.setDataType(xsdTypeDefinition.getName());
        }
        if (xsdTypeDefinition instanceof XSDComplexTypeDefinition) {
          addComplexTypeDetails(xsdSchema,partNode,xsdTypeDefinition,prefix,namespace,path);
        }
 else {
          resolvedAsComplex=false;
        }
      }
    }
    if (!resolvedAsComplex) {
      String dataType=xsdElementDeclarationParticle.getTypeDefinition().getQName();
      if (xsdElementDeclarationParticle.getTypeDefinition().getBaseType() != null) {
        if (!"String_Node_Str".equals(xsdElementDeclarationParticle.getTypeDefinition().getBaseType().getQName())) {
          dataType=xsdElementDeclarationParticle.getTypeDefinition().getBaseType().getQName();
        }
      }
      partNode.setDataType(dataType);
    }
    handleOptionalAttribute(partNode,xsdParticle);
    addSubstitutionDetails(xsdSchema,partNode,xsdElementDeclarationParticle,null);
  }
 else   if (xsdTerm instanceof XSDModelGroup) {
    XSDModelGroup xsdModelGroup=(XSDModelGroup)xsdTerm;
    ATreeNode node=addChoiceDetails(parentNode,xsdModelGroup);
    handleOptionalAttribute(node,xsdParticle);
    for (Iterator j=xsdModelGroup.getParticles().iterator(); j.hasNext(); ) {
      XSDParticle childParticle=(XSDParticle)j.next();
      addParticleDetail(xsdSchema,childParticle,node,currentPath);
    }
  }
}