<commit_before>package com.intellij.execution.process;

import com.intellij.openapi.util.ModificationTracker;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * @author Gregory.Shrago
 */
public class ConsoleHistoryModel implements ModificationTracker {

  public static final int DEFAULT_MAX_SIZE = 20;

  private int myHistoryCursor;
  private int myMaxHistorySize = DEFAULT_MAX_SIZE;
  private final LinkedList<String> myHistory = new LinkedList<String>();
  private volatile long myModificationTracker;


  public void addToHistory(final String statement) {
    synchronized (myHistory) {
      removeFromHistory(statement);
      if (myHistory.size() >= myMaxHistorySize) {
        myHistory.removeLast();
      }
      myHistory.addFirst(statement);
    }
  }

  public void removeFromHistory(final String statement) {
    synchronized (myHistory) {
      myModificationTracker++;
      myHistoryCursor = -1;
      myHistory.remove(statement);
    }
  }

  public List<String> getHistory() {
    synchronized (myHistory) {
      return new ArrayList<String>(myHistory);
    }
  }

  public int getMaxHistorySize() {
    synchronized (myHistory) {
      return myMaxHistorySize;
    }
  }

  public int getHistorySize() {
    synchronized (myHistory) {
      return myHistory.size();
    }
  }

  public void setMaxHistorySize(final int maxHistorySize) {
    synchronized (myHistory) {
      myMaxHistorySize = maxHistorySize;
    }
  }

  @Nullable
  public String getHistoryNext() {
    synchronized (myHistory) {
      if (myHistoryCursor < myHistory.size() - 1) {
        return myHistory.get(++myHistoryCursor);
      }
      else {
        if (myHistoryCursor == myHistory.size() - 1) myHistoryCursor++;
        return null;
      }
    }
  }

  @Nullable
  public String getHistoryPrev() {
    synchronized (myHistory) {
      if (myHistoryCursor > 0) {
        return myHistory.get(--myHistoryCursor);
      }
      else {
        if (myHistoryCursor == 0) myHistoryCursor--;<commit_msg>one history size option: javaee part<commit_after>package com.intellij.execution.process;

import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.util.ModificationTracker;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * @author Gregory.Shrago
 */
public class ConsoleHistoryModel implements ModificationTracker {

  private int myHistoryCursor;
  private final LinkedList<String> myHistory = new LinkedList<String>();
  private volatile long myModificationTracker;


  public void addToHistory(final String statement) {
    final int maxHistorySize = getMaxHistorySize();
    synchronized (myHistory) {
      removeFromHistory(statement);
      if (myHistory.size() >= maxHistorySize) {
        myHistory.removeLast();
      }
      myHistory.addFirst(statement);
    }
  }

  public int getMaxHistorySize() {
    return UISettings.getInstance().CONSOLE_COMMAND_HISTORY_LIMIT;
  }

  public void removeFromHistory(final String statement) {
    synchronized (myHistory) {
      myModificationTracker++;
      myHistoryCursor = -1;
      myHistory.remove(statement);
    }
  }

  public List<String> getHistory() {
    synchronized (myHistory) {
      return new ArrayList<String>(myHistory);
    }
  }

  public int getHistorySize() {
    synchronized (myHistory) {
      return myHistory.size();
    }
  }

  @Nullable
  public String getHistoryNext() {
    synchronized (myHistory) {
      if (myHistoryCursor < myHistory.size() - 1) {
        return myHistory.get(++myHistoryCursor);
      }
      else {
        if (myHistoryCursor == myHistory.size() - 1) myHistoryCursor++;
        return null;
      }
    }
  }

  @Nullable
  public String getHistoryPrev() {
    synchronized (myHistory) {
      if (myHistoryCursor > 0) {
        return myHistory.get(--myHistoryCursor);
      }
      else {
        if (myHistoryCursor == 0) myHistoryCursor--;
{'fraction_non_alphanumeric': 0.10027302060064532, 'fraction_numerical': 0.0029784065524944155, 'mean_word_length': 3.2198952879581153, 'pattern_counts': {'":': 0, '<': 13, '<?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': '7491204', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1169, 'n_words': 255}