Program: 88525
Project: 88525
Buggy source:
private void addElementActions(ActionsManager manager,Element e,List<Element> es){
  Project project=Project.getProject(e);
  if (project == null && !es.isEmpty()) {
    project=Project.getProject(es.iterator().next());
  }
  if (project == null) {
    return;
  }
  Stereotype sysmlview=Utils.getViewStereotype(project);
  Stereotype sysmlviewpoint=Utils.getViewpointStereotype(project);
  Stereotype documentView=Utils.getProductStereotype(project);
  Stereotype classview=Utils.getViewClassStereotype(project);
  Stereotype elementGroupStereotype=Utils.getElementGroupStereotype(project);
  ActionsCategory refactorWithIDActionCat=myCategory(manager,"String_Node_Str","String_Node_Str");
  if (e instanceof com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class & !(e instanceof com.nomagic.uml2.ext.magicdraw.components.mdbasiccomponents.Component)) {
    if (manager.getActionFor(ClassToComponentRefactorWithIDAction.DEFAULT_ID) == null) {
      refactorWithIDActionCat.addAction(new ClassToComponentRefactorWithIDAction(es));
    }
  }
  if (e instanceof com.nomagic.uml2.ext.magicdraw.components.mdbasiccomponents.Component) {
    if (manager.getActionFor(ComponentToClassRefactorWithIDAction.DEFAULT_ID) == null) {
      refactorWithIDActionCat.addAction(new ComponentToClassRefactorWithIDAction(es));
    }
  }
  ActionsCategory modelLoad=myCategory(manager,"String_Node_Str","String_Node_Str");
  if (!TicketUtils.isTicketSet(project)) {
    ActionsCategory login=getCategory(manager,"String_Node_Str","String_Node_Str",modelLoad);
    if (manager.getActionFor(MMSLoginAction.DEFAULT_ID) == null) {
      login.addAction(new MMSLoginAction());
    }
  }
  ActionsCategory models=getCategory(manager,"String_Node_Str","String_Node_Str",modelLoad);
  if (MDUtils.isDeveloperMode()) {
    if (e instanceof Model && manager.getActionFor(CommitProjectAction.DEFAULT_ID) == null) {
      models.addAction(new CommitProjectAction(project,false,true));
      models.addAction(new CommitProjectAction(project,true,true));
    }
  }
  if (manager.getActionFor(ValidateModelAction.DEFAULT_ID) == null) {
    models.addAction(new ValidateModelAction(es,"String_Node_Str"));
  }
  if (manager.getActionFor(ValidateElementDepthAction.DEFAULT_ID) == null) {
    models.addAction(new ValidateElementDepthAction(es,"String_Node_Str"));
  }
  if (manager.getActionFor(ValidateElementAction.DEFAULT_ID) == null) {
    models.addAction(new ValidateElementAction(es,"String_Node_Str"));
  }
  ActionsStateUpdater.updateActionsState();
  if (StereotypesHelper.hasStereotypeOrDerived(e,DocGenProfile.validationScriptStereotype)) {
    ActionsCategory c=myCategory(manager,"String_Node_Str","String_Node_Str");
    UserScript us=new UserScript();
    us.setDgElement(e);
    List<Element> targets=Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(e,DocGenProfile.queriesStereotype,1,false,1);
    targets.addAll(Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(e,DocGenProfile.oldQueriesStereotype,1,false,1));
    us.setTargets(Utils2.asList(targets,Object.class));
    if (manager.getActionFor(RunUserValidationScriptAction.DEFAULT_ID) == null) {
      c.addAction(new RunUserValidationScriptAction(us,true));
    }
  }
 else   if (StereotypesHelper.hasStereotypeOrDerived(e,DocGenProfile.userScriptStereotype)) {
    ActionsCategory c=myCategory(manager,"String_Node_Str","String_Node_Str");
    UserScript us=new UserScript();
    us.setDgElement(e);
    List<Element> targets=Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(e,DocGenProfile.queriesStereotype,1,false,1);
    targets.addAll(Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(e,DocGenProfile.oldQueriesStereotype,1,false,1));
    us.setTargets(Utils2.asList(targets,Object.class));
    if (manager.getActionFor(RunUserScriptAction.DEFAULT_ID) == null) {
      c.addAction(new RunUserScriptAction(us,true));
    }
  }
  boolean canShowGeneration=true;
  for (  Element element : es) {
    if (!StereotypesHelper.hasStereotypeOrDerived(element,sysmlview) && !StereotypesHelper.hasStereotypeOrDerived(element,elementGroupStereotype)) {
      canShowGeneration=false;
      break;
    }
  }
  if (canShowGeneration) {
    if (classview != null && es.size() == 1 && StereotypesHelper.hasStereotypeOrDerived(e,sysmlview)) {
      Boolean collectActions=(Boolean)StereotypesHelper.getStereotypePropertyFirst(e,classview,"String_Node_Str");
      if (collectActions != null && collectActions) {
        ActionsCategory category=(ActionsCategory)manager.getActionFor("String_Node_Str");
        if (category == null) {
          category=new MDActionsCategory("String_Node_Str","String_Node_Str");
          category.setNested(true);
          boolean added=addViewQueryActions(manager,category,(NamedElement)e);
          if (added) {
            manager.addCategory(0,category);
          }
        }
      }
    }
    ActionsCategory modelLoad2=myCategory(manager,"String_Node_Str","String_Node_Str");
    ActionsCategory viewInstances=getCategory(manager,"String_Node_Str","String_Node_Str",modelLoad2);
    NMAction action=manager.getActionFor(GenerateViewPresentationAction.DEFAULT_ID);
    if (action == null) {
      viewInstances.addAction(new GenerateViewPresentationAction(new LinkedHashSet<>(es),false));
    }
    action=manager.getActionFor(GenerateViewPresentationAction.RECURSE_DEFAULT_ID);
    if (action == null) {
      viewInstances.addAction(new GenerateViewPresentationAction(new LinkedHashSet<>(es),true));
    }
    String url;
    if (StereotypesHelper.hasStereotype(project.getPrimaryModel(),"String_Node_Str") && (url=(String)StereotypesHelper.getStereotypePropertyFirst(project.getPrimaryModel(),"String_Node_Str","String_Node_Str")) != null && !url.isEmpty()) {
      ActionsCategory tracingCategory=manager.getCategory("String_Node_Str");
      if (tracingCategory != null) {
        action=manager.getActionFor(MMSViewLinkAction.DEFAULT_ID);
        if (action == null) {
          tracingCategory.addAction(new MMSViewLinkAction(es));
        }
      }
    }
    ActionsStateUpdater.updateActionsState();
  }
  if (e == project.getPrimaryModel()) {
    NMAction act=null;
    ActionsCategory c=myCategory(manager,"String_Node_Str","String_Node_Str");
    act=manager.getActionFor(ValidateOldDocgen.DEFAULT_ID);
    if (act == null) {
      c.addAction(new ValidateOldDocgen());
    }
  }
  if ((e instanceof Activity && StereotypesHelper.hasStereotypeOrDerived(e,DocGenProfile.documentStereotype)) || StereotypesHelper.hasStereotypeOrDerived(e,sysmlview)) {
    NMAction act=null;
    ActionsCategory c=myCategory(manager,"String_Node_Str","String_Node_Str");
    act=manager.getActionFor(ValidateDocument3Action.DEFAULT_ID);
    if (act == null) {
      c.addAction(new ValidateDocument3Action(e));
    }
    act=manager.getActionFor(ValidateViewStructureAction.DEFAULT_ID);
    if (act == null && e instanceof Classifier) {
      c.addAction(new ValidateViewStructureAction(e));
    }
    act=manager.getActionFor(ViewDocument3Action.DEFAULT_ID);
    if (act == null) {
      c.addAction(new ViewDocument3Action(e));
    }
    act=manager.getActionFor(GenerateDocumentAction.DEFAULT_ID);
    if (act == null) {
      c.addAction(new GenerateDocumentAction(e));
    }
    if (StereotypesHelper.hasStereotypeOrDerived(e,documentView)) {
      if (e instanceof Package) {
        act=manager.getActionFor(NumberDependencyAction.DEFAULT_ID);
        if (act == null) {
          c.addAction(new NumberDependencyAction(e));
        }
        act=manager.getActionFor(MigrateToClassViewAction.DEFAULT_ID);
        if (act == null) {
          c.addAction(new MigrateToClassViewAction(e));
        }
      }
      if (e instanceof Class) {
        act=manager.getActionFor(NumberAssociationAction.DEFAULT_ID);
        if (act == null) {
          c.addAction(new NumberAssociationAction((Class)e));
        }
      }
    }
  }
  if (StereotypesHelper.hasStereotypeOrDerived(e,sysmlviewpoint)) {
    ActionsCategory c=myCategory(manager,"String_Node_Str","String_Node_Str");
    NMAction act=manager.getActionFor(InstanceViewpointAction.DEFAULT_ID);
    if (act == null) {
      c.addAction(new InstanceViewpointAction(e));
    }
  }
  ArrayList<Property> selectedProperties=new ArrayList<Property>();
  for (  Element el : es) {
    if (el instanceof Property) {
      selectedProperties.add((Property)el);
    }
  }
  if (!(selectedProperties.isEmpty())) {
    ActionsCategory c=myCategory(manager,"String_Node_Str","String_Node_Str");
    NMAction act=manager.getActionFor(CreateRestrictedValueAction.DEFAULT_ID);
    if (act == null) {
      c.addAction(new CreateRestrictedValueAction(selectedProperties));
    }
  }
}

Fixed version (ground truth):
private void addElementActions(ActionsManager manager,Element e,List<Element> es){
  Project project=Project.getProject(e);
  if (project == null && !es.isEmpty()) {
    project=Project.getProject(es.iterator().next());
  }
  if (project == null) {
    return;
  }
  Stereotype sysmlview=Utils.getViewStereotype(project);
  Stereotype sysmlviewpoint=Utils.getViewpointStereotype(project);
  Stereotype documentView=Utils.getProductStereotype(project);
  Stereotype classview=Utils.getViewClassStereotype(project);
  Stereotype elementGroupStereotype=Utils.getElementGroupStereotype(project);
  ActionsCategory refactorWithIDActionCat=myCategory(manager,"String_Node_Str","String_Node_Str");
  if (e instanceof com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class & !(e instanceof com.nomagic.uml2.ext.magicdraw.components.mdbasiccomponents.Component)) {
    if (manager.getActionFor(ClassToComponentRefactorWithIDAction.DEFAULT_ID) == null) {
      refactorWithIDActionCat.addAction(new ClassToComponentRefactorWithIDAction(es));
    }
  }
  if (e instanceof com.nomagic.uml2.ext.magicdraw.components.mdbasiccomponents.Component) {
    if (manager.getActionFor(ComponentToClassRefactorWithIDAction.DEFAULT_ID) == null) {
      refactorWithIDActionCat.addAction(new ComponentToClassRefactorWithIDAction(es));
    }
  }
  ActionsCategory modelLoad=myCategory(manager,"String_Node_Str","String_Node_Str");
  if (!TicketUtils.isTicketSet(project)) {
    ActionsCategory login=getCategory(manager,"String_Node_Str","String_Node_Str",modelLoad);
    if (manager.getActionFor(MMSLoginAction.DEFAULT_ID) == null) {
      login.addAction(new MMSLoginAction());
    }
  }
  ActionsCategory models=getCategory(manager,"String_Node_Str","String_Node_Str",modelLoad);
  if (MDUtils.isDeveloperMode()) {
    if (e instanceof Model && manager.getActionFor(CommitProjectAction.DEFAULT_ID) == null) {
      models.addAction(new CommitProjectAction(project,false,true));
      models.addAction(new CommitProjectAction(project,true,true));
    }
  }
  if (manager.getActionFor(ValidateModelAction.DEFAULT_ID) == null) {
    models.addAction(new ValidateModelAction(es,"String_Node_Str"));
  }
  if (manager.getActionFor(ValidateElementDepthAction.DEFAULT_ID) == null) {
    models.addAction(new ValidateElementDepthAction(es,"String_Node_Str"));
  }
  if (manager.getActionFor(ValidateElementAction.DEFAULT_ID) == null) {
    models.addAction(new ValidateElementAction(es,"String_Node_Str"));
  }
  ActionsStateUpdater.updateActionsState();
  if (StereotypesHelper.hasStereotypeOrDerived(e,DocGenProfile.validationScriptStereotype)) {
    ActionsCategory c=myCategory(manager,"String_Node_Str","String_Node_Str");
    UserScript us=new UserScript();
    us.setDgElement(e);
    List<Element> targets=Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(e,DocGenProfile.queriesStereotype,1,false,1);
    targets.addAll(Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(e,DocGenProfile.oldQueriesStereotype,1,false,1));
    us.setTargets(Utils2.asList(targets,Object.class));
    if (manager.getActionFor(RunUserValidationScriptAction.DEFAULT_ID) == null) {
      c.addAction(new RunUserValidationScriptAction(us,true));
    }
  }
 else   if (StereotypesHelper.hasStereotypeOrDerived(e,DocGenProfile.userScriptStereotype)) {
    ActionsCategory c=myCategory(manager,"String_Node_Str","String_Node_Str");
    UserScript us=new UserScript();
    us.setDgElement(e);
    List<Element> targets=Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(e,DocGenProfile.queriesStereotype,1,false,1);
    targets.addAll(Utils.collectDirectedRelatedElementsByRelationshipStereotypeString(e,DocGenProfile.oldQueriesStereotype,1,false,1));
    us.setTargets(Utils2.asList(targets,Object.class));
    if (manager.getActionFor(RunUserScriptAction.DEFAULT_ID) == null) {
      c.addAction(new RunUserScriptAction(us,true));
    }
  }
  boolean canShowGeneration=true;
  for (  Element element : es) {
    if (!StereotypesHelper.hasStereotypeOrDerived(element,sysmlview) && !StereotypesHelper.hasStereotypeOrDerived(element,elementGroupStereotype)) {
      canShowGeneration=false;
      break;
    }
  }
  if (canShowGeneration) {
    if (classview != null && es.size() == 1 && StereotypesHelper.hasStereotypeOrDerived(e,sysmlview)) {
      Boolean collectActions=(Boolean)StereotypesHelper.getStereotypePropertyFirst(e,classview,"String_Node_Str");
      if (collectActions != null && collectActions) {
        ActionsCategory category=(ActionsCategory)manager.getActionFor("String_Node_Str");
        if (category == null) {
          category=new MDActionsCategory("String_Node_Str","String_Node_Str");
          category.setNested(true);
          boolean added=addViewQueryActions(manager,category,(NamedElement)e);
          if (added) {
            manager.addCategory(0,category);
          }
        }
      }
    }
    ActionsCategory modelLoad2=myCategory(manager,"String_Node_Str","String_Node_Str");
    ActionsCategory viewInstances=getCategory(manager,"String_Node_Str","String_Node_Str",modelLoad2);
    NMAction action=manager.getActionFor(GenerateViewPresentationAction.DEFAULT_ID);
    if (action == null) {
      viewInstances.addAction(new GenerateViewPresentationAction(new LinkedHashSet<>(es),false));
    }
    action=manager.getActionFor(GenerateViewPresentationAction.RECURSE_DEFAULT_ID);
    if (action == null) {
      viewInstances.addAction(new GenerateViewPresentationAction(new LinkedHashSet<>(es),true));
    }
    String url;
    if (StereotypesHelper.hasStereotype(project.getPrimaryModel(),"String_Node_Str") && (url=(String)StereotypesHelper.getStereotypePropertyFirst(project.getPrimaryModel(),"String_Node_Str","String_Node_Str")) != null && !url.isEmpty()) {
      ActionsCategory tracingCategory=manager.getCategory("String_Node_Str");
      if (tracingCategory != null) {
        action=manager.getActionFor(MMSViewLinkAction.DEFAULT_ID);
        if (action == null) {
          tracingCategory.addAction(new MMSViewLinkAction(es));
        }
      }
    }
    ActionsStateUpdater.updateActionsState();
  }
  if ((e instanceof Activity && StereotypesHelper.hasStereotypeOrDerived(e,DocGenProfile.documentStereotype)) || StereotypesHelper.hasStereotypeOrDerived(e,sysmlview)) {
    NMAction act=null;
    ActionsCategory c=myCategory(manager,"String_Node_Str","String_Node_Str");
    act=manager.getActionFor(ValidateDocument3Action.DEFAULT_ID);
    if (act == null) {
      c.addAction(new ValidateDocument3Action(e));
    }
    act=manager.getActionFor(ValidateViewStructureAction.DEFAULT_ID);
    if (act == null && e instanceof Classifier) {
      c.addAction(new ValidateViewStructureAction(e));
    }
    act=manager.getActionFor(ViewDocument3Action.DEFAULT_ID);
    if (act == null) {
      c.addAction(new ViewDocument3Action(e));
    }
    act=manager.getActionFor(GenerateDocumentAction.DEFAULT_ID);
    if (act == null) {
      c.addAction(new GenerateDocumentAction(e));
    }
    if (StereotypesHelper.hasStereotypeOrDerived(e,documentView)) {
      if (e instanceof Package) {
        act=manager.getActionFor(NumberDependencyAction.DEFAULT_ID);
        if (act == null) {
          c.addAction(new NumberDependencyAction(e));
        }
        act=manager.getActionFor(MigrateToClassViewAction.DEFAULT_ID);
        if (act == null) {
          c.addAction(new MigrateToClassViewAction(e));
        }
      }
      if (e instanceof Class) {
        act=manager.getActionFor(NumberAssociationAction.DEFAULT_ID);
        if (act == null) {
          c.addAction(new NumberAssociationAction((Class)e));
        }
      }
    }
  }
  if (StereotypesHelper.hasStereotypeOrDerived(e,sysmlviewpoint)) {
    ActionsCategory c=myCategory(manager,"String_Node_Str","String_Node_Str");
    NMAction act=manager.getActionFor(InstanceViewpointAction.DEFAULT_ID);
    if (act == null) {
      c.addAction(new InstanceViewpointAction(e));
    }
  }
  ArrayList<Property> selectedProperties=new ArrayList<Property>();
  for (  Element el : es) {
    if (el instanceof Property) {
      selectedProperties.add((Property)el);
    }
  }
  if (!(selectedProperties.isEmpty())) {
    ActionsCategory c=myCategory(manager,"String_Node_Str","String_Node_Str");
    NMAction act=manager.getActionFor(CreateRestrictedValueAction.DEFAULT_ID);
    if (act == null) {
      c.addAction(new CreateRestrictedValueAction(selectedProperties));
    }
  }
}