Skip to content

Commit f34498b

Browse files
Textual Rules: allow XBase between then … end
* changes the Rules.xtext grammar not to use explicitly the Script object from the Script.xtext grammar. This allows at a later time to extend DSL Scripts to start with `import`s, without allowing `import` statements right after `rule … when … then <IMPORT> … end`. * also allows at a later moment to merge DSL Rules and DSL Scripts into one.
1 parent 45e9907 commit f34498b

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

  • bundles
    • org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal
    • org.openhab.core.model.rule/src/org/openhab/core/model/rule

bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/DSLRuleProvider.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.eclipse.jdt.annotation.NonNullByDefault;
2626
import org.eclipse.jdt.annotation.Nullable;
2727
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
28-
import org.eclipse.xtext.xbase.XBlockExpression;
2928
import org.eclipse.xtext.xbase.XExpression;
3029
import org.eclipse.xtext.xbase.interpreter.IEvaluationContext;
3130
import org.openhab.core.automation.Action;
@@ -272,7 +271,7 @@ private Rule toRule(String modelName, org.openhab.core.model.rule.rules.Rule rul
272271

273272
// Create Action
274273
String context = DSLScriptContextProvider.CONTEXT_IDENTIFIER + modelName + "-" + index + "\n";
275-
XBlockExpression expression = rule.getScript();
274+
XExpression expression = rule.getScript();
276275
String script = NodeModelUtils.findActualNodeFor(expression).getText();
277276
Configuration cfg = new Configuration();
278277
cfg.put("script", context + removeIndentation(script));

bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/Rules.xtext

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ VariableDeclaration:
2222
Rule:
2323
'rule' name=(STRING|ID)
2424
'when' eventtrigger+=EventTrigger ('or' eventtrigger+=EventTrigger)*
25-
'then' script=Script
25+
'then' script=XExpressionInClosure
2626
'end'
2727
;
2828

0 commit comments

Comments
 (0)