@@ -8,11 +8,12 @@ use rustc_hash::FxHasher;
88
99use crate :: {
1010 helpers:: {
11- stream_and_get_source_and_map, stream_chunks_of_raw_source,
12- stream_chunks_of_source_map, GeneratedInfo , Stream , ToStream ,
11+ get_generated_source_info, stream_and_get_source_and_map,
12+ stream_chunks_of_raw_source, stream_chunks_of_source_map, GeneratedInfo ,
13+ Stream , ToStream ,
1314 } ,
1415 object_pool:: ObjectPool ,
15- source:: { IndexSourceMap , SourceValue } ,
16+ source:: { IndexSourceMap , Section , SectionOffset , SourceValue } ,
1617 BoxSource , MapOptions , RawBufferSource , Source , SourceExt , SourceMap ,
1718} ;
1819
@@ -257,7 +258,48 @@ impl Stream for CachedSourceStream<'_> {
257258 columns : bool ,
258259 on_section : crate :: helpers:: OnSection < ' _ , ' a > ,
259260 ) -> GeneratedInfo {
260- todo ! ( )
261+ let cell = if columns {
262+ & self . cache . columns_index_map
263+ } else {
264+ & self . cache . line_only_index_map
265+ } ;
266+ match cell. get ( ) {
267+ Some ( index_map) => {
268+ let generated_info =
269+ get_generated_source_info ( self . source . as_ref ( ) ) ;
270+ if let Some ( index_map) = index_map {
271+ for section in index_map. sections ( ) {
272+ on_section ( section. offset , Some ( section. map . clone ( ) ) ) ;
273+ }
274+ } else {
275+ on_section ( SectionOffset :: default ( ) , None ) ;
276+ }
277+ generated_info
278+ }
279+ None => {
280+ let mut sections = Vec :: new ( ) ;
281+ let generated_info = self . stream . sections (
282+ object_pool,
283+ columns,
284+ & mut |offset, map| {
285+ if let Some ( ref map) = map {
286+ sections. push ( Section {
287+ offset,
288+ map : map. clone ( ) ,
289+ } ) ;
290+ }
291+ on_section ( offset, map) ;
292+ } ,
293+ ) ;
294+ let index_map = if sections. is_empty ( ) {
295+ None
296+ } else {
297+ Some ( IndexSourceMap :: new ( sections) )
298+ } ;
299+ cell. get_or_init ( || index_map) ;
300+ generated_info
301+ }
302+ }
261303 }
262304}
263305
0 commit comments