Skip to content

Commit

Permalink
Also collect generic ELP fixmes and ignores
Browse files Browse the repository at this point in the history
Summary: We start to collect ELP metadata here. The code will be refactored further in the stack. The ELP metadata is unused at this stage.

Reviewed By: alanz

Differential Revision: D54536793

fbshipit-source-id: 36f5650fc9272439c4626232b32034d2baca7c9a
  • Loading branch information
robertoaloi authored and facebook-github-bot committed Mar 8, 2024
1 parent 00868a4 commit cac672d
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions crates/ide_db/src/fixmes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,37 @@ impl From<Fixme> for eetf::Term {
}
}

pub fn fixmes_eetf(line_index: &LineIndex, file_text: &str) -> eetf::Term {
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(eqwalizer_fixmes).into(),
])
.into(),
fn fixmes_tuple(
line_index: &LineIndex,
file_text: &str,
pats: Vec<(&str, bool)>,
label: &str,
) -> eetf::Term {
let fixmes = collect_fixmes(line_index, file_text, pats);
let fixmes: Vec<eetf::Term> = fixmes.into_iter().map(|f| f.into()).collect();
eetf::Tuple::from(vec![
eetf::Atom::from(label).into(),
eetf::List::from(fixmes).into(),
])
.into()
}

pub fn fixmes_eetf(line_index: &LineIndex, file_text: &str) -> eetf::Term {
let eqwalizer_fixmes = fixmes_tuple(
line_index,
file_text,
vec![("% eqwalizer:fixme", false), ("% eqwalizer:ignore", true)],
"eqwalizer_fixmes",
);
let elp_fixmes = fixmes_tuple(
line_index,
file_text,
vec![("% elp:fixme", false), ("% elp:ignore", true)],
"elp_fixmes",
);
eetf::List::from(vec![eqwalizer_fixmes, elp_fixmes]).into()
}

fn collect_fixmes(line_index: &LineIndex, file_text: &str, pats: Vec<(&str, bool)>) -> Vec<Fixme> {
let mut fixmes = Vec::new();
for (pat, is_ignore) in pats {
Expand Down

0 comments on commit cac672d

Please sign in to comment.