godotengine / godotengine/godot

ResourceFormatLoaderGDScript::get_dependencies always returns an empty list

Open
#90,643 4 comments 8 reactions 0 assignees View on GitHub
enhancement topic:gdscript
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in Godot_v4.3-dev5_linux.x86_64
- Reproducible in Godot_v4.2.1-stable_linux.x86_64

### System information

Godot v4.2.1.stable - Ubuntu 22.04.4 LTS 22.04 - X11 - Vulkan (Forward+) - integrated Intel(R) Graphics (ADL GT2) () - 12th Gen Intel(R) Core(TM) i7-12700H (14 Threads)

### Issue description

When porting https://github.com/jamie-pate/godot-code-coverage to godot4 I found that `ResourceLoader.get_dependencies("res://script.gd")` now returns empty for all scripts.

In godot3 the dependencies were tracked in `gdscript_parser.cpp`, but now there is just a TODO comment in `gdscript_parser.h`:
```
const List get_dependencies() const {
// TODO: Keep track of deps.
return List();
}
```

Workaround: I guess I'll have to find `preload` and `load` using regex which won't work for dynamic loading

### Steps to reproduce

* Create a script "some_script.gd" with a `preload("res://other_script.gd")` statement
* call `var deps = ResourceLoader.get_dependencies("res://some_script.gd")`.
The deps should have one member "res://other_script.gd"

### Minimal reproduction project (MRP)

[gdscript_parser_get_dependencies.zip](https://github.com/godotengine/godot/files/14968673/gdscript_parser_get_dependencies.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.