feat: Add comprehensive Godot file type support

Complete support for all Godot file types:
- GDScript (.gd) - Regex-based parser for Godot-specific syntax
- Godot Scenes (.tscn) - Node hierarchy and script attachments
- Godot Resources (.tres) - Properties and dependencies
- Godot Shaders (.gdshader) - Uniforms and shader functions

Implementation details:
- Added 4 new analyzer methods to CodeAnalyzer class
  - _analyze_gdscript(): Functions, signals, @export vars, class_name
  - _analyze_godot_scene(): Node hierarchy, scripts, resources
  - _analyze_godot_resource(): Resource type, properties, script refs
  - _analyze_godot_shader(): Shader type, uniforms, varyings, functions

- Updated dependency_analyzer.py
  - Added _extract_godot_resources() for ext_resource and preload()
  - Fixed DependencyInfo calls (removed invalid 'alias' parameter)

- Updated codebase_scraper.py
  - Added Godot file extensions to LANGUAGE_EXTENSIONS
  - Extended content filter to accept Godot-specific keys
    (nodes, properties, uniforms, signals, exports)

Tested on Cosmic Ideler Godot project:
- 443/452 files successfully analyzed (98%)
- 265 GDScript, 118 .tscn, 38 .tres, 9 .gdshader, 13 .cs

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
yusyus
2026-02-02 21:36:56 +03:00
parent 583a774b00
commit b252f43d0e
3 changed files with 340 additions and 3 deletions

View File

@@ -111,6 +111,9 @@ class DependencyAnalyzer:
elif language == "GDScript":
# GDScript is Python-like, uses similar import syntax
deps = self._extract_python_imports(content, file_path)
elif language in ("GodotScene", "GodotResource", "GodotShader"):
# Godot resource files use ext_resource references
deps = self._extract_godot_resources(content, file_path)
elif language in ("JavaScript", "TypeScript"):
deps = self._extract_js_imports(content, file_path)
elif language in ("C++", "C"):
@@ -758,3 +761,48 @@ class DependencyAnalyzer:
[node for node in self.graph.nodes() if self.graph.in_degree(node) == 0]
),
}
def _extract_godot_resources(self, content: str, file_path: str) -> list[DependencyInfo]:
"""
Extract resource dependencies from Godot files (.tscn, .tres, .gdshader).
Extracts:
- ext_resource paths (scripts, scenes, textures, etc.)
- preload() and load() calls
"""
deps = []
# Extract ext_resource dependencies
for match in re.finditer(r'\[ext_resource.*?path="(.+?)".*?\]', content):
resource_path = match.group(1)
# Convert res:// paths to relative paths
if resource_path.startswith("res://"):
resource_path = resource_path[6:] # Remove res:// prefix
deps.append(
DependencyInfo(
source_file=file_path,
imported_module=resource_path,
import_type="ext_resource",
line_number=content[: match.start()].count("\n") + 1,
)
)
# Extract preload() and load() calls (in GDScript sections)
for match in re.finditer(r'(?:preload|load)\("(.+?)"\)', content):
resource_path = match.group(1)
if resource_path.startswith("res://"):
resource_path = resource_path[6:]
deps.append(
DependencyInfo(
source_file=file_path,
imported_module=resource_path,
import_type="preload",
line_number=content[: match.start()].count("\n") + 1,
)
)
return deps