Skip to content

Commit

Permalink
Merge pull request plantuml#1770 from travkin79/patch/1768
Browse files Browse the repository at this point in the history
Fix plantuml#1768 Consider "hide stereotype" statement
  • Loading branch information
arnaudroques authored May 8, 2024
2 parents d55f9d8 + 83b10aa commit 20b32a3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/net/atmp/CucaDiagram.java
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ public List<String> getVisibleStereotypeLabels(Entity entity) {
return null;
}

// collect hide or show statements on stereotypes
List<EntityHideOrShow> commands = new ArrayList<>();
for (EntityHideOrShow hideOrShowEntry : hideOrShows) {
if (hideOrShowEntry.portion == EntityPortion.STEREOTYPE) {
Expand All @@ -542,7 +543,7 @@ public List<String> getVisibleStereotypeLabels(Entity entity) {

List<String> visibleStereotypeLabels = new ArrayList<>();
for (String stereoTypeLabel : entity.getStereotype().getLabels(Guillemet.DOUBLE_COMPARATOR)) {
if (isHiddenStereotypeLabel(stereoTypeLabel, commands)) {
if (!isHiddenStereotypeLabel(stereoTypeLabel, commands)) {
visibleStereotypeLabels.add(stereoTypeLabel);
}
}
Expand All @@ -552,12 +553,16 @@ public List<String> getVisibleStereotypeLabels(Entity entity) {

private boolean isHiddenStereotypeLabel(String stereoTypeLabel, List<EntityHideOrShow> commands) {
for (EntityHideOrShow cmd : commands) {
// gender is here the stereotype name given in the hide or show command
String gender = cmd.gender.getGender();
if (gender != null && gender.equals(stereoTypeLabel)) {
return false;
return !cmd.show;
} else if (gender == null) {
// we have a hide or show command without a stereotype name => hide or show all stereotypes
return !cmd.show;
}
}
return true;
return false;
}

public final void hideOrShow(EntityGender gender, EntityPortion portions, boolean show) {
Expand Down

0 comments on commit 20b32a3

Please sign in to comment.