refactor: introduce separate classes for threads and comments
This MR is preparation for #317 (closed). It creates GitLabComment
and GitLabThread
classes, that are going to serve as models for comments and threads in VS Code MR review.
Design choice
We'll implement the MR comment interactions as methods on the comment and thread classes. The main reason is that we need to heavily conform to the VS Code Extension API, because we don't have a control over the whole commenting life-cycle.
- We create a
CommentController
- the implementation is not ours. - We create a CommentThread - the implementation is not ours.
- Then we set
commentThread.comments
with our implementation ofComment
Then we loose control over what's happening to these models.
When user triggers an action on a thread or a comment, our actions will get CommentThread
(VS Code implementation) or GitLabComment
(our implementation) as an argument.
These classes then need to be able to handle the action, e.g. GitLabComment.delete()
How to review
The MR is separated into commits that have long comments in their commit messages. I recommend reviewing commit-by-commit.
- First commit only restructures tests without changing them
- Second commit introduces the
GitLabComment
class - Third commit is the most involved. It takes large chunks of thread-related functionality from
mr_item_model.ts
and creates a separate classGitLabThread
- Fourth commit adds an integration test