Skip to content

Commit c73d0f8

Browse files
committed
feat: Add firstParameter to TParameter
1 parent b6d3083 commit c73d0f8

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

AstToEcoreConverter.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,20 +1108,23 @@ def create_method_signature(self, method_node, name, arguments):
11081108
name (str?): The name of the method.
11091109
arguments (list?): The list of arguments for the method.
11101110
"""
1111-
method_signature = self.create_ecore_instance(
1112-
NodeTypes.METHOD_SIGNATURE)
1111+
method_signature = self.create_ecore_instance(NodeTypes.METHOD_SIGNATURE)
11131112
method = self.create_ecore_instance(NodeTypes.METHOD)
11141113
method.tName = name
11151114
self.graph.methods.append(method)
11161115
method_signature.method = method
11171116

11181117
previous = None
1118+
first_parameter = None
11191119
for _ in arguments:
11201120
parameter = self.create_ecore_instance(NodeTypes.PARAMETER)
11211121
if previous is not None:
11221122
parameter.previous = previous
11231123
previous = parameter
11241124
method_signature.parameters.append(parameter)
1125+
if first_parameter is None:
1126+
first_parameter = parameter
1127+
method_signature.firstParameter = first_parameter
11251128

11261129
method_node.signature = method_signature
11271130

@@ -1177,7 +1180,14 @@ def create_field(self, field_node, name, field_type=None) -> None:
11771180
field.signature = field_signature
11781181
field.tName = name
11791182

1180-
# field_signature.type = field_type #Todo currently bugged get str('datatype)') probably need TAbstractType
1183+
# Todo currently bugged get str('datatype)') probably need TAbstractType
1184+
# -> tAbstractType can not be init bec. abstract.
1185+
# -> Use TClass instead
1186+
# -> if TClass used type will not be set in xmi
1187+
# Create a TClass instance and set its instanceClass attribute
1188+
type_class = self.create_ecore_instance(NodeTypes.CLASS)
1189+
type_class.tName = field_type
1190+
field_signature.type = type_class
11811191

11821192
self.graph.fields.append(field)
11831193

@@ -1246,18 +1256,6 @@ def __init__(self, ecore_graph):
12461256
self.names_in_scope: set = set()
12471257
self.fields_per_class: dict = dict()
12481258

1249-
self.INTEGER_TYPE = self.ecore_graph.get_class_by_name("int")
1250-
self.FLOAT_TYPE = self.ecore_graph.get_class_by_name("float")
1251-
self.STRING_TYPE = self.ecore_graph.get_class_by_name("str")
1252-
self.BOOL_TYPE = self.ecore_graph.get_class_by_name("bool")
1253-
self.LIST_TYPE = self.ecore_graph.get_class_by_name("list")
1254-
self.TUPLE_TYPE = self.ecore_graph.get_class_by_name("tuple")
1255-
self.DICT_TYPE = self.ecore_graph.get_class_by_name("dict")
1256-
self.SET_TYPE = self.ecore_graph.get_class_by_name("set")
1257-
1258-
def get_class_by_type(self, type_obj):
1259-
return self.ecore_graph.get_class_by_name(type_obj.__name__)
1260-
12611259
def visit_Import(self, node):
12621260
"""
12631261
Visits an import statement in the AST.

0 commit comments

Comments
 (0)