Skip to content

Commit

Permalink
diagnostics descriptor for missing_separator
Browse files Browse the repository at this point in the history
Summary: As title

Reviewed By: robertoaloi

Differential Revision: D55735480

fbshipit-source-id: 553087b9ad1b567b2c037fedf65f2901e925735f
  • Loading branch information
alanz authored and facebook-github-bot committed Apr 5, 2024
1 parent 2be92e3 commit be8075f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
7 changes: 5 additions & 2 deletions crates/ide/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,11 @@ pub fn native_diagnostics(
}

pub fn diagnostics_descriptors<'a>() -> Vec<&'a DiagnosticDescriptor<'a>> {
vec![&cross_node_eval::DESCRIPTOR, &atoms_exhaustion::DESCRIPTOR]
vec![
&cross_node_eval::DESCRIPTOR,
&atoms_exhaustion::DESCRIPTOR,
&missing_separator::DESCRIPTOR,
]
}

pub fn diagnostics_from_descriptors(
Expand Down Expand Up @@ -663,7 +667,6 @@ pub fn semantic_diagnostics(
deprecated_function::deprecated_function(res, sema, file_id);
undefined_function::undefined_function(res, sema, file_id);
head_mismatch::head_mismatch_semantic(res, sema, file_id);
missing_separator::missing_separator_semantic(res, sema, file_id);
}
}

Expand Down
20 changes: 15 additions & 5 deletions crates/ide/src/diagnostics/missing_separator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use elp_syntax::ast::ClauseSeparator;
use hir::Semantic;

use super::make_unexpected_diagnostic;
use super::DiagnosticConditions;
use super::DiagnosticDescriptor;
use crate::diagnostics::make_missing_diagnostic;
use crate::Diagnostic;

Expand All @@ -21,11 +23,19 @@ use crate::Diagnostic;
// Diagnostic for separators missing in function clauses.

// TODO: combine with head_mismatch?
pub(crate) fn missing_separator_semantic(
diagnostics: &mut Vec<Diagnostic>,
sema: &Semantic,
file_id: FileId,
) {

pub(crate) static DESCRIPTOR: DiagnosticDescriptor = DiagnosticDescriptor {
conditions: DiagnosticConditions {
experimental: false,
include_generated: true,
include_tests: true,
},
checker: &|diags, sema, file_id, _ext| {
missing_separator_semantic(diags, sema, file_id);
},
};

fn missing_separator_semantic(diagnostics: &mut Vec<Diagnostic>, sema: &Semantic, file_id: FileId) {
let def_map = sema.def_map(file_id);

def_map.get_functions().for_each(|(_, fun_def)| {
Expand Down

0 comments on commit be8075f

Please sign in to comment.