diff options
author | 2023-11-06 00:38:12 +0100 | |
---|---|---|
committer | 2023-11-17 12:41:34 +0100 | |
commit | 2e0bceb2f25989713f1baf6311d3787c3003d794 (patch) | |
tree | bf4ba62516d4328ac82e5eecb5853e2c3ee244af /subprojects/language-semantics/src/main/java/tools | |
parent | feat(language-ide): content assist filtering (diff) | |
download | refinery-2e0bceb2f25989713f1baf6311d3787c3003d794.tar.gz refinery-2e0bceb2f25989713f1baf6311d3787c3003d794.tar.zst refinery-2e0bceb2f25989713f1baf6311d3787c3003d794.zip |
feat: predicates as reference types
Now unary predicates may be used as types for cross-references.
This might create circular references between predicate, but no differently than
when the user manually creates predicates with circular references.
The reference types of containment and container references still have to be
classes, because we use the class hierarchy to encode contained types.
Diffstat (limited to 'subprojects/language-semantics/src/main/java/tools')
-rw-r--r-- | subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ModelInitializer.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ModelInitializer.java b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ModelInitializer.java index b3c58366..ecaa7e0d 100644 --- a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ModelInitializer.java +++ b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ModelInitializer.java | |||
@@ -63,6 +63,8 @@ public class ModelInitializer { | |||
63 | 63 | ||
64 | private final Map<PartialRelation, RelationInfo> partialRelationInfoMap = new HashMap<>(); | 64 | private final Map<PartialRelation, RelationInfo> partialRelationInfoMap = new HashMap<>(); |
65 | 65 | ||
66 | private final Set<PartialRelation> targetTypes = new HashSet<>(); | ||
67 | |||
66 | private final MetamodelBuilder metamodelBuilder = Metamodel.builder(); | 68 | private final MetamodelBuilder metamodelBuilder = Metamodel.builder(); |
67 | 69 | ||
68 | private Metamodel metamodel; | 70 | private Metamodel metamodel; |
@@ -285,6 +287,7 @@ public class ModelInitializer { | |||
285 | var relation = getPartialRelation(referenceDeclaration); | 287 | var relation = getPartialRelation(referenceDeclaration); |
286 | var source = getPartialRelation(classDeclaration); | 288 | var source = getPartialRelation(classDeclaration); |
287 | var target = getPartialRelation(referenceDeclaration.getReferenceType()); | 289 | var target = getPartialRelation(referenceDeclaration.getReferenceType()); |
290 | targetTypes.add(target); | ||
288 | boolean containment = referenceDeclaration.getKind() == ReferenceKind.CONTAINMENT; | 291 | boolean containment = referenceDeclaration.getKind() == ReferenceKind.CONTAINMENT; |
289 | var opposite = referenceDeclaration.getOpposite(); | 292 | var opposite = referenceDeclaration.getOpposite(); |
290 | PartialRelation oppositeRelation = null; | 293 | PartialRelation oppositeRelation = null; |
@@ -473,17 +476,16 @@ public class ModelInitializer { | |||
473 | private void collectPredicateDefinition(PredicateDefinition predicateDefinition, ModelStoreBuilder storeBuilder) { | 476 | private void collectPredicateDefinition(PredicateDefinition predicateDefinition, ModelStoreBuilder storeBuilder) { |
474 | var partialRelation = getPartialRelation(predicateDefinition); | 477 | var partialRelation = getPartialRelation(predicateDefinition); |
475 | var query = toQuery(partialRelation.name(), predicateDefinition); | 478 | var query = toQuery(partialRelation.name(), predicateDefinition); |
476 | boolean mutable; | 479 | boolean mutable = targetTypes.contains(partialRelation); |
477 | TruthValue defaultValue; | 480 | TruthValue defaultValue; |
478 | if (predicateDefinition.isError()) { | 481 | if (predicateDefinition.isError()) { |
479 | mutable = false; | ||
480 | defaultValue = TruthValue.FALSE; | 482 | defaultValue = TruthValue.FALSE; |
481 | } else { | 483 | } else { |
482 | var seed = modelSeed.getSeed(partialRelation); | 484 | var seed = modelSeed.getSeed(partialRelation); |
483 | defaultValue = seed.reducedValue() == TruthValue.FALSE ? TruthValue.FALSE : TruthValue.UNKNOWN; | 485 | defaultValue = seed.reducedValue() == TruthValue.FALSE ? TruthValue.FALSE : TruthValue.UNKNOWN; |
484 | var cursor = seed.getCursor(defaultValue, problemTrace.getNodeTrace().size()); | 486 | var cursor = seed.getCursor(defaultValue, problemTrace.getNodeTrace().size()); |
485 | // The symbol should be mutable if there is at least one non-default entry in the seed. | 487 | // The symbol should be mutable if there is at least one non-default entry in the seed. |
486 | mutable = cursor.move(); | 488 | mutable = mutable || cursor.move(); |
487 | } | 489 | } |
488 | var translator = new PredicateTranslator(partialRelation, query, mutable, defaultValue); | 490 | var translator = new PredicateTranslator(partialRelation, query, mutable, defaultValue); |
489 | storeBuilder.with(translator); | 491 | storeBuilder.with(translator); |