Revert "GDScript: Implement get_dependencies()"
This reverts commit dc73440f89
.
This commit in some form is needed to fix handling of dependencies on
export, but as it's also used for import, it's exposing some pre-existing
issues which we need to solve first.
So reverting for now to give ourselves time to iron this out for a future
Godot release.
Fixes #91726.
This commit is contained in:
parent
de196227e1
commit
0a67ee52d1
4 changed files with 7 additions and 29 deletions
|
@ -2919,7 +2919,7 @@ String ResourceFormatLoaderGDScript::get_resource_type(const String &p_path) con
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<String> *r_dependencies, bool p_add_types) {
|
void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
|
||||||
Ref<FileAccess> file = FileAccess::open(p_path, FileAccess::READ);
|
Ref<FileAccess> file = FileAccess::open(p_path, FileAccess::READ);
|
||||||
ERR_FAIL_COND_MSG(file.is_null(), "Cannot open file '" + p_path + "'.");
|
ERR_FAIL_COND_MSG(file.is_null(), "Cannot open file '" + p_path + "'.");
|
||||||
|
|
||||||
|
@ -2933,13 +2933,8 @@ void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<S
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScriptAnalyzer analyzer(&parser);
|
|
||||||
if (OK != analyzer.analyze()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const String &E : parser.get_dependencies()) {
|
for (const String &E : parser.get_dependencies()) {
|
||||||
r_dependencies->push_back(E);
|
p_dependencies->push_back(E);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -638,7 +638,7 @@ public:
|
||||||
virtual void get_recognized_extensions(List<String> *p_extensions) const override;
|
virtual void get_recognized_extensions(List<String> *p_extensions) const override;
|
||||||
virtual bool handles_type(const String &p_type) const override;
|
virtual bool handles_type(const String &p_type) const override;
|
||||||
virtual String get_resource_type(const String &p_path) const override;
|
virtual String get_resource_type(const String &p_path) const override;
|
||||||
virtual void get_dependencies(const String &p_path, List<String> *r_dependencies, bool p_add_types = false) override;
|
virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ResourceFormatSaverGDScript : public ResourceFormatSaver {
|
class ResourceFormatSaverGDScript : public ResourceFormatSaver {
|
||||||
|
|
|
@ -562,11 +562,6 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c
|
||||||
class_type.native_type = result.native_type;
|
class_type.native_type = result.native_type;
|
||||||
p_class->set_datatype(class_type);
|
p_class->set_datatype(class_type);
|
||||||
|
|
||||||
// Add base class to the list of dependencies.
|
|
||||||
if (result.kind == GDScriptParser::DataType::CLASS) {
|
|
||||||
parser->add_dependency(result.script_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply annotations.
|
// Apply annotations.
|
||||||
for (GDScriptParser::AnnotationNode *&E : p_class->annotations) {
|
for (GDScriptParser::AnnotationNode *&E : p_class->annotations) {
|
||||||
resolve_annotation(E);
|
resolve_annotation(E);
|
||||||
|
@ -873,11 +868,6 @@ GDScriptParser::DataType GDScriptAnalyzer::resolve_datatype(GDScriptParser::Type
|
||||||
}
|
}
|
||||||
|
|
||||||
p_type->set_datatype(result);
|
p_type->set_datatype(result);
|
||||||
|
|
||||||
if (result.kind == GDScriptParser::DataType::CLASS || result.kind == GDScriptParser::DataType::SCRIPT) {
|
|
||||||
parser->add_dependency(result.script_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4112,7 +4102,6 @@ void GDScriptAnalyzer::reduce_identifier(GDScriptParser::IdentifierNode *p_ident
|
||||||
|
|
||||||
if (ScriptServer::is_global_class(name)) {
|
if (ScriptServer::is_global_class(name)) {
|
||||||
p_identifier->set_datatype(make_global_class_meta_type(name, p_identifier));
|
p_identifier->set_datatype(make_global_class_meta_type(name, p_identifier));
|
||||||
parser->add_dependency(p_identifier->get_datatype().script_path);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4155,7 +4144,6 @@ void GDScriptAnalyzer::reduce_identifier(GDScriptParser::IdentifierNode *p_ident
|
||||||
}
|
}
|
||||||
result.is_constant = true;
|
result.is_constant = true;
|
||||||
p_identifier->set_datatype(result);
|
p_identifier->set_datatype(result);
|
||||||
parser->add_dependency(autoload.path);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4275,6 +4263,7 @@ void GDScriptAnalyzer::reduce_preload(GDScriptParser::PreloadNode *p_preload) {
|
||||||
push_error("Preloaded path must be a constant string.", p_preload->path);
|
push_error("Preloaded path must be a constant string.", p_preload->path);
|
||||||
} else {
|
} else {
|
||||||
p_preload->resolved_path = p_preload->path->reduced_value;
|
p_preload->resolved_path = p_preload->path->reduced_value;
|
||||||
|
// TODO: Save this as script dependency.
|
||||||
if (p_preload->resolved_path.is_relative_path()) {
|
if (p_preload->resolved_path.is_relative_path()) {
|
||||||
p_preload->resolved_path = parser->script_path.get_base_dir().path_join(p_preload->resolved_path);
|
p_preload->resolved_path = parser->script_path.get_base_dir().path_join(p_preload->resolved_path);
|
||||||
}
|
}
|
||||||
|
@ -4305,8 +4294,6 @@ void GDScriptAnalyzer::reduce_preload(GDScriptParser::PreloadNode *p_preload) {
|
||||||
push_error(vformat(R"(Could not preload resource file "%s".)", p_preload->resolved_path), p_preload->path);
|
push_error(vformat(R"(Could not preload resource file "%s".)", p_preload->resolved_path), p_preload->path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parser->add_dependency(p_preload->resolved_path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1432,8 +1432,6 @@ private:
|
||||||
void reset_extents(Node *p_node, GDScriptTokenizer::Token p_token);
|
void reset_extents(Node *p_node, GDScriptTokenizer::Token p_token);
|
||||||
void reset_extents(Node *p_node, Node *p_from);
|
void reset_extents(Node *p_node, Node *p_from);
|
||||||
|
|
||||||
HashSet<String> dependencies;
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T *alloc_node() {
|
T *alloc_node() {
|
||||||
T *node = memnew(T);
|
T *node = memnew(T);
|
||||||
|
@ -1577,11 +1575,9 @@ public:
|
||||||
bool annotation_exists(const String &p_annotation_name) const;
|
bool annotation_exists(const String &p_annotation_name) const;
|
||||||
|
|
||||||
const List<ParserError> &get_errors() const { return errors; }
|
const List<ParserError> &get_errors() const { return errors; }
|
||||||
const HashSet<String> &get_dependencies() const {
|
const List<String> get_dependencies() const {
|
||||||
return dependencies;
|
// TODO: Keep track of deps.
|
||||||
}
|
return List<String>();
|
||||||
void add_dependency(const String &p_dependency) {
|
|
||||||
dependencies.insert(p_dependency);
|
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
const List<GDScriptWarning> &get_warnings() const { return warnings; }
|
const List<GDScriptWarning> &get_warnings() const { return warnings; }
|
||||||
|
|
Loading…
Reference in a new issue