Skip to content

Commit

Permalink
Move tuple wrapping for eqwalizer_fixmes to fixme.rs
Browse files Browse the repository at this point in the history
Summary:
This stack aims at extracting ELP metadata (such as `elp:ignore` annotations) in the same way Eqwalizer does, and to leverage the metadata to suppress diagnostics (instead of using a separate implementation). This also enables detection of un-necessary ignore statements.

Before being able to do so, a few refactorings are required.

This first change simply moves EETF conversion details to the `fixmes_eetf` function.

Reviewed By: alanz

Differential Revision: D54536341

fbshipit-source-id: 348e513ac3a6948064a9cdfa1f328d0a42c5300e
  • Loading branch information
robertoaloi authored and facebook-github-bot committed Mar 8, 2024
1 parent e5a9a9d commit 81ea215
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 1 addition & 6 deletions crates/ide_db/src/erl_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,7 @@ fn module_ast(
fn elp_metadata(db: &dyn ErlAstDatabase, file_id: FileId) -> eetf::Term {
let line_index = db.file_line_index(file_id);
let file_text = db.file_text(file_id);
let fixmes = fixmes::fixmes_eetf(&line_index, &file_text);
// Erlang proplist: [{eqwalizer_fixmes, [Fixme1, Fixme2....]}]
eetf::List::from(vec![
eetf::Tuple::from(vec![eetf::Atom::from("eqwalizer_fixmes").into(), fixmes]).into(),
])
.into()
fixmes::fixmes_eetf(&line_index, &file_text)
}

pub fn files_from_bytes(bytes: &[u8]) -> Vec<String> {
Expand Down
10 changes: 9 additions & 1 deletion crates/ide_db/src/fixmes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ 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();
eetf::List::from(fixmes).into()
// 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(),
])
.into(),
])
.into()
}

fn collect_fixmes(line_index: &LineIndex, file_text: &str) -> Vec<Fixme> {
Expand Down

0 comments on commit 81ea215

Please sign in to comment.