Skip to content

Commit d9bdb87

Browse files
committed
rename
1 parent f0c5e32 commit d9bdb87

File tree

11 files changed

+108
-108
lines changed

11 files changed

+108
-108
lines changed

benches/bench_complex_replace_source.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub use criterion::*;
99
pub use codspeed_criterion_compat::*;
1010

1111
use rspack_sources::{
12-
stream_chunks::StreamChunks, BoxSource, CachedSource, MapOptions, ObjectPool,
12+
stream_chunks::ToStream, BoxSource, CachedSource, MapOptions, ObjectPool,
1313
OriginalSource, ReplaceSource, Source, SourceExt,
1414
};
1515

@@ -36737,7 +36737,7 @@ pub fn benchmark_complex_replace_source_map_cached_source_stream_chunks(
3673736737
cached_source.map(&ObjectPool::default(), &MapOptions::default());
3673836738

3673936739
b.iter(|| {
36740-
black_box(cached_source.stream_chunks().stream(
36740+
black_box(cached_source.to_stream().chunks(
3674136741
&ObjectPool::default(),
3674236742
&MapOptions::default(),
3674336743
&mut |_chunk, _mapping| {},

src/cached_source.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_hash::FxHasher;
99
use crate::{
1010
helpers::{
1111
stream_and_get_source_and_map, stream_chunks_of_raw_source,
12-
stream_chunks_of_source_map, Chunks, GeneratedInfo, StreamChunks,
12+
stream_chunks_of_source_map, Stream, GeneratedInfo, ToStream,
1313
},
1414
object_pool::ObjectPool,
1515
source::{IndexSourceMap, SourceValue},
@@ -182,26 +182,26 @@ impl Source for CachedSource {
182182
}
183183
}
184184

185-
struct CachedSourceChunks<'source> {
186-
chunks: Box<dyn Chunks + 'source>,
185+
struct CachedSourceStream<'source> {
186+
stream: Box<dyn Stream + 'source>,
187187
cache: Arc<CachedData>,
188188
source: Cow<'source, str>,
189189
}
190190

191-
impl<'a> CachedSourceChunks<'a> {
191+
impl<'a> CachedSourceStream<'a> {
192192
fn new(cache_source: &'a CachedSource) -> Self {
193193
let source = cache_source.source().into_string_lossy();
194194

195195
Self {
196-
chunks: cache_source.inner.stream_chunks(),
196+
stream: cache_source.inner.to_stream(),
197197
cache: cache_source.cache.clone(),
198198
source,
199199
}
200200
}
201201
}
202202

203-
impl Chunks for CachedSourceChunks<'_> {
204-
fn stream<'a>(
203+
impl Stream for CachedSourceStream<'_> {
204+
fn chunks<'a>(
205205
&'a self,
206206
object_pool: &'a ObjectPool,
207207
options: &MapOptions,
@@ -240,7 +240,7 @@ impl Chunks for CachedSourceChunks<'_> {
240240
let (generated_info, map) = stream_and_get_source_and_map(
241241
options,
242242
object_pool,
243-
self.chunks.as_ref(),
243+
self.stream.as_ref(),
244244
on_chunk,
245245
on_source,
246246
on_name,
@@ -252,9 +252,9 @@ impl Chunks for CachedSourceChunks<'_> {
252252
}
253253
}
254254

255-
impl StreamChunks for CachedSource {
256-
fn stream_chunks<'a>(&'a self) -> Box<dyn Chunks + 'a> {
257-
Box::new(CachedSourceChunks::new(self))
255+
impl ToStream for CachedSource {
256+
fn to_stream<'a>(&'a self) -> Box<dyn Stream + 'a> {
257+
Box::new(CachedSourceStream::new(self))
258258
}
259259
}
260260

@@ -409,8 +409,8 @@ mod tests {
409409
let mut on_name_count = 0;
410410
let generated_info = {
411411
let object_pool = ObjectPool::default();
412-
let chunks = source.stream_chunks();
413-
chunks.stream(
412+
let stream = source.to_stream();
413+
stream.chunks(
414414
&object_pool,
415415
&map_options,
416416
&mut |_chunk, _mapping| {
@@ -426,7 +426,7 @@ mod tests {
426426
};
427427

428428
let cached_source = CachedSource::new(source);
429-
cached_source.stream_chunks().stream(
429+
cached_source.to_stream().chunks(
430430
&ObjectPool::default(),
431431
&map_options,
432432
&mut |_chunk, _mapping| {},
@@ -437,7 +437,7 @@ mod tests {
437437
let mut cached_on_chunk_count = 0;
438438
let mut cached_on_source_count = 0;
439439
let mut cached_on_name_count = 0;
440-
let cached_generated_info = cached_source.stream_chunks().stream(
440+
let cached_generated_info = cached_source.to_stream().chunks(
441441
&ObjectPool::default(),
442442
&map_options,
443443
&mut |_chunk, _mapping| {

src/concat_source.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
use rustc_hash::FxHashMap as HashMap;
99

1010
use crate::{
11-
helpers::{get_map, Chunks, GeneratedInfo, StreamChunks},
11+
helpers::{get_map, Stream, GeneratedInfo, ToStream},
1212
linear_map::LinearMap,
1313
object_pool::ObjectPool,
1414
source::{IndexSourceMap, Mapping, OriginalLocation, Section, SectionOffset},
@@ -211,8 +211,8 @@ impl Source for ConcatSource {
211211
object_pool: &'a ObjectPool,
212212
options: &MapOptions,
213213
) -> Option<SourceMap> {
214-
let chunks = self.stream_chunks();
215-
let result = get_map(object_pool, chunks.as_ref(), options);
214+
let stream = self.to_stream();
215+
let result = get_map(object_pool, stream.as_ref(), options);
216216
result
217217
}
218218

@@ -334,23 +334,23 @@ impl PartialEq for ConcatSource {
334334
}
335335
impl Eq for ConcatSource {}
336336

337-
struct ConcatSourceChunks<'source> {
338-
children_chunks: Vec<Box<dyn Chunks + 'source>>,
337+
struct ConcatSourceStream<'source> {
338+
children_chunks: Vec<Box<dyn Stream + 'source>>,
339339
}
340340

341-
impl<'source> ConcatSourceChunks<'source> {
341+
impl<'source> ConcatSourceStream<'source> {
342342
fn new(concat_source: &'source ConcatSource) -> Self {
343343
let children = concat_source.optimized_children();
344344
let children_chunks = children
345345
.iter()
346-
.map(|child| child.stream_chunks())
346+
.map(|child| child.to_stream())
347347
.collect::<Vec<_>>();
348348
Self { children_chunks }
349349
}
350350
}
351351

352-
impl Chunks for ConcatSourceChunks<'_> {
353-
fn stream<'b>(
352+
impl Stream for ConcatSourceStream<'_> {
353+
fn chunks<'b>(
354354
&'b self,
355355
object_pool: &'b ObjectPool,
356356
options: &MapOptions,
@@ -359,7 +359,7 @@ impl Chunks for ConcatSourceChunks<'_> {
359359
on_name: crate::helpers::OnName<'_, 'b>,
360360
) -> GeneratedInfo {
361361
if self.children_chunks.len() == 1 {
362-
return self.children_chunks[0].stream(
362+
return self.children_chunks[0].chunks(
363363
object_pool,
364364
options,
365365
on_chunk,
@@ -385,7 +385,7 @@ impl Chunks for ConcatSourceChunks<'_> {
385385
let GeneratedInfo {
386386
generated_line,
387387
generated_column,
388-
} = child_handle.stream(
388+
} = child_handle.chunks(
389389
object_pool,
390390
options,
391391
&mut |chunk, mapping| {
@@ -525,9 +525,9 @@ impl Chunks for ConcatSourceChunks<'_> {
525525
}
526526
}
527527

528-
impl StreamChunks for ConcatSource {
529-
fn stream_chunks<'a>(&'a self) -> Box<dyn Chunks + 'a> {
530-
Box::new(ConcatSourceChunks::new(self))
528+
impl ToStream for ConcatSource {
529+
fn to_stream<'a>(&'a self) -> Box<dyn Stream + 'a> {
530+
Box::new(ConcatSourceStream::new(self))
531531
}
532532
}
533533

src/helpers.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ use crate::{
2020

2121
pub fn get_map<'a>(
2222
object_pool: &'a ObjectPool,
23-
chunks: &'a dyn Chunks,
23+
stream: &'a dyn Stream,
2424
options: &MapOptions,
2525
) -> Option<SourceMap> {
2626
let mut mappings_encoder = create_encoder(options.columns);
2727
let mut sources: Vec<String> = Vec::new();
2828
let mut sources_content: Vec<Arc<str>> = Vec::new();
2929
let mut names: Vec<String> = Vec::new();
3030

31-
chunks.stream(
31+
stream.chunks(
3232
object_pool,
3333
&MapOptions {
3434
columns: options.columns,
@@ -72,13 +72,13 @@ pub fn get_map<'a>(
7272
/// while building source map information. It's designed to handle the transformation
7373
/// of source code into mappings that connect generated code positions to original
7474
/// source positions.
75-
pub trait Chunks {
75+
pub trait Stream {
7676
/// Streams through source code chunks and generates source map information.
7777
///
7878
/// This method processes the source code in chunks, calling the provided callbacks
7979
/// for each chunk, source reference, and name reference encountered. It's the core
8080
/// method for building source maps during code transformation.
81-
fn stream<'a>(
81+
fn chunks<'a>(
8282
&'a self,
8383
object_pool: &'a ObjectPool,
8484
options: &MapOptions,
@@ -88,10 +88,10 @@ pub trait Chunks {
8888
) -> crate::helpers::GeneratedInfo;
8989
}
9090

91-
/// [StreamChunks] abstraction, see [webpack-sources source.streamChunks](https://github.com/webpack/webpack-sources/blob/9f98066311d53a153fdc7c633422a1d086528027/lib/helpers/streamChunks.js#L13).
92-
pub trait StreamChunks {
93-
/// [StreamChunks] abstraction
94-
fn stream_chunks<'a>(&'a self) -> Box<dyn Chunks + 'a>;
91+
/// [ToStream] abstraction, see [webpack-sources source.streamChunks](https://github.com/webpack/webpack-sources/blob/9f98066311d53a153fdc7c633422a1d086528027/lib/helpers/streamChunks.js#L13).
92+
pub trait ToStream {
93+
/// [ToStream] abstraction
94+
fn to_stream<'a>(&'a self) -> Box<dyn Stream + 'a>;
9595
}
9696

9797
/// [OnChunk] abstraction, see [webpack-sources onChunk](https://github.com/webpack/webpack-sources/blob/9f98066311d53a153fdc7c633422a1d086528027/lib/helpers/streamChunks.js#L13).
@@ -1229,7 +1229,7 @@ pub fn stream_chunks_of_combined_source_map<'a>(
12291229
pub fn stream_and_get_source_and_map<'a>(
12301230
options: &MapOptions,
12311231
object_pool: &'a ObjectPool,
1232-
chunks: &'a dyn Chunks,
1232+
stream: &'a dyn Stream,
12331233
on_chunk: OnChunk<'_, 'a>,
12341234
on_source: OnSource<'_, 'a>,
12351235
on_name: OnName<'_, 'a>,
@@ -1239,7 +1239,7 @@ pub fn stream_and_get_source_and_map<'a>(
12391239
let mut sources_content: Vec<Arc<str>> = Vec::new();
12401240
let mut names: Vec<String> = Vec::new();
12411241

1242-
let generated_info = chunks.stream(
1242+
let generated_info = stream.chunks(
12431243
object_pool,
12441244
options,
12451245
&mut |chunk, mapping| {

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ pub use source_map_source::{
3030
SourceMapSource, SourceMapSourceOptions, WithoutOriginalOptions,
3131
};
3232

33-
/// Reexport `StreamChunks` related types.
33+
/// Reexport `ToStream` related types.
3434
pub mod stream_chunks {
3535
pub use super::helpers::{
36-
stream_chunks_default, Chunks, GeneratedInfo, OnChunk, OnName, OnSource,
37-
StreamChunks,
36+
stream_chunks_default, Stream, GeneratedInfo, OnChunk, OnName, OnSource,
37+
ToStream,
3838
};
3939
}
4040

src/original_source.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
use crate::{
88
helpers::{
99
get_generated_source_info, get_map, split_into_lines,
10-
split_into_potential_tokens, Chunks, GeneratedInfo, StreamChunks,
10+
split_into_potential_tokens, Stream, GeneratedInfo, ToStream,
1111
},
1212
object_pool::ObjectPool,
1313
source::{Mapping, OriginalLocation},
@@ -73,8 +73,8 @@ impl Source for OriginalSource {
7373
object_pool: &ObjectPool,
7474
options: &MapOptions,
7575
) -> Option<SourceMap> {
76-
let chunks = self.stream_chunks();
77-
get_map(object_pool, chunks.as_ref(), options)
76+
let stream = self.to_stream();
77+
get_map(object_pool, stream.as_ref(), options)
7878
}
7979

8080
fn to_writer(&self, writer: &mut dyn std::io::Write) -> std::io::Result<()> {
@@ -111,16 +111,16 @@ impl std::fmt::Debug for OriginalSource {
111111
}
112112
}
113113

114-
struct OriginalSourceChunks<'a>(&'a OriginalSource);
114+
struct OriginalSourceStream<'a>(&'a OriginalSource);
115115

116-
impl<'source> OriginalSourceChunks<'source> {
116+
impl<'source> OriginalSourceStream<'source> {
117117
pub fn new(source: &'source OriginalSource) -> Self {
118118
Self(source)
119119
}
120120
}
121121

122-
impl Chunks for OriginalSourceChunks<'_> {
123-
fn stream<'b>(
122+
impl Stream for OriginalSourceStream<'_> {
123+
fn chunks<'b>(
124124
&'b self,
125125
_object_pool: &'b ObjectPool,
126126
options: &MapOptions,
@@ -249,9 +249,9 @@ impl Chunks for OriginalSourceChunks<'_> {
249249
}
250250
}
251251

252-
impl StreamChunks for OriginalSource {
253-
fn stream_chunks<'a>(&'a self) -> Box<dyn Chunks + 'a> {
254-
Box::new(OriginalSourceChunks::new(self))
252+
impl ToStream for OriginalSource {
253+
fn to_stream<'a>(&'a self) -> Box<dyn Stream + 'a> {
254+
Box::new(OriginalSourceStream::new(self))
255255
}
256256
}
257257

@@ -365,8 +365,8 @@ mod tests {
365365
let source = OriginalSource::new(code, "test.js");
366366
let mut chunks = vec![];
367367
let object_pool = ObjectPool::default();
368-
let handle = source.stream_chunks();
369-
let generated_info = handle.stream(
368+
let handle = source.to_stream();
369+
let generated_info = handle.chunks(
370370
&object_pool,
371371
&MapOptions::default(),
372372
&mut |chunk, mapping| {

0 commit comments

Comments
 (0)