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

Method source_map

crates/string_wizard/src/magic_string/source_map.rs:27–69  ·  view source on GitHub ↗
(&self, opts: SourceMapOptions)

Source from the content-addressed store, hash-verified

25
26impl MagicString<'_> {
27 pub fn source_map(&self, opts: SourceMapOptions) -> oxc_sourcemap::SourceMap<'static> {
28 let mut source_builder = SourcemapBuilder::new(opts.hires);
29
30 source_builder.set_source_and_content(&opts.source, &self.source);
31
32 let locator = Locator::new(&self.source);
33
34 self.intro.iter().for_each(|frag| {
35 source_builder.advance(frag);
36 });
37
38 let utf16_index_map =
39 precompute_utf16_index_map(&self.source, self.iter_chunks().map(|chunk| chunk.start()));
40
41 self.iter_chunks().for_each(|chunk| {
42 chunk.intro.iter().for_each(|frag| {
43 source_builder.advance(frag);
44 });
45 let name =
46 (chunk.keep_in_mappings && chunk.is_edited()).then(|| chunk.span.text(&self.source));
47
48 source_builder.add_chunk(
49 chunk,
50 utf16_index_map[&chunk.start()],
51 &locator,
52 &self.source,
53 name,
54 );
55
56 chunk.outro.iter().for_each(|frag| {
57 source_builder.advance(frag);
58 });
59 });
60
61 let mut source_map = source_builder.into_source_map();
62
63 if self.ignore_list {
64 // The source is always at index 0 for a single MagicString instance.
65 source_map.set_x_google_ignore_list(vec![0]);
66 }
67
68 source_map
69 }
70}
71
72fn precompute_utf16_index_map(

Callers 15

transformMethod · 0.80
render_chunkMethod · 0.80
transformMethod · 0.80
renderMethod · 0.80
render_chunkMethod · 0.80
render_chunkMethod · 0.80
generate_mapMethod · 0.80
generate_decoded_mapMethod · 0.80
transformMethod · 0.80
create_sourcemapMethod · 0.80
send_magic_stringMethod · 0.80

Calls 12

advanceMethod · 0.80
iter_chunksMethod · 0.80
thenMethod · 0.80
is_editedMethod · 0.80
textMethod · 0.80
into_source_mapMethod · 0.80
iterMethod · 0.45
mapMethod · 0.45
startMethod · 0.45
add_chunkMethod · 0.45

Tested by 4

basicFunction · 0.64
visualizeFunction · 0.64
replace_sourcemapFunction · 0.64