Skip to content

Introduce a typed DocumentUri identifier #353

Description

@Firehed

Document URIs are currently passed as bare string throughout the codebase — e.g. DocumentManager::get(string $uri), the uri field on the new TextDocumentPositionParams value object (#352), and every handler that extracts textDocument.uri. This is stringly-typed: a document URI, a class name, and an arbitrary string are indistinguishable to the type system, and nothing prevents an unrelated string from being passed where a URI is expected.

Proposal

Introduce a DocumentUri value object (likely in src/Protocol/ or src/Document/) and thread it through the URI-handling surface:

  • DocumentManager::get() / storage keys
  • TextDocumentPositionParams::$uri
  • Handler param extraction and any TextDocumentSyncHandler open/change/close paths
  • Location/definition results that carry a URI back to the client

Notes

  • This is a broader refactor than the Extract TextDocumentPositionParams value object #352 extraction, which deliberately preserved the existing string type to stay in scope.
  • Worth deciding up front whether DocumentUri should validate/normalize (file:// scheme, percent-encoding) or remain a thin wrapper, and whether it should be introduced incrementally (one boundary at a time) to keep diffs reviewable.

This issue body was written by AI (Claude Code) at the request of the maintainer.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions