trackoor opened a new issue, #4086:
URL: https://github.com/apache/incubator-kie-tools/issues/4086
`IdentifiersRefactor.rename` (used when renaming inputs, decisions, BKMs, or
data types in the DMN Editor) does not update identifiers in a decision-table
unary test when the endpoint after `<`, `<=`, `>`, `>=`, `=`, or `!=` has more
than one token, such as `>= P.Miles` or `> Limit + 1` (`? >= P.Miles`,
`[0..P.Miles]`, and bare `> Limit` are updated).
```js
// repro.mjs
import { getMarshaller } from "@kie-tools/dmn-marshaller";
import { IdentifiersRefactor } from
"@kie-tools/dmn-language-service/dist/IdentifiersRefactor";
const xml = `<definitions
xmlns="https://www.omg.org/spec/DMN/20240513/MODEL/" namespace="ns1" name="m"
id="defs">
<itemDefinition id="t1" name="tP"><itemComponent id="t1m"
name="Miles"><typeRef>number</typeRef></itemComponent></itemDefinition>
<inputData id="in1" name="Amount"><variable id="v1" name="Amount"
typeRef="number"/></inputData>
<inputData id="in2" name="P"><variable id="v2" name="P"
typeRef="tP"/></inputData>
<inputData id="in3" name="Limit"><variable id="v3" name="Limit"
typeRef="number"/></inputData>
<decision id="d0" name="D"><variable id="dv0" name="D" typeRef="string"/>
<informationRequirement id="r1"><requiredInput
href="#in1"/></informationRequirement>
<informationRequirement id="r2"><requiredInput
href="#in2"/></informationRequirement>
<informationRequirement id="r3"><requiredInput
href="#in3"/></informationRequirement>
<decisionTable id="dt0" hitPolicy="FIRST"><input id="i0"><inputExpression
id="ie0" typeRef="number"><text>Amount</text></inputExpression></input>
<output id="o0" name="out" typeRef="string"/>
<rule id="ru0"><inputEntry id="en0"><text>>=
P.Miles</text></inputEntry><outputEntry
id="oe0"><text>"a"</text></outputEntry></rule>
<rule id="ru1"><inputEntry id="en1"><text>> Limit +
1</text></inputEntry><outputEntry id="oe1"><text>"b"</text></outputEntry></rule>
<rule id="ru2"><inputEntry id="en2"><text>? >=
P.Miles</text></inputEntry><outputEntry
id="oe2"><text>"c"</text></outputEntry></rule>
<rule id="ru3"><inputEntry id="en3"><text>>
Limit</text></inputEntry><outputEntry
id="oe3"><text>"d"</text></outputEntry></rule>
<rule id="ru4"><inputEntry
id="en4"><text>[0..P.Miles]</text></inputEntry><outputEntry
id="oe4"><text>"e"</text></outputEntry></rule>
</decisionTable></decision></definitions>`;
const defs = getMarshaller(xml, { upgradeTo: "latest"
}).parser.parse().definitions;
const refactor = new IdentifiersRefactor({
writeableDmnDefinitions: defs,
_readonly_externalDmnModelsByNamespaceMap: new Map(),
});
refactor.rename({ identifierUuid: "in2", newName: "Passenger" });
refactor.rename({ identifierUuid: "in3", newName: "MaxLimit" });
console.log(defs.drgElement[3].expression.rule.map((r) =>
r.inputEntry[0].text.__$$text));
```
Run with:
```sh
npm i @kie-tools/[email protected]
@kie-tools/[email protected] esbuild
npx esbuild repro.mjs --bundle --platform=node --format=cjs
--external:antlr4 --external:jsdom --outfile=repro.cjs
node repro.cjs
```
Actual:
```
[
'>= P.Miles',
'> Limit + 1',
'? >= Passenger.Miles',
'> MaxLimit',
'[0..Passenger.Miles]'
]
```
Expected (per [DMN 1.6](https://www.omg.org/spec/DMN/1.6/), simple positive
unary test endpoints after comparison operators are FEEL expressions):
```
[
'>= Passenger.Miles',
'> MaxLimit + 1',
'? >= Passenger.Miles',
'> MaxLimit',
'[0..Passenger.Miles]'
]
```
In `packages/dmn-feel-antlr4-parser/src/parser/grammar/FEEL_1_1.g4` and
`ParserHelper.ts`, `simplePositiveUnaryTest` enables `dynamicResolution` around
`endpoint`, and `ParserHelper.followUp` returns `true` unconditionally whenever
`isDynamicResolution()` is true (the `FEELParser.isVariableNamePartValid` check
from Java was left commented out), so `nameRefOtherToken` consumes `.` and
arithmetic operators into a single `Unknown` identifier (`"P.Miles"`, `"Limit +
1"`) with no `source` (the same happens in `for ... return`, `some`/`every ...
satisfies`, and `function(...)` bodies).
Version: `@kie-tools/[email protected]`,
`@kie-tools/[email protected]`, `@kie-tools/[email protected]`
(Node.js v26.13.0, Linux x86_64), also on `apache/incubator-kie-tools` `main`
`b9041f0`.
Credit: https://ucsbplse.github.io/
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]