Skip to content

Commit

Permalink
diagnostic descriptor: slow_functions
Browse files Browse the repository at this point in the history
Summary: As title

Reviewed By: robertoaloi

Differential Revision: D55737827

fbshipit-source-id: 226b29e11a0efbca4c4cc576d20929d58229a4b6
  • Loading branch information
alanz authored and facebook-github-bot committed Apr 5, 2024
1 parent ace5919 commit e2403d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/ide/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ pub fn diagnostics_descriptors<'a>() -> Vec<&'a DiagnosticDescriptor<'a>> {
&missing_separator::DESCRIPTOR,
&deprecated_function::DESCRIPTOR,
&dependent_header::DESCRIPTOR,
&slow_functions::DESCRIPTOR,
]
}

Expand Down Expand Up @@ -666,7 +667,6 @@ pub fn semantic_diagnostics(
expression_can_be_simplified::diagnostic(res, sema, file_id);
application_env::application_env(res, sema, file_id);
missing_compile_warn_missing_spec::missing_compile_warn_missing_spec(res, sema, file_id);
slow_functions::slow_functions(res, sema, file_id);
}
}

Expand Down
19 changes: 14 additions & 5 deletions crates/ide/src/diagnostics/slow_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,25 @@ use lazy_static::lazy_static;
use super::helpers::check_used_functions;
use super::helpers::DiagnosticTemplate;
use super::Diagnostic;
use super::DiagnosticConditions;
use super::DiagnosticDescriptor;
use crate::codemod_helpers::FunctionMatch;
use crate::diagnostics::helpers::FunctionCallDiagnostic;
use crate::diagnostics::DiagnosticCode;
use crate::diagnostics::Severity;

pub(crate) fn slow_functions(diags: &mut Vec<Diagnostic>, sema: &Semantic, file_id: FileId) {
if sema.db.is_generated(file_id) || Some(true) == sema.db.is_test_suite_or_test_helper(file_id)
{
return;
}
pub(crate) static DESCRIPTOR: DiagnosticDescriptor = DiagnosticDescriptor {
conditions: DiagnosticConditions {
experimental: false,
include_generated: false,
include_tests: false,
},
checker: &|diags, sema, file_id, _ext| {
slow_functions(diags, sema, file_id);
},
};

fn slow_functions(diags: &mut Vec<Diagnostic>, sema: &Semantic, file_id: FileId) {
check_used_functions(sema, file_id, &USED_FUNCTIONS, diags);
}

Expand Down

0 comments on commit e2403d2

Please sign in to comment.