Skip to content

Commit 95ac0ab

Browse files
Fixes #374.
1 parent a998bfa commit 95ac0ab

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## (unreleased)
4+
5+
- structurizr-dsl: Fixes https://github.com/structurizr/java/issues/374 (!identifiers hierarchical isn't propagated when extending a workspace).
6+
37
## 3.2.1 (10th December 2024)
48

59
- structurizr-core: Fixes https://github.com/structurizr/java/issues/362 (Ordering of replicated relationships in deployment environment is non-deterministic).

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@
44

55
final class DslParserContext extends DslContext {
66

7-
private final boolean restricted;
7+
private final StructurizrDslParser parser;
88
private final File file;
9+
private final boolean restricted;
910

10-
DslParserContext(File file, boolean restricted) {
11+
DslParserContext(StructurizrDslParser parser, File file, boolean restricted) {
12+
this.parser = parser;
1113
this.file = file;
1214
this.restricted = restricted;
1315
}
1416

17+
StructurizrDslParser getParser() {
18+
return parser;
19+
}
20+
1521
File getFile() {
1622
return file;
1723
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ void parse(List<String> lines, File dslFile, boolean fragment, boolean includeIn
634634
if (parsedTokens.contains(WORKSPACE_TOKEN)) {
635635
throw new RuntimeException("Multiple workspaces are not permitted in a DSL definition");
636636
}
637-
DslParserContext dslParserContext = new DslParserContext(dslFile, restricted);
637+
DslParserContext dslParserContext = new DslParserContext(this, dslFile, restricted);
638638
dslParserContext.setIdentifierRegister(identifiersRegister);
639639

640640
workspace = new WorkspaceParser().parse(dslParserContext, tokens.withoutContextStartToken());

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Workspace parse(DslParserContext context, Tokens tokens) {
4949
structurizrDslParser.setRestricted(context.isRestricted());
5050
structurizrDslParser.parse(context, dsl);
5151
workspace = structurizrDslParser.getWorkspace();
52+
context.getParser().setIdentifierScope(structurizrDslParser.getIdentifierScope());
5253
}
5354
} else {
5455
if (context.isRestricted()) {
@@ -72,6 +73,7 @@ Workspace parse(DslParserContext context, Tokens tokens) {
7273
StructurizrDslParser structurizrDslParser = new StructurizrDslParser();
7374
structurizrDslParser.parse(context, file);
7475
workspace = structurizrDslParser.getWorkspace();
76+
context.getParser().setIdentifierScope(structurizrDslParser.getIdentifierScope());
7577
}
7678
}
7779
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,8 @@ void test_extendWorkspaceFromDsl(String dslFile) throws Exception {
479479
parser.parse(new File(dslFile));
480480

481481
Workspace workspace = parser.getWorkspace();
482+
assertEquals(IdentifierScope.Hierarchical, parser.getIdentifierScope());
483+
482484
Model model = workspace.getModel();
483485
assertEquals(CreateImpliedRelationshipsUnlessAnyRelationshipExistsStrategy.class, model.getImpliedRelationshipsStrategy().getClass());
484486

0 commit comments

Comments
 (0)