You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
GDScript: Implement get_dependencies()
The parser and analyzer now track the dependencies of the script and return the list when the resource loader ask for them. What is considered a dependency: - Any `preload()` call. - The base script this one extends. - Any identifier, including types, that refers to global scripts. - Any autoload singleton reference.
This commit is contained in:
@@ -2884,7 +2884,7 @@ String ResourceFormatLoaderGDScript::get_resource_type(const String &p_path) con
|
||||
return "";
|
||||
}
|
||||
|
||||
void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
|
||||
void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<String> *r_dependencies, bool p_add_types) {
|
||||
Ref<FileAccess> file = FileAccess::open(p_path, FileAccess::READ);
|
||||
ERR_FAIL_COND_MSG(file.is_null(), "Cannot open file '" + p_path + "'.");
|
||||
|
||||
@@ -2898,8 +2898,13 @@ void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<S
|
||||
return;
|
||||
}
|
||||
|
||||
GDScriptAnalyzer analyzer(&parser);
|
||||
if (OK != analyzer.analyze()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const String &E : parser.get_dependencies()) {
|
||||
p_dependencies->push_back(E);
|
||||
r_dependencies->push_back(E);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user