Repository navigation
ref: Refactor sources - #153
loewenheim wants to merge 1 commit into
Conversation
| /// - `ignore_list` optional list of source indexes for devtools to ignore | ||
| pub fn new( | ||
| /// - `sources` a vector of sources (filenames, contents, and scopes) | ||
| pub(crate) fn new( |
There was a problem hiding this comment.
I'm changing this constructor's signature and making it private. I don't think it was ever meaningfully usable outside of the crate; if we want a public way to construct SourceMap we should think of something better.
| None => None, | ||
| }; | ||
|
|
||
| let name = name.map(Arc::from); |
There was a problem hiding this comment.
What is the type of name before the conversion here? &str?
There was a problem hiding this comment.
String. The RawSourceMap type uses String internally, though we could change that to Arc<str>.
| indices: &'a [usize], | ||
| pub(crate) sm: &'a SourceMap, | ||
| pub(crate) scopes: &'a [RawOriginalScope], | ||
| pub(crate) indices: &'a [usize], |
There was a problem hiding this comment.
This looks leaky, why does the crate need access to the iterator's internals now? Can that access be replaced by a getter?
There was a problem hiding this comment.
Just for construction purposes. If you prefer I can refactor this to use a constructor function instead.
This refactors sources (original source files) in sourcemaps in several ways.
RawSource) instead of separate vectors/maps.Source<'a>which represents a reference to a source file in a sourcemap. It has accessor methods for the name, contents, and scopes.get_source/sources/… methods now return (iterators of)Sourceinstead of just the source name. Because it's common,Tokenalso hasget_source_namewhich behaves likeget_sourceused to.get_source_contents/SourceContentsIter&c. are removed; source contents are now accessed viaSource.