Skip to main content

module salix::Diff

rascal-0.40.17
salix-core-0.2.7

Usage

import salix::Diff;

Source code

http://github.com/usethesource/salix-core/src/main/rascal/salix/Diff.rsc

Dependencies

import salix::Node;
import List;
import util::Math;
import IO;
import vis::Text;

data Patch

data Patch  
= patch(int pos, list[Patch] patches = [], list[Edit] edits = [])
;

Patch are positioned at pos in the parent element where they originate. This allows sparse/shallow traversal during patching: not all kids of an element will have changes, so patches for those kids will not end up in the patch at all. At each level a list of edits can be applied. A root patch will have pos = - 1.

data EditType

data EditType  
= setText()
| replace()
| removeNode()
| appendNode()
| setAttr()
| setProp()
| setEvent()
| setExtra()
| removeAttr()
| removeProp()
| removeEvent()
| removeExtra()
;

data Node

data Node  
= none()
;

data Hnd

data Hnd  
= null()
;

data Edit

data Edit  
= edit(EditType \type, str contents="", Node html=none(), Hnd handler=null(),
str name="", str val="", value extra=())
;

function diff

Patch diff(Node old, Node new)

Patch diff(Node old, Node new, int idx)

function diffKids

Patch diffKids(list[Node] oldKids, list[Node] newKids, Patch myPatch)

function diffEventMap

list[Edit] diffEventMap(map[str, Hnd] old, map[str, Hnd] new)

function diffMap

list[Edit] diffMap(map[str, str] old, map[str, str] new, EditType upd, EditType del)

function diffExtra

list[Edit] diffExtra(map[str, value] old, map[str, value] new)