This is an automated email from the ASF dual-hosted git repository.
tiagobento pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git
The following commit(s) were added to refs/heads/main by this push:
new cd7b6f526bd kie-issue#1124: Autocomplete does not consider inputs in
the Iterator, Conditional, and Filter expressions (#2276)
cd7b6f526bd is described below
commit cd7b6f526bdb76dd432f745b93fca98fd37e7457
Author: Daniel José dos Santos <[email protected]>
AuthorDate: Tue Apr 30 10:56:43 2024 -0300
kie-issue#1124: Autocomplete does not consider inputs in the Iterator,
Conditional, and Filter expressions (#2276)
---
.../src/parser/VariablesRepository.ts | 77 +++++++++++++++++++---
1 file changed, 67 insertions(+), 10 deletions(-)
diff --git a/packages/dmn-feel-antlr4-parser/src/parser/VariablesRepository.ts
b/packages/dmn-feel-antlr4-parser/src/parser/VariablesRepository.ts
index c26f7ba35f1..78988ed333d 100644
--- a/packages/dmn-feel-antlr4-parser/src/parser/VariablesRepository.ts
+++ b/packages/dmn-feel-antlr4-parser/src/parser/VariablesRepository.ts
@@ -43,7 +43,7 @@ import {
DMN15__tRelation,
} from "@kie-tools/dmn-marshaller/dist/schemas/dmn-1_5/ts-gen/types";
import { Expression } from "./VariableOccurrence";
-import { DmnLatestModel, getMarshaller } from "@kie-tools/dmn-marshaller";
+import { DmnLatestModel } from "@kie-tools/dmn-marshaller";
type DmnLiteralExpression = { __$$element: "literalExpression" } &
DMN15__tLiteralExpression;
type DmnInvocation = { __$$element: "invocation" } & DMN15__tInvocation;
@@ -53,14 +53,11 @@ type DmnFunctionDefinition = { __$$element:
"functionDefinition" } & DMN15__tFun
type DmnRelation = { __$$element: "relation" } & DMN15__tRelation;
type DmnList = { __$$element: "list" } & DMN15__tList;
type DmnKnowledgeRequirement = DMN15__tKnowledgeRequirement;
-
-type UnsupportedDmnExpressions =
- | ({ __$$element: "for" } & DMN15__tFor)
- | ({ __$$element: "every" } & DMN15__tQuantified)
- | ({ __$$element: "some" } & DMN15__tQuantified)
- | ({ __$$element: "conditional" } & DMN15__tConditional)
- | ({ __$$element: "filter" } & DMN15__tFilter);
-
+type DmnConditional = { __$$element: "conditional" } & DMN15__tConditional;
+type DmnFilter = { __$$element: "filter" } & DMN15__tFilter;
+type DmnFor = { __$$element: "for" } & DMN15__tFor;
+type DmnEvery = { __$$element: "every" } & DMN15__tQuantified;
+type DmnSome = { __$$element: "some" } & DMN15__tQuantified;
type DmnDecisionNode = { __$$element: "decision" } & DMN15__tDecision;
type DmnBusinessKnowledgeModel = DMN15__tBusinessKnowledgeModel;
export type DmnDefinitions = DMN15__tDefinitions;
@@ -471,6 +468,45 @@ export class VariablesRepository {
}
}
+ private addConditional(parent: VariableContext, element: DmnConditional) {
+ if (element.if?.expression) {
+ this.addInnerExpression(parent, element.if.expression);
+ }
+ if (element.then?.expression) {
+ this.addInnerExpression(parent, element.then.expression);
+ }
+ if (element.else?.expression) {
+ this.addInnerExpression(parent, element.else.expression);
+ }
+ }
+
+ private addIterable(parent: VariableContext, expression: DmnSome | DmnEvery)
{
+ if (expression.satisfies.expression) {
+ this.addInnerExpression(parent, expression.satisfies.expression);
+ }
+ if (expression.in.expression) {
+ this.addInnerExpression(parent, expression.in.expression);
+ }
+ }
+
+ private addFor(parent: VariableContext, expression: DmnFor) {
+ if (expression.return.expression) {
+ this.addInnerExpression(parent, expression.return.expression);
+ }
+ if (expression.in.expression) {
+ this.addInnerExpression(parent, expression.in.expression);
+ }
+ }
+
+ private addFilter(parent: VariableContext, expression: DmnFilter) {
+ if (expression.in.expression) {
+ this.addInnerExpression(parent, expression.in.expression);
+ }
+ if (expression.match.expression) {
+ this.addInnerExpression(parent, expression.match.expression);
+ }
+ }
+
private addInnerExpression(
parent: VariableContext,
expression:
@@ -481,7 +517,11 @@ export class VariablesRepository {
| DmnFunctionDefinition
| DmnRelation
| DmnList
- | UnsupportedDmnExpressions
+ | DmnFor
+ | DmnFilter
+ | DmnEvery
+ | DmnSome
+ | DmnConditional
) {
switch (expression.__$$element) {
case "literalExpression":
@@ -512,6 +552,23 @@ export class VariablesRepository {
this.addList(parent, expression);
break;
+ case "conditional":
+ this.addConditional(parent, expression);
+ break;
+
+ case "every":
+ case "some":
+ this.addIterable(parent, expression);
+ break;
+
+ case "for":
+ this.addFor(parent, expression);
+ break;
+
+ case "filter":
+ this.addFilter(parent, expression);
+ break;
+
default:
// throw new Error("Unknown or not supported type for expression.");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]