Skip to content

Commit

Permalink
support param_name_case in dataProvider for TS
Browse files Browse the repository at this point in the history
  • Loading branch information
kosheverov committed Jun 27, 2023
1 parent 841aaca commit c568a3a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/evgen/code_generators/type_script/dict_tracker_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,13 @@ def _generate_class_interfaces(self, code: evgen_code.Code):
)
]

statements.extend(self._get_params_class(code.global_params))
statements.extend(
self._get_params_class(code.global_params, self.param_name_case)
)
statements.append(st.EmptyLine())
statements.extend(self._get_params_class(code.platform_params))
statements.extend(
self._get_params_class(code.platform_params, self.param_name_case)
)
statements.append(st.EmptyLine())

class_statement = st.Closure(
Expand Down Expand Up @@ -261,7 +265,9 @@ def _generate_namespace(self, namespace: str, functions: List[evgen_code.Functio
helpers.write_statements(statements, fp)

def _get_params_class(
self, global_params: Union[evgen_code.GlobalParams, evgen_code.PlatformParams]
self,
global_params: Union[evgen_code.GlobalParams, evgen_code.PlatformParams],
param_name_case: str,
) -> List[st.Statement]:
gp_statements = list()

Expand All @@ -276,13 +282,16 @@ def _get_params_class(
class_statements = list()
# public parameters
for param in global_params.params:
param_name = (
param.code_name if param_name_case == "camel_case" else param.event_name
)
if not isinstance(param.type, evgen_code.ConstType):
class_statements.append(
st.Line(f"{param.code_name}: {param.type.declaration()}")
st.Line(f"{param_name}: {param.type.declaration()}")
)
else:
class_statements.append(
st.Line(f'{param.code_name}: "{param.type.type_value}"')
st.Line(f'{param_name}: "{param.type.type_value}"')
)

gp_statements.append(
Expand Down

0 comments on commit c568a3a

Please sign in to comment.