From d87718047613a56f8c4df0a7519f12351b84e749 Mon Sep 17 00:00:00 2001 From: cha0s Date: Sat, 30 Jan 2021 20:10:40 -0600 Subject: [PATCH] feat: assignment --- .../src/behavior-components/expression.jsx | 59 ++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/packages/entity/src/behavior-components/expression.jsx b/packages/entity/src/behavior-components/expression.jsx index 80ddcd1..6d3f7ba 100644 --- a/packages/entity/src/behavior-components/expression.jsx +++ b/packages/entity/src/behavior-components/expression.jsx @@ -11,6 +11,7 @@ import classnames from 'classnames'; import Invocation from './expression/invocation'; import Key from './expression/key'; +import Variant from './variant'; const Expression = ({ context, @@ -21,7 +22,7 @@ const Expression = ({ const latus = useLatus(); const patch = useJsonPatcher(); let i = 0; - const {ops} = value; + const {ops, value: expressionValue} = value; const Renderables = []; let opsCount = 0; // eslint-disable-next-line react/destructuring-assignment @@ -205,6 +206,57 @@ const Expression = ({ opsCount += 1; } const [lastOp] = ops.slice(-1); + if ( + 'void' === type + && !description.args + && isKey(lastOp) + ) { + const opPath = join(path, 'value'); + Renderables.push( + { + if ('.' === value) { + patch({ + op: 'remove', + path: opPath, + }); + } + else { + patch({ + path: opPath, + value: { + type: 'literal', + }, + }); + } + }} + path={opPath} + value={expressionValue ? '≔' : '.'} + />, + ); + if (expressionValue) { + Renderables.push( + { + patch({ + path: localPath, + value, + }); + }} + key={join(opPath, 'expression')} + path={opPath} + type={description.type} + value={expressionValue} + />, + ); + } + } let realType; if (isKey(lastOp)) { realType = description.args @@ -214,6 +266,9 @@ const Expression = ({ if (isInvocation(lastOp)) { realType = description.type; } + if (expressionValue) { + realType = 'void'; + } return (