feat(tests): update serializer
This commit is contained in:
@@ -6,16 +6,17 @@ from midas.ast.midas import (
|
|||||||
ConstraintType,
|
ConstraintType,
|
||||||
Expr,
|
Expr,
|
||||||
ExtendStmt,
|
ExtendStmt,
|
||||||
|
ExtensionType,
|
||||||
FunctionType,
|
FunctionType,
|
||||||
GenericType,
|
GenericType,
|
||||||
GetExpr,
|
GetExpr,
|
||||||
GroupingExpr,
|
GroupingExpr,
|
||||||
LiteralExpr,
|
LiteralExpr,
|
||||||
LogicalExpr,
|
LogicalExpr,
|
||||||
|
MemberStmt,
|
||||||
NamedType,
|
NamedType,
|
||||||
OpStmt,
|
OpStmt,
|
||||||
PredicateStmt,
|
PredicateStmt,
|
||||||
PropertyStmt,
|
|
||||||
Stmt,
|
Stmt,
|
||||||
Type,
|
Type,
|
||||||
TypeParam,
|
TypeParam,
|
||||||
@@ -58,9 +59,10 @@ class MidasAstJsonSerializer(
|
|||||||
"bound": self._serialize_optional(param.bound),
|
"bound": self._serialize_optional(param.bound),
|
||||||
}
|
}
|
||||||
|
|
||||||
def visit_property_stmt(self, stmt: PropertyStmt) -> dict:
|
def visit_member_stmt(self, stmt: MemberStmt) -> dict:
|
||||||
return {
|
return {
|
||||||
"_type": "PropertyStmt",
|
"_type": "MemberStmt",
|
||||||
|
"kind": stmt.kind.name,
|
||||||
"name": stmt.name.lexeme,
|
"name": stmt.name.lexeme,
|
||||||
"type": stmt.type.accept(self),
|
"type": stmt.type.accept(self),
|
||||||
}
|
}
|
||||||
@@ -68,8 +70,9 @@ class MidasAstJsonSerializer(
|
|||||||
def visit_extend_stmt(self, stmt: ExtendStmt) -> dict:
|
def visit_extend_stmt(self, stmt: ExtendStmt) -> dict:
|
||||||
return {
|
return {
|
||||||
"_type": "ExtendStmt",
|
"_type": "ExtendStmt",
|
||||||
"type": stmt.type.accept(self),
|
"name": stmt.name.lexeme,
|
||||||
"operations": self._serialize_list(stmt.operations),
|
"params": [self._serialize_type_param(param) for param in stmt.params],
|
||||||
|
"members": self._serialize_list(stmt.members),
|
||||||
}
|
}
|
||||||
|
|
||||||
def visit_op_stmt(self, stmt: OpStmt) -> dict:
|
def visit_op_stmt(self, stmt: OpStmt) -> dict:
|
||||||
@@ -163,7 +166,7 @@ class MidasAstJsonSerializer(
|
|||||||
def visit_complex_type(self, type: ComplexType) -> dict:
|
def visit_complex_type(self, type: ComplexType) -> dict:
|
||||||
return {
|
return {
|
||||||
"_type": "ComplexType",
|
"_type": "ComplexType",
|
||||||
"properties": self._serialize_list(type.properties),
|
"members": self._serialize_list(type.members),
|
||||||
}
|
}
|
||||||
|
|
||||||
def visit_function_type(self, type: FunctionType) -> dict:
|
def visit_function_type(self, type: FunctionType) -> dict:
|
||||||
@@ -180,3 +183,10 @@ class MidasAstJsonSerializer(
|
|||||||
"type": arg.type.accept(self),
|
"type": arg.type.accept(self),
|
||||||
"required": arg.required,
|
"required": arg.required,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def visit_extension_type(self, type: ExtensionType) -> dict:
|
||||||
|
return {
|
||||||
|
"_type": "ExtensionType",
|
||||||
|
"base": type.base.accept(self),
|
||||||
|
"extension": type.extension.accept(self),
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user