mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
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:
+1
-2
@@ -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'
|
||||
;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user