@@ -2,18 +2,13 @@ use std::{
22 borrow:: { BorrowMut , Cow } ,
33 cell:: { OnceCell , RefCell } ,
44 marker:: PhantomData ,
5- ops:: Range ,
5+ ops:: Range , rc :: Rc ,
66} ;
77
88use rustc_hash:: FxHashMap as HashMap ;
99
1010use crate :: {
11- decoder:: MappingsDecoder ,
12- encoder:: create_encoder,
13- linear_map:: LinearMap ,
14- source:: { Mapping , OriginalLocation } ,
15- with_indices:: WithIndices ,
16- MapOptions , Rope , SourceMap ,
11+ decoder:: MappingsDecoder , encoder:: create_encoder, linear_map:: LinearMap , source:: { Mapping , OriginalLocation } , with_indices:: WithIndices , work_context:: { self , WorkContext } , MapOptions , Rope , SourceMap
1712} ;
1813
1914// Adding this type because sourceContentLine not happy
@@ -33,6 +28,7 @@ pub fn get_map<'a, S: StreamChunks>(
3328 & MapOptions {
3429 columns : options. columns ,
3530 final_source : true ,
31+ work_context : options. work_context . clone ( ) ,
3632 } ,
3733 // on_chunk
3834 & mut |_, mapping| {
@@ -317,24 +313,28 @@ where
317313 MapOptions {
318314 columns : true ,
319315 final_source : true ,
316+ ..
320317 } => stream_chunks_of_source_map_final (
321318 source, source_map, on_chunk, on_source, on_name,
322319 ) ,
323320 MapOptions {
324321 columns : true ,
325322 final_source : false ,
323+ work_context
326324 } => stream_chunks_of_source_map_full (
327- source, source_map, on_chunk, on_source, on_name,
325+ work_context . clone ( ) , source, source_map, on_chunk, on_source, on_name,
328326 ) ,
329327 MapOptions {
330328 columns : false ,
331329 final_source : true ,
330+ ..
332331 } => stream_chunks_of_source_map_lines_final (
333332 source, source_map, on_chunk, on_source, on_name,
334333 ) ,
335334 MapOptions {
336335 columns : false ,
337336 final_source : false ,
337+ ..
338338 } => stream_chunks_of_source_map_lines_full (
339339 source, source_map, on_chunk, on_source, on_name,
340340 ) ,
@@ -413,6 +413,7 @@ where
413413}
414414
415415fn stream_chunks_of_source_map_full < ' a , S > (
416+ work_context : Rc < WorkContext > ,
416417 source : S ,
417418 source_map : & ' a SourceMap ,
418419 on_chunk : OnChunk < ' _ , ' a > ,
@@ -423,7 +424,7 @@ where
423424 S : SourceText < ' a > + ' a ,
424425{
425426 let lines = split_into_lines ( & source) ;
426- let line_with_indices_list = lines. map ( WithIndices :: new) . collect :: < Vec < _ > > ( ) ;
427+ let line_with_indices_list = lines. map ( |line| WithIndices :: new ( work_context . clone ( ) , line ) ) . collect :: < Vec < _ > > ( ) ;
427428
428429 if line_with_indices_list. is_empty ( ) {
429430 return GeneratedInfo {
@@ -710,6 +711,7 @@ type InnerSourceIndexValueMapping<'a> =
710711
711712#[ allow( clippy:: too_many_arguments) ]
712713pub fn stream_chunks_of_combined_source_map < ' a , S > (
714+ work_context : Rc < WorkContext > ,
713715 source : S ,
714716 source_map : & ' a SourceMap ,
715717 inner_source_name : & ' a str ,
@@ -830,7 +832,7 @@ where
830832 match inner_source_contents. get ( & inner_source_index) {
831833 Some ( Some ( source_content) ) => Some (
832834 split_into_lines ( source_content)
833- . map ( WithIndices :: new)
835+ . map ( |line| WithIndices :: new ( work_context . clone ( ) , line ) )
834836 . collect ( ) ,
835837 ) ,
836838 _ => None ,
@@ -930,7 +932,7 @@ where
930932 match inner_source_contents. get ( & inner_source_index) {
931933 Some ( Some ( source_content) ) => Some (
932934 split_into_lines ( source_content)
933- . map ( WithIndices :: new)
935+ . map ( |line| WithIndices :: new ( work_context . clone ( ) , line ) )
934936 . collect ( ) ,
935937 ) ,
936938 _ => None ,
@@ -1167,6 +1169,7 @@ where
11671169 & MapOptions {
11681170 columns : options. columns ,
11691171 final_source : false ,
1172+ work_context : options. work_context . clone ( ) ,
11701173 } ,
11711174 ) ;
11721175 } else {
0 commit comments