Skip to content

Commit 1cffac0

Browse files
Adds a warning message (see #253).
1 parent e34f70e commit 1cffac0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import com.structurizr.model.*;
55
import com.structurizr.util.StringUtils;
66
import com.structurizr.view.*;
7+
import org.apache.commons.logging.Log;
8+
import org.apache.commons.logging.LogFactory;
79

810
import java.io.File;
911
import java.io.IOException;
@@ -20,6 +22,8 @@
2022
*/
2123
public final class StructurizrDslParser extends StructurizrDslTokens {
2224

25+
private static final Log log = LogFactory.getLog(StructurizrDslParser.class);
26+
2327
private static final String BOM = "\uFEFF";
2428

2529
private static final Pattern EMPTY_LINE_PATTERN = Pattern.compile("^\\s*");
@@ -869,6 +873,9 @@ void parse(List<String> lines, File dslFile, boolean include) throws Structurizr
869873

870874
} else if (CONSTANT_TOKEN.equalsIgnoreCase(firstToken)) {
871875
Constant constant = new ConstantParser().parse(getContext(), tokens);
876+
if (constants.containsKey(constant.getName())) {
877+
log.warn("A constant named " + constant.getName() + " already exists");
878+
}
872879
constants.put(constant.getName(), constant);
873880

874881
} else if (IDENTIFIERS_TOKEN.equalsIgnoreCase(firstToken) && (inContext(WorkspaceDslContext.class) || inContext(ModelDslContext.class))) {

0 commit comments

Comments
 (0)