mirror of
https://github.com/github/codeql.git
synced 2026-06-29 16:47:09 +02:00
yeast: Remove dead Captures methods
`Captures::map_captures`, `Captures::map_captures_to`, and `Captures::try_map_all_captures` had no callers. The last one was subsumed by `try_map_captures_except` (which takes a skip list and degenerates to the old behaviour when the list is empty). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -54,37 +54,15 @@ impl Captures {
|
||||
self.captures.entry(key).or_default().push(id);
|
||||
}
|
||||
|
||||
pub fn map_captures(&mut self, kind: &str, f: &mut impl FnMut(Id) -> Id) {
|
||||
if let Some(ids) = self.captures.get_mut(kind) {
|
||||
for id in ids {
|
||||
*id = f(*id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Apply a fallible function to every captured id (across all keys),
|
||||
/// replacing each id with the results. A function returning an empty
|
||||
/// vector removes the capture; returning multiple ids splices them
|
||||
/// into the capture's value list (suitable for `*`/`+` captures).
|
||||
/// Stops and returns the error on the first failure.
|
||||
pub fn try_map_all_captures<E>(
|
||||
&mut self,
|
||||
mut f: impl FnMut(Id) -> Result<Vec<Id>, E>,
|
||||
) -> Result<(), E> {
|
||||
for ids in self.captures.values_mut() {
|
||||
let mut new_ids = Vec::with_capacity(ids.len());
|
||||
for &id in ids.iter() {
|
||||
new_ids.extend(f(id)?);
|
||||
}
|
||||
*ids = new_ids;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Like [`try_map_all_captures`] but leaves captures whose name appears
|
||||
/// in `skip` untouched. Used by the `rule!` macro to support `@@name`
|
||||
/// (raw) captures alongside the default auto-translated `@name`
|
||||
/// captures.
|
||||
/// Apply a fallible function to every captured id, replacing each id
|
||||
/// with the results. A function returning an empty vector removes
|
||||
/// the capture; returning multiple ids splices them into the
|
||||
/// capture's value list (suitable for `*`/`+` captures). Captures
|
||||
/// whose name appears in `skip` are left untouched. Stops and
|
||||
/// returns the error on the first failure.
|
||||
///
|
||||
/// Used by the `rule!` macro's auto-translate prefix to translate
|
||||
/// every capture except those marked `@@name` (raw).
|
||||
pub fn try_map_captures_except<E>(
|
||||
&mut self,
|
||||
skip: &[&str],
|
||||
@@ -102,12 +80,6 @@ impl Captures {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
pub fn map_captures_to(&mut self, from: &str, to: &'static str, f: &mut impl FnMut(Id) -> Id) {
|
||||
if let Some(from_ids) = self.captures.get(from) {
|
||||
let new_values = from_ids.iter().copied().map(f).collect();
|
||||
self.captures.insert(to, new_values);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn merge(&mut self, other: &Captures) {
|
||||
for (key, ids) in &other.captures {
|
||||
|
||||
Reference in New Issue
Block a user