Skip to content

Commit b7b7b81

Browse files
committed
Use the term 'annotation' instead of 'macro'
1 parent 6752d12 commit b7b7b81

16 files changed

Lines changed: 52 additions & 52 deletions

src/main/java/org/variantsync/diffdetective/diff/difftree/DiffNode.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ public Lines getLinesAfterEdit() {
653653
* Returns the formula that is stored in this node.
654654
* The formula is null for artifact nodes (i.e., {@link NodeType#CODE}).
655655
* The formula is not null for mapping nodes
656-
* @see NodeType#isMacro
656+
* @see NodeType#isAnnotation
657657
*/
658658
public Node getDirectFeatureMapping() {
659659
return featureMapping;
@@ -927,7 +927,7 @@ public DiffType getDiffType() {
927927
}
928928

929929
/**
930-
* Returns true if this node represents an ELIF macro.
930+
* Returns true if this node represents an ELIF annotation.
931931
* @see NodeType#ELIF
932932
*/
933933
public boolean isElif() {
@@ -960,7 +960,7 @@ public boolean isEndif() {
960960
}
961961

962962
/**
963-
* Returns true if this node represents an ELSE macro.
963+
* Returns true if this node represents an ELSE annotation.
964964
* @see NodeType#ELSE
965965
*/
966966
public boolean isElse() {
@@ -975,10 +975,10 @@ public boolean isRoot() {
975975
}
976976

977977
/**
978-
* Returns {@link NodeType#isMacro()} for this node's {@link DiffNode#nodeType}.
978+
* Returns {@link NodeType#isAnnotation()} for this node's {@link DiffNode#nodeType}.
979979
*/
980-
public boolean isMacro() {
981-
return this.nodeType.isMacro();
980+
public boolean isAnnotation() {
981+
return this.nodeType.isAnnotation();
982982
}
983983

984984
/**
@@ -1115,7 +1115,7 @@ public String toTextDiff() {
11151115
}
11161116

11171117
// Add endif after macro
1118-
if (isMacro()) {
1118+
if (isAnnotation()) {
11191119
diff
11201120
.append(toTextDiffLine(this.diffType, List.of(NodeType.ENDIF.asMacroText())))
11211121
.append(StringUtils.LINEBREAK);

src/main/java/org/variantsync/diffdetective/diff/difftree/DiffTree.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public List<DiffNode> computeCodeNodes() {
214214
* @see DiffTree#computeAllNodesThat
215215
*/
216216
public List<DiffNode> computeAnnotationNodes() {
217-
return computeAllNodesThat(DiffNode::isMacro);
217+
return computeAllNodesThat(DiffNode::isAnnotation);
218218
}
219219

220220
/**

src/main/java/org/variantsync/diffdetective/diff/difftree/NodeType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public enum NodeType {
2828
/**
2929
* Returns true iff this node type represents a conditional feature annotation (i.e., if or elif).
3030
*/
31-
public boolean isConditionalMacro() {
31+
public boolean isConditionalAnnotation() {
3232
return this == IF || this == ELIF;
3333
}
3434

src/main/java/org/variantsync/diffdetective/diff/difftree/parse/MultiLineMacroParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ ParseResult consume(
8282
if (continuesMultilineDefinition(line)) {
8383
// If this multiline macro line is a header...
8484
final NodeType nodeType = NodeType.ofDiffLine(line);
85-
if (nodeType.isConditionalMacro()) {
85+
if (nodeType.isConditionalAnnotation()) {
8686
// ... create a new multi line macro to complete.
8787
if (!isAdd) {
8888
if (beforeMLMacro != null) {

src/main/java/org/variantsync/diffdetective/diff/difftree/serialize/nodeformat/DebugDiffNodeFormat.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
import org.variantsync.diffdetective.util.FileUtils;
55

66
/**
7-
* Print NodeType and DiffType and Mappings if Macro and Text if Code.
7+
* Print NodeType, DiffType and Mappings for Annotations and Text for Code.
88
* @author Paul Bittner, Kevin Jedelhauser
99
*/
1010
public class DebugDiffNodeFormat implements DiffNodeLabelFormat {
1111
@Override
1212
public String toLabel(final DiffNode node) {
1313
return node.diffType + "_" + node.nodeType + "_\"" +
14-
DiffNodeLabelPrettyfier.prettyPrintIfMacroOr(
14+
DiffNodeLabelPrettyfier.prettyPrintIfAnnotationOr(
1515
node,
1616
FileUtils.replaceLineEndings(node.getLabel().trim().replaceAll("\t", " "), "<br>"))
1717
+ "\"";

src/main/java/org/variantsync/diffdetective/diff/difftree/serialize/nodeformat/DiffNodeLabelPrettyfier.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
public abstract class DiffNodeLabelPrettyfier {
1111
/**
12-
* Auxiliary method for {@link DiffNodeLabelPrettyfier#prettyPrintIfMacroOr(DiffNode, String)}.
12+
* Auxiliary method for {@link DiffNodeLabelPrettyfier#prettyPrintIfAnnotationOr(DiffNode, String)}.
1313
* Returns a string starting with the nodes {@link DiffNode#nodeType}, and its {@link DiffNode#getDirectFeatureMapping()}
1414
* if it has a formula.
1515
* @param node The {@link DiffNode} to print.
@@ -26,14 +26,14 @@ private static String prettyPrintTypeAndMapping(final DiffNode node) {
2626

2727
/**
2828
* Invokes {@link #prettyPrintTypeAndMapping(DiffNode)} if the given
29-
* node {@link NodeType#isMacro() is a macro}, and returns the elseValue otherwise.
29+
* node {@link NodeType#isAnnotation() is an annotation}, and returns the elseValue otherwise.
3030
* @param node The {@link DiffNode} to prettyprint.
31-
* @param elseValue The value to return in case the given node is not a macro.
31+
* @param elseValue The value to return in case the given node is not an annotation.
3232
* @return The generated label.
3333
*/
34-
public static String prettyPrintIfMacroOr(final DiffNode node, final String elseValue) {
34+
public static String prettyPrintIfAnnotationOr(final DiffNode node, final String elseValue) {
3535
String result = "";
36-
if (node.nodeType.isMacro()) {
36+
if (node.nodeType.isAnnotation()) {
3737
result += prettyPrintTypeAndMapping(node);
3838
} else {
3939
result += elseValue;

src/main/java/org/variantsync/diffdetective/diff/difftree/serialize/nodeformat/FormulasAndLineNumbersNodeFormat.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.variantsync.diffdetective.diff.difftree.DiffNode;
44

55
/**
6-
* Produces labels of kind <code>fromLine-toLine: NodeType</code>, suffixed by the node's formula if it is a macro.
6+
* Produces labels of kind <code>fromLine-toLine: NodeType</code>, suffixed by the node's formula if it is an annotation.
77
* The line numbers reference the line numbers in the diff.
88
* @see DiffNode#getFromLine()
99
* @see DiffNode#getToLine()
@@ -14,7 +14,7 @@ public class FormulasAndLineNumbersNodeFormat implements DiffNodeLabelFormat {
1414
@Override
1515
public String toLabel(DiffNode node) {
1616
final String lineNumbers = node.getFromLine().inDiff + "-" + node.getToLine().inDiff + ": " + node.nodeType;
17-
if (node.isMacro()) {
17+
if (node.isAnnotation()) {
1818
return lineNumbers + " " + node.getDirectFeatureMapping();
1919
}
2020
return lineNumbers;

src/main/java/org/variantsync/diffdetective/diff/difftree/serialize/nodeformat/MappingsDiffNodeFormat.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import org.variantsync.diffdetective.diff.difftree.DiffNode;
44

55
/**
6-
* Print NodeType and DiffType and Mappings of Macros.
7-
* The produced label will be <code>NodeType"macro formula"</code> for mapping nodes,
6+
* Print NodeType and DiffType and Mappings of Annotations.
7+
* The produced label will be <code>NodeType"annotation formula"</code> for mapping nodes,
88
* and <code>NodeType""</code> for non-mapping nodes.
9-
* @see DiffNodeLabelPrettyfier#prettyPrintIfMacroOr(DiffNode, String)
9+
* @see DiffNodeLabelPrettyfier#prettyPrintIfAnnotationOr(DiffNode, String)
1010
* @author Paul Bittner, Kevin Jedelhauser
1111
*/
1212
public class MappingsDiffNodeFormat implements DiffNodeLabelFormat {
1313
@Override
1414
public String toLabel(final DiffNode node) {
15-
return node.diffType + "_" + node.nodeType + "_\"" + DiffNodeLabelPrettyfier.prettyPrintIfMacroOr(node, "") + "\"";
15+
return node.diffType + "_" + node.nodeType + "_\"" + DiffNodeLabelPrettyfier.prettyPrintIfAnnotationOr(node, "") + "\"";
1616
}
1717
}

src/main/java/org/variantsync/diffdetective/diff/difftree/transform/CollapseNestedNonEditedMacros.java renamed to src/main/java/org/variantsync/diffdetective/diff/difftree/transform/CollapseNestedNonEditedAnnotations.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
import java.util.Stack;
1515

1616
/**
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).
2222
* This collapse is realized by this transformer.
2323
*
2424
* Fun fact: We implemented this transformation because of the
2525
* <a href="https://scryfall.com/card/2xm/308/wurmcoil-engine">wurmcoil edit in Marlin</a>.
2626
*
2727
* @author Paul Bittner
2828
*/
29-
public class CollapseNestedNonEditedMacros implements DiffTreeTransformer {
29+
public class CollapseNestedNonEditedAnnotations implements DiffTreeTransformer {
3030
private final List<Stack<DiffNode>> chainCandidates = new ArrayList<>();
3131
private final List<Stack<DiffNode>> chains = new ArrayList<>();
3232

@@ -66,7 +66,7 @@ private void finalize(Stack<DiffNode> chain) {
6666
}
6767

6868
private void findChains(DiffTreeTraversal traversal, DiffNode subtree) {
69-
if (subtree.isNon() && subtree.isMacro()) {
69+
if (subtree.isNon() && subtree.isAnnotation()) {
7070
if (isHead(subtree)) {
7171
final Stack<DiffNode> s = new Stack<>();
7272
s.push(subtree);
@@ -114,7 +114,7 @@ private static void collapseChain(Stack<DiffNode> chain) {
114114
}
115115
}
116116
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!");
118118
case ENDIF -> {}
119119
}
120120
}
@@ -178,6 +178,6 @@ private static boolean isEnd(DiffNode d) {
178178

179179
@Override
180180
public String toString() {
181-
return "CollapseNestedNonEditedMacros";
181+
return "CollapseNestedNonEditedAnnotations";
182182
}
183183
}

src/main/java/org/variantsync/diffdetective/diff/difftree/transform/FeatureExpressionFilter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ public record FeatureExpressionFilter(Predicate<DiffNode> isFeatureAnnotation) i
1717
public void transform(DiffTree diffTree) {
1818
final List<DiffNode> illegalNodes = new ArrayList<>();
1919
diffTree.forAll(node -> {
20-
if (node.isMacro() && !isFeatureAnnotation.test(node)) {
20+
if (node.isAnnotation() && !isFeatureAnnotation.test(node)) {
2121
illegalNodes.add(node);
2222
}
2323
});
2424

25-
for (final DiffNode illegalMacro : illegalNodes) {
26-
diffTree.removeNode(illegalMacro);
25+
for (final DiffNode illegalAnnotation : illegalNodes) {
26+
diffTree.removeNode(illegalAnnotation);
2727
}
2828
}
2929
}

0 commit comments

Comments
 (0)