<commit_before>package com.intellij.codeInsight.template;

import com.intellij.psi.PsiElement;
import com.intellij.util.containers.HashMap;

import java.util.*;

/**
 * @author mike
 */
public class TemplateBuilder {
  private PsiElement myContainerElement;
  private Map<PsiElement,Expression> myExpressions = new HashMap<PsiElement, Expression>();
  private Map<PsiElement,String> myVariableExpressions = new HashMap<PsiElement, String>();
  private Map<PsiElement, Boolean> myAlwaysStopAtMap = new HashMap<PsiElement, Boolean>();
  private Map<PsiElement, String> myVariableNamesMap = new HashMap<PsiElement, String>();
  private Set<PsiElement> myElements = new TreeSet<PsiElement>(new Comparator<PsiElement>() {
    public int compare(final PsiElement e1, final PsiElement e2) {
      return e1.getTextRange().getStartOffset() - e2.getTextRange().getStartOffset();
    }
  });

  private PsiElement myEndElement;
  private PsiElement mySelection;

  public TemplateBuilder(PsiElement element) {
    myContainerElement = element;
  }

  public void replaceElement(PsiElement element, Expression expression, boolean alwaysStopAt) {
    myAlwaysStopAtMap.put(element, alwaysStopAt ? Boolean.TRUE : Boolean.FALSE);
    replaceElement(element, expression);
  }

  public void replaceElement(PsiElement element, String varName, Expression expression, boolean alwaysStopAt) {
    myAlwaysStopAtMap.put(element, alwaysStopAt ? Boolean.TRUE : Boolean.FALSE);
    myVariableNamesMap.put(element, varName);
    replaceElement(element, expression);
  }

  public void replaceElement (PsiElement element, String varName, String dependantVariableName, boolean alwaysStopAt) {
    myAlwaysStopAtMap.put(element, alwaysStopAt ? Boolean.TRUE : Boolean.FALSE);
    myVariableNamesMap.put(element, varName);
    myVariableExpressions.put(element, dependantVariableName);
    myElements.add(element);
  }

  public void replaceElement(PsiElement element, Expression expression) {
    myExpressions.put(element, expression);
    myElements.add(element);
  }

  /**
   * Adds end variable after the specified element
   */
  public void setEndVariableAfter(PsiElement element) {
    element = element.getNextSibling();
    myEndElement = element;
    myElements.add(element);
  }

  public void setSelection(PsiElement element) {
    mySelection = element;
    myElements.add(element);<commit_msg>49156<commit_after>package com.intellij.codeInsight.template;

import com.intellij.psi.PsiElement;
import com.intellij.util.containers.HashMap;

import java.util.*;

/**
 * @author mike
 */
public class TemplateBuilder {
  private PsiElement myContainerElement;
  private Map<PsiElement,Expression> myExpressions = new HashMap<PsiElement, Expression>();
  private Map<PsiElement,String> myVariableExpressions = new HashMap<PsiElement, String>();
  private Map<PsiElement, Boolean> myAlwaysStopAtMap = new HashMap<PsiElement, Boolean>();
  private Map<PsiElement, String> myVariableNamesMap = new HashMap<PsiElement, String>();
  private Set<PsiElement> myElements = new TreeSet<PsiElement>(new Comparator<PsiElement>() {
    public int compare(final PsiElement e1, final PsiElement e2) {
      return e1.getTextRange().getStartOffset() - e2.getTextRange().getStartOffset();
    }
  });

  private PsiElement myEndElement;
  private PsiElement mySelection;

  public TemplateBuilder(PsiElement element) {
    myContainerElement = element;
  }

  public void replaceElement(PsiElement element, Expression expression, boolean alwaysStopAt) {
    myAlwaysStopAtMap.put(element, alwaysStopAt ? Boolean.TRUE : Boolean.FALSE);
    replaceElement(element, expression);
  }

  public void replaceElement(PsiElement element, String varName, Expression expression, boolean alwaysStopAt) {
    myAlwaysStopAtMap.put(element, alwaysStopAt ? Boolean.TRUE : Boolean.FALSE);
    myVariableNamesMap.put(element, varName);
    replaceElement(element, expression);
  }

  public void replaceElement (PsiElement element, String varName, String dependantVariableName, boolean alwaysStopAt) {
    myAlwaysStopAtMap.put(element, alwaysStopAt ? Boolean.TRUE : Boolean.FALSE);
    myVariableNamesMap.put(element, varName);
    myVariableExpressions.put(element, dependantVariableName);
    myElements.add(element);
  }

  public void replaceElement(PsiElement element, Expression expression) {
    myExpressions.put(element, expression);
    myElements.add(element);
  }

  /**
   * Adds end variable after the specified element
   */
  public void setEndVariableAfter(PsiElement element) {
    myElements.remove(myEndElement);
    element = element.getNextSibling();
    myEndElement = element;
    myElements.add(element);
  }

  public void setSelection(PsiElement element) {
    mySelection = element;
    myElements.add(element);
{'fraction_non_alphanumeric': 0.0960534558362915, 'fraction_numerical': 0.002714554186677803, 'mean_word_length': 5.261437908496732, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '4668553', 'n_tokens_mistral': 1332, 'n_tokens_neox': 1308, 'n_words': 308}