From ed9f0870892b50375f5d7728080f5fcaefef9138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20Horcas?= Date: Fri, 4 Oct 2024 16:22:45 +0200 Subject: [PATCH] Add check for single feature constraints not covered by simple or complex --- flamapy/metamodels/fm_metamodel/models/feature_model.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/flamapy/metamodels/fm_metamodel/models/feature_model.py b/flamapy/metamodels/fm_metamodel/models/feature_model.py index 4909165..5f666aa 100644 --- a/flamapy/metamodels/fm_metamodel/models/feature_model.py +++ b/flamapy/metamodels/fm_metamodel/models/feature_model.py @@ -214,6 +214,13 @@ def get_features(self) -> list[str]: stack.append(node.left) return list(features) + def is_single_feature_constraint(self) -> bool: + """Return true if the constraint is a single feature or its negation.""" + root_op = self._ast.root + return (root_op.is_term() or + root_op.is_unary_op() and root_op.left.is_term() or + root_op.is_unary_op() and root_op.right.is_term()) + def is_simple_constraint(self) -> bool: """Return true if the constraint is a simple constraint (requires or excludes).""" return self.is_requires_constraint() or self.is_excludes_constraint()