The com.intellij.diagram.Provider extension point is not documented, and since Diagrams are an IntelliJ Ultimate feature, access to doc-strings does not appear to be available. This makes implementing extensions reasonably difficult as one is doing so in the dark.
Would the IntelliJ team consider sharing some minimal information about the extension point? Even an export of the doc-strings would go a long way.
Thanks for these pointers. I’ll share the tips which helped me below, to give you a sense of what documentation may be helpful in the future.
The Diagrams API is an abstraction on top of yFiles.
DiagramExtras.createNodeComponent is the best place to modify the appearance of nodes. Knowledge of JSwing is helpful here. I spent a lot of time looking at NodeRealizer but this was counterproductive.
DiagramUpdateService and DiagramPresentationModel.refreshModelWhenSmart are crucial in controlling how your diagram is updated, for example many changes require .withNodePresentationsUpdate(true) or .withAllNodeSizeUpdate() to be added.
GraphBuilderImpl caches diagram nodes, which can be problematic particularly if you fail to implement DiagramNode.equals() correctly.
Avoid making PSI changes in DiagramDataModel.removeNode() since it isn’t only called by “Delete” in the UI, but also by various internal structures when rebuilding the diagram. Use the “Safe Delete” provided by refactoring instead.
It is clearer in retrospect, but DiagramNodeContentManager applies to things within nodes, not nodes themselves.
Use DiagramDataModel.isPsiListener() and DiagramDataModel.getModificationTracker() to refresh your diagram when the PSI changes.
The initial “seeding” (creation) of your diagram does not use the same flow as a data model refresh and you may need to take care to ensure they the produce the same diagram.
During development stale diagram data can be cached across IDE restarts. If you experience odd behavior, try closing and reopening your test project.
The debugger is useful for understanding how the IDE will interact with your provider.
@bardi - I don’t see myself in a position to need to do any diagram-related work in an IJ plug-in anytime soon, but I really appreciate the time you took to type this all up and share with the community!! Thank you!!