From cac672d98f2f2b766d512d3b1e37dec40025c39d Mon Sep 17 00:00:00 2001 From: Roberto Aloi Date: Fri, 8 Mar 2024 12:15:52 -0800 Subject: [PATCH] Also collect generic ELP fixmes and ignores 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 --- crates/ide_db/src/fixmes.rs | 39 +++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/crates/ide_db/src/fixmes.rs b/crates/ide_db/src/fixmes.rs index d829210714..b4936c5e49 100644 --- a/crates/ide_db/src/fixmes.rs +++ b/crates/ide_db/src/fixmes.rs @@ -47,22 +47,37 @@ impl From 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 = - 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 = 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 { let mut fixmes = Vec::new(); for (pat, is_ignore) in pats {