From 3f93027f9e0ad7728d076ea3f61e8fa29c8b02ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B8=D0=BB=D1=8F=D0=BD=20=D0=9F=D0=B0=D0=BB=D0=B0?= =?UTF-8?q?=D1=83=D0=B7=D0=BE=D0=B2?= Date: Wed, 4 Mar 2026 21:03:02 +0200 Subject: [PATCH] =?UTF-8?q?Textual=20Rules:=20allow=20XBase=20between=20th?= =?UTF-8?q?en=20=E2=80=A6=20end=20(#5398)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 … end`. * also allows at a later moment to merge DSL Rules and DSL Scripts into one. --- .../core/model/rule/runtime/internal/DSLRuleProvider.java | 3 +-- .../src/org/openhab/core/model/rule/Rules.xtext | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/DSLRuleProvider.java b/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/DSLRuleProvider.java index a6d2f42ab..035aa22c0 100644 --- a/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/DSLRuleProvider.java +++ b/bundles/org.openhab.core.model.rule.runtime/src/org/openhab/core/model/rule/runtime/internal/DSLRuleProvider.java @@ -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)); diff --git a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/Rules.xtext b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/Rules.xtext index ffd916fd9..5c25a258f 100644 --- a/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/Rules.xtext +++ b/bundles/org.openhab.core.model.rule/src/org/openhab/core/model/rule/Rules.xtext @@ -22,7 +22,7 @@ VariableDeclaration: Rule: 'rule' name=(STRING|ID) 'when' eventtrigger+=EventTrigger ('or' eventtrigger+=EventTrigger)* - 'then' script=Script + 'then' script=XExpressionInClosure 'end' ;