Program: 147548
Project: 147548
Buggy source:
@Override public IStatus doAction(){
  try {
    conceptList=WorkbenchClipboard.getWorkbenchClipboard().getConcepts();
    XSDFactory factory=XSDFactory.eINSTANCE;
    if (!conceptList.isEmpty()) {
      int index=0;
      for (Iterator<XSDElementDeclaration> it=conceptList.iterator(); it.hasNext(); ) {
        if (conceptList.get(index).getSchema() != null) {
          typeList=Util.getTypeDefinition(conceptList.get(index).getSchema());
        }
        index++;
        Object concept=it.next();
        if (concept instanceof XSDElementDeclaration) {
          XSDElementDeclaration copy_concept=(XSDElementDeclaration)concept;
          XSDElementDeclaration new_copy_concept=factory.createXSDElementDeclaration();
          new_copy_concept=(XSDElementDeclaration)copy_concept.cloneConcreteComponent(true,false);
          InputDialog id=new InputDialog(page.getSite().getShell(),Messages.XSDPasteConceptAction_CopyElement,Messages.XSDPasteConceptAction_DialogTip,Messages.bind(Messages.XSDPasteConceptAction_CopyOf,copy_concept.getName()),new IInputValidator(){
            public String isValid(            String newText){
              if ((newText == null) || "String_Node_Str".equals(newText)) {
                return Messages.XSDPasteConceptAction_NameCannNotbeEmpty;
              }
              EList<XSDElementDeclaration> list=schema.getElementDeclarations();
              for (              XSDElementDeclaration d : list) {
                if (d.getName().equalsIgnoreCase(newText)) {
                  return Messages.XSDPasteConceptAction_EntityAlreadyExists;
                }
              }
              return null;
            }
          }
);
          id.setBlockOnOpen(true);
          int ret=id.open();
          if (ret == Window.CANCEL) {
            return Status.CANCEL_STATUS;
          }
          new_copy_concept.setName(id.getValue());
          for (int i=0; i < new_copy_concept.getIdentityConstraintDefinitions().size(); i++) {
            String name=new_copy_concept.getIdentityConstraintDefinitions().get(i).getName().replaceAll(copy_concept.getName(),new_copy_concept.getName());
            new_copy_concept.getIdentityConstraintDefinitions().get(i).setName(name);
          }
          if (new_copy_concept.getAnonymousTypeDefinition() == null) {
            XSDComplexTypeDefinition copyType=(XSDComplexTypeDefinition)copy_concept.getTypeDefinition().cloneConcreteComponent(true,false);
            String originalName=copyType.getName();
            String typeName="String_Node_Str" + originalName;
            copyType.setName(typeName);
            schema.getContents().add(copyType);
            new_copy_concept.setTypeDefinition(copyType);
          }
          new_copy_concept.updateElement();
          schema.getContents().add(new_copy_concept);
          addAnnotationForXSDElementDeclaration(copy_concept,new_copy_concept);
        }
      }
      HashMap<String,XSDTypeDefinition> typeDef=Util.getTypeDefinition(schema);
      for (      XSDTypeDefinition type : copyTypeSet) {
        if (typeDef.containsKey(type.getName())) {
          continue;
        }
        XSDTypeDefinition typedefinitionClone=null;
        if (type instanceof XSDComplexTypeDefinition) {
          typedefinitionClone=factory.createXSDComplexTypeDefinition();
          typedefinitionClone=(XSDComplexTypeDefinition)type.cloneConcreteComponent(true,false);
          schema.getContents().add(typedefinitionClone);
          addAnnotationForComplexType((XSDComplexTypeDefinition)type,(XSDComplexTypeDefinition)typedefinitionClone);
        }
 else         if (type instanceof XSDSimpleTypeDefinition) {
          schema.getContents().add((XSDSimpleTypeDefinition)type.cloneConcreteComponent(true,false));
        }
      }
      schema.getElement();
      page.markDirty();
      page.refresh();
      getOperationHistory();
      WorkbenchClipboard.getWorkbenchClipboard().conceptsReset();
      typeList.clear();
      return Status.OK_STATUS;
    }
 else     if (WorkbenchClipboard.getWorkbenchClipboard().getParticles().size() > 0) {
      copyElements();
      WorkbenchClipboard.getWorkbenchClipboard().particlesReset();
      page.markDirty();
      page.refresh();
      getOperationHistory();
      return Status.OK_STATUS;
    }
 else {
      return Status.CANCEL_STATUS;
    }
  }
 catch (  Exception e) {
    log.error(e.getMessage(),e);
    MessageDialog.openError(page.getSite().getShell(),Messages._Error,Messages.bind(Messages.XSDPasteConceptAction_ErrorMsg1,e.getLocalizedMessage()));
  }
  return Status.OK_STATUS;
}

Fixed version (ground truth):
@Override public IStatus doAction(){
  try {
    conceptList=WorkbenchClipboard.getWorkbenchClipboard().getConcepts();
    XSDFactory factory=XSDFactory.eINSTANCE;
    if (!conceptList.isEmpty()) {
      int index=0;
      for (Iterator<XSDElementDeclaration> it=conceptList.iterator(); it.hasNext(); ) {
        if (conceptList.get(index).getSchema() != null) {
          typeList=Util.getTypeDefinition(conceptList.get(index).getSchema());
        }
        index++;
        Object concept=it.next();
        if (concept instanceof XSDElementDeclaration) {
          XSDElementDeclaration copy_concept=(XSDElementDeclaration)concept;
          XSDElementDeclaration new_copy_concept=factory.createXSDElementDeclaration();
          new_copy_concept=(XSDElementDeclaration)copy_concept.cloneConcreteComponent(true,false);
          InputDialog id=new InputDialog(page.getSite().getShell(),Messages.XSDPasteConceptAction_CopyElement,Messages.XSDPasteConceptAction_DialogTip,Messages.bind(Messages.XSDPasteConceptAction_CopyOf,copy_concept.getName()),new IInputValidator(){
            public String isValid(            String newText){
              if ((newText == null) || "String_Node_Str".equals(newText)) {
                return Messages.XSDPasteConceptAction_NameCannNotbeEmpty;
              }
              EList<XSDElementDeclaration> list=schema.getElementDeclarations();
              for (              XSDElementDeclaration d : list) {
                if (d.getName().equalsIgnoreCase(newText)) {
                  return Messages.XSDPasteConceptAction_EntityAlreadyExists;
                }
              }
              return null;
            }
          }
);
          id.setBlockOnOpen(true);
          int ret=id.open();
          if (ret == Window.CANCEL) {
            return Status.CANCEL_STATUS;
          }
          new_copy_concept.setName(id.getValue());
          for (int i=0; i < new_copy_concept.getIdentityConstraintDefinitions().size(); i++) {
            String name=new_copy_concept.getIdentityConstraintDefinitions().get(i).getName().replaceAll(copy_concept.getName(),new_copy_concept.getName());
            new_copy_concept.getIdentityConstraintDefinitions().get(i).setName(name);
          }
          if (new_copy_concept.getAnonymousTypeDefinition() == null) {
            XSDComplexTypeDefinition copyType=(XSDComplexTypeDefinition)copy_concept.getTypeDefinition().cloneConcreteComponent(true,false);
            String originalName=copyType.getName();
            String typeName="String_Node_Str" + originalName;
            copyType.setName(typeName);
            schema.getContents().add(copyType);
            new_copy_concept.setTypeDefinition(copyType);
          }
          new_copy_concept.updateElement();
          schema.getContents().add(new_copy_concept);
          addAnnotationForXSDElementDeclaration(copy_concept,new_copy_concept);
        }
      }
      Map<String,XSDTypeDefinition> typeDef=Util.getTypeDefinition(schema);
      for (      XSDTypeDefinition type : copyTypeSet) {
        if (typeDef.containsKey(type.getName())) {
          continue;
        }
        XSDTypeDefinition typedefinitionClone=null;
        if (type instanceof XSDComplexTypeDefinition) {
          typedefinitionClone=factory.createXSDComplexTypeDefinition();
          typedefinitionClone=(XSDComplexTypeDefinition)type.cloneConcreteComponent(true,false);
          schema.getContents().add(typedefinitionClone);
          addAnnotationForComplexType((XSDComplexTypeDefinition)type,(XSDComplexTypeDefinition)typedefinitionClone);
        }
 else         if (type instanceof XSDSimpleTypeDefinition) {
          schema.getContents().add((XSDSimpleTypeDefinition)type.cloneConcreteComponent(true,false));
        }
      }
      schema.getElement();
      page.markDirty();
      page.refresh();
      getOperationHistory();
      WorkbenchClipboard.getWorkbenchClipboard().conceptsReset();
      typeList.clear();
      return Status.OK_STATUS;
    }
 else     if (WorkbenchClipboard.getWorkbenchClipboard().getParticles().size() > 0) {
      copyElements();
      WorkbenchClipboard.getWorkbenchClipboard().particlesReset();
      page.markDirty();
      page.refresh();
      getOperationHistory();
      return Status.OK_STATUS;
    }
 else {
      return Status.CANCEL_STATUS;
    }
  }
 catch (  Exception e) {
    log.error(e.getMessage(),e);
    MessageDialog.openError(page.getSite().getShell(),Messages._Error,Messages.bind(Messages.XSDPasteConceptAction_ErrorMsg1,e.getLocalizedMessage()));
  }
  return Status.OK_STATUS;
}