Skip to content

Commit f8c6dbe

Browse files
committed
feat: 🚧 added is_setter
used to ignore setter funcs
1 parent 0daeb0d commit f8c6dbe

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

addons/mod_loader/_export_plugin/export_plugin.gd

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ func _export_file(path: String, type: String, features: PackedStringArray) -> vo
3535
var method_first_line_start := get_index_at_method_start(method.name, source_code)
3636
if method_first_line_start == -1 or method.name in method_store:
3737
continue
38-
38+
3939
if not is_func_moddable(method_first_line_start, source_code):
4040
continue
41-
42-
#print(method.flags)
41+
42+
if is_setter(method.name, source_code):
43+
continue
44+
4345
var type_string := get_return_type_string(method.return)
4446
var is_static := true if method.flags == METHOD_FLAG_STATIC + METHOD_FLAG_NORMAL else false
4547
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
6264
method_store.push_back(method.name)
6365
source_code = prefix_method_name(method.name, is_static, source_code)
6466
source_code_additions += "\n%s" % mod_loader_hook_string
65-
67+
6668
#if we have some additions to the code, append them at the end
6769
if source_code_additions != "":
6870
source_code = "%s\n%s\n%s" % [source_code,mod_loader_hooks_start_string, source_code_additions]
69-
71+
7072
skip()
7173
add_file(path, source_code.to_utf8_buffer(), false)
7274

@@ -91,7 +93,7 @@ static func get_function_arg_name_string(args: Array) -> String:
9193
arg_string += args[x].name
9294
else:
9395
arg_string += "%s, " % args[x].name
94-
96+
9597
return arg_string
9698

9799

@@ -207,7 +209,7 @@ static func get_previous_line_to(text: String, index: int) -> String:
207209

208210
if start_index == 0:
209211
return ""
210-
212+
211213
start_index -= 1
212214

213215
# Find the start of the previous line
@@ -254,10 +256,29 @@ static func get_return_type_string(return_data: Dictionary) -> String:
254256
return ""
255257
var type_base
256258
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)
258260
else:
259261
type_base = type_string(return_data.type)
260-
262+
261263
var type_hint = "" if return_data.hint_string.is_empty() else ("[%s]" % return_data.hint_string)
262264

263265
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

Comments
 (0)