|
14 | 14 | import java.util.Stack; |
15 | 15 |
|
16 | 16 | /** |
17 | | - * Collapses chains of nested non-edited macros. |
18 | | - * Imagine a macro node that is unchanged and has the same parent before and after the edit that |
19 | | - * is again an unchanged macro node that has the same parent before and after the edit, and so on. |
20 | | - * Such chains <code>NON_IF -> NON_IF -> NON_IF -> ... -> NON_IF</code> can be collapsed |
21 | | - * into a single unchanged macro node with the formulas of all nodes combined (by AND). |
| 17 | + * Collapses chains of nested non-edited annotations. |
| 18 | + * Imagine a annotation node that is unchanged and has the same parent before and after the edit |
| 19 | + * that is again an unchanged annotation node that has the same parent before and after the edit, |
| 20 | + * and so on. Such chains <code>NON_IF -> NON_IF -> NON_IF -> ... -> NON_IF</code> can be collapsed |
| 21 | + * into a single unchanged annotation node with the formulas of all nodes combined (by AND). |
22 | 22 | * This collapse is realized by this transformer. |
23 | 23 | * |
24 | 24 | * Fun fact: We implemented this transformation because of the |
25 | 25 | * <a href="https://scryfall.com/card/2xm/308/wurmcoil-engine">wurmcoil edit in Marlin</a>. |
26 | 26 | * |
27 | 27 | * @author Paul Bittner |
28 | 28 | */ |
29 | | -public class CollapseNestedNonEditedMacros implements DiffTreeTransformer { |
| 29 | +public class CollapseNestedNonEditedAnnotations implements DiffTreeTransformer { |
30 | 30 | private final List<Stack<DiffNode>> chainCandidates = new ArrayList<>(); |
31 | 31 | private final List<Stack<DiffNode>> chains = new ArrayList<>(); |
32 | 32 |
|
@@ -66,7 +66,7 @@ private void finalize(Stack<DiffNode> chain) { |
66 | 66 | } |
67 | 67 |
|
68 | 68 | private void findChains(DiffTreeTraversal traversal, DiffNode subtree) { |
69 | | - if (subtree.isNon() && subtree.isMacro()) { |
| 69 | + if (subtree.isNon() && subtree.isAnnotation()) { |
70 | 70 | if (isHead(subtree)) { |
71 | 71 | final Stack<DiffNode> s = new Stack<>(); |
72 | 72 | s.push(subtree); |
@@ -114,7 +114,7 @@ private static void collapseChain(Stack<DiffNode> chain) { |
114 | 114 | } |
115 | 115 | } |
116 | 116 | case ROOT, CODE -> |
117 | | - throw new RuntimeException("Unexpected node type " + lastPopped.nodeType + " within macro chain!"); |
| 117 | + throw new RuntimeException("Unexpected node type " + lastPopped.nodeType + " within annotation chain!"); |
118 | 118 | case ENDIF -> {} |
119 | 119 | } |
120 | 120 | } |
@@ -178,6 +178,6 @@ private static boolean isEnd(DiffNode d) { |
178 | 178 |
|
179 | 179 | @Override |
180 | 180 | public String toString() { |
181 | | - return "CollapseNestedNonEditedMacros"; |
| 181 | + return "CollapseNestedNonEditedAnnotations"; |
182 | 182 | } |
183 | 183 | } |
0 commit comments