Inside of a namespace, classes defined within a together block are not recognized outside of the block

0 votes
asked Feb 2 in Bug by djerius (120 points)

In a larger diagram I'm trying to improve layout of  like classes using together blocks.  The together blocks and other code are inside of a namespace.  The problem I'm running into is that relationships defined outside of the together block (but still inside of the namespace) create new classes, rather than using the ones already defined in the together blocks. Here's a snippet of code:

@startuml
namespace Observation {

   together {
       abstract class BadPix {
       }

       class Role::BadPix <<role>> {
       }

    }

   class Base {

   }

   BadPix *-- Role::BadPix
   Base <|-- Role::BadPix

}
@enduml

and here's what it looks like:

http://www.plantuml.com/plantuml/png/PKzT2i8m37xlAV8ix0AZZE4556-GTM4EkbQIACBqxYkaGzIy95--dv1U55dlItG95v8R1eBJ8CGFr3adM9q30CqJwPMuGB32GPGnA8I88d34yJm_F_JRxPFnbnofRQlAUowmw_xarlP4eNhTrjLyQ9glDAEArhz-6LUCFQMnVBS1

If I remove the namespace, things work:

http://www.plantuml.com/plantuml/png/SoWkIImgAStDuU9IK50eoKzFBSb8BLAe1l50836fkAGeCRb48JadiRXOmIan9I2p0Y5TomLZGUI3ydDIhQoWgcniYe1SEpiCvH0APc9nAb015rmOgbbBLnV5D8WKKArD3ReC5vT3QbuAq0y0

1 Answer

0 votes
answered Feb 4 by plantuml (160,740 points)
Thanks for the feedback.

We're going to investigate this, not sure that this is easy to solve. In some (near?) future, we are going to simplify the difference between namespace and package within PlantUML because this is really confusing for users.

Note that your example is working fine with package http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuIf8JCvEJ4zLy4ygJYqgIop9pCzJgERYKb1GACbFJot9I2q2SXKW836fkAGeCRb48JadiRXOmIan9I2p0Y5TomLZGUI3ydDIhQoWgcniYe1SEpiCvH0APc9nAjHsY31KivQkBeff42cWMfiQT1ckMYw7rBmKeDS0

Regards,
commented Feb 7 by djerius (120 points)
Thanks.

I'm using namespace rather than package because of  the ability to have similarly named classes in different namespaces, which package doesn't allow.   This maps directly onto namespaces in C++ (which is nice!) and also leads to less visual clutter, as the top-level name in the class hierarchy name doesn't have to appear in every class.  (But I'm sure you already know that!)
...