diff options
author | 2024-06-01 18:37:20 +0200 | |
---|---|---|
committer | 2024-06-01 20:17:47 +0200 | |
commit | 07b4048828d9ef8126282c4626dd3f0729213d91 (patch) | |
tree | 4523d01e7802585ae3a3c7ec622d1b0a1e3dfa91 /subprojects/language/src/main/java/tools | |
parent | fix(reasoning): candidate count literal rewriting (diff) | |
download | refinery-07b4048828d9ef8126282c4626dd3f0729213d91.tar.gz refinery-07b4048828d9ef8126282c4626dd3f0729213d91.tar.zst refinery-07b4048828d9ef8126282c4626dd3f0729213d91.zip |
feat: partial references
References marked as partial are not concretized during model generation. The
should be managed by the user manually using propagation rules instead.
Diffstat (limited to 'subprojects/language/src/main/java/tools')
3 files changed, 12 insertions, 9 deletions
diff --git a/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext b/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext index ebb5bf71..10e994a0 100644 --- a/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext +++ b/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext | |||
@@ -45,7 +45,7 @@ AggregatorDeclaration: | |||
45 | "extern" "aggregator" name=Identifier "."; | 45 | "extern" "aggregator" name=Identifier "."; |
46 | 46 | ||
47 | enum ReferenceKind: | 47 | enum ReferenceKind: |
48 | REFERENCE="refers" | CONTAINMENT="contains" | CONTAINER="container"; | 48 | REFERENCE="refers" | CONTAINMENT="contains" | CONTAINER="container" | PARTIAL="partial"; |
49 | 49 | ||
50 | ReferenceDeclaration: | 50 | ReferenceDeclaration: |
51 | (referenceType=[Relation|NonContainmentQualifiedName] | | 51 | (referenceType=[Relation|NonContainmentQualifiedName] | |
diff --git a/subprojects/language/src/main/java/tools/refinery/language/utils/ProblemUtil.java b/subprojects/language/src/main/java/tools/refinery/language/utils/ProblemUtil.java index 9daa8f61..e1820261 100644 --- a/subprojects/language/src/main/java/tools/refinery/language/utils/ProblemUtil.java +++ b/subprojects/language/src/main/java/tools/refinery/language/utils/ProblemUtil.java | |||
@@ -42,13 +42,11 @@ public final class ProblemUtil { | |||
42 | } | 42 | } |
43 | 43 | ||
44 | public static boolean isImplicit(EObject eObject) { | 44 | public static boolean isImplicit(EObject eObject) { |
45 | if (eObject instanceof Node node) { | 45 | return switch (eObject) { |
46 | return isImplicitNode(node); | 46 | case Node node -> isImplicitNode(node); |
47 | } else if (eObject instanceof Variable variable) { | 47 | case Variable variable -> isImplicitVariable(variable); |
48 | return isImplicitVariable(variable); | 48 | default -> false; |
49 | } else { | 49 | }; |
50 | return false; | ||
51 | } | ||
52 | } | 50 | } |
53 | 51 | ||
54 | public static boolean isError(EObject eObject) { | 52 | public static boolean isError(EObject eObject) { |
@@ -119,7 +117,7 @@ public final class ProblemUtil { | |||
119 | return false; | 117 | return false; |
120 | } | 118 | } |
121 | return switch (kind) { | 119 | return switch (kind) { |
122 | case CONTAINMENT -> false; | 120 | case CONTAINMENT, PARTIAL -> false; |
123 | case CONTAINER -> true; | 121 | case CONTAINER -> true; |
124 | case DEFAULT, REFERENCE -> { | 122 | case DEFAULT, REFERENCE -> { |
125 | var opposite = referenceDeclaration.getOpposite(); | 123 | var opposite = referenceDeclaration.getOpposite(); |
diff --git a/subprojects/language/src/main/java/tools/refinery/language/validation/ProblemValidator.java b/subprojects/language/src/main/java/tools/refinery/language/validation/ProblemValidator.java index 9f5fdeae..754572d1 100644 --- a/subprojects/language/src/main/java/tools/refinery/language/validation/ProblemValidator.java +++ b/subprojects/language/src/main/java/tools/refinery/language/validation/ProblemValidator.java | |||
@@ -318,6 +318,11 @@ public class ProblemValidator extends AbstractProblemValidator { | |||
318 | referenceDeclaration, ProblemPackage.Literals.REFERENCE_DECLARATION__OPPOSITE, 0, | 318 | referenceDeclaration, ProblemPackage.Literals.REFERENCE_DECLARATION__OPPOSITE, 0, |
319 | INVALID_OPPOSITE_ISSUE); | 319 | INVALID_OPPOSITE_ISSUE); |
320 | } | 320 | } |
321 | } else if (kind == ReferenceKind.PARTIAL && opposite != null && opposite.getKind() != ReferenceKind.PARTIAL) { | ||
322 | acceptError("Opposite '%s' of partial reference '%s' is not a partial reference." | ||
323 | .formatted(opposite.getName(), referenceDeclaration.getName()), | ||
324 | referenceDeclaration, ProblemPackage.Literals.REFERENCE_DECLARATION__OPPOSITE, 0, | ||
325 | INVALID_OPPOSITE_ISSUE); | ||
321 | } | 326 | } |
322 | } | 327 | } |
323 | 328 | ||