structurizr / dsl

Structurizr DSL
https://docs.structurizr.com/dsl
Apache License 2.0
1.41k stars 266 forks source link

!identifiers hierarchical are not always discovered and parser is failing #374

Closed galuszkak closed 8 months ago

galuszkak commented 8 months ago

Description

Hi @simonbrowndotje ,

Thanks for the fantastic & hard work on Structurizr! I've been using it for over a year now with https://github.com/avisi-cloud/structurizr-site-generatr .

The bug that I'm experiencing is related to my idea of moving to start using !identifiers hierarchical directive.

This example DSL is failing:

workspace {

    !identifiers hierarchical

    model {
        systemTest = softwareSystem "System that we test" {
            container1 = container "Test container 1" {
                this -> systemTest.container2
            }
            container2 = container "Test container 2" {

            }
        }
    }

  views {
    container systemTest {
      include *
      autoLayout
    }

}

This would end up with error:

com.structurizr.dsl.StructurizrDslParserException: The destination element "systemTest.container2" does not exist at line 8 of /Users/galuszkak/Projects/airlift/architecture/bug.dsl: this -> systemTest.container2
        at com.structurizr.dsl.StructurizrDslParser.parse(StructurizrDslParser.java:912)
        at com.structurizr.dsl.StructurizrDslParser.parse(StructurizrDslParser.java:128)

Having semantically equivalent is working:

workspace {

    !identifiers hierarchical

    model {
        systemTest = softwareSystem "System that we test" {
            container1 = container "Test container 1" {

            }
            container2 = container "Test container 2" {
                systemTest.container1 -> this
            }
        }
    }

  views {
    container systemTest {
      include *
      autoLayout
    }

}

Steps to reproduce

With this DSL:

workspace {

    !identifiers hierarchical

    model {
        systemTest = softwareSystem "System that we test" {
            container1 = container "Test container 1" {
                this -> systemTest.container2
            }
            container2 = container "Test container 2" {

            }
        }
    }

  views {
    container systemTest {
      include *
      autoLayout
    }

}

It will fail with error:

com.structurizr.dsl.StructurizrDslParserException: The destination element "systemTest.container2" does not exist at line 8 of /Users/galuszkak/Projects/airlift/architecture/bug.dsl: this -> systemTest.container2
        at com.structurizr.dsl.StructurizrDslParser.parse(StructurizrDslParser.java:912)
        at com.structurizr.dsl.StructurizrDslParser.parse(StructurizrDslParser.java:128)

Screenshot

No response

Code sample

No response

Configuration

No response

Severity

Major

Priority

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

More information

While I can't confirm, I will try to see if our company has the budget to fix this bug. Would you be able to provide any potential estimation and rate for fixing this bug?

simonbrowndotje commented 8 months ago

This is as expected ... the DSL is like a programming language, and you can't forward reference elements that haven't yet been created.