From 5ca81fd56753fbabbb690f133a6e665297d0ee28 Mon Sep 17 00:00:00 2001 From: JOOHOJANG Date: Wed, 12 Jul 2023 09:42:41 +0900 Subject: [PATCH 01/11] change the structure of tree node > single to multi --- pkg/document/crdt/tree.go | 52 +++++++------ pkg/document/json/tree.go | 108 +++++++++++++++++---------- pkg/document/operations/tree_edit.go | 33 ++++---- 3 files changed, 119 insertions(+), 74 deletions(-) diff --git a/pkg/document/crdt/tree.go b/pkg/document/crdt/tree.go index 7559cb5b7..4cb98de2d 100644 --- a/pkg/document/crdt/tree.go +++ b/pkg/document/crdt/tree.go @@ -473,7 +473,7 @@ func (t *Tree) ToXML() string { // EditByIndex edits the given range with the given value. // This method uses indexes instead of a pair of TreePos for testing. -func (t *Tree) EditByIndex(start, end int, content *TreeNode, editedAt *time.Ticket) error { +func (t *Tree) EditByIndex(start, end int, contents []*TreeNode, editedAt *time.Ticket) error { fromPos, err := t.FindPos(start) if err != nil { return err @@ -483,7 +483,7 @@ func (t *Tree) EditByIndex(start, end int, content *TreeNode, editedAt *time.Tic return err } - return t.Edit(fromPos, toPos, content, editedAt) + return t.Edit(fromPos, toPos, contents, editedAt) } // FindPos finds the position of the given index in the tree. @@ -501,7 +501,7 @@ func (t *Tree) FindPos(offset int) (*TreePos, error) { // Edit edits the tree with the given range and content. // If the content is undefined, the range will be removed. -func (t *Tree) Edit(from, to *TreePos, content *TreeNode, editedAt *time.Ticket) error { +func (t *Tree) Edit(from, to *TreePos, contents []*TreeNode, editedAt *time.Ticket) error { // 01. split text nodes at the given range if needed. toPos, toRight, err := t.findTreePosWithSplitText(to, editedAt) if err != nil { @@ -567,29 +567,39 @@ func (t *Tree) Edit(from, to *TreePos, content *TreeNode, editedAt *time.Ticket) } // 03. insert the given node at the given position. - if content != nil { - // 03-1. insert the content nodes to the list. + if len(contents) != 0 { + previous := fromRight.Prev - index.TraverseNode(content.IndexTreeNode, func(node *index.Node[*TreeNode], depth int) { - t.InsertAfter(previous, node.Value) - previous = node.Value - }) - - // 03-2. insert the content nodes to the tree. - if fromPos.Node.IsText() { - if fromPos.Offset == 0 { - if err := fromPos.Node.Parent.InsertBefore(content.IndexTreeNode, fromPos.Node); err != nil { - return err + offset := fromPos.Offset + node := fromPos.Node + + for _, content := range contents { + // 03-1. insert the content nodes to the list. + index.TraverseNode(content.IndexTreeNode, func(node *index.Node[*TreeNode], depth int) { + t.InsertAfter(previous, node.Value) + previous = node.Value + }) + + // 03-2. insert the content nodes to the tree. + if node.IsText() { + // if `contents` is consist of text nodes, then there'll be only one element in `contents` + // thus, there's no need to update fromPos + if fromPos.Offset == 0 { + if err := node.Parent.InsertBefore(content.IndexTreeNode, node); err != nil { + return err + } + } else { + if err := node.Parent.InsertAfter(content.IndexTreeNode, node); err != nil { + return err + } } } else { - if err := fromPos.Node.Parent.InsertAfter(content.IndexTreeNode, fromPos.Node); err != nil { + target := node + if err := target.InsertAt(content.IndexTreeNode, offset+1); err != nil { return err } - } - } else { - target := fromPos.Node - if err := target.InsertAt(content.IndexTreeNode, fromPos.Offset+1); err != nil { - return err + + offset++ } } } diff --git a/pkg/document/json/tree.go b/pkg/document/json/tree.go index dc7710bc6..758e75f68 100644 --- a/pkg/document/json/tree.go +++ b/pkg/document/json/tree.go @@ -63,26 +63,34 @@ func NewTree(ctx *change.Context, tree *crdt.Tree) *Tree { } // Edit edits this tree with the given node. -func (t *Tree) Edit(fromIdx, toIdx int, content *TreeNode) bool { +func (t *Tree) Edit(fromIdx, toIdx int, contents []*TreeNode) bool { if fromIdx > toIdx { panic("from should be less than or equal to to") } ticket := t.context.IssueTimeTicket() - var node *crdt.TreeNode - if content != nil { - var attributes *crdt.RHT - if content.Attributes != nil { - attributes = crdt.NewRHT() - for key, val := range content.Attributes { - attributes.Set(key, val, ticket) + var nodes []*crdt.TreeNode + + if len(contents) != 0 { + for _, content := range contents { + var attributes *crdt.RHT + if content.Attributes != nil { + attributes = crdt.NewRHT() + for key, val := range content.Attributes { + attributes.Set(key, val, ticket) + } } - } - node = crdt.NewTreeNode(crdt.NewTreePos(ticket, 0), content.Type, attributes, content.Value) - for _, child := range content.Children { - if err := buildDescendants(t.context, child, node); err != nil { - panic(err) + var node *crdt.TreeNode + + node = crdt.NewTreeNode(crdt.NewTreePos(ticket, 0), content.Type, attributes, content.Value) + + for _, child := range content.Children { + if err := buildDescendants(t.context, child, node); err != nil { + panic(err) + } } + + nodes = append(nodes, node) } } @@ -95,16 +103,22 @@ func (t *Tree) Edit(fromIdx, toIdx int, content *TreeNode) bool { panic(err) } - var clone *crdt.TreeNode - if node != nil { - clone, err = node.DeepCopy() - if err != nil { - panic(err) + var clones []*crdt.TreeNode + if len(nodes) != 0 { + for _, node := range nodes { + var clone *crdt.TreeNode + + clone, err = node.DeepCopy() + if err != nil { + panic(err) + } + + clones = append(clones, clone) } } ticket = t.context.LastTimeTicket() - if err = t.Tree.Edit(fromPos, toPos, clone, ticket); err != nil { + if err = t.Tree.Edit(fromPos, toPos, clones, ticket); err != nil { panic(err) } @@ -112,7 +126,7 @@ func (t *Tree) Edit(fromIdx, toIdx int, content *TreeNode) bool { t.CreatedAt(), fromPos, toPos, - node, + nodes, ticket, )) @@ -129,23 +143,31 @@ func (t *Tree) Len() int { } // EditByPath edits this tree with the given path and node. -func (t *Tree) EditByPath(fromPath []int, toPath []int, content *TreeNode) bool { +func (t *Tree) EditByPath(fromPath []int, toPath []int, contents []*TreeNode) bool { ticket := t.context.IssueTimeTicket() - var node *crdt.TreeNode - if content != nil { - var attributes *crdt.RHT - if content.Attributes != nil { - attributes = crdt.NewRHT() - for key, val := range content.Attributes { - attributes.Set(key, val, ticket) + var nodes []*crdt.TreeNode + + if len(contents) != 0 { + for _, content := range contents { + var attributes *crdt.RHT + if content.Attributes != nil { + attributes = crdt.NewRHT() + for key, val := range content.Attributes { + attributes.Set(key, val, ticket) + } } - } - node = crdt.NewTreeNode(crdt.NewTreePos(ticket, 0), content.Type, attributes, content.Value) - for _, child := range content.Children { - if err := buildDescendants(t.context, child, node); err != nil { - panic(err) + var node *crdt.TreeNode + + node = crdt.NewTreeNode(crdt.NewTreePos(ticket, 0), content.Type, attributes, content.Value) + + for _, child := range content.Children { + if err := buildDescendants(t.context, child, node); err != nil { + panic(err) + } } + + nodes = append(nodes, node) } } @@ -158,16 +180,22 @@ func (t *Tree) EditByPath(fromPath []int, toPath []int, content *TreeNode) bool panic(err) } - var clone *crdt.TreeNode - if node != nil { - clone, err = node.DeepCopy() - if err != nil { - panic(err) + var clones []*crdt.TreeNode + if len(nodes) != 0 { + for _, node := range nodes { + var clone *crdt.TreeNode + + clone, err = node.DeepCopy() + if err != nil { + panic(err) + } + + clones = append(clones, clone) } } ticket = t.context.LastTimeTicket() - if err = t.Tree.Edit(fromPos, toPos, clone, ticket); err != nil { + if err = t.Tree.Edit(fromPos, toPos, clones, ticket); err != nil { panic(err) } @@ -175,7 +203,7 @@ func (t *Tree) EditByPath(fromPath []int, toPath []int, content *TreeNode) bool t.CreatedAt(), fromPos, toPos, - node, + nodes, ticket, )) diff --git a/pkg/document/operations/tree_edit.go b/pkg/document/operations/tree_edit.go index aeb4e8c6d..845c02451 100644 --- a/pkg/document/operations/tree_edit.go +++ b/pkg/document/operations/tree_edit.go @@ -33,8 +33,8 @@ type TreeEdit struct { // toPos represents the end point of the editing range. to *crdt.TreePos - // content is the content of tree added when editing. - content *crdt.TreeNode + // contents is the content of tree added when editing. + contents []*crdt.TreeNode // executedAt is the time the operation was executed. executedAt *time.Ticket @@ -45,14 +45,14 @@ func NewTreeEdit( parentCreatedAt *time.Ticket, from *crdt.TreePos, to *crdt.TreePos, - content *crdt.TreeNode, + contents []*crdt.TreeNode, executedAt *time.Ticket, ) *TreeEdit { return &TreeEdit{ parentCreatedAt: parentCreatedAt, from: from, to: to, - content: content, + contents: contents, executedAt: executedAt, } } @@ -63,15 +63,22 @@ func (e *TreeEdit) Execute(root *crdt.Root) error { switch obj := parent.(type) { case *crdt.Tree: - var content *crdt.TreeNode + var contents []*crdt.TreeNode var err error - if e.Content() != nil { - content, err = e.Content().DeepCopy() - if err != nil { - return err + if len(e.Contents()) != 0 { + for _, content := range e.Contents() { + var clone *crdt.TreeNode + + clone, err = content.DeepCopy() + if err != nil { + return err + } + + contents = append(contents, clone) } + } - if err = obj.Edit(e.from, e.to, content, e.executedAt); err != nil { + if err = obj.Edit(e.from, e.to, contents, e.executedAt); err != nil { return err } @@ -110,7 +117,7 @@ func (e *TreeEdit) ParentCreatedAt() *time.Ticket { return e.parentCreatedAt } -// Content returns the content of Edit. -func (e *TreeEdit) Content() *crdt.TreeNode { - return e.content +// Contents returns the content of Edit. +func (e *TreeEdit) Contents() []*crdt.TreeNode { + return e.contents } From 98522afa1f96c562384cf3a192c7b4413937f717 Mon Sep 17 00:00:00 2001 From: JOOHOJANG Date: Wed, 12 Jul 2023 09:42:50 +0900 Subject: [PATCH 02/11] update proto --- api/converter/to_pb.go | 2 +- api/yorkie/v1/resources.proto | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api/converter/to_pb.go b/api/converter/to_pb.go index 350f3ed85..be2a3f0f7 100644 --- a/api/converter/to_pb.go +++ b/api/converter/to_pb.go @@ -395,7 +395,7 @@ func toTreeEdit(e *operations.TreeEdit) (*api.Operation_TreeEdit_, error) { ParentCreatedAt: ToTimeTicket(e.ParentCreatedAt()), From: toTreePos(e.FromPos()), To: toTreePos(e.ToPos()), - Content: ToTreeNodes(e.Content()), + Content: ToTreeNodes(e.Contents()), ExecutedAt: ToTimeTicket(e.ExecutedAt()), }, }, nil diff --git a/api/yorkie/v1/resources.proto b/api/yorkie/v1/resources.proto index 0955ea0de..d695f363a 100644 --- a/api/yorkie/v1/resources.proto +++ b/api/yorkie/v1/resources.proto @@ -108,7 +108,7 @@ message Operation { TimeTicket parent_created_at = 1; TreePos from = 2; TreePos to = 3; - repeated TreeNode content = 4; + repeated TreeNodes contents = 4; TimeTicket executed_at = 5; } message TreeStyle { @@ -233,6 +233,10 @@ message TreeNode { map attributes = 7; } +message TreeNodes { + repeated TreeNode content = 1; +} + message TreePos { TimeTicket created_at = 1; int32 offset = 2; From 7c99d034958669b3e48919dc17a176118f725c00 Mon Sep 17 00:00:00 2001 From: JOOHOJANG Date: Wed, 12 Jul 2023 09:53:18 +0900 Subject: [PATCH 03/11] update converter to handle array of tree node when edit --- api/converter/from_pb.go | 24 ++++++++++++++++++++++-- api/converter/to_bytes.go | 20 ++++++++++++++++++++ api/converter/to_pb.go | 2 +- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/api/converter/from_pb.go b/api/converter/from_pb.go index 0e12ca109..74a5f6a2c 100644 --- a/api/converter/from_pb.go +++ b/api/converter/from_pb.go @@ -541,7 +541,7 @@ func fromTreeEdit(pbTreeEdit *api.Operation_TreeEdit) (*operations.TreeEdit, err return nil, err } - node, err := FromTreeNodes(pbTreeEdit.Content) + nodes, err := FromTreeNodesWhenEdit(pbTreeEdit.Contents) if err != nil { return nil, err } @@ -550,7 +550,7 @@ func fromTreeEdit(pbTreeEdit *api.Operation_TreeEdit) (*operations.TreeEdit, err parentCreatedAt, from, to, - node, + nodes, executedAt, ), nil } @@ -647,6 +647,26 @@ func FromTreeNodes(pbNodes []*api.TreeNode) (*crdt.TreeNode, error) { return crdt.NewTree(root, nil).Root(), nil } +func FromTreeNodesWhenEdit(pbNodes []*api.TreeNodes) ([]*crdt.TreeNode, error) { + if len(pbNodes) == 0 { + return nil, nil + } + + var treeNodes []*crdt.TreeNode + + for _, pbNode := range pbNodes { + treeNode, err := FromTreeNodes(pbNode.Content) + + if err != nil { + return nil, err + } + + treeNodes = append(treeNodes, treeNode) + } + + return treeNodes, nil +} + func fromTreeNode(pbNode *api.TreeNode) (*crdt.TreeNode, error) { pos, err := fromTreePos(pbNode.Pos) if err != nil { diff --git a/api/converter/to_bytes.go b/api/converter/to_bytes.go index f6b5b08e5..fdd7de5f6 100644 --- a/api/converter/to_bytes.go +++ b/api/converter/to_bytes.go @@ -240,6 +240,26 @@ func ToTreeNodes(treeNode *crdt.TreeNode) []*api.TreeNode { return pbTreeNodes } +// ToTreeNodesWhenEdit converts a TreeNodes to a slice of two-dimensional array of TreeNodes in post-order traversal. +func ToTreeNodesWhenEdit(treeNodes []*crdt.TreeNode) []*api.TreeNodes { + pbTreeNodes := make([]*api.TreeNodes, len(treeNodes)) + + if len(treeNodes) == 0 { + return pbTreeNodes + } + + for i, treeNode := range treeNodes { + var pbTreeNode []*api.TreeNode + + pbTreeNode = append(pbTreeNode, ToTreeNodes(treeNode)[:]...) + + pbTreeNodes[i] = &api.TreeNodes{} + pbTreeNodes[i].Content = append(pbTreeNodes[i].Content, pbTreeNode[:]...) + } + + return pbTreeNodes +} + func toTreeNode(treeNode *crdt.TreeNode, depth int) *api.TreeNode { var attrs map[string]*api.NodeAttr if treeNode.Attrs != nil { diff --git a/api/converter/to_pb.go b/api/converter/to_pb.go index be2a3f0f7..be40e3273 100644 --- a/api/converter/to_pb.go +++ b/api/converter/to_pb.go @@ -395,7 +395,7 @@ func toTreeEdit(e *operations.TreeEdit) (*api.Operation_TreeEdit_, error) { ParentCreatedAt: ToTimeTicket(e.ParentCreatedAt()), From: toTreePos(e.FromPos()), To: toTreePos(e.ToPos()), - Content: ToTreeNodes(e.Contents()), + Contents: ToTreeNodesWhenEdit(e.Contents()), ExecutedAt: ToTimeTicket(e.ExecutedAt()), }, }, nil From 97a51e735926e0e430dad933fb81b910214b5fe1 Mon Sep 17 00:00:00 2001 From: JOOHOJANG Date: Wed, 12 Jul 2023 09:53:41 +0900 Subject: [PATCH 04/11] make proto --- api/yorkie/v1/resources.pb.go | 560 +++++++++++++++++++++++----------- 1 file changed, 377 insertions(+), 183 deletions(-) diff --git a/api/yorkie/v1/resources.pb.go b/api/yorkie/v1/resources.pb.go index 177adde83..b33c3167a 100644 --- a/api/yorkie/v1/resources.pb.go +++ b/api/yorkie/v1/resources.pb.go @@ -1116,14 +1116,14 @@ func (m *Operation_Increase) GetExecutedAt() *TimeTicket { } type Operation_TreeEdit struct { - ParentCreatedAt *TimeTicket `protobuf:"bytes,1,opt,name=parent_created_at,json=parentCreatedAt,proto3" json:"parent_created_at,omitempty"` - From *TreePos `protobuf:"bytes,2,opt,name=from,proto3" json:"from,omitempty"` - To *TreePos `protobuf:"bytes,3,opt,name=to,proto3" json:"to,omitempty"` - Content []*TreeNode `protobuf:"bytes,4,rep,name=content,proto3" json:"content,omitempty"` - ExecutedAt *TimeTicket `protobuf:"bytes,5,opt,name=executed_at,json=executedAt,proto3" json:"executed_at,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + ParentCreatedAt *TimeTicket `protobuf:"bytes,1,opt,name=parent_created_at,json=parentCreatedAt,proto3" json:"parent_created_at,omitempty"` + From *TreePos `protobuf:"bytes,2,opt,name=from,proto3" json:"from,omitempty"` + To *TreePos `protobuf:"bytes,3,opt,name=to,proto3" json:"to,omitempty"` + Contents []*TreeNodes `protobuf:"bytes,4,rep,name=contents,proto3" json:"contents,omitempty"` + ExecutedAt *TimeTicket `protobuf:"bytes,5,opt,name=executed_at,json=executedAt,proto3" json:"executed_at,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *Operation_TreeEdit) Reset() { *m = Operation_TreeEdit{} } @@ -1180,9 +1180,9 @@ func (m *Operation_TreeEdit) GetTo() *TreePos { return nil } -func (m *Operation_TreeEdit) GetContent() []*TreeNode { +func (m *Operation_TreeEdit) GetContents() []*TreeNodes { if m != nil { - return m.Content + return m.Contents } return nil } @@ -2329,6 +2329,53 @@ func (m *TreeNode) GetAttributes() map[string]*NodeAttr { return nil } +type TreeNodes struct { + Content []*TreeNode `protobuf:"bytes,1,rep,name=content,proto3" json:"content,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TreeNodes) Reset() { *m = TreeNodes{} } +func (m *TreeNodes) String() string { return proto.CompactTextString(m) } +func (*TreeNodes) ProtoMessage() {} +func (*TreeNodes) Descriptor() ([]byte, []int) { + return fileDescriptor_36361b2f5d0f0896, []int{12} +} +func (m *TreeNodes) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TreeNodes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TreeNodes.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TreeNodes) XXX_Merge(src proto.Message) { + xxx_messageInfo_TreeNodes.Merge(m, src) +} +func (m *TreeNodes) XXX_Size() int { + return m.Size() +} +func (m *TreeNodes) XXX_DiscardUnknown() { + xxx_messageInfo_TreeNodes.DiscardUnknown(m) +} + +var xxx_messageInfo_TreeNodes proto.InternalMessageInfo + +func (m *TreeNodes) GetContent() []*TreeNode { + if m != nil { + return m.Content + } + return nil +} + type TreePos struct { CreatedAt *TimeTicket `protobuf:"bytes,1,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` Offset int32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` @@ -2341,7 +2388,7 @@ func (m *TreePos) Reset() { *m = TreePos{} } func (m *TreePos) String() string { return proto.CompactTextString(m) } func (*TreePos) ProtoMessage() {} func (*TreePos) Descriptor() ([]byte, []int) { - return fileDescriptor_36361b2f5d0f0896, []int{12} + return fileDescriptor_36361b2f5d0f0896, []int{13} } func (m *TreePos) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2397,7 +2444,7 @@ func (m *User) Reset() { *m = User{} } func (m *User) String() string { return proto.CompactTextString(m) } func (*User) ProtoMessage() {} func (*User) Descriptor() ([]byte, []int) { - return fileDescriptor_36361b2f5d0f0896, []int{13} + return fileDescriptor_36361b2f5d0f0896, []int{14} } func (m *User) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2466,7 +2513,7 @@ func (m *Project) Reset() { *m = Project{} } func (m *Project) String() string { return proto.CompactTextString(m) } func (*Project) ProtoMessage() {} func (*Project) Descriptor() ([]byte, []int) { - return fileDescriptor_36361b2f5d0f0896, []int{14} + return fileDescriptor_36361b2f5d0f0896, []int{15} } func (m *Project) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2572,7 +2619,7 @@ func (m *UpdatableProjectFields) Reset() { *m = UpdatableProjectFields{} func (m *UpdatableProjectFields) String() string { return proto.CompactTextString(m) } func (*UpdatableProjectFields) ProtoMessage() {} func (*UpdatableProjectFields) Descriptor() ([]byte, []int) { - return fileDescriptor_36361b2f5d0f0896, []int{15} + return fileDescriptor_36361b2f5d0f0896, []int{16} } func (m *UpdatableProjectFields) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2644,7 +2691,7 @@ func (m *UpdatableProjectFields_AuthWebhookMethods) String() string { } func (*UpdatableProjectFields_AuthWebhookMethods) ProtoMessage() {} func (*UpdatableProjectFields_AuthWebhookMethods) Descriptor() ([]byte, []int) { - return fileDescriptor_36361b2f5d0f0896, []int{15, 0} + return fileDescriptor_36361b2f5d0f0896, []int{16, 0} } func (m *UpdatableProjectFields_AuthWebhookMethods) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2696,7 +2743,7 @@ func (m *DocumentSummary) Reset() { *m = DocumentSummary{} } func (m *DocumentSummary) String() string { return proto.CompactTextString(m) } func (*DocumentSummary) ProtoMessage() {} func (*DocumentSummary) Descriptor() ([]byte, []int) { - return fileDescriptor_36361b2f5d0f0896, []int{16} + return fileDescriptor_36361b2f5d0f0896, []int{17} } func (m *DocumentSummary) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2779,7 +2826,7 @@ func (m *Presence) Reset() { *m = Presence{} } func (m *Presence) String() string { return proto.CompactTextString(m) } func (*Presence) ProtoMessage() {} func (*Presence) Descriptor() ([]byte, []int) { - return fileDescriptor_36361b2f5d0f0896, []int{17} + return fileDescriptor_36361b2f5d0f0896, []int{18} } func (m *Presence) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2834,7 +2881,7 @@ func (m *Client) Reset() { *m = Client{} } func (m *Client) String() string { return proto.CompactTextString(m) } func (*Client) ProtoMessage() {} func (*Client) Descriptor() ([]byte, []int) { - return fileDescriptor_36361b2f5d0f0896, []int{18} + return fileDescriptor_36361b2f5d0f0896, []int{19} } func (m *Client) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2889,7 +2936,7 @@ func (m *Checkpoint) Reset() { *m = Checkpoint{} } func (m *Checkpoint) String() string { return proto.CompactTextString(m) } func (*Checkpoint) ProtoMessage() {} func (*Checkpoint) Descriptor() ([]byte, []int) { - return fileDescriptor_36361b2f5d0f0896, []int{19} + return fileDescriptor_36361b2f5d0f0896, []int{20} } func (m *Checkpoint) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2945,7 +2992,7 @@ func (m *TextNodePos) Reset() { *m = TextNodePos{} } func (m *TextNodePos) String() string { return proto.CompactTextString(m) } func (*TextNodePos) ProtoMessage() {} func (*TextNodePos) Descriptor() ([]byte, []int) { - return fileDescriptor_36361b2f5d0f0896, []int{20} + return fileDescriptor_36361b2f5d0f0896, []int{21} } func (m *TextNodePos) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3008,7 +3055,7 @@ func (m *TimeTicket) Reset() { *m = TimeTicket{} } func (m *TimeTicket) String() string { return proto.CompactTextString(m) } func (*TimeTicket) ProtoMessage() {} func (*TimeTicket) Descriptor() ([]byte, []int) { - return fileDescriptor_36361b2f5d0f0896, []int{21} + return fileDescriptor_36361b2f5d0f0896, []int{22} } func (m *TimeTicket) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3071,7 +3118,7 @@ func (m *DocEvent) Reset() { *m = DocEvent{} } func (m *DocEvent) String() string { return proto.CompactTextString(m) } func (*DocEvent) ProtoMessage() {} func (*DocEvent) Descriptor() ([]byte, []int) { - return fileDescriptor_36361b2f5d0f0896, []int{22} + return fileDescriptor_36361b2f5d0f0896, []int{23} } func (m *DocEvent) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3158,6 +3205,7 @@ func init() { proto.RegisterType((*TextNodeID)(nil), "yorkie.v1.TextNodeID") proto.RegisterType((*TreeNode)(nil), "yorkie.v1.TreeNode") proto.RegisterMapType((map[string]*NodeAttr)(nil), "yorkie.v1.TreeNode.AttributesEntry") + proto.RegisterType((*TreeNodes)(nil), "yorkie.v1.TreeNodes") proto.RegisterType((*TreePos)(nil), "yorkie.v1.TreePos") proto.RegisterType((*User)(nil), "yorkie.v1.User") proto.RegisterType((*Project)(nil), "yorkie.v1.Project") @@ -3176,159 +3224,161 @@ func init() { func init() { proto.RegisterFile("yorkie/v1/resources.proto", fileDescriptor_36361b2f5d0f0896) } var fileDescriptor_36361b2f5d0f0896 = []byte{ - // 2432 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x5a, 0xcd, 0x8f, 0x1b, 0x49, - 0x15, 0x9f, 0xb6, 0xdb, 0x1f, 0xfd, 0x3c, 0xc9, 0x38, 0x35, 0x49, 0xd6, 0xf1, 0x6e, 0x26, 0x13, - 0x67, 0x09, 0x93, 0x04, 0x3c, 0xc9, 0x90, 0xf0, 0xb1, 0x61, 0x01, 0x8f, 0xdd, 0x9b, 0x99, 0xec, - 0xc4, 0x33, 0x6a, 0x7b, 0x12, 0xb2, 0x02, 0xb5, 0x7a, 0xba, 0x2b, 0x71, 0xef, 0xd8, 0xdd, 0xbd, - 0xdd, 0x65, 0x6f, 0x7c, 0x40, 0x42, 0x08, 0x24, 0x90, 0xb8, 0x70, 0xe3, 0x3f, 0x40, 0xfc, 0x09, - 0x7b, 0xe5, 0x80, 0xe0, 0x80, 0x40, 0x62, 0x25, 0xae, 0x10, 0x0e, 0x88, 0x23, 0x42, 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 0x94, 0x44, 0x66, 0x96, 0x1c, 0x1b, 0xef, - 0x1a, 0x95, 0xdf, 0x96, 0x41, 0x0a, 0x39, 0x44, 0x5f, 0x80, 0xb4, 0x87, 0x89, 0xaf, 0x8b, 0x52, - 0x92, 0x10, 0xd5, 0x16, 0x26, 0x3b, 0x4b, 0x0a, 0x85, 0x51, 0xb4, 0x66, 0x18, 0xbe, 0x77, 0x24, - 0xa3, 0x6b, 0x86, 0x41, 0xd1, 0x9a, 0x61, 0xa0, 0x4d, 0x10, 0xa9, 0xe6, 0x19, 0x7f, 0x85, 0xad, - 0x0b, 0x89, 0xf0, 0x07, 0xf6, 0x00, 0xef, 0x2c, 0x29, 0x0c, 0x88, 0xee, 0x40, 0x96, 0x5b, 0x8f, - 0xf1, 0x5c, 0xd8, 0x7a, 0x33, 0x91, 0x84, 0xdb, 0x73, 0x67, 0x49, 0xf1, 0xc1, 0xf4, 0x1c, 0x6c, - 0x98, 0x81, 0xb7, 0x24, 0x9f, 0x23, 0x1b, 0x26, 0x95, 0x82, 0x01, 0xe9, 0x39, 0x1e, 0xee, 0x62, - 0x9d, 0x30, 0x27, 0x99, 0x76, 0x4e, 0x8b, 0x41, 0xe8, 0x39, 0x1c, 0x8c, 0xb6, 0x20, 0xe3, 0x91, - 0x61, 0x17, 0x97, 0x72, 0x8c, 0xaa, 0x9c, 0x4c, 0x45, 0x11, 0x3b, 0x4b, 0x0a, 0x87, 0xa2, 0xbb, - 0x90, 0x37, 0x2d, 0xdd, 0xc5, 0x9a, 0x87, 0x4b, 0x79, 0x46, 0x76, 0x31, 0x91, 0x6c, 0xd7, 0x07, - 0xed, 0x2c, 0x29, 0x21, 0x01, 0xfa, 0x3a, 0x48, 0xc4, 0xc5, 0x58, 0x65, 0xd2, 0x49, 0x33, 0xa8, - 0xdb, 0x2e, 0xc6, 0xbe, 0x84, 0x79, 0xe2, 0xff, 0x46, 0xdf, 0x04, 0x60, 0xd4, 0x9c, 0x67, 0x60, - 0xe4, 0x6b,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d, 0x6a, 0x14, 0x47, 0xdb, 0x15, 0x4a, 0xc5, 0x06, 0xe8, - 0x5b, 0x20, 0x39, 0xae, 0xd9, 0x33, 0x89, 0x19, 0xf6, 0x9c, 0xd3, 0x76, 0x38, 0x08, 0x70, 0x74, - 0x87, 0x90, 0x08, 0xdd, 0x02, 0x91, 0xe0, 0x67, 0x81, 0x1b, 0xbd, 0x39, 0x85, 0x98, 0xa6, 0x7c, - 0xda, 0x4a, 0x52, 0x28, 0x7a, 0x87, 0x06, 0x75, 0xdf, 0x22, 0xd8, 0xf5, 0xeb, 0x90, 0xb5, 0x29, - 0x54, 0x75, 0x8e, 0xda, 0x59, 0x52, 0x02, 0x02, 0x76, 0x9c, 0x8b, 0x83, 0x76, 0x72, 0xea, 0x71, - 0x2e, 0x66, 0x1d, 0x32, 0x85, 0x96, 0x3f, 0x15, 0x00, 0x46, 0x3a, 0x44, 0x1b, 0x90, 0xb1, 0x6c, - 0x03, 0x7b, 0x25, 0x81, 0x45, 0x52, 0x34, 0xea, 0x94, 0x9d, 0x36, 0xcb, 0x27, 0x1c, 0xb0, 0x60, - 0x15, 0x1b, 0xf5, 0xc9, 0xf4, 0x02, 0x3e, 0x29, 0xce, 0xe7, 0x93, 0xe5, 0x3f, 0x0a, 0x20, 0x85, - 0x56, 0x9d, 0x29, 0xd5, 0xbd, 0xda, 0xeb, 0x23, 0xd5, 0xdf, 0x05, 0x90, 0x42, 0x4f, 0x0b, 0xe3, - 0x4e, 0x98, 0x3f, 0xee, 0x52, 0x91, 0xb8, 0x5b, 0xb0, 0x87, 0x8a, 0xca, 0x2a, 0x2e, 0x20, 0x6b, - 0x66, 0x4e, 0x59, 0x7f, 0x2f, 0x80, 0x48, 0x03, 0x03, 0x5d, 0x1b, 0x37, 0xde, 0x6a, 0x42, 0xad, - 0xf4, 0x7a, 0x58, 0xef, 0x6f, 0x02, 0xe4, 0xfc, 0xa0, 0xfd, 0x7f, 0xb0, 0x9d, 0x8b, 0xf1, 0x4c, - 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 0x25, 0x52, 0xeb, 0xcd, 0x76, - 0xb1, 0x80, 0xde, 0x80, 0xd5, 0x98, 0x54, 0x6c, 0x61, 0x39, 0xbe, 0x93, 0x22, 0xcb, 0xc5, 0x53, - 0xd7, 0x7f, 0x21, 0xc0, 0x72, 0xd4, 0x7e, 0xe8, 0x6d, 0x58, 0x6f, 0xec, 0xd7, 0x55, 0xf9, 0xa1, - 0xdc, 0x6c, 0x07, 0x3a, 0xa8, 0x1f, 0x3e, 0x90, 0x9b, 0xed, 0x96, 0x5a, 0xdf, 0xa9, 0x35, 0xef, - 0xc9, 0x8d, 0xe2, 0xd2, 0x4c, 0xd4, 0xa3, 0x5a, 0xbb, 0xbe, 0x23, 0x37, 0x8a, 0x02, 0xba, 0x0a, - 0x95, 0xa9, 0xa8, 0xc3, 0x66, 0x80, 0x4b, 0xa1, 0x2b, 0x70, 0x29, 0x86, 0x3b, 0x50, 0xe4, 0x96, - 0xdc, 0xac, 0xcb, 0xe1, 0x91, 0xe9, 0xed, 0x1b, 0xbf, 0x79, 0xbe, 0x26, 0xfc, 0xe1, 0xf9, 0x9a, - 0xf0, 0xe7, 0xe7, 0x6b, 0xc2, 0xcf, 0xff, 0xba, 0xb6, 0x04, 0x67, 0x0c, 0x3c, 0x08, 0x9c, 0x4a, - 0x73, 0xcc, 0xea, 0xe0, 0xd6, 0x81, 0xf0, 0x81, 0x58, 0xbd, 0x3b, 0xb8, 0x75, 0x94, 0x65, 0xe9, - 0xee, 0x4b, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xe3, 0x01, 0xec, 0x60, 0x4e, 0x25, 0x00, 0x00, + // 2452 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x5a, 0x4d, 0x6f, 0xdb, 0xc8, + 0xf9, 0x37, 0xa9, 0x57, 0x3e, 0x72, 0x62, 0x65, 0xf2, 0xa6, 0x28, 0x89, 0xe3, 0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2, 0x18, 0xdb, 0x64, 0x77, 0xaf, 0xf1, + 0xa0, 0x98, 0x42, 0x67, 0xe1, 0x54, 0x64, 0x72, 0x6b, 0xef, 0x60, 0x73, 0x57, 0x2e, 0xa6, 0x63, + 0xd3, 0xcd, 0x16, 0xde, 0x69, 0x3c, 0x28, 0x66, 0xd0, 0x19, 0x28, 0x46, 0x8f, 0x7c, 0xda, 0x92, + 0x9b, 0xc5, 0x6c, 0x6c, 0xe3, 0xad, 0x5a, 0x4b, 0x2e, 0xe6, 0x50, 0x19, 0xce, 0x45, 0x26, 0x69, + 0x57, 0xa0, 0xec, 0x6d, 0x3e, 0x94, 0xeb, 0xad, 0x62, 0x1e, 0x5d, 0x80, 0xb3, 0xf1, 0xb5, 0x1a, + 0xc6, 0xb5, 0xa7, 0x45, 0x29, 0xb6, 0x57, 0x4b, 0xfe, 0x76, 0xab, 0x08, 0xb1, 0xbd, 0x7c, 0x89, + 0x94, 0x7a, 0xa3, 0x55, 0x2c, 0xa0, 0xf3, 0x70, 0x3a, 0x26, 0x15, 0x5b, 0x58, 0x8c, 0xef, 0x84, + 0x65, 0xb9, 0x78, 0xe2, 0xe6, 0x2f, 0x04, 0x58, 0x8c, 0xda, 0x0f, 0xbd, 0x03, 0x2b, 0x5b, 0x7b, + 0x75, 0x45, 0x7e, 0x2c, 0x37, 0x5a, 0x81, 0x0e, 0xea, 0x07, 0x8f, 0xe4, 0x46, 0xab, 0xa9, 0xd4, + 0xb7, 0x6b, 0x8d, 0x07, 0xf2, 0x56, 0x71, 0x61, 0x2a, 0xea, 0x49, 0xad, 0x55, 0xdf, 0x96, 0xb7, + 0x8a, 0x02, 0xba, 0x0e, 0x95, 0x89, 0xa8, 0x83, 0x46, 0x80, 0x13, 0xd1, 0x35, 0xb8, 0x12, 0xc3, + 0xed, 0x63, 0xb9, 0x29, 0x37, 0xea, 0x72, 0x78, 0x64, 0x6a, 0xf3, 0xd6, 0x6f, 0x5e, 0x2e, 0x0b, + 0x7f, 0x78, 0xb9, 0x2c, 0xfc, 0xf9, 0xe5, 0xb2, 0xf0, 0xf3, 0xbf, 0x2c, 0x2f, 0xc0, 0x29, 0x9d, + 0xf4, 0x03, 0xa7, 0x52, 0x6d, 0xa3, 0xda, 0xbf, 0xbd, 0x2f, 0x7c, 0x90, 0xae, 0xde, 0xef, 0xdf, + 0x3e, 0xcc, 0xb2, 0x74, 0xf7, 0xa5, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x9e, 0x7c, 0x09, 0xa2, + 0x8d, 0x25, 0x00, 0x00, } func (m *ChangePack) Marshal() (dAtA []byte, err error) { @@ -4453,10 +4503,10 @@ func (m *Operation_TreeEdit) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a } - if len(m.Content) > 0 { - for iNdEx := len(m.Content) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Contents) > 0 { + for iNdEx := len(m.Contents) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Content[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Contents[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -5686,6 +5736,47 @@ func (m *TreeNode) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *TreeNodes) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TreeNodes) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TreeNodes) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.Content) > 0 { + for iNdEx := len(m.Content) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Content[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintResources(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *TreePos) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -6859,8 +6950,8 @@ func (m *Operation_TreeEdit) Size() (n int) { l = m.To.Size() n += 1 + l + sovResources(uint64(l)) } - if len(m.Content) > 0 { - for _, e := range m.Content { + if len(m.Contents) > 0 { + for _, e := range m.Contents { l = e.Size() n += 1 + l + sovResources(uint64(l)) } @@ -7379,6 +7470,24 @@ func (m *TreeNode) Size() (n int) { return n } +func (m *TreeNodes) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Content) > 0 { + for _, e := range m.Content { + l = e.Size() + n += 1 + l + sovResources(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func (m *TreePos) Size() (n int) { if m == nil { return 0 @@ -10665,7 +10774,7 @@ func (m *Operation_TreeEdit) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Content", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Contents", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -10692,8 +10801,8 @@ func (m *Operation_TreeEdit) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Content = append(m.Content, &TreeNode{}) - if err := m.Content[len(m.Content)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Contents = append(m.Contents, &TreeNodes{}) + if err := m.Contents[len(m.Contents)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -13904,6 +14013,91 @@ func (m *TreeNode) Unmarshal(dAtA []byte) error { } return nil } +func (m *TreeNodes) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TreeNodes: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TreeNodes: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Content", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthResources + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthResources + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Content = append(m.Content, &TreeNode{}) + if err := m.Content[len(m.Content)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipResources(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthResources + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *TreePos) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 From dc43d23e91ee9d019773fcc5ff914ffa4f4d7d64 Mon Sep 17 00:00:00 2001 From: JOOHOJANG Date: Wed, 12 Jul 2023 09:59:35 +0900 Subject: [PATCH 05/11] Add tree node validation logic --- pkg/document/json/tree.go | 133 ++++++++++++++++++++++++++++++-------- 1 file changed, 105 insertions(+), 28 deletions(-) diff --git a/pkg/document/json/tree.go b/pkg/document/json/tree.go index 758e75f68..2b30b99dd 100644 --- a/pkg/document/json/tree.go +++ b/pkg/document/json/tree.go @@ -17,6 +17,8 @@ package json import ( + "errors" + "github.com/yorkie-team/yorkie/pkg/document/change" "github.com/yorkie-team/yorkie/pkg/document/crdt" "github.com/yorkie-team/yorkie/pkg/document/operations" @@ -29,6 +31,13 @@ const ( DefaultRootNodeType = "root" ) +var ( + // ErrEmptyTextNode is returned when there's empty string value in text node + ErrEmptyTextNode = errors.New("text node cannot have empty value") + // ErrMixedNodeType is returned when there're element node and text node inside contents array + ErrMixedNodeType = errors.New("element node and text node cannot be passed together") +) + // TreeNode is a node of Tree. type TreeNode struct { // Type is the type of this node. It is used to distinguish between text @@ -62,6 +71,41 @@ func NewTree(ctx *change.Context, tree *crdt.Tree) *Tree { } } +// validateTextNode make sure that text node have non-empty string value +func validateTextNode(treeNode TreeNode) error { + if len(treeNode.Value) == 0 { + return ErrEmptyTextNode + } + + return nil +} + +// validateTextNode make sure that treeNodes consist of only one of the two types (text or element) +func validateTreeNodes(treeNodes []*TreeNode) error { + firstTreeNodeType := treeNodes[0].Type + + if firstTreeNodeType == index.DefaultTextType { + for _, treeNode := range treeNodes { + if treeNode.Type != index.DefaultTextType { + return ErrMixedNodeType + } + + if err := validateTextNode(*treeNode); err != nil { + return err + } + } + + } else { + for _, treeNode := range treeNodes { + if treeNode.Type == index.DefaultTextType { + return ErrMixedNodeType + } + } + } + + return nil +} + // Edit edits this tree with the given node. func (t *Tree) Edit(fromIdx, toIdx int, contents []*TreeNode) bool { if fromIdx > toIdx { @@ -72,25 +116,39 @@ func (t *Tree) Edit(fromIdx, toIdx int, contents []*TreeNode) bool { var nodes []*crdt.TreeNode if len(contents) != 0 { - for _, content := range contents { - var attributes *crdt.RHT - if content.Attributes != nil { - attributes = crdt.NewRHT() - for key, val := range content.Attributes { - attributes.Set(key, val, ticket) - } + if err := validateTreeNodes(contents); err != nil { + panic(err) + } + + if contents[0].Type == index.DefaultTextType { + accOfValue := "" + + for _, content := range contents { + accOfValue += content.Value } - var node *crdt.TreeNode - node = crdt.NewTreeNode(crdt.NewTreePos(ticket, 0), content.Type, attributes, content.Value) + nodes = append(nodes, crdt.NewTreeNode(crdt.NewTreePos(ticket, 0), index.DefaultTextType, nil, accOfValue)) + } else { + for _, content := range contents { + var attributes *crdt.RHT + if content.Attributes != nil { + attributes = crdt.NewRHT() + for key, val := range content.Attributes { + attributes.Set(key, val, ticket) + } + } + var node *crdt.TreeNode + + node = crdt.NewTreeNode(crdt.NewTreePos(ticket, 0), content.Type, attributes, content.Value) - for _, child := range content.Children { - if err := buildDescendants(t.context, child, node); err != nil { - panic(err) + for _, child := range content.Children { + if err := buildDescendants(t.context, child, node); err != nil { + panic(err) + } } - } - nodes = append(nodes, node) + nodes = append(nodes, node) + } } } @@ -149,25 +207,39 @@ func (t *Tree) EditByPath(fromPath []int, toPath []int, contents []*TreeNode) bo var nodes []*crdt.TreeNode if len(contents) != 0 { - for _, content := range contents { - var attributes *crdt.RHT - if content.Attributes != nil { - attributes = crdt.NewRHT() - for key, val := range content.Attributes { - attributes.Set(key, val, ticket) - } + if err := validateTreeNodes(contents); err != nil { + panic(err) + } + + if contents[0].Type == index.DefaultTextType { + accOfValue := "" + + for _, content := range contents { + accOfValue += content.Value } - var node *crdt.TreeNode - node = crdt.NewTreeNode(crdt.NewTreePos(ticket, 0), content.Type, attributes, content.Value) + nodes = append(nodes, crdt.NewTreeNode(crdt.NewTreePos(ticket, 0), index.DefaultTextType, nil, accOfValue)) + } else { + for _, content := range contents { + var attributes *crdt.RHT + if content.Attributes != nil { + attributes = crdt.NewRHT() + for key, val := range content.Attributes { + attributes.Set(key, val, ticket) + } + } + var node *crdt.TreeNode - for _, child := range content.Children { - if err := buildDescendants(t.context, child, node); err != nil { - panic(err) + node = crdt.NewTreeNode(crdt.NewTreePos(ticket, 0), content.Type, attributes, content.Value) + + for _, child := range content.Children { + if err := buildDescendants(t.context, child, node); err != nil { + panic(err) + } } - } - nodes = append(nodes, node) + nodes = append(nodes, node) + } } } @@ -265,6 +337,11 @@ func buildRoot(ctx *change.Context, node *TreeNode, createdAt *time.Ticket) *crd // buildDescendants converts the given node to a CRDT-based tree node. func buildDescendants(ctx *change.Context, n TreeNode, parent *crdt.TreeNode) error { if n.Type == index.DefaultTextType { + + if err := validateTextNode(n); err != nil { + return err + } + treeNode := crdt.NewTreeNode(crdt.NewTreePos(ctx.IssueTimeTicket(), 0), n.Type, nil, n.Value) return parent.Append(treeNode) } From a77f5943ffc6e614a3dc45403ec627caeb45e7f9 Mon Sep 17 00:00:00 2001 From: JOOHOJANG Date: Wed, 12 Jul 2023 10:01:14 +0900 Subject: [PATCH 06/11] update TC --- api/converter/converter_test.go | 4 +- pkg/document/crdt/tree_test.go | 98 ++++++++++++++++----------------- test/integration/gc_test.go | 10 ++-- test/integration/tree_test.go | 64 +++++++++++---------- 4 files changed, 90 insertions(+), 86 deletions(-) diff --git a/api/converter/converter_test.go b/api/converter/converter_test.go index c247913a0..dd226ec38 100644 --- a/api/converter/converter_test.go +++ b/api/converter/converter_test.go @@ -115,13 +115,13 @@ func TestConverter(t *testing.T) { // tree root.SetNewTree("k5"). - Edit(0, 0, &json.TreeNode{ + Edit(0, 0, []*json.TreeNode{{ Type: "p", Children: []json.TreeNode{{ Type: "text", Value: "Hello world", }}, - }) + }}) return nil }) diff --git a/pkg/document/crdt/tree_test.go b/pkg/document/crdt/tree_test.go index 621671fc5..77fa3199e 100644 --- a/pkg/document/crdt/tree_test.go +++ b/pkg/document/crdt/tree_test.go @@ -105,7 +105,7 @@ func TestTree(t *testing.T) { // 1 //

- err := tree.EditByIndex(0, 0, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err := tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

", tree.ToXML()) helper.ListEqual(t, tree, []string{"p", "r"}) @@ -115,7 +115,7 @@ func TestTree(t *testing.T) { //

h e l l o

err = tree.EditByIndex( 1, 1, - crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "hello"), + []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "hello")}, helper.IssueTime(ctx), ) assert.NoError(t, err) @@ -128,7 +128,7 @@ func TestTree(t *testing.T) { p := crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil) err = p.InsertAt(crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "world"), 0) assert.NoError(t, err) - err = tree.EditByIndex(7, 7, p, helper.IssueTime(ctx)) + err = tree.EditByIndex(7, 7, []*crdt.TreeNode{p}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

hello

world

", tree.ToXML()) helper.ListEqual(t, tree, []string{"text.hello", "p", "text.world", "p", "r"}) @@ -138,7 +138,7 @@ func TestTree(t *testing.T) { //

h e l l o !

w o r l d

err = tree.EditByIndex( 6, 6, - crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "!"), + []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "!")}, helper.IssueTime(ctx), ) assert.NoError(t, err) @@ -173,7 +173,7 @@ func TestTree(t *testing.T) { //

h e l l o ~ !

w o r l d

err = tree.EditByIndex( 6, 6, - crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "~"), + []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "~")}, helper.IssueTime(ctx), ) assert.NoError(t, err) @@ -188,13 +188,13 @@ func TestTree(t *testing.T) { ctx := helper.TextChangeContext(helper.TestRoot()) tree := crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err := tree.EditByIndex(0, 0, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err := tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab"), helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(4, 4, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(4, 4, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(5, 5, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "cd"), helper.IssueTime(ctx)) + err = tree.EditByIndex(5, 5, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "cd")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

cd

", tree.ToXML()) helper.ListEqual(t, tree, []string{"text.ab", "p", "text.cd", "p", "root"}) @@ -225,13 +225,13 @@ func TestTree(t *testing.T) { ctx := helper.TextChangeContext(helper.TestRoot()) tree := crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err := tree.EditByIndex(0, 0, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err := tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab"), helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(4, 4, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(4, 4, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(5, 5, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "cd"), helper.IssueTime(ctx)) + err = tree.EditByIndex(5, 5, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "cd")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

cd

", tree.ToXML()) helper.ListEqual(t, tree, []string{"text.ab", "p", "text.cd", "p", "root"}) @@ -251,7 +251,7 @@ func TestTree(t *testing.T) { assert.Equal(t, 1, structure.Children[0].Children[1].Size) // 03. insert a new text node at the start of the first paragraph. - err = tree.EditByIndex(1, 1, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "@"), helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "@")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

@ad

", tree.ToXML()) }) @@ -262,13 +262,13 @@ func TestTree(t *testing.T) { //

a b

ctx := helper.TextChangeContext(helper.TestRoot()) tree := crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err := tree.EditByIndex(0, 0, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err := tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(2, 2, crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(3, 3, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab"), helper.IssueTime(ctx)) + err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

", tree.ToXML()) err = tree.EditByIndex(5, 6, nil, helper.IssueTime(ctx)) @@ -277,13 +277,13 @@ func TestTree(t *testing.T) { // 02. Edit between two element nodes in same hierarchy. tree = crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err = tree.EditByIndex(0, 0, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(2, 2, crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(3, 3, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab"), helper.IssueTime(ctx)) + err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

", tree.ToXML()) err = tree.EditByIndex(6, 7, nil, helper.IssueTime(ctx)) @@ -292,13 +292,13 @@ func TestTree(t *testing.T) { // 03. Edit between text and element node in same hierarchy. tree = crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err = tree.EditByIndex(0, 0, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(2, 2, crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(3, 3, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab"), helper.IssueTime(ctx)) + err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

", tree.ToXML()) err = tree.EditByIndex(4, 6, nil, helper.IssueTime(ctx)) @@ -307,13 +307,13 @@ func TestTree(t *testing.T) { // 04. Edit between text and element node in same hierarchy. tree = crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err = tree.EditByIndex(0, 0, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(2, 2, crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(3, 3, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab"), helper.IssueTime(ctx)) + err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

", tree.ToXML()) err = tree.EditByIndex(5, 7, nil, helper.IssueTime(ctx)) @@ -322,13 +322,13 @@ func TestTree(t *testing.T) { // 05. Edit between text and element node in same hierarchy. tree = crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err = tree.EditByIndex(0, 0, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(2, 2, crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(3, 3, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab"), helper.IssueTime(ctx)) + err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

", tree.ToXML()) err = tree.EditByIndex(4, 7, nil, helper.IssueTime(ctx)) @@ -337,13 +337,13 @@ func TestTree(t *testing.T) { // 06. Edit between text and element node in same hierarchy. tree = crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err = tree.EditByIndex(0, 0, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(2, 2, crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(3, 3, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab"), helper.IssueTime(ctx)) + err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

", tree.ToXML()) err = tree.EditByIndex(3, 7, nil, helper.IssueTime(ctx)) @@ -352,19 +352,19 @@ func TestTree(t *testing.T) { // 07. Edit between text and element node in same hierarchy. tree = crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err = tree.EditByIndex(0, 0, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab"), helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(4, 4, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(4, 4, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(5, 5, crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(5, 5, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(6, 6, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "cd"), helper.IssueTime(ctx)) + err = tree.EditByIndex(6, 6, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "cd")}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(10, 10, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(10, 10, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(11, 11, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ef"), helper.IssueTime(ctx)) + err = tree.EditByIndex(11, 11, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ef")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

cd

ef

", tree.ToXML()) err = tree.EditByIndex(9, 10, nil, helper.IssueTime(ctx)) @@ -376,13 +376,13 @@ func TestTree(t *testing.T) { // 01. style attributes to an element node. ctx := helper.TextChangeContext(helper.TestRoot()) tree := crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err := tree.EditByIndex(0, 0, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err := tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab"), helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(4, 4, crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil), helper.IssueTime(ctx)) + err = tree.EditByIndex(4, 4, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(5, 5, crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "cd"), helper.IssueTime(ctx)) + err = tree.EditByIndex(5, 5, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "cd")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

cd

", tree.ToXML()) diff --git a/test/integration/gc_test.go b/test/integration/gc_test.go index d425f2b23..32738ee4c 100644 --- a/test/integration/gc_test.go +++ b/test/integration/gc_test.go @@ -201,7 +201,7 @@ func TestGarbageCollection(t *testing.T) { assert.NoError(t, err) err = doc.Update(func(root *json.Object) error { - root.GetTree("t").EditByPath([]int{0, 0, 0}, []int{0, 0, 2}, &json.TreeNode{Type: "text", Value: "gh"}) + root.GetTree("t").EditByPath([]int{0, 0, 0}, []int{0, 0, 2}, []*json.TreeNode{{Type: "text", Value: "gh"}}) assert.Equal(t, `

ghcd

`, root.GetTree("t").ToXML()) return nil }) @@ -213,7 +213,7 @@ func TestGarbageCollection(t *testing.T) { assert.Equal(t, doc.GarbageLen(), 0) err = doc.Update(func(root *json.Object) error { - root.GetTree("t").EditByPath([]int{0, 0, 0}, []int{0, 0, 2}, &json.TreeNode{Type: "text", Value: "cv"}) + root.GetTree("t").EditByPath([]int{0, 0, 0}, []int{0, 0, 2}, []*json.TreeNode{{Type: "text", Value: "cv"}}) assert.Equal(t, `

cvcd

`, root.GetTree("t").ToXML()) return nil }) @@ -225,12 +225,12 @@ func TestGarbageCollection(t *testing.T) { assert.Equal(t, doc.GarbageLen(), 0) err = doc.Update(func(root *json.Object) error { - root.GetTree("t").EditByPath([]int{0}, []int{1}, &json.TreeNode{ + root.GetTree("t").EditByPath([]int{0}, []int{1}, []*json.TreeNode{{ Type: "p", Children: []json.TreeNode{{ Type: "tn", Children: []json.TreeNode{{ Type: "text", Value: "ab", }}, - }}}) + }}}}) assert.Equal(t, `

ab

`, root.GetTree("t").ToXML()) return nil }) @@ -282,7 +282,7 @@ func TestGarbageCollection(t *testing.T) { assert.NoError(t, err) err = d2.Update(func(root *json.Object) error { - root.GetTree("t").EditByPath([]int{0, 0, 0}, []int{0, 0, 2}, &json.TreeNode{Type: "text", Value: "gh"}) + root.GetTree("t").EditByPath([]int{0, 0, 0}, []int{0, 0, 2}, []*json.TreeNode{{Type: "text", Value: "gh"}}) return nil }) assert.NoError(t, err) diff --git a/test/integration/tree_test.go b/test/integration/tree_test.go index 9d803e3d8..b85300aa6 100644 --- a/test/integration/tree_test.go +++ b/test/integration/tree_test.go @@ -38,18 +38,18 @@ func TestTree(t *testing.T) { doc := document.New(helper.TestDocKey(t)) err := doc.Update(func(root *json.Object) error { // 01. Create a tree and insert a paragraph. - root.SetNewTree("t").Edit(0, 0, &json.TreeNode{ + root.SetNewTree("t").Edit(0, 0, []*json.TreeNode{{ Type: "p", Children: []json.TreeNode{}, - }) + }}) assert.Equal(t, "

", root.GetTree("t").ToXML()) assert.Equal(t, `{"t":{"type":"root","children":[{"type":"p","children":[]}]}}`, root.Marshal()) // 02. Create a text into the paragraph. - root.GetTree("t").Edit(1, 1, &json.TreeNode{ + root.GetTree("t").Edit(1, 1, []*json.TreeNode{{ Type: "text", Value: "AB", - }) + }}) assert.Equal(t, "

AB

", root.GetTree("t").ToXML()) assert.Equal( t, @@ -58,10 +58,10 @@ func TestTree(t *testing.T) { ) // 03. Insert a text into the paragraph. - root.GetTree("t").Edit(3, 3, &json.TreeNode{ + root.GetTree("t").Edit(3, 3, []*json.TreeNode{{ Type: "text", Value: "CD", - }) + }}) assert.Equal(t, "

ABCD

", root.GetTree("t").ToXML()) // TODO(krapie): consider other options to avoid line over @@ -74,10 +74,10 @@ func TestTree(t *testing.T) { ) // 04. Replace ABCD with Yorkie - root.GetTree("t").Edit(1, 5, &json.TreeNode{ + root.GetTree("t").Edit(1, 5, []*json.TreeNode{{ Type: "text", Value: "Yorkie", - }) + }}) assert.Equal(t, "

Yorkie

", root.GetTree("t").ToXML()) assert.Equal( t, @@ -149,19 +149,19 @@ func TestTree(t *testing.T) { }) assert.Equal(t, "

ab

", root.GetTree("t").ToXML()) - root.GetTree("t").Edit(1, 1, &json.TreeNode{ + root.GetTree("t").Edit(1, 1, []*json.TreeNode{{ Type: "text", Value: "X", - }) + }}) assert.Equal(t, "

Xab

", root.GetTree("t").ToXML()) root.GetTree("t").Edit(1, 2, nil) assert.Equal(t, "

ab

", root.GetTree("t").ToXML()) - root.GetTree("t").Edit(2, 2, &json.TreeNode{ + root.GetTree("t").Edit(2, 2, []*json.TreeNode{{ Type: "text", Value: "X", - }) + }}) assert.Equal(t, "

aXb

", root.GetTree("t").ToXML()) root.GetTree("t").Edit(2, 3, nil) @@ -182,10 +182,10 @@ func TestTree(t *testing.T) { }) assert.Equal(t, "

ab

", root.GetTree("t").ToXML()) - root.GetTree("t").Edit(3, 3, &json.TreeNode{ + root.GetTree("t").Edit(3, 3, []*json.TreeNode{{ Type: "text", Value: "X", - }) + }}) assert.Equal(t, "

abX

", root.GetTree("t").ToXML()) root.GetTree("t").Edit(3, 4, nil) @@ -217,27 +217,31 @@ func TestTree(t *testing.T) { }) assert.Equal(t, "

ab

", root.GetTree("t").ToXML()) - root.GetTree("t").EditByPath([]int{0, 0, 0, 1}, []int{0, 0, 0, 1}, &json.TreeNode{ + root.GetTree("t").EditByPath([]int{0, 0, 0, 1}, []int{0, 0, 0, 1}, []*json.TreeNode{{ Type: "text", Value: "X", - }) + }}) assert.Equal(t, "

aXb

", root.GetTree("t").ToXML()) - root.GetTree("t").EditByPath([]int{0, 0, 0, 3}, []int{0, 0, 0, 3}, &json.TreeNode{ + root.GetTree("t").EditByPath([]int{0, 0, 0, 3}, []int{0, 0, 0, 3}, []*json.TreeNode{{ Type: "text", Value: "!", - }) + }}) assert.Equal(t, "

aXb!

", root.GetTree("t").ToXML()) - root.GetTree("t").EditByPath([]int{0, 0, 1}, []int{0, 0, 1}, &json.TreeNode{ + root.GetTree("t").EditByPath([]int{0, 0, 1}, []int{0, 0, 1}, []*json.TreeNode{{ Type: "tn", Children: []json.TreeNode{}, - }) + }}) assert.Equal(t, "

aXb!

", root.GetTree("t").ToXML()) return nil }) assert.NoError(t, err) }) + return nil + }) + assert.NoError(t, err) + }) t.Run("edit its content with attributes test", func(t *testing.T) { doc := document.New(helper.TestDocKey(t)) @@ -245,18 +249,18 @@ func TestTree(t *testing.T) { root.SetNewTree("t", &json.TreeNode{Type: "doc"}) assert.Equal(t, "", root.GetTree("t").ToXML()) - root.GetTree("t").Edit(0, 0, &json.TreeNode{ + root.GetTree("t").Edit(0, 0, []*json.TreeNode{{ Type: "p", Attributes: map[string]string{"bold": "true"}, Children: []json.TreeNode{{Type: "text", Value: "ab"}}, - }) + }}) assert.Equal(t, `

ab

`, root.GetTree("t").ToXML()) - root.GetTree("t").Edit(4, 4, &json.TreeNode{ + root.GetTree("t").Edit(4, 4, []*json.TreeNode{{ Type: "p", Attributes: map[string]string{"italic": "true"}, Children: []json.TreeNode{{Type: "text", Value: "cd"}}, - }) + }}) assert.Equal(t, `

ab

cd

`, root.GetTree("t").ToXML()) root.GetTree("t").Edit(2, 6, nil) @@ -349,11 +353,11 @@ func TestTree(t *testing.T) { assert.NoError(t, c2.Attach(ctx, d2)) assert.NoError(t, d1.Update(func(root *json.Object) error { - root.GetTree("t").Edit(1, 1, &json.TreeNode{Type: "text", Value: "A"}) + root.GetTree("t").Edit(1, 1, []*json.TreeNode{{Type: "text", Value: "A"}}) return nil })) assert.NoError(t, d2.Update(func(root *json.Object) error { - root.GetTree("t").Edit(1, 1, &json.TreeNode{Type: "text", Value: "B"}) + root.GetTree("t").Edit(1, 1, []*json.TreeNode{{Type: "text", Value: "B"}}) return nil })) assert.Equal(t, "

A12

", d1.Root().GetTree("t").ToXML()) @@ -385,11 +389,11 @@ func TestTree(t *testing.T) { assert.NoError(t, c2.Attach(ctx, d2)) assert.NoError(t, d1.Update(func(root *json.Object) error { - root.GetTree("t").Edit(2, 2, &json.TreeNode{Type: "text", Value: "A"}) + root.GetTree("t").Edit(2, 2, []*json.TreeNode{{Type: "text", Value: "A"}}) return nil })) assert.NoError(t, d2.Update(func(root *json.Object) error { - root.GetTree("t").Edit(2, 2, &json.TreeNode{Type: "text", Value: "B"}) + root.GetTree("t").Edit(2, 2, []*json.TreeNode{{Type: "text", Value: "B"}}) return nil })) assert.Equal(t, "

1A2

", d1.Root().GetTree("t").ToXML()) @@ -420,11 +424,11 @@ func TestTree(t *testing.T) { assert.NoError(t, c2.Attach(ctx, d2)) assert.NoError(t, d1.Update(func(root *json.Object) error { - root.GetTree("t").Edit(3, 3, &json.TreeNode{Type: "text", Value: "A"}) + root.GetTree("t").Edit(3, 3, []*json.TreeNode{{Type: "text", Value: "A"}}) return nil })) assert.NoError(t, d2.Update(func(root *json.Object) error { - root.GetTree("t").Edit(3, 3, &json.TreeNode{Type: "text", Value: "B"}) + root.GetTree("t").Edit(3, 3, []*json.TreeNode{{Type: "text", Value: "B"}}) return nil })) assert.Equal(t, "

12A

", d1.Root().GetTree("t").ToXML()) From 36b134fcd73557c7821182e474beb25782005d6e Mon Sep 17 00:00:00 2001 From: JOOHOJANG Date: Wed, 12 Jul 2023 10:02:32 +0900 Subject: [PATCH 07/11] add TC for multi tree nodes passed --- test/integration/tree_test.go | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/integration/tree_test.go b/test/integration/tree_test.go index b85300aa6..932c7df01 100644 --- a/test/integration/tree_test.go +++ b/test/integration/tree_test.go @@ -238,6 +238,43 @@ func TestTree(t *testing.T) { }) assert.NoError(t, err) }) + + t.Run("edit its content when multi tree nodes passed", func(t *testing.T) { + doc := document.New(helper.TestDocKey(t)) + err := doc.Update(func(root *json.Object) error { + root.SetNewTree("t", &json.TreeNode{ + Type: "doc", + Children: []json.TreeNode{{ + Type: "tc", + Children: []json.TreeNode{{ + Type: "p", Children: []json.TreeNode{{ + Type: "tn", Children: []json.TreeNode{{ + Type: "text", Value: "ab", + }}, + }}, + }}, + }}, + }) + assert.Equal(t, "

ab

", root.GetTree("t").ToXML()) + + root.GetTree("t").EditByPath([]int{0, 0, 0, 1}, []int{0, 0, 0, 1}, []*json.TreeNode{{ + Type: "text", + Value: "X", + }, { + Type: "text", + Value: "X", + }}) + assert.Equal(t, "

aXXb

", root.GetTree("t").ToXML()) + + root.GetTree("t").EditByPath([]int{0, 1}, []int{0, 1}, []*json.TreeNode{{ + Type: "p", + Children: []json.TreeNode{{Type: "tn", Children: []json.TreeNode{{Type: "text", Value: "te"}, {Type: "text", Value: "st"}}}}, + }, { + Type: "p", + Children: []json.TreeNode{{Type: "tn", Children: []json.TreeNode{{Type: "text", Value: "te"}, {Type: "text", Value: "xt"}}}}, + }}) + assert.Equal(t, "

aXXb

test

text

", root.GetTree("t").ToXML()) + return nil }) assert.NoError(t, err) From d9776a9878ebe856ad61cf87ae080f40b7ce1a4b Mon Sep 17 00:00:00 2001 From: JOOHOJANG Date: Wed, 12 Jul 2023 10:19:14 +0900 Subject: [PATCH 08/11] update TC to test several cases --- test/integration/tree_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/integration/tree_test.go b/test/integration/tree_test.go index 932c7df01..5098fb7a9 100644 --- a/test/integration/tree_test.go +++ b/test/integration/tree_test.go @@ -275,6 +275,12 @@ func TestTree(t *testing.T) { }}) assert.Equal(t, "

aXXb

test

text

", root.GetTree("t").ToXML()) + root.GetTree("t").EditByPath([]int{0, 3}, []int{0, 3}, []*json.TreeNode{{ + Type: "p", + Children: []json.TreeNode{{Type: "tn", Children: []json.TreeNode{{Type: "text", Value: "te"}, {Type: "text", Value: "st"}}}}, + }, {Type: "tn", Children: []json.TreeNode{{Type: "text", Value: "te"}, {Type: "text", Value: "xt"}}}}) + assert.Equal(t, "

aXXb

test

text

test

text
", root.GetTree("t").ToXML()) + return nil }) assert.NoError(t, err) From 124c060d44b06809ba0d64dac3245bc862c332c6 Mon Sep 17 00:00:00 2001 From: JOOHOJANG Date: Wed, 12 Jul 2023 10:34:05 +0900 Subject: [PATCH 09/11] Fix lint and add comment --- api/converter/from_pb.go | 2 + pkg/document/crdt/tree_test.go | 138 ++++++++++++++++++++++----------- 2 files changed, 94 insertions(+), 46 deletions(-) diff --git a/api/converter/from_pb.go b/api/converter/from_pb.go index 74a5f6a2c..deee8b5f4 100644 --- a/api/converter/from_pb.go +++ b/api/converter/from_pb.go @@ -647,6 +647,8 @@ func FromTreeNodes(pbNodes []*api.TreeNode) (*crdt.TreeNode, error) { return crdt.NewTree(root, nil).Root(), nil } +// FromTreeNodesWhenEdit converts protobuf tree nodes to array of crdt.TreeNode. +// in each element in array, the last node in slice is the root node, because the slice is in post-order. func FromTreeNodesWhenEdit(pbNodes []*api.TreeNodes) ([]*crdt.TreeNode, error) { if len(pbNodes) == 0 { return nil, nil diff --git a/pkg/document/crdt/tree_test.go b/pkg/document/crdt/tree_test.go index 77fa3199e..a7e028f53 100644 --- a/pkg/document/crdt/tree_test.go +++ b/pkg/document/crdt/tree_test.go @@ -105,7 +105,8 @@ func TestTree(t *testing.T) { // 1 //

- err := tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + err := tree.EditByIndex(0, 0, + []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

", tree.ToXML()) helper.ListEqual(t, tree, []string{"p", "r"}) @@ -187,14 +188,19 @@ func TestTree(t *testing.T) { //

a b

c d

ctx := helper.TextChangeContext(helper.TestRoot()) - tree := crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err := tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + tree := crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), + "root", nil), helper.IssueTime(ctx)) + err := tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(4, 4, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(4, 4, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(5, 5, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "cd")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(5, 5, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "cd")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

cd

", tree.ToXML()) helper.ListEqual(t, tree, []string{"text.ab", "p", "text.cd", "p", "root"}) @@ -225,13 +231,17 @@ func TestTree(t *testing.T) { ctx := helper.TextChangeContext(helper.TestRoot()) tree := crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err := tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + err := tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(4, 4, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(4, 4, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(5, 5, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "cd")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(5, 5, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "cd")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

cd

", tree.ToXML()) helper.ListEqual(t, tree, []string{"text.ab", "p", "text.cd", "p", "root"}) @@ -251,7 +261,8 @@ func TestTree(t *testing.T) { assert.Equal(t, 1, structure.Children[0].Children[1].Size) // 03. insert a new text node at the start of the first paragraph. - err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "@")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "@")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

@ad

", tree.ToXML()) }) @@ -262,13 +273,17 @@ func TestTree(t *testing.T) { //

a b

ctx := helper.TextChangeContext(helper.TestRoot()) tree := crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err := tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + err := tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "b", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "i", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

", tree.ToXML()) err = tree.EditByIndex(5, 6, nil, helper.IssueTime(ctx)) @@ -277,13 +292,17 @@ func TestTree(t *testing.T) { // 02. Edit between two element nodes in same hierarchy. tree = crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "b", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "i", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

", tree.ToXML()) err = tree.EditByIndex(6, 7, nil, helper.IssueTime(ctx)) @@ -292,13 +311,17 @@ func TestTree(t *testing.T) { // 03. Edit between text and element node in same hierarchy. tree = crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "b", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "i", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

", tree.ToXML()) err = tree.EditByIndex(4, 6, nil, helper.IssueTime(ctx)) @@ -307,13 +330,17 @@ func TestTree(t *testing.T) { // 04. Edit between text and element node in same hierarchy. tree = crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "b", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "i", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

", tree.ToXML()) err = tree.EditByIndex(5, 7, nil, helper.IssueTime(ctx)) @@ -322,13 +349,17 @@ func TestTree(t *testing.T) { // 05. Edit between text and element node in same hierarchy. tree = crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "b", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "i", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

", tree.ToXML()) err = tree.EditByIndex(4, 7, nil, helper.IssueTime(ctx)) @@ -337,13 +368,17 @@ func TestTree(t *testing.T) { // 06. Edit between text and element node in same hierarchy. tree = crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "b", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "i", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(2, 2, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "i", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(3, 3, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

", tree.ToXML()) err = tree.EditByIndex(3, 7, nil, helper.IssueTime(ctx)) @@ -352,19 +387,26 @@ func TestTree(t *testing.T) { // 07. Edit between text and element node in same hierarchy. tree = crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(4, 4, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(4, 4, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(5, 5, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "b", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(5, 5, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "b", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(6, 6, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "cd")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(6, 6, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "cd")}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(10, 10, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(10, 10, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(11, 11, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ef")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(11, 11, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "ef")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

cd

ef

", tree.ToXML()) err = tree.EditByIndex(9, 10, nil, helper.IssueTime(ctx)) @@ -376,13 +418,17 @@ func TestTree(t *testing.T) { // 01. style attributes to an element node. ctx := helper.TextChangeContext(helper.TestRoot()) tree := crdt.NewTree(crdt.NewTreeNode(helper.IssuePos(ctx), "root", nil), helper.IssueTime(ctx)) - err := tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + err := tree.EditByIndex(0, 0, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "ab")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(1, 1, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "ab")}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(4, 4, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "p", nil)}, helper.IssueTime(ctx)) + err = tree.EditByIndex(4, 4, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "p", nil)}, helper.IssueTime(ctx)) assert.NoError(t, err) - err = tree.EditByIndex(5, 5, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), "text", nil, "cd")}, helper.IssueTime(ctx)) + err = tree.EditByIndex(5, 5, []*crdt.TreeNode{crdt.NewTreeNode(helper.IssuePos(ctx), + "text", nil, "cd")}, helper.IssueTime(ctx)) assert.NoError(t, err) assert.Equal(t, "

ab

cd

", tree.ToXML()) From 94bc5e5e38226e2af5f8fbc061daf94e85314501 Mon Sep 17 00:00:00 2001 From: JOOHOJANG Date: Wed, 12 Jul 2023 10:52:02 +0900 Subject: [PATCH 10/11] Remove duplicate code and specify error --- pkg/document/json/tree.go | 128 +++++++++++--------------------------- 1 file changed, 38 insertions(+), 90 deletions(-) diff --git a/pkg/document/json/tree.go b/pkg/document/json/tree.go index 2b30b99dd..dca35b223 100644 --- a/pkg/document/json/tree.go +++ b/pkg/document/json/tree.go @@ -36,6 +36,12 @@ var ( ErrEmptyTextNode = errors.New("text node cannot have empty value") // ErrMixedNodeType is returned when there're element node and text node inside contents array ErrMixedNodeType = errors.New("element node and text node cannot be passed together") + // ErrIndexBoundary is returned when from index is bigger than to index + ErrIndexBoundary = errors.New("from should be less than or equal to to") + // ErrPathLenDiff is returned when two paths have different length + ErrPathLenDiff = errors.New("both paths should have same length") + // ErrEmptyPath is returned when there's empty path + ErrEmptyPath = errors.New("path should not be empty") ) // TreeNode is a node of Tree. @@ -106,50 +112,10 @@ func validateTreeNodes(treeNodes []*TreeNode) error { return nil } -// Edit edits this tree with the given node. +// Edit edits this tree with the given nodes. func (t *Tree) Edit(fromIdx, toIdx int, contents []*TreeNode) bool { if fromIdx > toIdx { - panic("from should be less than or equal to to") - } - ticket := t.context.IssueTimeTicket() - - var nodes []*crdt.TreeNode - - if len(contents) != 0 { - if err := validateTreeNodes(contents); err != nil { - panic(err) - } - - if contents[0].Type == index.DefaultTextType { - accOfValue := "" - - for _, content := range contents { - accOfValue += content.Value - } - - nodes = append(nodes, crdt.NewTreeNode(crdt.NewTreePos(ticket, 0), index.DefaultTextType, nil, accOfValue)) - } else { - for _, content := range contents { - var attributes *crdt.RHT - if content.Attributes != nil { - attributes = crdt.NewRHT() - for key, val := range content.Attributes { - attributes.Set(key, val, ticket) - } - } - var node *crdt.TreeNode - - node = crdt.NewTreeNode(crdt.NewTreePos(ticket, 0), content.Type, attributes, content.Value) - - for _, child := range content.Children { - if err := buildDescendants(t.context, child, node); err != nil { - panic(err) - } - } - - nodes = append(nodes, node) - } - } + panic(ErrIndexBoundary) } fromPos, err := t.Tree.FindPos(fromIdx) @@ -161,38 +127,7 @@ func (t *Tree) Edit(fromIdx, toIdx int, contents []*TreeNode) bool { panic(err) } - var clones []*crdt.TreeNode - if len(nodes) != 0 { - for _, node := range nodes { - var clone *crdt.TreeNode - - clone, err = node.DeepCopy() - if err != nil { - panic(err) - } - - clones = append(clones, clone) - } - } - - ticket = t.context.LastTimeTicket() - if err = t.Tree.Edit(fromPos, toPos, clones, ticket); err != nil { - panic(err) - } - - t.context.Push(operations.NewTreeEdit( - t.CreatedAt(), - fromPos, - toPos, - nodes, - ticket, - )) - - if fromPos.CreatedAt.Compare(toPos.CreatedAt) != 0 || fromPos.Offset != toPos.Offset { - t.context.RegisterElementHasRemovedNodes(t.Tree) - } - - return true + return t.edit(fromPos, toPos, contents) } // Len returns the length of this tree. @@ -200,8 +135,8 @@ func (t *Tree) Len() int { return t.IndexTree.Root().Len() } -// EditByPath edits this tree with the given path and node. -func (t *Tree) EditByPath(fromPath []int, toPath []int, contents []*TreeNode) bool { +// edit edits the tree with the given nodes +func (t *Tree) edit(fromPos, toPos *crdt.TreePos, contents []*TreeNode) bool { ticket := t.context.IssueTimeTicket() var nodes []*crdt.TreeNode @@ -212,13 +147,13 @@ func (t *Tree) EditByPath(fromPath []int, toPath []int, contents []*TreeNode) bo } if contents[0].Type == index.DefaultTextType { - accOfValue := "" + value := "" for _, content := range contents { - accOfValue += content.Value + value += content.Value } - nodes = append(nodes, crdt.NewTreeNode(crdt.NewTreePos(ticket, 0), index.DefaultTextType, nil, accOfValue)) + nodes = append(nodes, crdt.NewTreeNode(crdt.NewTreePos(ticket, 0), index.DefaultTextType, nil, value)) } else { for _, content := range contents { var attributes *crdt.RHT @@ -243,21 +178,12 @@ func (t *Tree) EditByPath(fromPath []int, toPath []int, contents []*TreeNode) bo } } - fromPos, err := t.Tree.PathToPos(fromPath) - if err != nil { - panic(err) - } - toPos, err := t.Tree.PathToPos(toPath) - if err != nil { - panic(err) - } - var clones []*crdt.TreeNode if len(nodes) != 0 { for _, node := range nodes { var clone *crdt.TreeNode - clone, err = node.DeepCopy() + clone, err := node.DeepCopy() if err != nil { panic(err) } @@ -267,7 +193,7 @@ func (t *Tree) EditByPath(fromPath []int, toPath []int, contents []*TreeNode) bo } ticket = t.context.LastTimeTicket() - if err = t.Tree.Edit(fromPos, toPos, clones, ticket); err != nil { + if err := t.Tree.Edit(fromPos, toPos, clones, ticket); err != nil { panic(err) } @@ -286,6 +212,28 @@ func (t *Tree) EditByPath(fromPath []int, toPath []int, contents []*TreeNode) bo return true } +// EditByPath edits this tree with the given path and nodes. +func (t *Tree) EditByPath(fromPath []int, toPath []int, contents []*TreeNode) bool { + if len(fromPath) != len(toPath) { + panic(ErrPathLenDiff) + } + + if len(fromPath) == 0 || len(toPath) == 0 { + panic(ErrEmptyPath) + } + + fromPos, err := t.Tree.PathToPos(fromPath) + if err != nil { + panic(err) + } + toPos, err := t.Tree.PathToPos(toPath) + if err != nil { + panic(err) + } + + return t.edit(fromPos, toPos, contents) +} + // Style sets the attributes to the elements of the given range. func (t *Tree) Style(fromIdx, toIdx int, attributes map[string]string) bool { if fromIdx > toIdx { From d1f5991b05679b94010d336c0a3c2fb90e5b4a9e Mon Sep 17 00:00:00 2001 From: JOOHOJANG Date: Thu, 13 Jul 2023 16:47:05 +0900 Subject: [PATCH 11/11] Apply review > change contents to variadic arguments and fix TC --- api/converter/converter_test.go | 4 +- pkg/document/json/tree.go | 6 +-- test/integration/gc_test.go | 10 ++-- test/integration/tree_test.go | 85 ++++++++++++++++----------------- 4 files changed, 52 insertions(+), 53 deletions(-) diff --git a/api/converter/converter_test.go b/api/converter/converter_test.go index dd226ec38..c247913a0 100644 --- a/api/converter/converter_test.go +++ b/api/converter/converter_test.go @@ -115,13 +115,13 @@ func TestConverter(t *testing.T) { // tree root.SetNewTree("k5"). - Edit(0, 0, []*json.TreeNode{{ + Edit(0, 0, &json.TreeNode{ Type: "p", Children: []json.TreeNode{{ Type: "text", Value: "Hello world", }}, - }}) + }) return nil }) diff --git a/pkg/document/json/tree.go b/pkg/document/json/tree.go index dca35b223..78e33b228 100644 --- a/pkg/document/json/tree.go +++ b/pkg/document/json/tree.go @@ -113,7 +113,7 @@ func validateTreeNodes(treeNodes []*TreeNode) error { } // Edit edits this tree with the given nodes. -func (t *Tree) Edit(fromIdx, toIdx int, contents []*TreeNode) bool { +func (t *Tree) Edit(fromIdx, toIdx int, contents ...*TreeNode) bool { if fromIdx > toIdx { panic(ErrIndexBoundary) } @@ -141,7 +141,7 @@ func (t *Tree) edit(fromPos, toPos *crdt.TreePos, contents []*TreeNode) bool { var nodes []*crdt.TreeNode - if len(contents) != 0 { + if len(contents) != 0 && contents[0] != nil { if err := validateTreeNodes(contents); err != nil { panic(err) } @@ -213,7 +213,7 @@ func (t *Tree) edit(fromPos, toPos *crdt.TreePos, contents []*TreeNode) bool { } // EditByPath edits this tree with the given path and nodes. -func (t *Tree) EditByPath(fromPath []int, toPath []int, contents []*TreeNode) bool { +func (t *Tree) EditByPath(fromPath []int, toPath []int, contents ...*TreeNode) bool { if len(fromPath) != len(toPath) { panic(ErrPathLenDiff) } diff --git a/test/integration/gc_test.go b/test/integration/gc_test.go index 32738ee4c..d425f2b23 100644 --- a/test/integration/gc_test.go +++ b/test/integration/gc_test.go @@ -201,7 +201,7 @@ func TestGarbageCollection(t *testing.T) { assert.NoError(t, err) err = doc.Update(func(root *json.Object) error { - root.GetTree("t").EditByPath([]int{0, 0, 0}, []int{0, 0, 2}, []*json.TreeNode{{Type: "text", Value: "gh"}}) + root.GetTree("t").EditByPath([]int{0, 0, 0}, []int{0, 0, 2}, &json.TreeNode{Type: "text", Value: "gh"}) assert.Equal(t, `

ghcd

`, root.GetTree("t").ToXML()) return nil }) @@ -213,7 +213,7 @@ func TestGarbageCollection(t *testing.T) { assert.Equal(t, doc.GarbageLen(), 0) err = doc.Update(func(root *json.Object) error { - root.GetTree("t").EditByPath([]int{0, 0, 0}, []int{0, 0, 2}, []*json.TreeNode{{Type: "text", Value: "cv"}}) + root.GetTree("t").EditByPath([]int{0, 0, 0}, []int{0, 0, 2}, &json.TreeNode{Type: "text", Value: "cv"}) assert.Equal(t, `

cvcd

`, root.GetTree("t").ToXML()) return nil }) @@ -225,12 +225,12 @@ func TestGarbageCollection(t *testing.T) { assert.Equal(t, doc.GarbageLen(), 0) err = doc.Update(func(root *json.Object) error { - root.GetTree("t").EditByPath([]int{0}, []int{1}, []*json.TreeNode{{ + root.GetTree("t").EditByPath([]int{0}, []int{1}, &json.TreeNode{ Type: "p", Children: []json.TreeNode{{ Type: "tn", Children: []json.TreeNode{{ Type: "text", Value: "ab", }}, - }}}}) + }}}) assert.Equal(t, `

ab

`, root.GetTree("t").ToXML()) return nil }) @@ -282,7 +282,7 @@ func TestGarbageCollection(t *testing.T) { assert.NoError(t, err) err = d2.Update(func(root *json.Object) error { - root.GetTree("t").EditByPath([]int{0, 0, 0}, []int{0, 0, 2}, []*json.TreeNode{{Type: "text", Value: "gh"}}) + root.GetTree("t").EditByPath([]int{0, 0, 0}, []int{0, 0, 2}, &json.TreeNode{Type: "text", Value: "gh"}) return nil }) assert.NoError(t, err) diff --git a/test/integration/tree_test.go b/test/integration/tree_test.go index 5098fb7a9..beceb8f44 100644 --- a/test/integration/tree_test.go +++ b/test/integration/tree_test.go @@ -38,18 +38,18 @@ func TestTree(t *testing.T) { doc := document.New(helper.TestDocKey(t)) err := doc.Update(func(root *json.Object) error { // 01. Create a tree and insert a paragraph. - root.SetNewTree("t").Edit(0, 0, []*json.TreeNode{{ + root.SetNewTree("t").Edit(0, 0, &json.TreeNode{ Type: "p", Children: []json.TreeNode{}, - }}) + }) assert.Equal(t, "

", root.GetTree("t").ToXML()) assert.Equal(t, `{"t":{"type":"root","children":[{"type":"p","children":[]}]}}`, root.Marshal()) // 02. Create a text into the paragraph. - root.GetTree("t").Edit(1, 1, []*json.TreeNode{{ + root.GetTree("t").Edit(1, 1, &json.TreeNode{ Type: "text", Value: "AB", - }}) + }) assert.Equal(t, "

AB

", root.GetTree("t").ToXML()) assert.Equal( t, @@ -58,10 +58,10 @@ func TestTree(t *testing.T) { ) // 03. Insert a text into the paragraph. - root.GetTree("t").Edit(3, 3, []*json.TreeNode{{ + root.GetTree("t").Edit(3, 3, &json.TreeNode{ Type: "text", Value: "CD", - }}) + }) assert.Equal(t, "

ABCD

", root.GetTree("t").ToXML()) // TODO(krapie): consider other options to avoid line over @@ -74,10 +74,10 @@ func TestTree(t *testing.T) { ) // 04. Replace ABCD with Yorkie - root.GetTree("t").Edit(1, 5, []*json.TreeNode{{ + root.GetTree("t").Edit(1, 5, &json.TreeNode{ Type: "text", Value: "Yorkie", - }}) + }) assert.Equal(t, "

Yorkie

", root.GetTree("t").ToXML()) assert.Equal( t, @@ -149,19 +149,19 @@ func TestTree(t *testing.T) { }) assert.Equal(t, "

ab

", root.GetTree("t").ToXML()) - root.GetTree("t").Edit(1, 1, []*json.TreeNode{{ + root.GetTree("t").Edit(1, 1, &json.TreeNode{ Type: "text", Value: "X", - }}) + }) assert.Equal(t, "

Xab

", root.GetTree("t").ToXML()) root.GetTree("t").Edit(1, 2, nil) assert.Equal(t, "

ab

", root.GetTree("t").ToXML()) - root.GetTree("t").Edit(2, 2, []*json.TreeNode{{ + root.GetTree("t").Edit(2, 2, &json.TreeNode{ Type: "text", Value: "X", - }}) + }) assert.Equal(t, "

aXb

", root.GetTree("t").ToXML()) root.GetTree("t").Edit(2, 3, nil) @@ -182,10 +182,10 @@ func TestTree(t *testing.T) { }) assert.Equal(t, "

ab

", root.GetTree("t").ToXML()) - root.GetTree("t").Edit(3, 3, []*json.TreeNode{{ + root.GetTree("t").Edit(3, 3, &json.TreeNode{ Type: "text", Value: "X", - }}) + }) assert.Equal(t, "

abX

", root.GetTree("t").ToXML()) root.GetTree("t").Edit(3, 4, nil) @@ -217,22 +217,22 @@ func TestTree(t *testing.T) { }) assert.Equal(t, "

ab

", root.GetTree("t").ToXML()) - root.GetTree("t").EditByPath([]int{0, 0, 0, 1}, []int{0, 0, 0, 1}, []*json.TreeNode{{ + root.GetTree("t").EditByPath([]int{0, 0, 0, 1}, []int{0, 0, 0, 1}, &json.TreeNode{ Type: "text", Value: "X", - }}) + }) assert.Equal(t, "

aXb

", root.GetTree("t").ToXML()) - root.GetTree("t").EditByPath([]int{0, 0, 0, 3}, []int{0, 0, 0, 3}, []*json.TreeNode{{ + root.GetTree("t").EditByPath([]int{0, 0, 0, 3}, []int{0, 0, 0, 3}, &json.TreeNode{ Type: "text", Value: "!", - }}) + }) assert.Equal(t, "

aXb!

", root.GetTree("t").ToXML()) - root.GetTree("t").EditByPath([]int{0, 0, 1}, []int{0, 0, 1}, []*json.TreeNode{{ + root.GetTree("t").EditByPath([]int{0, 0, 1}, []int{0, 0, 1}, &json.TreeNode{ Type: "tn", Children: []json.TreeNode{}, - }}) + }) assert.Equal(t, "

aXb!

", root.GetTree("t").ToXML()) return nil }) @@ -257,28 +257,27 @@ func TestTree(t *testing.T) { }) assert.Equal(t, "

ab

", root.GetTree("t").ToXML()) - root.GetTree("t").EditByPath([]int{0, 0, 0, 1}, []int{0, 0, 0, 1}, []*json.TreeNode{{ + root.GetTree("t").EditByPath([]int{0, 0, 0, 1}, []int{0, 0, 0, 1}, &json.TreeNode{ Type: "text", - Value: "X", - }, { + Value: "X"}, &json.TreeNode{ Type: "text", Value: "X", - }}) + }) assert.Equal(t, "

aXXb

", root.GetTree("t").ToXML()) - root.GetTree("t").EditByPath([]int{0, 1}, []int{0, 1}, []*json.TreeNode{{ + root.GetTree("t").EditByPath([]int{0, 1}, []int{0, 1}, &json.TreeNode{ Type: "p", - Children: []json.TreeNode{{Type: "tn", Children: []json.TreeNode{{Type: "text", Value: "te"}, {Type: "text", Value: "st"}}}}, - }, { - Type: "p", - Children: []json.TreeNode{{Type: "tn", Children: []json.TreeNode{{Type: "text", Value: "te"}, {Type: "text", Value: "xt"}}}}, - }}) + Children: []json.TreeNode{{Type: "tn", Children: []json.TreeNode{{Type: "text", Value: "te"}, {Type: "text", Value: "st"}}}}}, + &json.TreeNode{ + Type: "p", + Children: []json.TreeNode{{Type: "tn", Children: []json.TreeNode{{Type: "text", Value: "te"}, {Type: "text", Value: "xt"}}}}, + }) assert.Equal(t, "

aXXb

test

text

", root.GetTree("t").ToXML()) - root.GetTree("t").EditByPath([]int{0, 3}, []int{0, 3}, []*json.TreeNode{{ + root.GetTree("t").EditByPath([]int{0, 3}, []int{0, 3}, &json.TreeNode{ Type: "p", - Children: []json.TreeNode{{Type: "tn", Children: []json.TreeNode{{Type: "text", Value: "te"}, {Type: "text", Value: "st"}}}}, - }, {Type: "tn", Children: []json.TreeNode{{Type: "text", Value: "te"}, {Type: "text", Value: "xt"}}}}) + Children: []json.TreeNode{{Type: "tn", Children: []json.TreeNode{{Type: "text", Value: "te"}, {Type: "text", Value: "st"}}}}}, + &json.TreeNode{Type: "tn", Children: []json.TreeNode{{Type: "text", Value: "te"}, {Type: "text", Value: "xt"}}}) assert.Equal(t, "

aXXb

test

text

test

text
", root.GetTree("t").ToXML()) return nil @@ -292,18 +291,18 @@ func TestTree(t *testing.T) { root.SetNewTree("t", &json.TreeNode{Type: "doc"}) assert.Equal(t, "", root.GetTree("t").ToXML()) - root.GetTree("t").Edit(0, 0, []*json.TreeNode{{ + root.GetTree("t").Edit(0, 0, &json.TreeNode{ Type: "p", Attributes: map[string]string{"bold": "true"}, Children: []json.TreeNode{{Type: "text", Value: "ab"}}, - }}) + }) assert.Equal(t, `

ab

`, root.GetTree("t").ToXML()) - root.GetTree("t").Edit(4, 4, []*json.TreeNode{{ + root.GetTree("t").Edit(4, 4, &json.TreeNode{ Type: "p", Attributes: map[string]string{"italic": "true"}, Children: []json.TreeNode{{Type: "text", Value: "cd"}}, - }}) + }) assert.Equal(t, `

ab

cd

`, root.GetTree("t").ToXML()) root.GetTree("t").Edit(2, 6, nil) @@ -396,11 +395,11 @@ func TestTree(t *testing.T) { assert.NoError(t, c2.Attach(ctx, d2)) assert.NoError(t, d1.Update(func(root *json.Object) error { - root.GetTree("t").Edit(1, 1, []*json.TreeNode{{Type: "text", Value: "A"}}) + root.GetTree("t").Edit(1, 1, &json.TreeNode{Type: "text", Value: "A"}) return nil })) assert.NoError(t, d2.Update(func(root *json.Object) error { - root.GetTree("t").Edit(1, 1, []*json.TreeNode{{Type: "text", Value: "B"}}) + root.GetTree("t").Edit(1, 1, &json.TreeNode{Type: "text", Value: "B"}) return nil })) assert.Equal(t, "

A12

", d1.Root().GetTree("t").ToXML()) @@ -432,11 +431,11 @@ func TestTree(t *testing.T) { assert.NoError(t, c2.Attach(ctx, d2)) assert.NoError(t, d1.Update(func(root *json.Object) error { - root.GetTree("t").Edit(2, 2, []*json.TreeNode{{Type: "text", Value: "A"}}) + root.GetTree("t").Edit(2, 2, &json.TreeNode{Type: "text", Value: "A"}) return nil })) assert.NoError(t, d2.Update(func(root *json.Object) error { - root.GetTree("t").Edit(2, 2, []*json.TreeNode{{Type: "text", Value: "B"}}) + root.GetTree("t").Edit(2, 2, &json.TreeNode{Type: "text", Value: "B"}) return nil })) assert.Equal(t, "

1A2

", d1.Root().GetTree("t").ToXML()) @@ -467,11 +466,11 @@ func TestTree(t *testing.T) { assert.NoError(t, c2.Attach(ctx, d2)) assert.NoError(t, d1.Update(func(root *json.Object) error { - root.GetTree("t").Edit(3, 3, []*json.TreeNode{{Type: "text", Value: "A"}}) + root.GetTree("t").Edit(3, 3, &json.TreeNode{Type: "text", Value: "A"}) return nil })) assert.NoError(t, d2.Update(func(root *json.Object) error { - root.GetTree("t").Edit(3, 3, []*json.TreeNode{{Type: "text", Value: "B"}}) + root.GetTree("t").Edit(3, 3, &json.TreeNode{Type: "text", Value: "B"}) return nil })) assert.Equal(t, "

12A

", d1.Root().GetTree("t").ToXML())