plantuml / plantuml

Generate diagrams from textual description
https://plantuml.com
Other
10.04k stars 914 forks source link

Allow steps before break merge #1387

Open golddragon007 opened 1 year ago

golddragon007 commented 1 year ago

Is your feature request related to a problem? Please describe. I have a group list with a hierarchy, where I have to check if the user is part of that group or on of the parent. Code looks like this which I try to replicate in plantuml:

function IsPartOfGroupHierarchy($group_id, $user) {
[...]
if ($group_id == null) {
  return false;
}
$spec_id = GetSpecialIdentifier($group_id);
while ($spec_id) {
  if ($spec_id == $user->group_spec_id) {
    return true;
  }

  $group_id = GetParentGroup($group_id);
  $spec_id = GetSpecialIdentifier($group_id);
}

return false;
}

The problem is the last return as I should somehow represent it in the diagram. https://www.plantuml.com/plantuml/umla/VKynKiGm4Elz2fMvBzmrLm0tgU43FhAvxE3Onhicm-ynSPnGeSQIHoEjhg8sQPwTMOa1U4HtIo57y722JkJHzGAVdJiP59nVh1Ew54xbhLytKhn6UcVhq0-uV-EnHlHFnLUmJEm8NRFy9hFKtA1_icjzinq7F7zc_YgrM5WdPA44EKm66yvlATDbb_T4zgD9yWEFbTTxeqta5OzjAwmSV4nXtbLB-7zbhLY7cjOc6gAv5fvdzmC0

Describe the solution you'd like I need somehow to put a step on the while loop condition exit before the merge happens from the break.

Describe alternatives you've considered

Additional context

arnaudroques commented 1 year ago

What about having this ?

@startuml
start
  if (Group id) then (Is null)
    :False;
  else
    :Get Special Id by group ID;
    while (Special id) is (Is not null)
      if (Special id) then (Equivals with user special id)
        :True;
        stop
      endif
      :Get parent group id as group id from group id;
      :Get Special Id by group ID;
    endwhile
  endif
stop
@enduml

golddragon007 commented 1 year ago

Well, it's a kinda acceptable workaround for this case as there's no flow after it.