You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We now use the old position of a class which in some cases makes whitespace
appear on the correct position beside the class. A testcase based on Buildings
was added.
case ((diff1 as (Diff.Equal,tree1))::(Diff.Add, tree2)::diffLocal)
2322
+
guard parseTreeIsNewLine(List.last(tree1)) and parseTreeIsNewLine(List.first(tree2))
2323
+
algorithm
2324
+
print("New case\n");
2325
+
then diff1::(Diff.Add, listRest(tree2))::diffLocal;
2236
2326
// NEWLINE ADD WS DEL => NEWLINE WS ADD DEL
2237
2327
case (diff1 as (Diff.Equal,tree1))::(diff2 as (Diff.Add, tree2))::(diff3 as (Diff.Equal, tree3))::(diff4 as (Diff.Delete, tree4First::tree4))::diffLocal
2238
2328
guard parseTreeIsNewLine(List.last(tree1)) and min(parseTreeIsWhitespaceNotComment(t) for t in tree3)
input Boolean inAllLabelsAreInOrder "If all labels are in order, there are no moves and we can replace the deleted node which keeps whitespace in better positions";
if parseTreeStr(labelOfDiffedDeletedNodes::{}) =="$equation_section" then
2501
+
allLabelsAreInOrder :=false;
2502
+
end if;
2374
2503
for diff in inDiff loop
2375
2504
res := match diff
2376
2505
case (Diff.Equal, _) then diff::res;
2377
-
case (Diff.Add, lst) guard not max(compare(nodeLabel(t), labelOfDiffedNodes) for t in lst) then diff::res;
2378
-
case (Diff.Delete, lst) guard not max(compare(nodeLabel(t), labelOfDiffedNodes) for t in lst) then diff::res;
2379
-
case (Diff.Delete, lst) then (Diff.Delete, list(t for t guard not compare(nodeLabel(t), labelOfDiffedNodes) in lst))::res; // TODO: Handle the deletion better...
2380
-
case (Diff.Add, lst)
2506
+
case (Diff.Add, lst) guard not max(compare(nodeLabel(t), labelOfDiffedAddedNodes) for t in lst) then diff::res;
2507
+
case (Diff.Delete, lst) guard not max(compare(nodeLabel(t), labelOfDiffedDeletedNodes) for t in lst) then diff::res;
2508
+
case (Diff.Add, lst) guard allLabelsAreInOrder then (Diff.Add, list(t for t guard not compare(nodeLabel(t), labelOfDiffedAddedNodes) in lst))::res; // TODO: Handle the deletion better...
2509
+
case (Diff.Delete, lst) guard not allLabelsAreInOrder then (Diff.Delete, list(t for t guard not compare(nodeLabel(t), labelOfDiffedDeletedNodes) in lst))::res; // TODO: Handle the deletion better...
2510
+
case (d, lst)
2381
2511
algorithm
2382
2512
acc := {};
2383
2513
for t in lst loop
2384
2514
// Assuming adjacent to the delete node
2385
-
if (not found) and compare(nodeLabel(t), labelOfDiffedNodes) then
2515
+
if (not found) and compare(nodeLabel(t), if allLabelsAreInOrder then labelOfDiffedDeletedNodes else labelOfDiffedAddedNodes) then
2386
2516
ifnot listEmpty(acc) then
2387
2517
res := (Diff.Add, listReverse(acc))::res;
2388
2518
acc := {};
@@ -2392,7 +2522,7 @@ algorithm
2392
2522
res := listAppend(filtered, res);
2393
2523
found :=true;
2394
2524
else
2395
-
res := (Diff.Add, {t})::res;
2525
+
res := (d, {t})::res;
2396
2526
end if;
2397
2527
end for;
2398
2528
ifnot listEmpty(acc) then
@@ -2605,7 +2735,7 @@ function firstTokenInTree
2605
2735
output Token token;
2606
2736
algorithm
2607
2737
token := match t
2608
-
caseEMPTY() then fail();
2738
+
caseEMPTY() algorithm print("No first token in tree\n"); then fail();
2609
2739
caseLEAF() then t.token;
2610
2740
caseNODE() then firstTokenInTree(listGet(t.nodes, 1));
0 commit comments