In "normal" cases, where we only reuse nodes defined from the same DiagramDescription, it does not cause any issue because the recursive walk on the DiagramDescription's content will end-up finding the element.
In a case where the reused node is defined in another DiagramDescription, findNodeDescriptionById can return Optional.empty().
Clicking a such a node (which is correctly rendered) then causes an NPE:
Caused by: java.lang.NullPointerException: null
at java.base/java.util.Objects.requireNonNull(Objects.java:208) ~[na:na]
at org.eclipse.sirius.components.collaborative.diagrams.dto.GetPaletteSuccessPayload.<init>(GetPaletteSuccessPayload.java:30) ~[classes/:na]
at org.eclipse.sirius.components.collaborative.diagrams.handlers.GetPaletteEventHandler.handle(GetPaletteEventHandler.java:117) ~[classes/:na]
GetPaletteEventHandler is not ready to handle the case where findDiagramElementDescription is empty. In that case it leaves palette to null, and GetPaletteSuccessPayload rejects it.
Note that DropNodeCompatibiliyProvider.forEachNodeDescription(DiagramDescription, Consumer<NodeDescription>) tries to work around the issue for its use case.
When looking for a node by id (
ViewRepresentationDescriptionSearchService.findNodeDescriptionById(DiagramDescription, String)
), we only search in:This ignores reused (sub, border) nodes.
In "normal" cases, where we only reuse nodes defined from the same
DiagramDescription
, it does not cause any issue because the recursive walk on theDiagramDescription
's content will end-up finding the element.In a case where the reused node is defined in another
DiagramDescription
,findNodeDescriptionById
can returnOptional.empty()
. Clicking a such a node (which is correctly rendered) then causes an NPE:GetPaletteEventHandler
is not ready to handle the case wherefindDiagramElementDescription
is empty. In that case it leavespalette
tonull
, andGetPaletteSuccessPayload
rejects it.Note that (I think) we can not "simply" do:
This could cause infinite loops if e.g. A reuses B and B reuses A (even indirectly).