Program: 123535
Project: 123535
Buggy source:
@Override public void buildContextMenu(IMenuManager menu){
  List selectedEditParts=getGraphicalViewer().getSelectedEditParts();
  if (selectedEditParts != null && !selectedEditParts.isEmpty()) {
    Object object=selectedEditParts.get(selectedEditParts.size() - 1);
    if (object instanceof OutputTreeNodeEditPart) {
      OutputTreeNode model=(OutputTreeNode)((OutputTreeNodeEditPart)object).getModel();
      if (XmlMapUtil.DOCUMENT.equals(model.getType()) || XmlMapUtil.getXPathLength(model.getXpath()) > 2) {
        ImportTreeFromXml importAction=(ImportTreeFromXml)getActionRegistry().getAction(ImportTreeFromXml.ID);
        importAction.update(object);
        importAction.setInput(false);
        if (importAction.isEnabled()) {
          menu.add(importAction);
        }
        CreateElementAction createElement=(CreateElementAction)getActionRegistry().getAction(CreateElementAction.ID);
        createElement.update(object);
        createElement.setInput(false);
        if (createElement.isEnabled()) {
          menu.add(createElement);
        }
        CreateAttributeAction createAttribute=(CreateAttributeAction)getActionRegistry().getAction(CreateAttributeAction.ID);
        createAttribute.update(object);
        createAttribute.setInput(false);
        if (createAttribute.isEnabled()) {
          menu.add(createAttribute);
        }
        CreateNameSpaceAction createNameSpace=(CreateNameSpaceAction)getActionRegistry().getAction(CreateNameSpaceAction.ID);
        createNameSpace.update(object);
        createNameSpace.setInput(false);
        if (createNameSpace.isEnabled()) {
          menu.add(createNameSpace);
        }
        FixValueAction fixValueAction=(FixValueAction)getActionRegistry().getAction(FixValueAction.ID);
        fixValueAction.update(object);
        if (fixValueAction.isEnabled()) {
          menu.add(fixValueAction);
        }
        DeleteTreeNodeAction action=(DeleteTreeNodeAction)getActionRegistry().getAction(DeleteTreeNodeAction.ID);
        action.update(object);
        action.setInput(false);
        if (action.isEnabled()) {
          menu.add(action);
        }
        SetLoopAction loopAction=(SetLoopAction)getActionRegistry().getAction(SetLoopAction.ID);
        loopAction.update(object);
        if (loopAction.isEnabled()) {
          menu.add(loopAction);
        }
        SetGroupAction grouptAction=(SetGroupAction)getActionRegistry().getAction(SetGroupAction.ID);
        grouptAction.update(object);
        if (grouptAction.isEnabled()) {
          menu.add(grouptAction);
        }
        ImportTreeFromRepository importFromRepository=(ImportTreeFromRepository)getActionRegistry().getAction(ImportTreeFromRepository.ID);
        importFromRepository.update(object);
        importFromRepository.setInput(false);
        if (importFromRepository.isEnabled()) {
          menu.add(importFromRepository);
        }
        SetAggregateAction aggreateAction=(SetAggregateAction)getActionRegistry().getAction(SetAggregateAction.ID);
        aggreateAction.update(object);
        if (aggreateAction.isEnabled()) {
          menu.add(aggreateAction);
        }
        RenameTreeNodeAction renameTreeNodeAction=(RenameTreeNodeAction)getActionRegistry().getAction(RenameTreeNodeAction.ID);
        renameTreeNodeAction.update(object);
        if (renameTreeNodeAction.isEnabled()) {
          menu.add(renameTreeNodeAction);
        }
      }
    }
 else     if (object instanceof TreeNodeEditPart) {
      TreeNode model=(TreeNode)((TreeNodeEditPart)object).getModel();
      if (XmlMapUtil.DOCUMENT.equals(model.getType()) || XmlMapUtil.getXPathLength(model.getXpath()) > 2) {
        ImportTreeFromXml importAction=(ImportTreeFromXml)getActionRegistry().getAction(ImportTreeFromXml.ID);
        importAction.setInput(true);
        importAction.update(object);
        if (importAction.isEnabled()) {
          menu.add(importAction);
        }
        CreateElementAction createElement=(CreateElementAction)getActionRegistry().getAction(CreateElementAction.ID);
        createElement.setInput(true);
        createElement.update(object);
        if (createElement.isEnabled()) {
          menu.add(createElement);
        }
        CreateAttributeAction createAttribute=(CreateAttributeAction)getActionRegistry().getAction(CreateAttributeAction.ID);
        createAttribute.setInput(true);
        createAttribute.update(object);
        if (createAttribute.isEnabled()) {
          menu.add(createAttribute);
        }
        CreateNameSpaceAction createNameSpace=(CreateNameSpaceAction)getActionRegistry().getAction(CreateNameSpaceAction.ID);
        createNameSpace.setInput(true);
        createNameSpace.update(object);
        if (createNameSpace.isEnabled()) {
          menu.add(createNameSpace);
        }
        FixValueAction fixValueAction=(FixValueAction)getActionRegistry().getAction(FixValueAction.ID);
        fixValueAction.update(object);
        if (fixValueAction.isEnabled()) {
          menu.add(fixValueAction);
        }
        DeleteTreeNodeAction deleteAction=(DeleteTreeNodeAction)getActionRegistry().getAction(DeleteTreeNodeAction.ID);
        deleteAction.setInput(true);
        deleteAction.update(object);
        if (deleteAction.isEnabled()) {
          menu.add(deleteAction);
        }
        SetLoopAction loopAction=(SetLoopAction)getActionRegistry().getAction(SetLoopAction.ID);
        loopAction.update(object);
        if (loopAction.isEnabled()) {
          menu.add(loopAction);
        }
        ImportTreeFromRepository importFromRepository=(ImportTreeFromRepository)getActionRegistry().getAction(ImportTreeFromRepository.ID);
        importFromRepository.setInput(true);
        importFromRepository.update(object);
        if (importFromRepository.isEnabled()) {
          menu.add(importFromRepository);
        }
        RenameTreeNodeAction renameTreeNodeAction=(RenameTreeNodeAction)getActionRegistry().getAction(RenameTreeNodeAction.ID);
        renameTreeNodeAction.update(object);
        if (renameTreeNodeAction.isEnabled()) {
          menu.add(renameTreeNodeAction);
        }
      }
    }
  }
}

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);
    }
    SetLoopAction loopAction=(SetLoopAction)getActionRegistry().getAction(SetLoopAction.ID);
    loopAction.update(selectedEditParts);
    if (loopAction.isEnabled()) {
      menu.add(loopAction);
    }
    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);
    }
  }
}