-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kie-issues#237: Implement DMN 1.4 Boxed iterator expression #2243
Conversation
kie-issues#238: Implement DMN 1.4 every/some -> in -> satisfies boxed expression Co-authored-by: Tiago Bento <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielzhe Thanks for the PR! I left some comments inline.
return ret; | ||
} else if (args.rowIndex === 2) { | ||
if (prev.__$$element === "for") { | ||
const ret: BoxedFor = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comment "// Do not inline this variable for type safety. See microsoft/TypeScript#241"
} else { | ||
// Do not inline this variable for type safety. See https://github.com/microsoft/TypeScript/issues/241 | ||
const iterator: BoxedIterator = { | ||
...prev, | ||
satisfies: { expression: undefined! }, // SPEC DISCREPANCY | ||
}; | ||
return iterator; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaulting to "every" and "some", while I think we should actively check for those types and throw an Error if anything else is found.
return iterator; | ||
} | ||
} else { | ||
throw new Error("ConditionalExpression shouldn't have more than 3 rows."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong error message.
else if (expression.__$$element === "for") { | ||
const nestedExpressions = [expression.in.expression, expression.return.expression]; | ||
return ( | ||
resizingWidth ?? | ||
CONDITIONAL_EXPRESSION_LABEL_COLUMN_WIDTH + | ||
Math.max( | ||
CONDITIONAL_EXPRESSION_CLAUSE_COLUMN_MIN_WIDTH, | ||
...nestedExpressions.map((e) => getExpressionResizingWidth(e, resizingWidths, widthsById)) | ||
) + | ||
CONDITIONAL_EXPRESSION_EXTRA_WIDTH | ||
); | ||
} | ||
|
||
// Every and Some | ||
else if (expression.__$$element === "every" || expression.__$$element === "some") { | ||
const nestedExpressions = [expression.in.expression, expression.satisfies.expression]; | ||
return ( | ||
resizingWidth ?? | ||
CONDITIONAL_EXPRESSION_LABEL_COLUMN_WIDTH + | ||
Math.max( | ||
CONDITIONAL_EXPRESSION_CLAUSE_COLUMN_MIN_WIDTH, | ||
...nestedExpressions.map((e) => getExpressionResizingWidth(e, resizingWidths, widthsById)) | ||
) + | ||
CONDITIONAL_EXPRESSION_EXTRA_WIDTH | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not using the ITERATOR_EXPRESSION constants.
} else { | ||
return ( | ||
<IteratorExpressionCell | ||
iteratorClause={props.data[props.rowIndex]} | ||
{...props} | ||
parentElementId={parentElementId} | ||
/> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaulting to this, while I think we should explicitly check for rowIndex being 1 and 2, as iterator expressions shouldn't have more than 3 rows.
} else { | ||
if (expression.__$$element === "for") { | ||
return "return"; | ||
} else return "satisfies"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Defaulting to "satisfies", while we should check for explicit cases we support and throw an error for all other unexpected cases.
const getIterableRowLabel = useCallback( | ||
(rowNumber: number) => { | ||
if (rowNumber === 0) { | ||
return expression.__$$element; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using __$$element
here is not ideal, as it is a coincidence that those two things have the same value. Please explicitly return the name of the expression based on what type of iterator it is.
|
||
const currentExpression = useMemo(() => { | ||
if (typeof iteratorClause.child !== "string") { | ||
return iteratorClause.child?.expression as any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why "as any"?
expression: getNewExpression(), | ||
}, | ||
}; | ||
} else { | ||
return { | ||
...prev, | ||
satisfies: { | ||
expression: getNewExpression(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not pass prev
here, like you're doing at the in
part?
return { | ||
...prev, | ||
"@_iteratorVariable": updatedValue, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the same strategy of extracting the return value to a variable, explicitly typing it and adding the comment saying why this is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielzhe Amazing new features. The code is looking good.
Hi @ljmotta @tiagobento @danielzhe I've just tested this new functionality and I'm getting the following exception:
KIE.Sandbox.__.Untitled.dmn.-.Google.Chrome.2024-04-18.15-27-22.mp4Build Version: Google Chrome Version 123.0.6312.123 (Official Build) (64-bit) in Windows 10 |
@jaimeizuz Ty for your report. It got broken in the code review, I'm already fixing it. |
) Co-authored-by: Tiago Bento <[email protected]>
Closes: apache/incubator-kie-issues#237
Closes: apache/incubator-kie-issues#238
Both tickets were made together because the
iterator expression
covers both as it is in the spec. See 10.2.1.10 Boxed iterator