Skip to content

Commit

Permalink
Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
danielzhe committed Nov 6, 2023
1 parent 0f33ddb commit 0d97b55
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/dmn-editor/src/boxedExpressions/BoxedExpression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import {
import { PMMLFieldData } from "@kie-tools/pmml-editor-marshaller/dist/api/PMMLFieldData";
import { getDefaultColumnWidth } from "./getDefaultColumnWidth";
import { FeelVariables } from "@kie-tools/dmn-feel-antlr4-parser";
import { DmnModel } from "@kie-tools/dmn-marshaller";
import { DmnLatestModel } from "@kie-tools/dmn-marshaller";

export function BoxedExpression({ container }: { container: React.RefObject<HTMLElement> }) {
const thisDmn = useDmnEditorStore((s) => s.dmn);
Expand All @@ -79,7 +79,7 @@ export function BoxedExpression({ container }: { container: React.RefObject<HTML
const dmnEditorStoreApi = useDmnEditorStoreApi();

const feelVariables = useMemo(() => {
const externalModels = new Map<string, DmnModel>();
const externalModels = new Map<string, DmnLatestModel>();

for (const [key, externalDmn] of externalDmnsByNamespace) {
externalModels.set(key, externalDmn.model);
Expand Down
14 changes: 12 additions & 2 deletions packages/dmn-feel-antlr4-parser/src/FeelVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,27 @@

import { FeelVariablesParser } from "./parser/FeelVariablesParser";
import { DmnDefinitions, VariablesRepository } from "./parser/VariablesRepository";
import { DmnModel } from "@kie-tools/dmn-marshaller";
import { DmnLatestModel, getMarshaller } from "@kie-tools/dmn-marshaller";

export class FeelVariables {
private readonly _parser: FeelVariablesParser;
private readonly _repository: VariablesRepository;

constructor(dmnDefinitions: DmnDefinitions, externalDefinitions: Map<string, DmnModel>) {
constructor(dmnDefinitions: DmnDefinitions, externalDefinitions: Map<string, DmnLatestModel>) {
this._repository = new VariablesRepository(dmnDefinitions, externalDefinitions);
this._parser = new FeelVariablesParser(this._repository);
}

static fromModelXml(xml: string): FeelVariables {
const def = this.getDefinitions(xml);
return new FeelVariables(def, new Map<string, DmnLatestModel>());
}

static getDefinitions(xml: string) {
const marshaller = getMarshaller(xml, { upgradeTo: "latest" });
return marshaller.parser.parse().definitions;
}

get parser(): FeelVariablesParser {
return this._parser;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/

import { DmnModel } from "@kie-tools/dmn-marshaller";
import { DataType } from "./DataType";
import { FeelSyntacticSymbolNature } from "./FeelSyntacticSymbolNature";
import { VariableContext } from "./VariableContext";
Expand All @@ -43,6 +42,8 @@ import {
DMN15__tQuantified,
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";

type DmnLiteralExpression = { __$$element: "literalExpression" } & DMN15__tLiteralExpression;
type DmnInvocation = { __$$element: "invocation" } & DMN15__tInvocation;
Expand Down Expand Up @@ -76,7 +77,7 @@ export class VariablesRepository {
private currentVariablePrefix: string;
private currentUuidPrefix: string;

constructor(dmnDefinitions: DmnDefinitions, externalDefinitions: Map<string, DmnModel>) {
constructor(dmnDefinitions: DmnDefinitions, externalDefinitions: Map<string, DmnLatestModel>) {
this.dataTypes = new Map<string, DataType>();
this.variablesIndexedByUuid = new Map<string, VariableContext>();
this.expressionsIndexedByUuid = new Map<string, Expression>();
Expand Down Expand Up @@ -549,7 +550,7 @@ export class VariablesRepository {
this.createVariables(dmnDefinitions);
}

private loadImportedVariables(dmnDefinitions: DmnDefinitions, externalDefinitions: Map<string, DmnModel>) {
private loadImportedVariables(dmnDefinitions: DmnDefinitions, externalDefinitions: Map<string, DmnLatestModel>) {
if (dmnDefinitions.import) {
for (const dmnImport of dmnDefinitions.import) {
if (externalDefinitions.has(dmnImport["@_namespace"])) {
Expand Down
2 changes: 1 addition & 1 deletion packages/stunner-editors-dmn-loader/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const renderImportJavaClasses = (selector: string) => {
};

const getVariables = (xml: string): FeelVariables => {
return new FeelVariables(xml);
return FeelVariables.fromModelXml(xml);
};

export { renderBoxedExpressionEditor, renderImportJavaClasses, unmountBoxedExpressionEditor, getVariables };
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0d97b55

Please sign in to comment.