-
-
Notifications
You must be signed in to change notification settings - Fork 33
Add support for ignoreList property #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
use std::borrow::Cow; | ||
use std::cmp::Ordering; | ||
use std::collections::BTreeSet; | ||
use std::fmt; | ||
use std::io::{Read, Write}; | ||
use std::path::Path; | ||
|
@@ -464,6 +465,7 @@ pub struct SourceMap { | |
pub(crate) sources: Vec<Arc<str>>, | ||
pub(crate) sources_prefixed: Option<Vec<Arc<str>>>, | ||
pub(crate) sources_content: Vec<Option<SourceView>>, | ||
pub(crate) ignore_list: BTreeSet<u32>, | ||
pub(crate) debug_id: Option<DebugId>, | ||
} | ||
|
||
|
@@ -571,12 +573,14 @@ impl SourceMap { | |
/// - `names`: a vector of names | ||
/// - `sources` a vector of source filenames | ||
/// - `sources_content` optional source contents | ||
/// - `ignore_list` optional list of source indexes for devtools to ignore | ||
pub fn new( | ||
file: Option<Arc<str>>, | ||
mut tokens: Vec<RawToken>, | ||
names: Vec<Arc<str>>, | ||
sources: Vec<Arc<str>>, | ||
sources_content: Option<Vec<Option<Arc<str>>>>, | ||
ignore_list: Option<Vec<u32>>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a breaking change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good point. This could be avoided by removing this parameter and using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we add a corresponding |
||
) -> SourceMap { | ||
tokens.sort_unstable_by_key(|t| (t.dst_line, t.dst_col)); | ||
SourceMap { | ||
|
@@ -591,6 +595,10 @@ impl SourceMap { | |
.into_iter() | ||
.map(|opt| opt.map(SourceView::new)) | ||
.collect(), | ||
ignore_list: match ignore_list { | ||
Some(ignore_list) => ignore_list.into_iter().collect(), | ||
None => BTreeSet::default(), | ||
}, | ||
debug_id: None, | ||
} | ||
} | ||
|
@@ -651,6 +659,14 @@ impl SourceMap { | |
} | ||
} | ||
|
||
pub fn add_to_ignore_list(&mut self, src_id: u32) { | ||
self.ignore_list.insert(src_id); | ||
} | ||
|
||
pub fn ignore_list(&self) -> impl Iterator<Item = &u32> { | ||
self.ignore_list.iter() | ||
} | ||
|
||
/// Looks up a token by its index. | ||
pub fn get_token(&self, idx: usize) -> Option<Token<'_>> { | ||
self.tokens.get(idx).map(|raw| Token { | ||
|
@@ -1201,6 +1217,9 @@ impl SourceMapIndex { | |
map.get_source_contents(token.get_src_id()), | ||
); | ||
} | ||
if map.ignore_list.contains(&token.get_src_id()) { | ||
builder.add_to_ignore_list(raw.src_id); | ||
} | ||
} | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.