package jetbrains.mps.internal.make.runtime.script;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import jetbrains.mps.messages.IMessageHandler;
import jetbrains.mps.make.script.IFeedback;
import jetbrains.mps.messages.MessageKind;
import jetbrains.mps.messages.Message;

@GeneratedClass(node = "r:8e0d2787-667a-41b8-9f98-9bb45c087fba(jetbrains.mps.internal.make.runtime.script)/6214179127578269219", model = "r:8e0d2787-667a-41b8-9f98-9bb45c087fba(jetbrains.mps.internal.make.runtime.script)")
public class MessageFeedbackStrategy {
  private final IMessageHandler handler;
  public MessageFeedbackStrategy(IMessageHandler handler) {
    this.handler = handler;
  }
  public void reportFeedback(IFeedback fdk) {
    MessageKind messageKind;
    switch (fdk.getSeverity()) {
      case ERROR:
        messageKind = MessageKind.ERROR;
        break;
      case WARNING:
        messageKind = MessageKind.WARNING;
        break;
      case INFO:
        messageKind = MessageKind.INFORMATION;
        break;
      default:
        messageKind = MessageKind.ERROR;
        break;
    }
    Message message = new Message(messageKind, fdk.getMessage());
    message.setException(fdk.getException());
    message.setHintObject(fdk.getSource());
    handler.handle(message);
  }
}
