Program: 121701
Project: 121701
Buggy source:
public void buildContextMenu(IMenuManager menu){
  List selectedEditParts=getGraphicalViewer().getSelectedEditParts();
  if (selectedEditParts != null && !selectedEditParts.isEmpty()) {
    List output=new ArrayList();
    List input=new ArrayList();
    for (    Object selected : selectedEditParts) {
      if (selected instanceof OutputTreeNodeEditPart) {
        output.add(selected);
      }
 else       if (selected instanceof TreeNodeEditPart) {
        input.add(selected);
      }
    }
    if (!output.isEmpty() && !input.isEmpty()) {
      return;
    }
    boolean isInput=!input.isEmpty();
    ImportTreeFromXml importAction=(ImportTreeFromXml)getActionRegistry().getAction(ImportTreeFromXml.ID);
    importAction.update(selectedEditParts);
    importAction.setInput(isInput);
    if (importAction.isEnabled()) {
      menu.add(importAction);
    }
    CreateElementAction createElement=(CreateElementAction)getActionRegistry().getAction(CreateElementAction.ID);
    createElement.update(selectedEditParts);
    createElement.setInput(isInput);
    if (createElement.isEnabled()) {
      menu.add(createElement);
    }
    CreateAttributeAction createAttribute=(CreateAttributeAction)getActionRegistry().getAction(CreateAttributeAction.ID);
    createAttribute.update(selectedEditParts);
    createAttribute.setInput(isInput);
    if (createAttribute.isEnabled()) {
      menu.add(createAttribute);
    }
    CreateNameSpaceAction createNameSpace=(CreateNameSpaceAction)getActionRegistry().getAction(CreateNameSpaceAction.ID);
    createNameSpace.update(selectedEditParts);
    createNameSpace.setInput(isInput);
    if (createNameSpace.isEnabled()) {
      menu.add(createNameSpace);
    }
    FixValueAction fixValueAction=(FixValueAction)getActionRegistry().getAction(FixValueAction.ID);
    fixValueAction.update(selectedEditParts);
    if (fixValueAction.isEnabled()) {
      menu.add(fixValueAction);
    }
    AddChoiceAction addChoice=(AddChoiceAction)getActionRegistry().getAction(AddChoiceAction.ID);
    addChoice.update(selectedEditParts);
    addChoice.setInput(isInput);
    if (addChoice.isEnabled()) {
      menu.add(addChoice);
    }
    SetSubstitutionAction setSubs=(SetSubstitutionAction)getActionRegistry().getAction(SetSubstitutionAction.ID);
    setSubs.update(selectedEditParts);
    setSubs.setInput(isInput);
    if (setSubs.isEnabled()) {
      menu.add(setSubs);
    }
    SetLoopAction loopAction=(SetLoopAction)getActionRegistry().getAction(SetLoopAction.ID);
    loopAction.update(selectedEditParts);
    loopAction.setInput(isInput);
    if (loopAction.isEnabled()) {
      menu.add(loopAction);
    }
    SetLoopOptional loopOptinalAction=(SetLoopOptional)getActionRegistry().getAction(SetLoopOptional.ID);
    loopOptinalAction.update(selectedEditParts);
    if (loopOptinalAction.isEnabled()) {
      menu.add(loopOptinalAction);
    }
    SetGroupAction grouptAction=(SetGroupAction)getActionRegistry().getAction(SetGroupAction.ID);
    grouptAction.update(selectedEditParts);
    if (grouptAction.isEnabled()) {
      menu.add(grouptAction);
    }
    ImportTreeFromRepository importFromRepository=(ImportTreeFromRepository)getActionRegistry().getAction(ImportTreeFromRepository.ID);
    importFromRepository.update(selectedEditParts);
    importFromRepository.setInput(isInput);
    if (importFromRepository.isEnabled()) {
      menu.add(importFromRepository);
    }
    SetAggregateAction aggreateAction=(SetAggregateAction)getActionRegistry().getAction(SetAggregateAction.ID);
    aggreateAction.update(selectedEditParts);
    if (aggreateAction.isEnabled()) {
      menu.add(aggreateAction);
    }
    RenameTreeNodeAction renameTreeNodeAction=(RenameTreeNodeAction)getActionRegistry().getAction(RenameTreeNodeAction.ID);
    renameTreeNodeAction.update(selectedEditParts);
    if (renameTreeNodeAction.isEnabled()) {
      menu.add(renameTreeNodeAction);
    }
    DeleteTreeNodeAction action=(DeleteTreeNodeAction)getActionRegistry().getAction(DeleteTreeNodeAction.ID);
    action.update(selectedEditParts);
    action.setInput(isInput);
    if (action.isEnabled()) {
      menu.add(action);
    }
  }
}

Fixed version (ground truth):
@Override public void buildContextMenu(IMenuManager menu){
  List selectedEditParts=getGraphicalViewer().getSelectedEditParts();
  if (selectedEditParts != null && !selectedEditParts.isEmpty()) {
    List output=new ArrayList();
    List input=new ArrayList();
    for (    Object selected : selectedEditParts) {
      if (selected instanceof OutputTreeNodeEditPart) {
        output.add(selected);
      }
 else       if (selected instanceof TreeNodeEditPart) {
        input.add(selected);
      }
    }
    if (!output.isEmpty() && !input.isEmpty()) {
      return;
    }
    boolean isInput=!input.isEmpty();
    ImportTreeFromXml importAction=(ImportTreeFromXml)getActionRegistry().getAction(ImportTreeFromXml.ID);
    importAction.update(selectedEditParts);
    importAction.setInput(isInput);
    if (importAction.isEnabled()) {
      menu.add(importAction);
    }
    CreateElementAction createElement=(CreateElementAction)getActionRegistry().getAction(CreateElementAction.ID);
    createElement.update(selectedEditParts);
    createElement.setInput(isInput);
    if (createElement.isEnabled()) {
      menu.add(createElement);
    }
    CreateAttributeAction createAttribute=(CreateAttributeAction)getActionRegistry().getAction(CreateAttributeAction.ID);
    createAttribute.update(selectedEditParts);
    createAttribute.setInput(isInput);
    if (createAttribute.isEnabled()) {
      menu.add(createAttribute);
    }
    CreateNameSpaceAction createNameSpace=(CreateNameSpaceAction)getActionRegistry().getAction(CreateNameSpaceAction.ID);
    createNameSpace.update(selectedEditParts);
    createNameSpace.setInput(isInput);
    if (createNameSpace.isEnabled()) {
      menu.add(createNameSpace);
    }
    FixValueAction fixValueAction=(FixValueAction)getActionRegistry().getAction(FixValueAction.ID);
    fixValueAction.update(selectedEditParts);
    if (fixValueAction.isEnabled()) {
      menu.add(fixValueAction);
    }
    AddChoiceAction addChoice=(AddChoiceAction)getActionRegistry().getAction(AddChoiceAction.ID);
    addChoice.update(selectedEditParts);
    addChoice.setInput(isInput);
    if (addChoice.isEnabled()) {
      menu.add(addChoice);
    }
    SetSubstitutionAction setSubs=(SetSubstitutionAction)getActionRegistry().getAction(SetSubstitutionAction.ID);
    setSubs.update(selectedEditParts);
    setSubs.setInput(isInput);
    if (setSubs.isEnabled()) {
      menu.add(setSubs);
    }
    SetLoopAction loopAction=(SetLoopAction)getActionRegistry().getAction(SetLoopAction.ID);
    loopAction.update(selectedEditParts);
    loopAction.setInput(isInput);
    if (loopAction.isEnabled()) {
      menu.add(loopAction);
    }
    SetLoopOptional loopOptinalAction=(SetLoopOptional)getActionRegistry().getAction(SetLoopOptional.ID);
    loopOptinalAction.update(selectedEditParts);
    if (loopOptinalAction.isEnabled()) {
      menu.add(loopOptinalAction);
    }
    SetGroupAction grouptAction=(SetGroupAction)getActionRegistry().getAction(SetGroupAction.ID);
    grouptAction.update(selectedEditParts);
    if (grouptAction.isEnabled()) {
      menu.add(grouptAction);
    }
    ImportTreeFromRepository importFromRepository=(ImportTreeFromRepository)getActionRegistry().getAction(ImportTreeFromRepository.ID);
    importFromRepository.update(selectedEditParts);
    importFromRepository.setInput(isInput);
    if (importFromRepository.isEnabled()) {
      menu.add(importFromRepository);
    }
    SetAggregateAction aggreateAction=(SetAggregateAction)getActionRegistry().getAction(SetAggregateAction.ID);
    aggreateAction.update(selectedEditParts);
    if (aggreateAction.isEnabled()) {
      menu.add(aggreateAction);
    }
    RenameTreeNodeAction renameTreeNodeAction=(RenameTreeNodeAction)getActionRegistry().getAction(RenameTreeNodeAction.ID);
    renameTreeNodeAction.update(selectedEditParts);
    if (renameTreeNodeAction.isEnabled()) {
      menu.add(renameTreeNodeAction);
    }
    DeleteTreeNodeAction action=(DeleteTreeNodeAction)getActionRegistry().getAction(DeleteTreeNodeAction.ID);
    action.update(selectedEditParts);
    action.setInput(isInput);
    if (action.isEnabled()) {
      menu.add(action);
    }
  }
}