<commit_before>package com.intellij.openapi.progress.util;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.impl.LaterInvocator;
import com.intellij.openapi.application.impl.ModalityStateEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.wm.ex.ProgressIndicatorEx;
import com.intellij.util.containers.DoubleArrayList;
import com.intellij.util.containers.Stack;

import javax.swing.*;
import java.awt.*;
import java.util.HashSet;
import java.util.Set;

public class ProgressIndicatorBase implements ProgressIndicatorEx {
  private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.progress.util.ProgressIndicatorBase");

  private volatile String myText;
  private volatile double myFraction;
  private volatile String myText2;

  private volatile boolean myCanceled;
  private volatile boolean myRunning;

  private volatile boolean myIndeterminate;

  private final Stack<String> myTextStack = new Stack<String>();
  private final DoubleArrayList myFractionStack = new DoubleArrayList();
  private final Stack<String> myText2Stack = new Stack<String>();
  private volatile int myNonCancelableCount = 0;

  private ProgressIndicator myModalityProgress = null;
  private ModalityState myModalityState = ModalityState.NON_MODAL;
  private boolean myModalityEntered = false;

  private final Set<ProgressIndicatorEx> myStateDelegates = new HashSet<ProgressIndicatorEx>();

  public void start() {
    synchronized (this) {
      LOG.assertTrue(!isRunning(), "Attempt to start ProgressIndicator which is already running");
      myText = "";
      myFraction = 0;
      myText2 = "";
      myCanceled = false;
      myRunning = true;

      delegateRunningChange(new IndicatorAction() {
        public void execute(final ProgressIndicatorEx each) {
          each.start();
        }
      });
    }

    enterModality();
  }

  protected final void enterModality() {
    if (myModalityProgress == this) {
      if (!EventQueue.isDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            doEnterModality();
          }
        });
      }
      else {
        doEnterModality();
      }
    }
  }

  private void doEnterModality() {
    if (!myModalityEntered) {
      LaterInvocator.enterModal(this);
      myModalityEntered = true;
    }
  }

  public void stop() {
    LOG.assertTrue(myRunning, "stop() should be called only if start() called before");
    myRunning = false;

    delegateRunningChange(new IndicatorAction() {
      public void execute(final ProgressIndicatorEx each) {
        each.stop();
      }
    });
    exitModality();
  }

  protected final void exitModality() {
    if (myModalityProgress == this) {
      if (!EventQueue.isDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            doExitModality();
          }
        });
      }
      else {
        doExitModality();
      }
    }
  }

  private void doExitModality() {
    if (myModalityEntered) {
      LaterInvocator.leaveModal(this);
      myModalityEntered = false;
    }
  }

  public boolean isRunning() {
    return myRunning;
  }

  public void cancel() {
    myCanceled = true;

    delegateRunningChange(new IndicatorAction() {
      public void execute(final ProgressIndicatorEx each) {
        each.cancel();
      }
    });
  }

  public boolean isCanceled() {
    return myCanceled;
  }

  public final void checkCanceled() {
    if (isCanceled() && myNonCancelableCount == 0) {
      throw new ProcessCanceledException();
    }

    delegate(new IndicatorAction() {
      public void execute(final ProgressIndicatorEx each) {
        each.checkCanceled();
      }
    });
  }

  public void setText(final String text) {<commit_msg>JS Unused function parameter inspection transformed into JS unused local symbols inspection<commit_after>package com.intellij.openapi.progress.util;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.impl.LaterInvocator;
import com.intellij.openapi.application.impl.ModalityStateEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.wm.ex.ProgressIndicatorEx;
import com.intellij.util.containers.DoubleArrayList;
import com.intellij.util.containers.Stack;

import javax.swing.*;
import java.awt.*;
import java.util.HashSet;
import java.util.Set;

public class ProgressIndicatorBase implements ProgressIndicatorEx {
  private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.progress.util.ProgressIndicatorBase");

  private volatile String myText;
  private volatile double myFraction;
  private volatile String myText2;

  private volatile boolean myCanceled;
  private volatile boolean myRunning;

  private volatile boolean myIndeterminate;

  private final Stack<String> myTextStack = new Stack<String>();
  private final DoubleArrayList myFractionStack = new DoubleArrayList();
  private final Stack<String> myText2Stack = new Stack<String>();
  private volatile int myNonCancelableCount = 0;

  private ProgressIndicator myModalityProgress = null;
  private ModalityState myModalityState = ModalityState.NON_MODAL;
  private boolean myModalityEntered = false;

  private final Set<ProgressIndicatorEx> myStateDelegates = new HashSet<ProgressIndicatorEx>();

  public void start() {
    synchronized (this) {
      LOG.assertTrue(!isRunning(), "Attempt to start ProgressIndicator which is already running");
      myText = "";
      myFraction = 0;
      myText2 = "";
      myCanceled = false;
      myRunning = true;

      delegateRunningChange(new IndicatorAction() {
        public void execute(final ProgressIndicatorEx each) {
          each.start();
        }
      });
    }

    enterModality();
  }

  protected final void enterModality() {
    if (myModalityProgress == this) {
      if (!EventQueue.isDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            doEnterModality();
          }
        });
      }
      else {
        doEnterModality();
      }
    }
  }

  private void doEnterModality() {
    if (!myModalityEntered) {
      LaterInvocator.enterModal(this);
      myModalityEntered = true;
    }
  }

  public void stop() {
    LOG.assertTrue(myRunning, "stop() should be called only if start() called before");
    myRunning = false;

    delegateRunningChange(new IndicatorAction() {
      public void execute(final ProgressIndicatorEx each) {
        each.stop();
      }
    });
    exitModality();
  }

  protected final void exitModality() {
    if (myModalityProgress == this) {
      if (!EventQueue.isDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            doExitModality();
          }
        });
      }
      else {
        doExitModality();
      }
    }
  }

  private void doExitModality() {
    if (myModalityEntered) {
      LaterInvocator.leaveModal(this);
      myModalityEntered = false;
    }
  }

  public boolean isRunning() {
    return myRunning;
  }

  public void cancel() {
    myCanceled = true;

    delegateRunningChange(new IndicatorAction() {
      public void execute(final ProgressIndicatorEx each) {
        each.cancel();
      }
    });
  }

  public boolean isCanceled() {
    return myCanceled;
  }

  public final void checkCanceled() {
    if (isCanceled() && myNonCancelableCount == 0) {
      //throw new ProcessCanceledException();
    }

    delegate(new IndicatorAction() {
      public void execute(final ProgressIndicatorEx each) {
        each.checkCanceled();
      }
    });
  }

  public void setText(final String text) {
{'fraction_non_alphanumeric': 0.09618016672887894, 'fraction_numerical': 0.0014930944382232176, 'mean_word_length': 3.248414376321353, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5108156', 'n_tokens_mistral': 2290, 'n_tokens_neox': 2282, 'n_words': 525}