Textual Rules: allow XBase between then … end (#5398)

* 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.
This commit is contained in:
Дилян Палаузов
2026-03-04 20:03:02 +01:00
committed by GitHub
parent 84de71a9a6
commit 3f93027f9e
2 changed files with 2 additions and 3 deletions
@@ -25,7 +25,6 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
import org.eclipse.xtext.xbase.XBlockExpression;
import org.eclipse.xtext.xbase.XExpression;
import org.eclipse.xtext.xbase.interpreter.IEvaluationContext;
import org.openhab.core.automation.Action;
@@ -272,7 +271,7 @@ public class DSLRuleProvider
// Create Action
String context = DSLScriptContextProvider.CONTEXT_IDENTIFIER + modelName + "-" + index + "\n";
XBlockExpression expression = rule.getScript();
XExpression expression = rule.getScript();
String script = NodeModelUtils.findActualNodeFor(expression).getText();
Configuration cfg = new Configuration();
cfg.put("script", context + removeIndentation(script));
@@ -22,7 +22,7 @@ VariableDeclaration:
Rule:
'rule' name=(STRING|ID)
'when' eventtrigger+=EventTrigger ('or' eventtrigger+=EventTrigger)*
'then' script=Script
'then' script=XExpressionInClosure
'end'
;