<commit_before>package com.intellij.openapi.vcs.changes.ui;

import com.intellij.ide.dnd.*;
import com.intellij.ide.util.treeView.TreeState;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.FileStatusListener;
import com.intellij.openapi.vcs.FileStatusManager;
import com.intellij.openapi.vcs.changes.*;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.peer.PeerFactory;
import com.intellij.pom.Navigatable;
import com.intellij.ui.*;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.awt.RelativeRectangle;
import com.intellij.util.EditSourceOnDoubleClickHandler;
import com.intellij.util.Icons;
import com.intellij.util.containers.Convertor;
import com.intellij.util.ui.Tree;
import com.intellij.util.ui.tree.TreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import javax.swing.table.TableCellRenderer;
import javax.swing.tree.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.*;
import java.util.List;

/**
 * @author max
 */
public class ChangesListView extends Tree implements DataProvider {
  private ChangesListView.DragSource myDragSource;
  private ChangesListView.DropTarget myDropTarget;
  private DnDManager myDndManager;
  private ChangeListOwner myDragOwner;
  private final Project myProject;
  private FileStatusListener myFileStatusManager;
  private TreeState myTreeState;
  private boolean myShowFlatten = false;


  private static FilePath getFilePath(final Change change) {
    ContentRevision revision = change.getAfterRevision();
    if (revision == null) revision = change.getBeforeRevision();

    return revision.getFile();
  }

  private FileStatus getChangeStatus(Change change) {
    final VirtualFile vFile = getFilePath(change).getVirtualFile();
    if (vFile == null) return FileStatus.DELETED;
    return FileStatusManager.getInstance(myProject).getStatus(vFile);
  }

  public ChangesListView(final Project project) {
    myProject = project;

    setShowsRootHandles(true);
    setRootVisible(false);
    setCellRenderer(new NodeRenderer());
    new TreeSpeedSearch(this, new NodeToTextConvertor());
    SmartExpander.installOn(this);

    myFileStatusManager = new FileStatusListener() {
      public void fileStatusesChanged() {
        reload();
      }

      public void fileStatusChanged(@NotNull VirtualFile virtualFile) {
        reload();
      }
    };

    FileStatusManager.getInstance(project).addFileStatusListener(myFileStatusManager);
  }

  public FilePath safeCastToFilePath(Object o) {
    if (o instanceof FilePath) return (FilePath)o;
    return null;
  }

  public String getRelativePath(FilePath parent, FilePath child) {
    if (parent == null) return child.getPath();
    return child.getPath().substring(parent.getPath().length() + 1);
  }

  public void installDndSupport(ChangeListOwner owner) {
    myDragOwner = owner;
    myDragSource = new DragSource();
    myDropTarget = new DropTarget();
    myDndManager = DnDManager.getInstance(myProject);

    myDndManager.registerSource(myDragSource, this);
    myDndManager.registerTarget(myDropTarget, this);
  }

  public void dispose() {
    FileStatusManager.getInstance(myProject).removeFileStatusListener(myFileStatusManager);
    if (myDragSource != null) {<commit_msg>Windows should have backward slashes apper in file nodes.<commit_after>package com.intellij.openapi.vcs.changes.ui;

import com.intellij.ide.dnd.*;
import com.intellij.ide.util.treeView.TreeState;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.FileStatusListener;
import com.intellij.openapi.vcs.FileStatusManager;
import com.intellij.openapi.vcs.changes.*;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.peer.PeerFactory;
import com.intellij.pom.Navigatable;
import com.intellij.ui.*;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.awt.RelativeRectangle;
import com.intellij.util.EditSourceOnDoubleClickHandler;
import com.intellij.util.Icons;
import com.intellij.util.containers.Convertor;
import com.intellij.util.ui.Tree;
import com.intellij.util.ui.tree.TreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import javax.swing.table.TableCellRenderer;
import javax.swing.tree.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.*;
import java.util.List;

/**
 * @author max
 */
public class ChangesListView extends Tree implements DataProvider {
  private ChangesListView.DragSource myDragSource;
  private ChangesListView.DropTarget myDropTarget;
  private DnDManager myDndManager;
  private ChangeListOwner myDragOwner;
  private final Project myProject;
  private FileStatusListener myFileStatusManager;
  private TreeState myTreeState;
  private boolean myShowFlatten = false;


  private static FilePath getFilePath(final Change change) {
    ContentRevision revision = change.getAfterRevision();
    if (revision == null) revision = change.getBeforeRevision();

    return revision.getFile();
  }

  private FileStatus getChangeStatus(Change change) {
    final VirtualFile vFile = getFilePath(change).getVirtualFile();
    if (vFile == null) return FileStatus.DELETED;
    return FileStatusManager.getInstance(myProject).getStatus(vFile);
  }

  public ChangesListView(final Project project) {
    myProject = project;

    setShowsRootHandles(true);
    setRootVisible(false);
    setCellRenderer(new NodeRenderer());
    new TreeSpeedSearch(this, new NodeToTextConvertor());
    SmartExpander.installOn(this);

    myFileStatusManager = new FileStatusListener() {
      public void fileStatusesChanged() {
        reload();
      }

      public void fileStatusChanged(@NotNull VirtualFile virtualFile) {
        reload();
      }
    };

    FileStatusManager.getInstance(project).addFileStatusListener(myFileStatusManager);
  }

  public FilePath safeCastToFilePath(Object o) {
    if (o instanceof FilePath) return (FilePath)o;
    return null;
  }

  public String getRelativePath(FilePath parent, FilePath child) {
    if (parent == null) return child.getPath();
    return child.getPath().substring(parent.getPath().length() + 1).replace('/', File.separatorChar);
  }

  public void installDndSupport(ChangeListOwner owner) {
    myDragOwner = owner;
    myDragSource = new DragSource();
    myDropTarget = new DropTarget();
    myDndManager = DnDManager.getInstance(myProject);

    myDndManager.registerSource(myDragSource, this);
    myDndManager.registerTarget(myDropTarget, this);
  }

  public void dispose() {
    FileStatusManager.getInstance(myProject).removeFileStatusListener(myFileStatusManager);
    if (myDragSource != null) {
{'fraction_non_alphanumeric': 0.10071751262290725, 'fraction_numerical': 0.00026574541589157585, 'mean_word_length': 5.05064308681672, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3227033', 'n_tokens_mistral': 2288, 'n_tokens_neox': 2228, 'n_words': 443}