Maran23 / script-ide

Script-IDE is a plugin for Godot. It transforms the Script UI into an IDE like UI. Tabs are used for navigating between scripts. The default Outline got an overhaul and now shows all members of the script (not just methods) with unique icons for faster navigation.
MIT License
365 stars 16 forks source link

Setter function can't be located in source code #31

Closed farfalk closed 10 months ago

farfalk commented 10 months ago

Hi, thank you for your work!

The issue happens with all setters associated with exported properties. I will give an easy to replicate example.

The code:

@export var max_height: float = 1.0 :
    set(value):
        max_height = value
        _update_height()

The setter is shown as @max_height_setter with a green tag in the lateral panel.

The error, when clicking on @max_height_setter:

func core/variant/variant_utility.cpp:1091 - func @max_height_setter( or static not found in source code

My system: Windows 10 latest update, Godot 4.2.1 stable

farfalk commented 10 months ago

As an easy workaround, it's possible to add:

if (('func @' in type_with_text) and ('_setter(' in type_with_text)):
    # This is a setter of a variable. Trim!
    type_with_text = "var " + type_with_text.trim_prefix('func @').trim_suffix('_setter(')

here: https://github.com/Maran23/script-ide/blob/aba268f58cc397e59bd3762332a5e45384c9b5bc/addons/script-ide/plugin.gd#L387 like this:

[...]
var type_with_text: String = type + " " + text
if (type == "func"):
    type_with_text = type_with_text + "("   

if (('func @' in type_with_text) and ('_setter(' in type_with_text)):
    # This is a setter of a variable. Trim!
    type_with_text = "var " + type_with_text.trim_prefix('func @').trim_suffix('_setter(')

var source_code: String = script.get_source_code()
[...]
Maran23 commented 10 months ago

Interesting, I did not tested it with inline getter or setters yet. I'm always using e.g. set = set_speed, get = get_speed.

I will check this out soon, thanks for the report!