package jetbrains.mps.make;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import jetbrains.mps.project.Project;
import jetbrains.mps.messages.IMessageHandler;
import org.jetbrains.annotations.NotNull;
import jetbrains.mps.make.script.IScript;
import jetbrains.mps.make.script.ScriptBuilder;

@GeneratedClass(node = "r:b25dd364-bc3f-4a66-97d1-262009610c5e(jetbrains.mps.make)/8695426379435232461", model = "r:b25dd364-bc3f-4a66-97d1-262009610c5e(jetbrains.mps.make)")
public class MakeSession {
  private final Project myProject;
  private final IMessageHandler myMessageHandler;
  private final boolean myIsCleanMake;
  private final boolean myIsSticky;
  /**
   * <code>MakeSession</code> captures global parameters for the make session to run
   * Note, unlike earlier versions, <code>null</code> message handler is no longer supported.
   * Use <code>IMessageHandler.NULL_HANDLER</code> if <code>/dev/null</code> for messages is indeed what you want.
   * Otherwise, use meaningful handler, e.g. <code>DefaultMakeMessageHandler</code> or 
   * <code>DefaultMessageHandler</code>from IDE, <code>IMessageHandler.LogHandler</code> or any tailored handler for non-IDE uses.
   * 
   * @param mpsProject MPS project to run make at
   * @param messageHandler where to pipe make messages
   * @param cleanMake <code>true</code> to perform complete rebuild, not make of dirty models only.
   */
  public MakeSession(@NotNull Project mpsProject, @NotNull IMessageHandler messageHandler, boolean cleanMake) {
    myProject = mpsProject;
    this.myMessageHandler = messageHandler;
    this.myIsCleanMake = cleanMake;
    this.myIsSticky = false;
  }

  @NotNull
  public Project getProject() {
    return myProject;
  }

  @NotNull
  public IMessageHandler getMessageHandler() {
    return myMessageHandler;
  }

  public boolean isCleanMake() {
    return myIsCleanMake;
  }

  /**
   * 
   * @deprecated according to Fedor, obsolete functionality. There are usecases when we can benefit from sticky make session and its explicit shutdown, perhaps shall resurrect.
   */
  @Deprecated(since = "3.2", forRemoval = true)
  public boolean isSticky() {
    return myIsSticky;
  }

  public void doExecute(Runnable scriptRunnable) {
    scriptRunnable.run();
  }

  public IScript toScript(ScriptBuilder scriptBuilder) {
    return scriptBuilder.toScript();
  }
}
