diff options
Diffstat (limited to 'subprojects/language-semantics')
3 files changed, 25 insertions, 4 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 c2243f08..8bfc8acd 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 | |||
@@ -967,6 +967,7 @@ public class ModelInitializer { | |||
967 | .orElseGet(() -> "::rule" + ruleCount); | 967 | .orElseGet(() -> "::rule" + ruleCount); |
968 | ruleCount++; | 968 | ruleCount++; |
969 | var rule = toRule(name, ruleDefinition); | 969 | var rule = toRule(name, ruleDefinition); |
970 | problemTrace.putRuleDefinition(ruleDefinition, rule); | ||
970 | switch (ruleDefinition.getKind()) { | 971 | switch (ruleDefinition.getKind()) { |
971 | case DECISION -> storeBuilder.tryGetAdapter(DesignSpaceExplorationBuilder.class) | 972 | case DECISION -> storeBuilder.tryGetAdapter(DesignSpaceExplorationBuilder.class) |
972 | .ifPresent(dseBuilder -> dseBuilder.transformation(rule)); | 973 | .ifPresent(dseBuilder -> dseBuilder.transformation(rule)); |
diff --git a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ProblemTrace.java b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ProblemTrace.java index b8d0b804..9122cf1f 100644 --- a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ProblemTrace.java +++ b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ProblemTrace.java | |||
@@ -10,6 +10,8 @@ import org.eclipse.xtext.naming.QualifiedName; | |||
10 | import tools.refinery.language.model.problem.Node; | 10 | import tools.refinery.language.model.problem.Node; |
11 | import tools.refinery.language.model.problem.Problem; | 11 | import tools.refinery.language.model.problem.Problem; |
12 | import tools.refinery.language.model.problem.Relation; | 12 | import tools.refinery.language.model.problem.Relation; |
13 | import tools.refinery.language.model.problem.RuleDefinition; | ||
14 | import tools.refinery.store.dse.transition.Rule; | ||
13 | import tools.refinery.store.reasoning.representation.AnyPartialSymbol; | 15 | import tools.refinery.store.reasoning.representation.AnyPartialSymbol; |
14 | import tools.refinery.store.reasoning.representation.PartialRelation; | 16 | import tools.refinery.store.reasoning.representation.PartialRelation; |
15 | import tools.refinery.store.reasoning.translator.TranslationException; | 17 | import tools.refinery.store.reasoning.translator.TranslationException; |
@@ -36,6 +38,8 @@ public interface ProblemTrace { | |||
36 | 38 | ||
37 | Relation getRelation(AnyPartialSymbol partialSymbol); | 39 | Relation getRelation(AnyPartialSymbol partialSymbol); |
38 | 40 | ||
41 | RuleDefinition getRuleDefinition(Rule rule); | ||
42 | |||
39 | RuntimeException wrapException(TranslationException translationException); | 43 | RuntimeException wrapException(TranslationException translationException); |
40 | 44 | ||
41 | PartialRelation getPartialRelation(Relation relation); | 45 | PartialRelation getPartialRelation(Relation relation); |
diff --git a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ProblemTraceImpl.java b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ProblemTraceImpl.java index 4b44339c..5584af10 100644 --- a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ProblemTraceImpl.java +++ b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ProblemTraceImpl.java | |||
@@ -13,10 +13,8 @@ import org.eclipse.xtext.naming.IQualifiedNameConverter; | |||
13 | import org.eclipse.xtext.naming.QualifiedName; | 13 | import org.eclipse.xtext.naming.QualifiedName; |
14 | import org.eclipse.xtext.scoping.IScope; | 14 | import org.eclipse.xtext.scoping.IScope; |
15 | import org.eclipse.xtext.scoping.IScopeProvider; | 15 | import org.eclipse.xtext.scoping.IScopeProvider; |
16 | import tools.refinery.language.model.problem.Node; | 16 | import tools.refinery.language.model.problem.*; |
17 | import tools.refinery.language.model.problem.Problem; | 17 | import tools.refinery.store.dse.transition.Rule; |
18 | import tools.refinery.language.model.problem.ProblemPackage; | ||
19 | import tools.refinery.language.model.problem.Relation; | ||
20 | import tools.refinery.store.reasoning.representation.AnyPartialSymbol; | 18 | import tools.refinery.store.reasoning.representation.AnyPartialSymbol; |
21 | import tools.refinery.store.reasoning.representation.PartialRelation; | 19 | import tools.refinery.store.reasoning.representation.PartialRelation; |
22 | import tools.refinery.store.reasoning.translator.TranslationException; | 20 | import tools.refinery.store.reasoning.translator.TranslationException; |
@@ -46,6 +44,7 @@ class ProblemTraceImpl implements ProblemTrace { | |||
46 | Collections.unmodifiableMap(mutableRelationTrace); | 44 | Collections.unmodifiableMap(mutableRelationTrace); |
47 | private final Map<AnyPartialSymbol, Relation> mutableInverseTrace = new HashMap<>(); | 45 | private final Map<AnyPartialSymbol, Relation> mutableInverseTrace = new HashMap<>(); |
48 | private final Map<AnyPartialSymbol, Relation> inverseTrace = Collections.unmodifiableMap(mutableInverseTrace); | 46 | private final Map<AnyPartialSymbol, Relation> inverseTrace = Collections.unmodifiableMap(mutableInverseTrace); |
47 | private final Map<Rule, RuleDefinition> mutableInverseRuleDefinitionTrace = new LinkedHashMap<>(); | ||
49 | 48 | ||
50 | @Override | 49 | @Override |
51 | public Problem getProblem() { | 50 | public Problem getProblem() { |
@@ -129,6 +128,23 @@ class ProblemTraceImpl implements ProblemTrace { | |||
129 | return relation; | 128 | return relation; |
130 | } | 129 | } |
131 | 130 | ||
131 | void putRuleDefinition(RuleDefinition ruleDefinition, Rule rule) { | ||
132 | var oldRuleDefinition = mutableInverseRuleDefinitionTrace.put(rule, ruleDefinition); | ||
133 | if (oldRuleDefinition != null) { | ||
134 | throw new TracedException(oldRuleDefinition, "Rule definition %s was already mapped to rule" | ||
135 | .formatted(rule.getName())); | ||
136 | } | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public RuleDefinition getRuleDefinition(Rule rule) { | ||
141 | var ruleDefinition = mutableInverseRuleDefinitionTrace.get(rule); | ||
142 | if (ruleDefinition == null) { | ||
143 | throw new IllegalArgumentException("No definition for rule: " + rule.getName()); | ||
144 | } | ||
145 | return ruleDefinition; | ||
146 | } | ||
147 | |||
132 | @Override | 148 | @Override |
133 | public RuntimeException wrapException(TranslationException translationException) { | 149 | public RuntimeException wrapException(TranslationException translationException) { |
134 | var partialSymbol = translationException.getPartialSymbol(); | 150 | var partialSymbol = translationException.getPartialSymbol(); |