refactor: introduce uri_for_id and deref_syntax_at (#267)

* dev: add documentation

* refactor: introduce uri_for_id and deref_syntax_at
This commit is contained in:
Myriad-Dreamin 2024-05-09 12:32:20 +08:00 committed by GitHub
parent 6d669461f9
commit e2b7bc4b56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 236 additions and 174 deletions

View file

@ -28,7 +28,7 @@ fn convert_diagnostic(
let uri;
let lsp_range;
if let Some((id, span)) = diagnostic_span_id(typst_diagnostic) {
uri = path_to_url(&ctx.path_for_id(id)?)?;
uri = ctx.uri_for_id(id)?;
let source = ctx.world().source(id)?;
lsp_range = diagnostic_range(&source, span, ctx.position_encoding());
} else {
@ -63,7 +63,7 @@ fn tracepoint_to_relatedinformation(
position_encoding: PositionEncoding,
) -> anyhow::Result<Option<DiagnosticRelatedInformation>> {
if let Some(id) = tracepoint.span.id() {
let uri = path_to_url(&project.path_for_id(id)?)?;
let uri = project.uri_for_id(id)?;
let source = project.world().source(id)?;
if let Some(typst_range) = source.range(tracepoint.span) {