Skip to content

feat(parser): detect class-name expressions, parse .tres, resolve autoload singletons#21

Merged
LeTuR merged 1 commit into
mainfrom
claude/detect-all-class-names-H26yQ
Apr 29, 2026
Merged

feat(parser): detect class-name expressions, parse .tres, resolve autoload singletons#21
LeTuR merged 1 commit into
mainfrom
claude/detect-all-class-names-H26yQ

Conversation

@LeTuR

@LeTuR LeTuR commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes the rule-coverage gap where .gdcruiser.json rules only saw extends, preload(), and load(). Three S-tier detections so architectural rules natively cover everything that previously needed a separate pre-commit hook.

Class-name expressions in GDScript

  • Typed annotations: var x: Foo, func f(c: Foo) -> Foo
  • Generic params: Array[Foo], Dictionary[String, Foo]
  • Type checks / casts: obj is Foo, obj as Foo
  • Static / constant access: Foo.method(), Foo.CONST

Refs are resolved against the project symbol table; built-ins and unresolved identifiers are dropped to keep the graph clean. New CLASS_REF dependency type plus an expanded built-ins list (~250 entries).

.tres resource parsing

  • script_class="..." from the [gd_resource] header registers the resource in the symbol table.
  • Every [ext_resource path="res://..."] is captured — scripts become SCENE_SCRIPT edges, other resource refs become a new RESOURCE_REF edge — so rules now cover the data layer.
  • Scanner walks *.tres; analyzer parses them after .tscn.

Autoload singletons (project.godot)

  • Reads the [autoload] section and registers each identifier in the symbol table before class-ref resolution runs.
  • TurnManager.advance(), EventBus.emit_signal(...), etc. then resolve via the same MEMBER_ACCESS pattern as any other class reference.
  • Both *Identifier="*res://..." (enabled singleton) and bare entries are parsed; section-scoped so look-alike lines under other sections are ignored.
  • References inside string literals and comments are sanitized away — explicit regression tests for both.

Ancillary

  • DOT and Mermaid formatters got uses / resource edge labels.
  • README updated with the new pattern table, .tres section, and autoload section.

Test plan

  • uv run pytest — 140 tests pass (39 new)
  • uv run ruff check . clean
  • uv run ruff format --check . clean
  • uv run gdcruiser tests/fixtures --no-cycles shows new class_ref edges (e.g. enemy.gd → player.gd from var target: Player) and heal_skill.tres in the graph
  • uv run gdcruiser tests/fixtures/autoload_project --no-cycles resolves TurnManager.advance() and EventBus.something_happened to their backing scripts; in-string and in-comment references absent

Generated by Claude Code

Read the `[autoload]` section of `project.godot` at analysis start and
register each identifier in the symbol table. The class-ref pipeline
landed in the previous commit then resolves `TurnManager.advance()`,
`EventBus.emit_signal(...)`, and any other autoload-prefixed member
access to its backing script — so an existing rule like
`forbidden: { from: scripts/skills/, to: scripts/autoload/ }` fires
without any auxiliary tooling.

Both `*` (enabled singleton) and bare entries are parsed; only the
`[autoload]` section is read so look-alike lines under other sections
don't leak through. References inside string literals or comments are
already filtered by the class-ref sanitizer; added explicit regression
tests covering both.
@LeTuR
LeTuR force-pushed the claude/detect-all-class-names-H26yQ branch from 8859f59 to 429ee35 Compare April 29, 2026 14:41
@LeTuR
LeTuR merged commit 53ffa58 into main Apr 29, 2026
2 checks passed
@LeTuR
LeTuR deleted the claude/detect-all-class-names-H26yQ branch April 29, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants