feat(extractors): add GDScript (.gd) + Godot scene/resource (.tscn/.t…#1929
Open
ozdemirsarman wants to merge 1 commit into
Open
feat(extractors): add GDScript (.gd) + Godot scene/resource (.tscn/.t…#1929ozdemirsarman wants to merge 1 commit into
ozdemirsarman wants to merge 1 commit into
Conversation
…res/project.godot) extraction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add GDScript + Godot scene/resource extraction
Adds first-class support for Godot Engine projects: GDScript (
.gd) ASTextraction plus a grammar-free extractor for Godot's scene/resource/project
text formats (
.tscn,.tres,project.godot). This closes the gap where aGodot codebase currently contributes almost nothing to the graph.
What's new
GDScript (
.gd) —graphify/extractors/gdscript.py(tree-sitter-gdscript)class_name Foo/ innerclass Foodefinesextends Bar/extends "res://x.gd"extendsedge (res:// resolved)func f(): …definesfoo()/obj.method()in a bodycallsedges (local funcs resolved)Autoload.method()callsedge resolved to the function in the autoload's script (autoload map read fromproject.godot)signal s(args)declaresemit_signal("s")/s.emit()emitsedges.connect(handler)connectsedge (handler resolved to local func)preload("res://y.gd")/load(...)importsedge (res:// resolved)Godot scenes/resources/project —
graphify/extractors/godot_scene.py(no grammar; line parser)[ext_resource type="Script" path="res://x.gd"]attaches_scriptedge[ext_resource type="PackedScene" path="res://y.tscn"]instancesedgescript = ExtResource("id")on a nodeattaches_script[connection signal="s" from="A" to="." method="m"]connectsedge, resolved to the target script's function nodeproject.godot [autoload]autoload+scriptedgesproject.godot run/main_scenemain_sceneedgeThe scene
[connection]→ function resolution is the payoff Godot devs can'tget from GDScript-only tooling: signal wires defined in
.tscnfiles linkstraight to the handler
funcin the.gdfile, because both sides mint thesame
_make_id(script_stem, method)node id.Wiring (mirrors every other language)
graphify/extractors/gdscript.py,graphify/extractors/godot_scene.py(new)detect.py:.gd .tscn .tres .godotadded toCODE_EXTENSIONSextract.py: facade re-exports +_DISPATCHentriesextractors/__init__.py:LANGUAGE_EXTRACTORSregistry entriespyproject.toml: optionalgodot = ["tree-sitter-gdscript"]extraREADME.md: language table updatedGraceful degradation
Both extractors are safe without the grammar.
.gdreturns a bare file nodewhen tree-sitter-gdscript is absent (same pattern as
sql/pascal), and thescene extractor needs no grammar at all — so scene/autoload/signal-wire edges
always work.
Tests
tests/test_gdscript.py(skipped when the grammar is absent) andtests/test_godot_scene.py(always runs) cover every relation above, plus theregistry-identity sweep in
test_extractors_registry.pyauto-covers the two newregistry entries. All fixtures are synthetic; no third-party project code.
Open question for maintainers — grammar packaging
tree-sitter-gdscript(PrestonKnopp, MIT) is not yet published to PyPI as astandalone wheel, though its repo ships working Python bindings and builds from
source cleanly. The
.gdloader therefore triestree_sitter_gdscriptfirstand falls back to a grammar from
tree-sitter-language-pack. I'm happy to (a)publish
tree-sitter-gdscriptto PyPI with proper attribution, or (b) switchthe
godotextra to whatever dependency you prefer — let me know. The.tscnhalf needs no grammar regardless.