refactor: Associate comment bar buttons with the comment view. by gonfunko · Pull Request #9278 · RaspberryPiFoundation/blockly

The basics

The details

Resolves

This PR refactors the recently-introduced comment bar button classes to be associated with the CommentView they are hosted in rather than the RenderedWorkspaceComment that the CommentView (may) be associated with. This was driven by Scratch, which uses CommentView to display block comments in addition to workspace comments, and thus has no RenderedWorkspaceComment instance associated with them. Many other services also use workspace comment-styled block comments which may benefit from reusing CommentView if they do not already.

Breaking Change

This PR removes CommentBarButton.getParentComment() and changes the constructor (and that of the two concrete subclasses) to take a CommentView instance. The former can be replaced by workspace.getCommentById(barButton.getCommentView().commentId), if the comment bar button in question is actually associated with a comment view in a RenderedWorkspaceComment.