Skip to content

Commit a7e4818

Browse files
committed
use a resolver in a couple of places
1 parent e5ba202 commit a7e4818

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

crates/mdtest/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use colored::Colorize;
66
use parser::EmbeddedFileSourceMap;
77
use ruff_db::Db;
88
use ruff_db::files::File;
9-
use ruff_db::source::line_index;
109
use similar::{ChangeTag, TextDiff};
1110

1211
use ruff_db::diagnostic::{Diagnostic, DisplayDiagnosticConfig, FileResolver};
@@ -355,14 +354,15 @@ pub(crate) fn apply_snapshot_filters(rendered: &str) -> std::borrow::Cow<'_, str
355354
}
356355

357356
pub fn validate_inline_snapshot(
358-
db: &dyn ruff_db::Db,
357+
resolver: &dyn FileResolver,
359358
tool_name: &'static str,
360359
test_file: &TestFile<'_>,
361360
inline_diagnostics: &[Diagnostic],
362361
markdown_edits: &mut Vec<MarkdownEdit>,
363362
) -> Result<(), matcher::FailuresByLine> {
364363
let update_snapshots = is_update_inline_snapshots_enabled();
365-
let line_index = line_index(db, test_file.file);
364+
let input = resolver.input(test_file.file);
365+
let line_index = input.line_index();
366366
let mut failures = matcher::FailuresByLine::default();
367367
let mut inline_diagnostics = inline_diagnostics;
368368

@@ -416,8 +416,9 @@ pub fn validate_inline_snapshot(
416416
continue;
417417
};
418418

419-
let actual = apply_snapshot_filters(&render_diagnostics(&db, tool_name, block_diagnostics))
420-
.into_owned();
419+
let actual =
420+
apply_snapshot_filters(&render_diagnostics(resolver, tool_name, block_diagnostics))
421+
.into_owned();
421422

422423
let Some(snapshot_code_block) = code_block.inline_snapshot_block() else {
423424
if update_snapshots {

crates/ruff_db/src/diagnostic/render.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,12 @@ pub struct Input {
907907
pub(crate) line_index: LineIndex,
908908
}
909909

910+
impl Input {
911+
pub fn line_index(&self) -> &LineIndex {
912+
&self.line_index
913+
}
914+
}
915+
910916
/// Returns the line number accounting for the given `len`
911917
/// number of preceding context lines.
912918
///

0 commit comments

Comments
 (0)