Fix synchronization of global class name
This commit is contained in:
@@ -2759,7 +2759,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b
|
||||
String source = f->get_as_utf8_string();
|
||||
|
||||
GDScriptParser parser;
|
||||
err = parser.parse(source, p_path, false);
|
||||
err = parser.parse(source, p_path, false, false);
|
||||
|
||||
const GDScriptParser::ClassNode *c = parser.get_tree();
|
||||
if (!c) {
|
||||
|
||||
@@ -309,13 +309,14 @@ void GDScriptParser::set_last_completion_call_arg(int p_argument) {
|
||||
completion_call_stack.back()->get().argument = p_argument;
|
||||
}
|
||||
|
||||
Error GDScriptParser::parse(const String &p_source_code, const String &p_script_path, bool p_for_completion) {
|
||||
Error GDScriptParser::parse(const String &p_source_code, const String &p_script_path, bool p_for_completion, bool p_parse_body) {
|
||||
clear();
|
||||
|
||||
String source = p_source_code;
|
||||
int cursor_line = -1;
|
||||
int cursor_column = -1;
|
||||
for_completion = p_for_completion;
|
||||
parse_body = p_parse_body;
|
||||
|
||||
int tab_size = 4;
|
||||
#ifdef TOOLS_ENABLED
|
||||
@@ -689,6 +690,12 @@ void GDScriptParser::parse_program() {
|
||||
}
|
||||
}
|
||||
|
||||
// When the only thing needed is the class name and the icon, we don't need to parse the hole file.
|
||||
// It really speed up the call to GDScriptLanguage::get_global_class_name especially for large script.
|
||||
if (!parse_body) {
|
||||
return;
|
||||
}
|
||||
|
||||
#undef PUSH_PENDING_ANNOTATIONS_TO_HEAD
|
||||
|
||||
parse_class_body(true);
|
||||
|
||||
@@ -1329,6 +1329,7 @@ private:
|
||||
bool _is_tool = false;
|
||||
String script_path;
|
||||
bool for_completion = false;
|
||||
bool parse_body = true;
|
||||
bool panic_mode = false;
|
||||
bool can_break = false;
|
||||
bool can_continue = false;
|
||||
@@ -1560,7 +1561,7 @@ private:
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
public:
|
||||
Error parse(const String &p_source_code, const String &p_script_path, bool p_for_completion);
|
||||
Error parse(const String &p_source_code, const String &p_script_path, bool p_for_completion, bool p_parse_body = true);
|
||||
Error parse_binary(const Vector<uint8_t> &p_binary, const String &p_script_path);
|
||||
ClassNode *get_tree() const { return head; }
|
||||
bool is_tool() const { return _is_tool; }
|
||||
|
||||
Reference in New Issue
Block a user