Skip to content

feature: add source map support for Go to Definition navigation - #9

Merged
joshmanders merged 8 commits into
masterfrom
feature-goto-def-support
Jan 11, 2026
Merged

feature: add source map support for Go to Definition navigation#9
joshmanders merged 8 commits into
masterfrom
feature-goto-def-support

Conversation

@joshmanders

Copy link
Copy Markdown
Contributor

Summary

Add source mapping support to enable "Go to Definition" navigation from generated TypeScript types back to the original PHP source files. (closes #8)

Features

  • Generate .d.ts.map source map files for each enum and resource type
  • Add JSDoc @see comments with PHP file references for hover documentation
  • Track source locations (file, line, column) during PHP AST parsing
  • Support field-level precision for navigating to specific properties

Changes

  • Source Map Utility: New VLQ encoder and source map generator (src/utils/source-map.ts)
  • PHP Parser: Enable AST position tracking and capture source locations for enums, enum cases, and resource fields
  • Enum Generator: Generate individual .d.ts, .d.ts.map, and .js files with JSDoc comments
  • Resource Generator: Generate individual .d.ts, .d.ts.map, and .js files with JSDoc comments
  • File Utility: Clean up .d.ts.map files during regeneration
  • Deprecated Functions Removed: Removed generateEnumTypeScript, generateEnumRuntime, and generateResourceTypeScript in favor of single-file generation functions

Generated Output Example

// UserResource.d.ts
/** @see app/Http/Resources/UserResource.php */
export type UserResource = {
    id: string;
    name: string;
    email: string;
};
//# sourceMappingURL=UserResource.d.ts.map

Test Plan

  • All 115 tests pass
  • Source map VLQ encoding tests
  • PHP parser source location tracking tests
  • Enum and resource generator tests with exact output matching

joshmanders and others added 8 commits January 11, 2026 00:47
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
@joshmanders joshmanders changed the title Support Go to Definition feature: add source map support for Go to Definition navigation Jan 11, 2026
@joshmanders
joshmanders merged commit f0d07eb into master Jan 11, 2026
1 check passed
@joshmanders
joshmanders deleted the feature-goto-def-support branch January 11, 2026 08:54
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.

go to definition support

1 participant