diff --git a/src/script/typescript_language.cpp b/src/script/typescript_language.cpp index e2148b3..f5df79c 100644 --- a/src/script/typescript_language.cpp +++ b/src/script/typescript_language.cpp @@ -38,6 +38,10 @@ constexpr const char *TS_CONTROL_FLOW_WORDS[] = { "finally", "for", "if", "return", "switch", "throw", "try", "while", "yield" }; +// Mirrors ScriptLanguage::TemplateLocation::TEMPLATE_BUILT_IN, which godot-cpp +// does not expose as a GDExtension enum. +constexpr int SCRIPT_TEMPLATE_ORIGIN_BUILT_IN = 0; + bool contains_word(const String &p_word, const char *const *p_words, size_t p_count) { const String word = p_word.strip_edges(); for (size_t i = 0; i < p_count; i++) { @@ -148,6 +152,7 @@ Dictionary make_template_entry(const String &p_inherit, const String &p_name, co entry["description"] = p_description; entry["content"] = p_content; entry["id"] = p_id; + entry["origin"] = SCRIPT_TEMPLATE_ORIGIN_BUILT_IN; return entry; } diff --git a/test/test_repository_integrity.py b/test/test_repository_integrity.py index 547e8b5..f2f1f2c 100644 --- a/test/test_repository_integrity.py +++ b/test/test_repository_integrity.py @@ -1103,6 +1103,18 @@ def test_typescript_language_editor_surface_is_not_stubbed(self): self.assertNotIn("script->_get_global_name()", global_class_body) self.assertNotIn("script->get_base_class_name()", global_class_body) + def test_typescript_builtin_template_entries_include_godot_required_fields(self): + source = (ROOT / "src/script/typescript_language.cpp").read_text(encoding="utf-8") + match = re.search(r"Dictionary make_template_entry\(.*?\n\}", source, re.DOTALL) + self.assertIsNotNone(match) + body = match.group(0) + + for key in ("inherit", "name", "description", "content", "id", "origin"): + self.assertIn(f'entry["{key}"]', body) + self.assertIn("SCRIPT_TEMPLATE_ORIGIN_BUILT_IN", source) + self.assertIn('entry["origin"] = SCRIPT_TEMPLATE_ORIGIN_BUILT_IN;', body) + self.assertNotIn('entry["origin"] = 0;', body) + def test_typescript_metadata_parser_resolves_project_imports_like_compiler(self): source = (ROOT / "src/script/typescript_script.cpp").read_text(encoding="utf-8")