Skip to content

Commit b4b113f

Browse files
brianzhang2101Varun-Sethuvuong
authored
feat(cms): add AST traversal (#214)
* created basic traversal function and attempting to unmarshall content * fixed cmsjson library * added few tests for ast traversal * finished ast traversal tests * added string edit tests, but array edits dont work * playing around with array operation * fixed up array function * fixed array traversal bug * added more array tests, but object broken now * edit update object * minor editor refactor Co-authored-by: Varun Sethu <[email protected]> Co-authored-by: vuong <[email protected]>
1 parent a3b8cd4 commit b4b113f

33 files changed

+755
-551
lines changed

backend/editor/OT/OTClient/operation.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ type noop = {};
99

1010
// atomicOperation is a single operation that can be applied in our system
1111
type atomicOperation =
12-
| { "$type": "stringOperation", stringOperation: stringOperation }
13-
| { "$type": "integerOperation", integerOperation: integerOperation }
14-
| { "$type": "booleanOperation", booleanOperation: booleanOperation }
15-
| { "$type": "objectOperation", objectOperation: objectOperation }
16-
| { "$type": "arrayOperation", arrayOperation: arrayOperation }
17-
| { "$type": "noop", noop: noop}
12+
| { type: "stringOperation", stringOperation: stringOperation }
13+
| { type: "integerOperation", integerOperation: integerOperation }
14+
| { type: "booleanOperation", booleanOperation: booleanOperation }
15+
| { type: "objectOperation", objectOperation: objectOperation }
16+
| { type: "arrayOperation", arrayOperation: arrayOperation }
17+
| { type: "noop", noop: noop}
1818

1919
// operation is the atomic operation that is sent between clients and servers
2020
export type Operation = {
@@ -30,7 +30,7 @@ export const noop: Operation = {
3030
OperationType: "insert",
3131
IsNoOp: true,
3232
Operation: {
33-
"$type": "noop",
33+
type: "noop",
3434
noop: {}
3535
}
3636
};

backend/editor/OT/client_view.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package editor
22

33
import (
4-
"cms.csesoc.unsw.edu.au/editor/OT/data"
4+
"cms.csesoc.unsw.edu.au/editor/OT/operations"
55
"github.com/gorilla/websocket"
66
)
77

@@ -14,15 +14,15 @@ import (
1414
type clientView struct {
1515
socket *websocket.Conn
1616

17-
sendOp chan data.Operation
17+
sendOp chan operations.Operation
1818
sendAcknowledgement chan empty
1919
sendTerminateSignal chan empty
2020
}
2121

2222
func newClient(socket *websocket.Conn) *clientView {
2323
return &clientView{
2424
socket: socket,
25-
sendOp: make(chan data.Operation),
25+
sendOp: make(chan operations.Operation),
2626
sendAcknowledgement: make(chan empty),
2727
sendTerminateSignal: make(chan empty),
2828
}
@@ -54,7 +54,7 @@ func (c *clientView) run(serverPipe pipe, terminatePipe alertLeaving) {
5454
default:
5555
if _, msg, err := c.socket.ReadMessage(); err == nil {
5656
// push the update to the documentServer
57-
if request, err := data.ParseOperation(string(msg)); err == nil {
57+
if request, err := operations.ParseOperation(string(msg)); err == nil {
5858
serverPipe(request)
5959
continue
6060
}

backend/editor/OT/data/applicator.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

backend/editor/OT/data/array_operation.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

backend/editor/OT/data/boolean_operation.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

backend/editor/OT/data/integer_operation.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

backend/editor/OT/data/object_operation.go

Lines changed: 0 additions & 21 deletions
This file was deleted.

backend/editor/OT/data/string_operation.go

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)