Common/Diagnostic/ClearDiagnostics.rs
1//! # ClearDiagnostics Effect
2//!
3//! Defines the `ActionEffect` for clearing all diagnostics from a specific
4//! owner.
5
6use std::sync::Arc;
7
8use super::DiagnosticManager::DiagnosticManager;
9use crate::{Effect::ActionEffect::ActionEffect, Error::CommonError::CommonError};
10
11/// Creates an effect that, when executed, will clear all diagnostics for a
12/// given owner.
13///
14/// This is used when an extension is disposed of or when a linter re-runs and
15/// finds no problems. It uses the `DiagnosticManager` capability from the
16/// environment to perform the operation.
17///
18/// # Parameters
19/// * `Owner`: A string identifying the source of the diagnostics to be cleared
20/// (e.g., 'typescript-linter').
21///
22/// # Returns
23/// An `ActionEffect` that resolves to `()` on success.
24pub fn ClearDiagnostics(Owner:String) -> ActionEffect<Arc<dyn DiagnosticManager>, CommonError, ()> {
25 ActionEffect::New(Arc::new(move |Manager:Arc<dyn DiagnosticManager>| {
26 let OwnerClone = Owner.clone();
27
28 Box::pin(async move { Manager.ClearDiagnostics(OwnerClone).await })
29 }))
30}