Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/script/typescript_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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;
}

Expand Down
12 changes: 12 additions & 0 deletions test/test_repository_integrity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down