Skip to content

Add SourceMap::resolve_span for resolving global span locations#2559

Merged
alexcrichton merged 5 commits into
bytecodealliance:mainfrom
PhoebeSzmucer:resolve-span
Jul 7, 2026
Merged

Add SourceMap::resolve_span for resolving global span locations#2559
alexcrichton merged 5 commits into
bytecodealliance:mainfrom
PhoebeSzmucer:resolve-span

Conversation

@PhoebeSzmucer

Copy link
Copy Markdown
Contributor

This PR adds SourceMap::resolve_span(Span) -> Option<SpanLocation>, which resolves a global span to its source file and a file-local byte range. This makes it possible for consumers of wit-parser to get precise error locations.

///
/// Spans pointing at the end of a file resolve to an empty range at the
/// file's length.
pub fn resolve_span(&self, span: Span) -> Option<SpanLocation<'_>> {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LSP will call this method for spans that we get from structured errors.

@PhoebeSzmucer PhoebeSzmucer marked this pull request as ready for review July 7, 2026 08:37
@PhoebeSzmucer PhoebeSzmucer requested a review from a team as a code owner July 7, 2026 08:37
@PhoebeSzmucer PhoebeSzmucer requested review from fitzgen and removed request for a team July 7, 2026 08:37
@alexcrichton alexcrichton added this pull request to the merge queue Jul 7, 2026
Merged via the queue into bytecodealliance:main with commit 2f82130 Jul 7, 2026
37 checks passed
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