Skip to content

Commit

Permalink
Merge pull request #6 from ZenWave360/develop
Browse files Browse the repository at this point in the history
adds field.isComplexType
  • Loading branch information
ivangsa authored Jan 28, 2024
2 parents 4c3ccd7 + ea5521b commit 44386c6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ public void enterField(io.github.zenwave360.zdl.antlr.ZdlParser.FieldContext ctx
var name = getText(ctx.field_name());
var type = ctx.field_type() != null && ctx.field_type().ID() != null? ctx.field_type().ID().getText() : null;
var javadoc = javadoc(first(ctx.javadoc(), ctx.suffix_javadoc()));
var isEnum = false; // TODO
var isEntity = false; // TODO
var isEnum = false; // see ZdlModelPostProcessor
var isEntity = false; // see ZdlModelPostProcessor
var isArray = ctx.field_type().ARRAY() != null;
var validations = processFieldValidations(ctx.field_validations());
var field = new FluentMap()
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/io/github/zenwave360/zdl/antlr/ZdlModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public FluentMap getOutputs() {
return (FluentMap) get("outputs");
}

public FluentMap getEvents() {
return (FluentMap) get("events");
}


public FluentMap getEnums() {
var enumsRoot = (FluentMap) get("enums");
if(enumsRoot != null) {
Expand Down Expand Up @@ -74,4 +79,5 @@ private Map problem(String path, String value, String error) {
private int[] getLocation(String path) {
return JSONPath.get(this, "$.locations.['" + path + "']");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,29 @@ public static ZdlModel postProcess(ZdlModel model) {
var inputs = model.getInputs();
var outputs = model.getOutputs();
var enums = model.getEnums();
var events = model.getEvents();

var fields = JSONPath.get(model, "$..fields[*]", List.<Map<String, Object>>of());
for (var field : fields) {
if(entities != null && entities.containsKey(field.get("name"))) {
if(entities != null && entities.containsKey(field.get("type"))) {
field.put("isEntity", true);
field.put("isComplexType", true);
}
if(enums != null && enums.containsKey(field.get("name"))) {
if(enums != null && enums.containsKey(field.get("type"))) {
field.put("isEnum", true);
field.put("isComplexType", true);
}
if(inputs != null && inputs.containsKey(field.get("name"))) {
if(inputs != null && inputs.containsKey(field.get("type"))) {
field.put("isInput", true);
field.put("isComplexType", true);
}
if(outputs != null && outputs.containsKey(field.get("name"))) {
if(outputs != null && outputs.containsKey(field.get("type"))) {
field.put("isOutput", true);
field.put("isComplexType", true);
}
if(events != null && events.containsKey(field.get("type"))) {
field.put("isEvent", true);
field.put("isComplexType", true);
}
}

Expand Down

0 comments on commit 44386c6

Please sign in to comment.