@@ -35,11 +35,13 @@ func _export_file(path: String, type: String, features: PackedStringArray) -> vo
35
35
var method_first_line_start := get_index_at_method_start (method .name , source_code )
36
36
if method_first_line_start == - 1 or method .name in method_store :
37
37
continue
38
-
38
+
39
39
if not is_func_moddable (method_first_line_start , source_code ):
40
40
continue
41
-
42
- # print(method.flags)
41
+
42
+ if is_setter (method .name , source_code ):
43
+ continue
44
+
43
45
var type_string := get_return_type_string (method .return )
44
46
var is_static := true if method .flags == METHOD_FLAG_STATIC + METHOD_FLAG_NORMAL else false
45
47
var method_arg_string_with_defaults_and_types := get_function_parameters (method .name , source_code , is_static )
@@ -62,11 +64,11 @@ func _export_file(path: String, type: String, features: PackedStringArray) -> vo
62
64
method_store .push_back (method .name )
63
65
source_code = prefix_method_name (method .name , is_static , source_code )
64
66
source_code_additions += "\n %s " % mod_loader_hook_string
65
-
67
+
66
68
# if we have some additions to the code, append them at the end
67
69
if source_code_additions != "" :
68
70
source_code = "%s \n %s \n %s " % [source_code ,mod_loader_hooks_start_string , source_code_additions ]
69
-
71
+
70
72
skip ()
71
73
add_file (path , source_code .to_utf8_buffer (), false )
72
74
@@ -91,7 +93,7 @@ static func get_function_arg_name_string(args: Array) -> String:
91
93
arg_string += args [x ].name
92
94
else :
93
95
arg_string += "%s , " % args [x ].name
94
-
96
+
95
97
return arg_string
96
98
97
99
@@ -207,7 +209,7 @@ static func get_previous_line_to(text: String, index: int) -> String:
207
209
208
210
if start_index == 0 :
209
211
return ""
210
-
212
+
211
213
start_index -= 1
212
214
213
215
# Find the start of the previous line
@@ -254,10 +256,29 @@ static func get_return_type_string(return_data: Dictionary) -> String:
254
256
return ""
255
257
var type_base
256
258
if return_data .has ("class_name" ) and not str (return_data .class_name ).is_empty ():
257
- type_base = str (return_data .class_name )
259
+ type_base = str (return_data .class_name )
258
260
else :
259
261
type_base = type_string (return_data .type )
260
-
262
+
261
263
var type_hint = "" if return_data .hint_string .is_empty () else ("[%s ]" % return_data .hint_string )
262
264
263
265
return "%s%s " % [type_base , type_hint ]
266
+
267
+
268
+ func is_setter (method_name : String , text : String , offset := 0 ) -> bool :
269
+ var pattern := "set\\ s*=\\ s*%s " % method_name
270
+ var regex := RegEx .new ()
271
+ regex .compile (pattern )
272
+
273
+ var result := regex .search (text , offset )
274
+
275
+ if result :
276
+ var line_start_index := text .rfind ("\n " , result .get_start ()) + 1
277
+ var line_start_string := text .substr (result .get_start (), result .get_start () - line_start_index )
278
+ if line_start_string .contains ("#" ):
279
+
280
+ return is_setter (method_name , text , result .get_end ())
281
+
282
+ return true
283
+
284
+ return false
0 commit comments