structurizr / java

Structurizr for Java
https://docs.structurizr.com/java
Apache License 2.0
1.01k stars 288 forks source link

Support references before definitions in DSL #328

Closed mattdrees closed 2 months ago

mattdrees commented 2 months ago

Description

It looks like the parser does a single pass through the DSL file, and validates references as it goes.

So, this is valid:

workspace {
  model {
        a = softwareSystem "A"
        b = softwareSystem "B"
        a -> b
  }
}

but this is not:

workspace {
  model {
        a = softwareSystem "A"
        a -> b
        b = softwareSystem "B"
  }
}

This is the error message from structurizr-cli validate:

The destination element "b" does not exist at line 4 of /myprojects/structurizr-java/structurizr-dsl/src/test/resources/dsl/relationship-ref-before-target.dsl: a -> b

Not the end of the world, but I've several times wished I could define a relationship in or around a source system (system "A"), rather than having to define it way down in the file after the target system (system "B").

Does that sound like something you'd be interested in supporting?

Priority

I have no budget and there's no rush, please add this feature for free

More information

No response

simonbrowndotje commented 2 months ago

This has been discussed a few times (example -> https://github.com/structurizr/java/discussions/260) ... it's not something that's particularly viable I'm afraid.