internal static void AddOnPropertyChanged(this DocumentEditor editor, ExpressionSyntax mutation, ExpressionStatementSyntax onPropertyChanged) { switch (mutation.Parent) { case SimpleLambdaExpressionSyntax lambda: editor.ReplaceNode( lambda, x => x.AddStatements(onPropertyChanged)); break; case ParenthesizedLambdaExpressionSyntax lambda: editor.ReplaceNode( lambda, x => x.AddStatements(onPropertyChanged)); break; case ExpressionStatementSyntax expressionStatement: editor.AddOnPropertyChangedAfter(expressionStatement, onPropertyChanged); break; case PrefixUnaryExpressionSyntax { Parent: IfStatementSyntax ifNot } unary when unary.IsKind(SyntaxKind.LogicalNotExpression) : editor.AddOnPropertyChangedAfter(ifNot, onPropertyChanged); break; } }