You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "danielzhe (via GitHub)" <gi...@apache.org> on 2024/10/18 18:58:20 UTC
[PR] kie-issues#2549: Decision Service cannot be recognized in columns of decision table [incubator-kie-tools]
danielzhe opened a new pull request, #2684:
URL: https://github.com/apache/incubator-kie-tools/pull/2684
Closes: https://github.com/apache/incubator-kie-tools/issues/2549
It closes the ticket related to the colorize and autocomplete only.
https://github.com/user-attachments/assets/0059f31e-8eee-4426-8c3a-1b58ccc0a4df
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2549: Decision Service cannot be recognized in columns of decision table [incubator-kie-tools]
Posted by "jomarko (via GitHub)" <gi...@apache.org>.
jomarko commented on code in PR #2684:
URL: https://github.com/apache/incubator-kie-tools/pull/2684#discussion_r1808425331
##########
packages/feel-input-component/tests/semanticTokensProvider.test.ts:
##########
@@ -22,6 +22,10 @@ import { BuiltInTypes, DmnDefinitions, FeelVariables } from "@kie-tools/dmn-feel
import * as Monaco from "@kie-tools-core/monaco-editor";
import { Element } from "@kie-tools/feel-input-component/dist/themes/Element";
+import * as fs from "fs";
+import * as path from "path";
+import { getMarshaller } from "@kie-tools/dmn-marshaller";
+//import {getMarshaller} from "@kie-tools/dmn-marshaller/d"
Review Comment:
leftover probably?
##########
packages/feel-input-component/tests/semanticTokensProvider.test.ts:
##########
@@ -286,6 +290,149 @@ ThatShouldFailWhenBreakLine`,
}
});
});
+
+ describe("variables inside Decision Tables", () => {
+ const dmnModelWithInclude = "../tests-data/variables-inside-decision-tables/modelWithInclude.dmn";
+ const includedDmnModel = "../tests-data/variables-inside-decision-tables/included.dmn";
+ test("should recognize local nodes", async () => {
+ const expression = "LocalInput + LocalDecision";
+ const id = "_AEC3EEB0-8436-4767-A214-20FF5E5CB7BE";
+ const modelMock = createModelMockForExpression(expression);
+
+ const localModel = getDmnModelFromFilePath(dmnModelWithInclude);
+ const includedModel = getDmnModelFromFilePath(includedDmnModel);
+
+ const feelVariables = new FeelVariables(
+ localModel.definitions,
+ new Map([[includedModel.definitions["@_namespace"] ?? "", includedModel]])
+ );
+
+ const semanticTokensProvider = new SemanticTokensProvider(feelVariables, id, () => {});
+
+ const semanticMonacoTokens = await semanticTokensProvider.provideDocumentSemanticTokens(
+ modelMock as unknown as Monaco.editor.ITextModel,
+ null,
+ cancellationTokenMock
+ );
+
+ const expected = [
+ ...getMonacoSemanticToken({
+ startLineRelativeToPreviousLine: 0,
+ startIndexRelativeToPreviousStartIndex: 0,
+ tokenLength: "LocalInput".length,
+ }),
+ ...getMonacoSemanticToken({
+ startLineRelativeToPreviousLine: 0,
+ startIndexRelativeToPreviousStartIndex: "LocalInput".length + 3, // +3 because of the " + "
+ tokenLength: "LocalDecision".length,
+ }),
+ ];
+
+ for (let i = 0; i < expected.length; i++) {
+ expect(semanticMonacoTokens?.data[i]).toEqual(expected[i]);
+ }
+ });
+
+ test("should recognize included nodes", async () => {
+ const expression = "MyIncludedModel.MyDS(LocalInput) + MyIncludedModel.RemoteInput";
+ const id = "_206131ED-0B81-4013-980A-4BB2539A53D0";
+ const modelMock = createModelMockForExpression(expression);
+
+ const localModel = getDmnModelFromFilePath(dmnModelWithInclude);
+ const includedModel = getDmnModelFromFilePath(includedDmnModel);
+
+ const feelVariables = new FeelVariables(
+ localModel.definitions,
+ new Map([[includedModel.definitions["@_namespace"] ?? "", includedModel]])
+ );
+
+ const semanticTokensProvider = new SemanticTokensProvider(feelVariables, id, () => {});
+
+ const semanticMonacoTokens = await semanticTokensProvider.provideDocumentSemanticTokens(
+ modelMock as unknown as Monaco.editor.ITextModel,
+ null,
+ cancellationTokenMock
+ );
+
+ const expected = [
+ ...getMonacoSemanticToken({
+ startLineRelativeToPreviousLine: 0,
+ startIndexRelativeToPreviousStartIndex: 0,
+ tokenLength: "MyIncludedModel.MyDS".length,
+ tokenType: Element.FunctionCall,
+ }),
+ ...getMonacoSemanticToken({
+ startLineRelativeToPreviousLine: 0,
+ startIndexRelativeToPreviousStartIndex: "MyIncludedModel.MyDS".length + 1, // +1 because of the "("
+ tokenLength: "LocalInput".length,
+ }),
+ ...getMonacoSemanticToken({
+ startLineRelativeToPreviousLine: 0,
+ startIndexRelativeToPreviousStartIndex: "LocalInput".length + ") + ".length,
+ tokenLength: "MyIncludedModel.RemoteInput".length,
+ }),
+ ];
+
+ for (let i = 0; i < expected.length; i++) {
+ expect(semanticMonacoTokens?.data[i]).toEqual(expected[i]);
+ }
Review Comment:
can't we simplify?:
```
expect(semanticMonacoTokens?.data).toEqual(expected)
```
see: https://jestjs.io/docs/expect#toequalvalue
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2549: Decision Service cannot be recognized in columns of decision table [incubator-kie-tools]
Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on code in PR #2684:
URL: https://github.com/apache/incubator-kie-tools/pull/2684#discussion_r1809829184
##########
packages/feel-input-component/tests/semanticTokensProvider.test.ts:
##########
@@ -377,3 +524,8 @@ function createModelMockForExpression(expression: string) {
getLinesContent: jest.fn().mockReturnValue(expression.split("\n")),
};
}
+
+function getDmnModelFromFilePath(filePath: string) {
Review Comment:
https://github.com/apache/incubator-kie-issues/issues/783#issuecomment-1871525975
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2549: Decision Service cannot be recognized in columns of decision table [incubator-kie-tools]
Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento merged PR #2684:
URL: https://github.com/apache/incubator-kie-tools/pull/2684
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2549: Decision Service cannot be recognized in columns of decision table [incubator-kie-tools]
Posted by "danielzhe (via GitHub)" <gi...@apache.org>.
danielzhe commented on code in PR #2684:
URL: https://github.com/apache/incubator-kie-tools/pull/2684#discussion_r1814085019
##########
packages/feel-input-component/tests/semanticTokensProvider.test.ts:
##########
@@ -286,6 +290,149 @@ ThatShouldFailWhenBreakLine`,
}
});
});
+
+ describe("variables inside Decision Tables", () => {
+ const dmnModelWithInclude = "../tests-data/variables-inside-decision-tables/modelWithInclude.dmn";
+ const includedDmnModel = "../tests-data/variables-inside-decision-tables/included.dmn";
+ test("should recognize local nodes", async () => {
+ const expression = "LocalInput + LocalDecision";
+ const id = "_AEC3EEB0-8436-4767-A214-20FF5E5CB7BE";
+ const modelMock = createModelMockForExpression(expression);
+
+ const localModel = getDmnModelFromFilePath(dmnModelWithInclude);
+ const includedModel = getDmnModelFromFilePath(includedDmnModel);
+
+ const feelVariables = new FeelVariables(
+ localModel.definitions,
+ new Map([[includedModel.definitions["@_namespace"] ?? "", includedModel]])
+ );
+
+ const semanticTokensProvider = new SemanticTokensProvider(feelVariables, id, () => {});
+
+ const semanticMonacoTokens = await semanticTokensProvider.provideDocumentSemanticTokens(
+ modelMock as unknown as Monaco.editor.ITextModel,
+ null,
+ cancellationTokenMock
+ );
+
+ const expected = [
+ ...getMonacoSemanticToken({
+ startLineRelativeToPreviousLine: 0,
+ startIndexRelativeToPreviousStartIndex: 0,
+ tokenLength: "LocalInput".length,
+ }),
+ ...getMonacoSemanticToken({
+ startLineRelativeToPreviousLine: 0,
+ startIndexRelativeToPreviousStartIndex: "LocalInput".length + 3, // +3 because of the " + "
+ tokenLength: "LocalDecision".length,
+ }),
+ ];
+
+ for (let i = 0; i < expected.length; i++) {
+ expect(semanticMonacoTokens?.data[i]).toEqual(expected[i]);
+ }
+ });
+
+ test("should recognize included nodes", async () => {
+ const expression = "MyIncludedModel.MyDS(LocalInput) + MyIncludedModel.RemoteInput";
+ const id = "_206131ED-0B81-4013-980A-4BB2539A53D0";
+ const modelMock = createModelMockForExpression(expression);
+
+ const localModel = getDmnModelFromFilePath(dmnModelWithInclude);
+ const includedModel = getDmnModelFromFilePath(includedDmnModel);
+
+ const feelVariables = new FeelVariables(
+ localModel.definitions,
+ new Map([[includedModel.definitions["@_namespace"] ?? "", includedModel]])
+ );
+
+ const semanticTokensProvider = new SemanticTokensProvider(feelVariables, id, () => {});
+
+ const semanticMonacoTokens = await semanticTokensProvider.provideDocumentSemanticTokens(
+ modelMock as unknown as Monaco.editor.ITextModel,
+ null,
+ cancellationTokenMock
+ );
+
+ const expected = [
+ ...getMonacoSemanticToken({
+ startLineRelativeToPreviousLine: 0,
+ startIndexRelativeToPreviousStartIndex: 0,
+ tokenLength: "MyIncludedModel.MyDS".length,
+ tokenType: Element.FunctionCall,
+ }),
+ ...getMonacoSemanticToken({
+ startLineRelativeToPreviousLine: 0,
+ startIndexRelativeToPreviousStartIndex: "MyIncludedModel.MyDS".length + 1, // +1 because of the "("
+ tokenLength: "LocalInput".length,
+ }),
+ ...getMonacoSemanticToken({
+ startLineRelativeToPreviousLine: 0,
+ startIndexRelativeToPreviousStartIndex: "LocalInput".length + ") + ".length,
+ tokenLength: "MyIncludedModel.RemoteInput".length,
+ }),
+ ];
+
+ for (let i = 0; i < expected.length; i++) {
+ expect(semanticMonacoTokens?.data[i]).toEqual(expected[i]);
+ }
Review Comment:
No, their types are different and it fails if we do this way:
```
Error: expect(received).toEqual(expected) // deep equality
Expected: [0, 0, 20, 6, 0, 0, 21, 10, 5, 0, …]
Received: serializes to the same string
<Click to see difference>
```
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#2549: Decision Service cannot be recognized in columns of decision table [incubator-kie-tools]
Posted by "danielzhe (via GitHub)" <gi...@apache.org>.
danielzhe commented on PR #2684:
URL: https://github.com/apache/incubator-kie-tools/pull/2684#issuecomment-2434139004
@jomarko @tiagobento Changes applied! Ready for you.
--
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: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org