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 dd1b7cd9813 kie-issues#239: Implement DMN 1.4 new FEEL functions
support (#2137)
dd1b7cd9813 is described below
commit dd1b7cd981360993c3494684a33e06c0ad35a4e4
Author: Yeser Amer <[email protected]>
AuthorDate: Thu Feb 1 16:04:47 2024 +0100
kie-issues#239: Implement DMN 1.4 new FEEL functions support (#2137)
---
.../src/parser/ReservedWords.ts | 10 +-
packages/feel-input-component/src/FeelConfigs.ts | 159 ++++++++++++++++++++-
2 files changed, 162 insertions(+), 7 deletions(-)
diff --git a/packages/dmn-feel-antlr4-parser/src/parser/ReservedWords.ts
b/packages/dmn-feel-antlr4-parser/src/parser/ReservedWords.ts
index 33a25af4d8a..3f9b7725251 100644
--- a/packages/dmn-feel-antlr4-parser/src/parser/ReservedWords.ts
+++ b/packages/dmn-feel-antlr4-parser/src/parser/ReservedWords.ts
@@ -52,6 +52,9 @@ export class ReservedWords {
"coincides",
"concatenate",
"contains",
+ "context",
+ "context put",
+ "context merge",
"count",
"date",
"date and time",
@@ -110,6 +113,10 @@ export class ReservedWords {
"remove",
"replace",
"reverse",
+ "round down",
+ "round half down",
+ "round half up",
+ "round up",
"sort",
"split",
"sqrt",
@@ -117,8 +124,9 @@ export class ReservedWords {
"starts with",
"starts",
"stddev",
- "string length",
"string",
+ "string join",
+ "string length",
"sublist",
"substring after",
"substring before",
diff --git a/packages/feel-input-component/src/FeelConfigs.ts
b/packages/feel-input-component/src/FeelConfigs.ts
index 25c0d78d8cc..0b9b64fe579 100644
--- a/packages/feel-input-component/src/FeelConfigs.ts
+++ b/packages/feel-input-component/src/FeelConfigs.ts
@@ -265,8 +265,8 @@ export const feelDefaultSuggestions = ():
Monaco.languages.CompletionItem[] => {
description: "Returns `n` with rounding mode ceiling. If `n` is null
the result is null.",
parameters: [["n", `\`number\``]],
examples: ["ceiling( 1.5 ) = 2", "ceiling( -1.5 ) = -1"],
- } /*
- { === DMN 1.4 ===
+ },
+ {
label: "ceiling(n, scale)",
insertText: "ceiling($1, $2)",
description:
@@ -276,7 +276,7 @@ export const feelDefaultSuggestions = ():
Monaco.languages.CompletionItem[] => {
["scale", `\`number\``],
],
examples: ["ceiling( -1.56, 1 ) = -1.5"],
- }, */,
+ },
{
label: "code(value)",
insertText: "code($1)",
@@ -325,6 +325,59 @@ export const feelDefaultSuggestions = ():
Monaco.languages.CompletionItem[] => {
],
examples: ['contains( "foobar", "of" ) = false', 'contains( "foobar",
"fo" ) = true'],
},
+ {
+ label: "context(entries)",
+ insertText: "context($1)",
+ description:
+ "Returns a new `context` that includes all specified entries. If a
`context` item contains additional entries beyond the required `key` and
`value` entries, the additional entries are ignored. If a `context` item is
missing the required `key` and `value` entries, the final result is null.",
+ parameters: [["entries", `\`list\` of \`context\``]],
+ examples: [
+ 'context( [{key:"a", value:1}, {key:"b", value:2}] ) = { a:1, b:2 }',
+ 'context([ {key:"a", value:1}, {key:"b", value:2, something:
"else"}] ) = {a:1, b:2}',
+ 'context( [{key:"a", value:1}, {key:"b"}] ) = null',
+ ],
+ },
+ {
+ label: "context merge(contexts)",
+ insertText: "context merge($1)",
+ description:
+ "Returns a new `context` that includes all entries from the given
`contexts`; if some of the keys are equal, the entries are overridden. The
entries are overridden in the same order as specified by the supplied
parameter, with new entries added as the last entry in the new context.",
+ parameters: [["contexts", `\`list\` of \`context\``]],
+ examples: ["context merge( [{x:1}, {y:2}] ) = {x:1, y:2}", "context
merge( [{x:1, y:0}, {y:2}] ) = {x:1, y:2}"],
+ },
+ {
+ label: "context put(context,key,value)",
+ insertText: "context put($1, $2, $3)",
+ description:
+ "Returns a new `context` that includes the new entry, or overrides
the existing value if an entry for the same key already exists in the supplied
`context` parameter. A new entry is added as the last entry of the new context.
If overriding an existing entry, the order of the keys maintains the same order
as in the original context.",
+ parameters: [
+ ["context", `\`context\``],
+ ["key", `\`string\``],
+ ["value", `\`Any\` type`],
+ ],
+ examples: [
+ 'context put( {x:1}, "y", 2 ) = {x:1, y:2}',
+ 'context put( {x:1, y:0}, "y", 2 ) = {x:1, y:2}',
+ 'context put( {x:1, y:0, z:0} , "y", 2) = {x:1, y:2, z:0}',
+ ],
+ },
+ {
+ label: "context put(context,keys,value)",
+ insertText: "context put($1, $2, $3)",
+ description:
+ "Returns the composite of nested invocations to `context put()` for
each item in keys hierarchy in `context`.",
+ parameters: [
+ ["context", `\`context\``],
+ ["keys", `\`list\` of \`string\``],
+ ["value", `\`Any\` type`],
+ ],
+ examples: [
+ 'context put( {x:1}, ["y"], 2 ) = context put( {x:1}, "y", 2) ',
+ 'context put( {x:1}, ["y"], 2 ) = {x:1, y:2}',
+ 'context put( {x:1, y: {a: 0} }, ["y", "a"], 2 ) = {x:1, y: {a: 2}
}',
+ `context put( {x:1, y: {a: 0} }, [], 2 ) = null`,
+ ],
+ },
{
label: "count(list)",
insertText: "count($1)",
@@ -600,8 +653,8 @@ export const feelDefaultSuggestions = ():
Monaco.languages.CompletionItem[] => {
description: "Returns `n` with rounding mode flooring. If `n` is null
the result is null.",
parameters: [["n", `\`number\``]],
examples: ["floor(1.5) = 1"],
- } /*
- { === DMN 1.4 ===
+ },
+ {
label: "floor(n, scale)",
insertText: "floor($1, $2)",
description:
@@ -611,7 +664,7 @@ export const feelDefaultSuggestions = ():
Monaco.languages.CompletionItem[] => {
["scale", `\`number\``],
],
examples: ["floor( -1.56, 1 ) = -1.6"],
- }, */,
+ },
{
label: "get entries(m)",
insertText: "get entries($1)",
@@ -1131,6 +1184,70 @@ export const feelDefaultSuggestions = ():
Monaco.languages.CompletionItem[] => {
parameters: [["list", `\`list\``]],
examples: ["reverse( [1,2,3] ) = [3,2,1]"],
},
+ {
+ label: "round down(n,scale)",
+ insertText: "round down($1, $2)",
+ description:
+ "Returns `n` with given `scale` and rounding mode round down. If at
least one of `n` or `scale` is null, the result is null.",
+ parameters: [
+ ["n", `\`number\``],
+ ["scale", `\`number\``],
+ ],
+ examples: [
+ "round down( 5.5, 0 ) = 5",
+ "round down( -5.5, 0 ) = -5",
+ "round down( 1.121, 2 ) = 1.12",
+ "round down( -1.126, 2 ) = -1.12",
+ ],
+ },
+ {
+ label: "round half down(n,scale)",
+ insertText: "round half down($1, $2)",
+ description:
+ "Returns `n` with given `scale` and rounding mode round half down.
If at least one of `n` or `scale` is null, the result is null.",
+ parameters: [
+ ["n", `\`number\``],
+ ["scale", `\`number\``],
+ ],
+ examples: [
+ "round half down( 5.5, 0 ) = 5",
+ "round half down( -5.5, 0 ) = -5",
+ "round half down( 1.121, 2 ) = 1.12",
+ "round half down( -1.126, 2 ) = -1.13",
+ ],
+ },
+ {
+ label: "round half up(n,scale)",
+ insertText: "round half up($1, $2)",
+ description:
+ "Returns `n` with given `scale` and rounding mode round half up. If
at least one of `n` or `scale` is null, the result is null.",
+ parameters: [
+ ["n", `\`number\``],
+ ["scale", `\`number\``],
+ ],
+ examples: [
+ "round half up( 5.5, 0 ) = 6",
+ "round half up( -5.5, 0 ) = -6",
+ "round half up( 1.121, 2 ) = 1.12",
+ "round half up( -1.126, 2 ) = -1.13",
+ ],
+ },
+ {
+ label: "round up(n,scale)",
+ insertText: "round up($1, $2)",
+ description:
+ "Returns `n` with given `scale` and rounding mode round up. If at
least one of `n` or `scale` is null, the result is null.",
+ parameters: [
+ ["n", `\`number\``],
+ ["scale", `\`number\``],
+ ],
+ examples: [
+ "round up( 5.5, 0 ) = 6",
+ "round up( -5.5, 0 ) = -6",
+ "round up( 1.121, 2 ) = 1.13",
+ "round up( -1.126, 2 ) = -1.13",
+ ],
+ },
{
label: "sort(list)",
insertText: "sort($1)",
@@ -1263,6 +1380,36 @@ export const feelDefaultSuggestions = ():
Monaco.languages.CompletionItem[] => {
parameters: [["from", `Not null value`]],
examples: ['string( 1.1 ) = "1.1"', "string( null ) = null"],
},
+ {
+ label: "string join(list)",
+ insertText: "string join($1)",
+ description:
+ "Returns a string which is composed by joining all the string
elements from the `list` parameter. Null elements in the `list` parameter are
ignored. If `list` is empty, the result is the empty string.",
+ parameters: [["list", `\`list\` of \`string\``]],
+ examples: [
+ 'string join( ["a","b","c"] ) = "abc"',
+ 'string join( ["a",null,"c"] ) = "ac"',
+ 'string join([]) = ""',
+ ],
+ },
+ {
+ label: "string join(list, delimiter)",
+ insertText: "string join($1, $2)",
+ description:
+ "Returns a string which is composed by joining all the string
elements from the `list` parameter, separated by the `delimiter`. The
`delimiter` can be an empty string. Null elements in the `list` parameter are
ignored. If `list` is empty, the result is the empty string. If `delimiter` is
null, the string elements are joined without a separator.",
+ parameters: [
+ ["list", `\`list\` of \`string\``],
+ ["delimiter", `\`string\``],
+ ],
+ examples: [
+ 'string join(["a","b","c"], "_and_") = "a_and_b_and_c"',
+ 'string join(["a","b","c"], "") = "abc"',
+ 'string join(["a","b","c"], null) = "abc"',
+ 'string join(["a"], "X") = "a"',
+ 'string join(["a",null,"c"], "X") = "aXc"',
+ 'string join([], "X") = ""',
+ ],
+ },
{
label: "sublist(list, start position)",
insertText: "sublist($1, $2)",
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]