Skip to content

Commit 990b1c2

Browse files
structurizr-dsl: Constants and variables are inherited when extending a DSL workspace.
1 parent dbe5d11 commit 990b1c2

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- structurizr-dsl: Adds support for removing relationships between software system instance/container instances, with a view to redefining them via infrastructure nodes.
1515
- structurizr-dsl: Adds support for a `jump` property on relationship styles.
1616
- structurizr-dsl: PlantUML, Mermaid, and Kroki image views can now be defined by an inline source block.
17+
- structurizr-dsl: Constants and variables are inherited when extending a DSL workspace.
1718
- structurizr-import: Adds support for `plantuml.inline`, `mermaid.inline`, and `kroki.inline` properties to inline the resulting PNG/SVG file into the workspace.
1819
- structurizr-inspection: Adds a way to disable inspections via a workspace property named `structurizr.inspection` (`false` to disable).
1920
- structurizr-inspection: Default inspector adds a summary of error/warning/info/ignore counts as workspace properties.

structurizr-dsl/src/main/java/com/structurizr/dsl/StructurizrDslParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public final class StructurizrDslParser extends StructurizrDslTokens {
4545
private final Stack<DslContext> contextStack;
4646
private final Set<String> parsedTokens = new HashSet<>();
4747
private final IdentifiersRegister identifiersRegister;
48-
private final Map<String, NameValuePair> constantsAndVariables;
48+
private Map<String, NameValuePair> constantsAndVariables;
4949
private final Features features = new Features();
5050

5151
private Map<String,Map<String,Archetype>> archetypes = Map.of(
@@ -78,6 +78,7 @@ public StructurizrDslParser() {
7878
void configureFrom(StructurizrDslParser parser) {
7979
setIdentifierScope(parser.getIdentifierScope());
8080
archetypes = parser.archetypes;
81+
constantsAndVariables = parser.constantsAndVariables;
8182
}
8283

8384
/**

structurizr-dsl/src/test/java/com/structurizr/dsl/DslTests.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,18 @@ void test_Constant() {
12691269
}
12701270
}
12711271

1272+
@Test
1273+
void test_ConstantsAndVariablesFromWorkspaceExtension() throws Exception {
1274+
File dslFile = new File("src/test/resources/dsl/constants-and-variables-from-workspace-extension-child.dsl");
1275+
1276+
StructurizrDslParser parser = new StructurizrDslParser();
1277+
parser.parse(dslFile);
1278+
1279+
SoftwareSystem softwareSystem = parser.getWorkspace().getModel().getSoftwareSystemWithName("Name");
1280+
assertNotNull(softwareSystem);
1281+
assertEquals("Description", softwareSystem.getDescription());
1282+
}
1283+
12721284
@Test
12731285
void test_UnbalancedCurlyBraces() {
12741286
try {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
workspace extends constants-and-variables-from-workspace-extension-parent.dsl {
2+
3+
model {
4+
softwareSystem "${NAME}" "${DESCRIPTION}"
5+
}
6+
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
workspace {
2+
3+
!const "NAME" "Name"
4+
!var "DESCRIPTION" "Description"
5+
6+
}

0 commit comments

Comments
 (0)