Skip to content

Commit

Permalink
Removes deprecated !constant keyword.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrowndotje committed Sep 9, 2024
1 parent be6b720 commit 3fdab62
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- structurizr-client: Adds support for [workspace branches](https://docs.structurizr.com/onpremises/workspace-branches) (on-premises installation only).
- structurizr-core: Adds name-value properties to dynamic view relationship views (https://github.com/structurizr/java/issues/316).
- structurizr-component: Initial rewrite of the original `structurizr-analysis` library - provides a way to automatically find components in a Java codebase.
- structurizr-dsl: Removes deprecated `!constant` keyword.
- structurizr-dsl: Adds name-value properties to dynamic view relationship views.
- structurizr-dsl: Fixes https://github.com/structurizr/java/issues/312 (!include doesn't work with files encoded as UTF-8 BOM).
- structurizr-dsl: Adds a way to explicitly specify the order of relationships in dynamic views.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -950,13 +950,7 @@ void parse(List<String> lines, File dslFile, boolean fragment, boolean includeIn
}

} else if (CONSTANT_TOKEN.equalsIgnoreCase(firstToken)) {
log.warn("!constant has been deprecated and will be removed in a future release - please use !const or !var instead");
NameValuePair nameValuePair = new NameValueParser().parseConstant(tokens);

if (constantsAndVariables.containsKey(nameValuePair.getName())) {
log.warn("A constant \"" + nameValuePair.getName() + "\" already exists");
}
constantsAndVariables.put(nameValuePair.getName(), nameValuePair);
throw new RuntimeException("!constant was previously deprecated, and has now been removed - please use !const or !var instead");

} else if (CONST_TOKEN.equalsIgnoreCase(firstToken)) {
NameValuePair nameValuePair = new NameValueParser().parseConstant(tokens);
Expand Down
13 changes: 13 additions & 0 deletions structurizr-dsl/src/test/java/com/structurizr/dsl/DslTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,19 @@ void test_Enterprise() {
}
}

@Test
void test_Constant() {
File dslFile = new File("src/test/resources/dsl/constant.dsl");

try {
StructurizrDslParser parser = new StructurizrDslParser();
parser.parse(dslFile);
fail();
} catch (StructurizrDslParserException e) {
assertEquals("!constant was previously deprecated, and has now been removed - please use !const or !var instead at line 3 of " + dslFile.getAbsolutePath() + ": !constant NAME VALUE", e.getMessage());
}
}

@Test
void test_UnbalancedCurlyBraces() {
try {
Expand Down
5 changes: 5 additions & 0 deletions structurizr-dsl/src/test/resources/dsl/constant.dsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
workspace {

!constant NAME VALUE

}

0 comments on commit 3fdab62

Please sign in to comment.