Skip to content

Commit

Permalink
Make patterns for ELP Metadata extraction configurable
Browse files Browse the repository at this point in the history
Summary: This moves eqwalizer specific patterns up one level, so the same logic can be reused to extract ELP patterns.

Reviewed By: alanz

Differential Revision: D54536539

fbshipit-source-id: e0fd89485c65f73dee8f54add81830528cd1f705
  • Loading branch information
robertoaloi authored and facebook-github-bot committed Mar 8, 2024
1 parent 81ea215 commit 00868a4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crates/ide_db/src/fixmes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,23 @@ impl From<Fixme> for eetf::Term {
}

pub fn fixmes_eetf(line_index: &LineIndex, file_text: &str) -> eetf::Term {
let fixmes = collect_fixmes(line_index, file_text);
let fixmes: Vec<eetf::Term> = fixmes.into_iter().map(|f| f.into()).collect();
let eqwalizer_pats = vec![("% eqwalizer:fixme", false), ("% eqwalizer:ignore", true)];
let eqwalizer_fixmes = collect_fixmes(line_index, file_text, eqwalizer_pats);
let eqwalizer_fixmes: Vec<eetf::Term> =
eqwalizer_fixmes.into_iter().map(|f| f.into()).collect();
// Erlang proplist: [{eqwalizer_fixmes, [Fixme1, Fixme2....]}]
eetf::List::from(vec![
eetf::Tuple::from(vec![
eetf::Atom::from("eqwalizer_fixmes").into(),
eetf::List::from(fixmes).into(),
eetf::List::from(eqwalizer_fixmes).into(),
])
.into(),
])
.into()
}

fn collect_fixmes(line_index: &LineIndex, file_text: &str) -> Vec<Fixme> {
fn collect_fixmes(line_index: &LineIndex, file_text: &str, pats: Vec<(&str, bool)>) -> Vec<Fixme> {
let mut fixmes = Vec::new();
let pats = vec![("% eqwalizer:fixme", false), ("% eqwalizer:ignore", true)];
for (pat, is_ignore) in pats {
let len = pat.len();
for (i, _) in file_text.match_indices(pat) {
Expand Down

0 comments on commit 00868a4

Please sign in to comment.