Skip to content

Commit

Permalink
fix(plc4c): fix tracer for enums
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Sep 28, 2021
1 parent e0819a8 commit c3e13b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,8 @@ public Map<String, Map<String, String>> getDiscriminatorValues() {
}

public TypeReference getArgumentType(TypeReference typeReference, int index) {
if (!(typeReference instanceof ComplexTypeReference)) {
throw new FreemarkerException("Only complex type references supported here.");
}
ComplexTypeReference complexTypeReference = (ComplexTypeReference) typeReference;
Objects.requireNonNull(typeReference, "type reference must not be null");
ComplexTypeReference complexTypeReference = typeReference.asComplexTypeReference().orElseThrow(() -> new FreemarkerException("Only complex type references supported here."));
if (!getTypeDefinitions().containsKey(complexTypeReference.getName())) {
throw new FreemarkerException("Could not find definition of complex type " + complexTypeReference.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -937,8 +937,7 @@ private String toVariableSerializationExpression(TypeDefinition baseType, Field
if ((typeDefinitionForTypeReference instanceof EnumTypeDefinition) && (variableLiteral.getChild().isPresent())) {
tracer = tracer.dive("is enum type definition");
sb.append(camelCaseToSnakeCase(variableLiteral.getName()));
return getCTypeName(typeDefinitionForTypeReference.getName()) +
tracer + "_get_" + camelCaseToSnakeCase(variableLiteral.getChild().get().getName()) +
return tracer + getCTypeName(typeDefinitionForTypeReference.getName()) + "_get_" + camelCaseToSnakeCase(variableLiteral.getChild().get().getName()) +
"(" + sb + ")";
}
}
Expand Down

0 comments on commit c3e13b7

Please sign in to comment.