MCPcopy Create free account
hub / github.com/rolldown/rolldown / replace_sourcemap

Function replace_sourcemap

crates/string_wizard/tests/magic_string_replace.rs:74–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72
73#[test]
74fn replace_sourcemap() {
75 let code = "* 2 * 4";
76 let mut s = MagicString::new(code);
77
78 s.replace_with("*", "#", ReplaceOptions { count: usize::MAX, store_original_in_sourcemap: true })
79 .unwrap();
80
81 let output = s.to_string();
82 let sourcemap = s.source_map(SourceMapOptions {
83 source: code.to_string().into(),
84 include_content: true,
85 ..Default::default()
86 });
87 println!("sourcemap {sourcemap:#?}");
88 let visualizer = SourcemapVisualizer::new(&output, &sourcemap);
89 assert_eq!(s.to_string(), "# 2 # 4");
90 insta::assert_snapshot!("sourcemap", visualizer.get_text());
91}

Callers

nothing calls this directly

Calls 4

unwrapMethod · 0.80
replace_withMethod · 0.80
source_mapMethod · 0.80
to_stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…