fn rewrite_action(&self, span: Span) -> Option<ProgramAction> {
        let ast = self.original_ast();
        let simplify_expr = |e| evaluate_expr(e, &self.rules, self.context.as_ref());
        let (span, original, simplified) = match get_item_at_span(span, &ast)? {
            AstItem::Expr(e) => (e.span, e.to_string(), simplify_expr(e.clone()).to_string()),
            AstItem::Assignment(a) => (
                a.span,
                a.to_string(),
                a.clone().redefine_with(simplify_expr).to_string(),
            ),
        };

        if original == simplified {
            None
        } else {
            Some(ProgramAction {
                title: "Simplify".to_owned(),
                kind: ProgramActionKind::Rewrite,
                resolved_diagnostic: None,
                uri: self.document_uri.as_ref().clone(),
                edit: ProgramTextEdit {
                    span,
                    edit: simplified,
                },
                is_preferred: true,
            })
        }
    }
/// Retrieves a rewrite action for the item covering the span, if there is such an item and it
/// has any rewrite.
Retrieves a rewrite action for the item covering the span, if there is such an item and it
has any rewrite.
Retrieves a rewrite action for the item covering the span if there is such an item and it has any rewrite .
fn rewrite_action(&self, span: Span) -> Option<ProgramAction> {
        let ast = self.original_ast();
        let simplify_expr = |e| evaluate_expr(e, &self.rules, self.context.as_ref());
        let (span, original, simplified) = match get_item_at_span(span, &ast)? {
            AstItem::Expr(e) => (e.span, e.to_string(), simplify_expr(e.clone()).to_string()),
            AstItem::Assignment(a) => (
                a.span,
                a.to_string(),
                a.clone().redefine_with(simplify_expr).to_string(),
            ),
        };
        if original == simplified {
            None
        } else {
            Some(ProgramAction {
                title: "Simplify".to_owned(),
                kind: ProgramActionKind::Rewrite,
                resolved_diagnostic: None,
                uri: self.document_uri.as_ref().clone(),
                edit: ProgramTextEdit {
                    span,
                    edit: simplified,
                },
                is_preferred: true,
            })
        }
    }
fn rewrite_action ( & self , span : Span ) -> Option < ProgramAction > { let ast = self . original_ast ( ) ; let simplify_expr = | e | evaluate_expr ( e , & self . rules , self . context . as_ref ( ) ) ; let ( span , original , simplified ) = match get_item_at_span ( span , & ast ) ? { AstItem :: Expr ( e ) => ( e . span , e . to_string ( ) , simplify_expr ( e . clone ( ) ) . to_string ( ) ) , AstItem :: Assignment ( a ) => ( a . span , a . to_string ( ) , a . clone ( ) . redefine_with ( simplify_expr ) . to_string ( ) , ) , } ; if original == simplified { None } else { Some ( ProgramAction { title : " " . to_owned ( ) , kind : ProgramActionKind :: Rewrite , resolved_diagnostic : None , uri : self . document_uri . as_ref ( ) . clone ( ) , edit : ProgramTextEdit { span , edit : simplified , } , is_preferred : true , } ) } }
Retrieves a rewrite action for the item covering the span, if there is such an item and it
has any rewrite.
Retrieves a rewrite action for the item covering the span if there is such an item and it has any rewrite .
&self
span
Span
&self
span
Span