Did you test that and did it do what you intended? Because that is only called for block widgets, and most types of replacing decorations (such as code folding) will be inline decorations.
Yes, it works as expected for block widgets (which is the use case I’m interested in), as long as the widget has a coordsAt method so the tooltip knows where to appear.
If there’s a way to do the same thing for inline decorations, that would probably be useful in other situations. Code folding is an interesting point - it might be useful if a lint gutter marker was shown next to folded code that contains diagnostics, but I’m not sure about that.