|
24 | 24 | import org.variantsync.diffdetective.variation.diff.traverse.VariationDiffTraversal; |
25 | 25 | import org.variantsync.diffdetective.variation.diff.traverse.VariationDiffVisitor; |
26 | 26 | import org.variantsync.diffdetective.variation.tree.VariationTree; |
| 27 | +import org.variantsync.diffdetective.util.fide.FixTrueFalse; |
27 | 28 | import org.variantsync.functjonal.Cast; |
28 | 29 | import org.variantsync.functjonal.Result; |
29 | 30 |
|
|
34 | 35 | import java.nio.file.Path; |
35 | 36 | import java.util.ArrayList; |
36 | 37 | import java.util.HashMap; |
| 38 | +import java.util.LinkedHashSet; |
37 | 39 | import java.util.List; |
38 | 40 | import java.util.Map; |
39 | 41 | import java.util.concurrent.atomic.AtomicBoolean; |
@@ -374,6 +376,25 @@ public int count(final Predicate<DiffNode<L>> nodesToCount) { |
374 | 376 | return count.get(); |
375 | 377 | } |
376 | 378 |
|
| 379 | + |
| 380 | + /** |
| 381 | + * Returns all variable names occurring in annotations (i.e., formulas of mapping nodes) in this variation diff. |
| 382 | + * This method is deterministic: It will return the feature names always in the same order, assuming the variation diff is not changed inbetween. |
| 383 | + * @return A set of every occuring feature name. |
| 384 | + */ |
| 385 | + public LinkedHashSet<String> computeAllFeatureNames() { |
| 386 | + LinkedHashSet<String> features = new LinkedHashSet<>(); |
| 387 | + forAll(node -> { |
| 388 | + if (node.isConditionalAnnotation()) { |
| 389 | + features.addAll(node.getFormula().getUniqueContainedFeatures()); |
| 390 | + } |
| 391 | + }); |
| 392 | + // Since FeatureIDE falsely reports constants "True" and "False" as feature names, we have to remove them from the resulting set. |
| 393 | + features.removeIf(FixTrueFalse::isTrueLiteral); |
| 394 | + features.removeIf(FixTrueFalse::isFalseLiteral); |
| 395 | + return features; |
| 396 | + } |
| 397 | + |
377 | 398 | /** |
378 | 399 | * Sets the source of this VariationDiff. |
379 | 400 | * @see VariationDiffSource |
|
0 commit comments