Skip to content

Commit 4c55e2e

Browse files
feat: set feature mapping and presence conditions of macro lines to false if PC changes are ignored
1 parent d29b412 commit 4c55e2e

2 files changed

Lines changed: 13 additions & 20 deletions

File tree

src/main/java/org/variantsync/vevos/extraction/FileGT.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ public class FileGT implements Iterable<LineAnnotation>, Serializable {
1717
// i.e., the matching line numbers before or after the changes have been applied
1818
// a match is -1 if there is no counterpart
1919
protected final ArrayList<Integer> matching;
20-
// Set of annotation block starts and ends
21-
protected final HashSet<Integer> blockEnds;
22-
protected final HashSet<Integer> blockStarts;
2320
// List of annotation for each line
2421
private final ArrayList<LineAnnotation> annotations;
2522
// The set of variables occurring in the annotations of this file
@@ -30,8 +27,6 @@ public class FileGT implements Iterable<LineAnnotation>, Serializable {
3027
protected FileGT(String file) {
3128
this.annotations = new ArrayList<>();
3229
this.matching = new ArrayList<>();
33-
this.blockStarts = new HashSet<>();
34-
this.blockEnds = new HashSet<>();
3530
this.consumed = false;
3631
this.file = file;
3732
this.variables = new HashSet<>();
@@ -40,8 +35,6 @@ protected FileGT(String file) {
4035
protected FileGT(FileGT other) {
4136
this.annotations = other.annotations;
4237
this.matching = other.matching;
43-
this.blockStarts = other.blockStarts;
44-
this.blockEnds = other.blockEnds;
4538
this.consumed = false;
4639
this.file = other.file;
4740
this.variables = other.variables;
@@ -206,13 +199,6 @@ public Complete finishMutation() {
206199
return new Complete(this);
207200
}
208201

209-
public void markBlockEnd(int lineNumber) {
210-
this.blockEnds.add(lineNumber);
211-
}
212-
213-
public void markBlockStart(int lineNumber) {
214-
this.blockStarts.add(lineNumber);
215-
}
216202
}
217203

218204
/**

src/main/java/org/variantsync/vevos/extraction/PCAnalysis.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ static void analyzeNode(FileGT.Mutable fileGT, DiffNode<DiffLinesLabel> node, Ti
5959
int toLine = currentRange.toExclusive();
6060

6161
if (node.isAnnotation()) {
62-
// Mark the start and end of this annotation block
63-
fileGT.markBlockStart(fromLine);
64-
fileGT.markBlockEnd(toLine);
6562
// Grow the root mapping
6663
fileGT.growIfRequired(toLine);
6764
} else {
@@ -75,15 +72,25 @@ static void analyzeNode(FileGT.Mutable fileGT, DiffNode<DiffLinesLabel> node, Ti
7572
fileGT.setMatching(currentRange, counterpartRange);
7673
}
7774

75+
// Also consider the #endif in case of an annotation
76+
toLine = (node.isAnnotation() && !node.isRoot()) ? toLine+1 : toLine;
7877
for (int lineNumber = fromLine; lineNumber < toLine; lineNumber++) {
7978
LineAnnotation existingAnnotation = fileGT.get(lineNumber - 1);
8079
if (existingAnnotation != null && existingAnnotation.nodeType().equals("artifact")) {
8180
// Never overwrite artifact pcs with annotation pcs
8281
continue;
8382
}
84-
LineAnnotation annotation = new LineAnnotation(lineNumber,
85-
new FeatureMapping(featureMapping.toString()), new PresenceCondition(presenceCondition.toString()),
86-
node.getNodeType().name, presenceCondition.getUniqueContainedFeatures());
83+
LineAnnotation annotation;
84+
if (node.isAnnotation() && ignorePCChanges) {
85+
// We set the PC and Mapping of all macro lines to '0', i.e., 'false
86+
annotation = new LineAnnotation(lineNumber,
87+
new FeatureMapping("0"), new PresenceCondition("0"),
88+
node.getNodeType().name, presenceCondition.getUniqueContainedFeatures());
89+
} else {
90+
annotation = new LineAnnotation(lineNumber,
91+
new FeatureMapping(featureMapping.toString()), new PresenceCondition(presenceCondition.toString()),
92+
node.getNodeType().name, presenceCondition.getUniqueContainedFeatures());
93+
}
8794
fileGT.insert(annotation);
8895
}
8996
}

0 commit comments

Comments
 (0)