Search in sources :

Example 1 with UnknownVariableErrorEvent

use of org.kie.dmn.feel.runtime.events.UnknownVariableErrorEvent in project drools by kiegroup.

the class DMNFEELHelper method processEvents.

public void processEvents(DMNModelImpl model, DMNElement element, Msg.Message msg, Object... msgParams) {
    Queue<FEELEvent> feelEvents = listener.getFeelEvents();
    while (!feelEvents.isEmpty()) {
        FEELEvent event = feelEvents.remove();
        if (!isDuplicateEvent(model, msg, element)) {
            if (event instanceof SyntaxErrorEvent || event.getSeverity() == FEELEvent.Severity.ERROR) {
                if (msg instanceof Msg.Message2) {
                    MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, element, model, null, event, (Msg.Message2) msg, msgParams[0], msgParams[1]);
                } else if (msg instanceof Msg.Message3) {
                    Object message3 = null;
                    if (msgParams.length == 3) {
                        message3 = msgParams[2];
                    } else {
                        // wrap the originating FEEL error as the last message
                        message3 = event.getMessage();
                    }
                    MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, element, model, null, event, (Msg.Message3) msg, msgParams[0], msgParams[1], message3);
                } else if (msg instanceof Msg.Message4) {
                    String message = null;
                    if (event.getOffendingSymbol() == null) {
                        message = "";
                    } else if (event instanceof UnknownVariableErrorEvent) {
                        message = event.getMessage();
                    } else if (event.getOffendingSymbol() instanceof CommonToken) {
                        message = "syntax error near '" + ((CommonToken) event.getOffendingSymbol()).getText() + "'";
                    } else {
                        message = "syntax error near '" + event.getOffendingSymbol() + "'";
                    }
                    MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, element, model, null, event, (Msg.Message4) msg, msgParams[0], msgParams[1], msgParams[2], message);
                }
            }
        }
    }
}
Also used : Msg(org.kie.dmn.core.util.Msg) SyntaxErrorEvent(org.kie.dmn.feel.runtime.events.SyntaxErrorEvent) UnknownVariableErrorEvent(org.kie.dmn.feel.runtime.events.UnknownVariableErrorEvent) CommonToken(org.antlr.v4.runtime.CommonToken) FEELEvent(org.kie.dmn.api.feel.runtime.events.FEELEvent)

Aggregations

CommonToken (org.antlr.v4.runtime.CommonToken)1 FEELEvent (org.kie.dmn.api.feel.runtime.events.FEELEvent)1 Msg (org.kie.dmn.core.util.Msg)1 SyntaxErrorEvent (org.kie.dmn.feel.runtime.events.SyntaxErrorEvent)1 UnknownVariableErrorEvent (org.kie.dmn.feel.runtime.events.UnknownVariableErrorEvent)1