d49c300939027b8082554644fceb17cf6663dabc
[idea/community.git] / platform / vcs-api / src / com / intellij / openapi / vcs / VcsDataKeys.java
1 // Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2
3 package com.intellij.openapi.vcs;
4
5 import com.intellij.openapi.ListSelection;
6 import com.intellij.openapi.actionSystem.DataKey;
7 import com.intellij.openapi.vcs.changes.Change;
8 import com.intellij.openapi.vcs.changes.ChangeList;
9 import com.intellij.openapi.vcs.history.VcsFileRevision;
10 import com.intellij.openapi.vcs.history.VcsHistoryProvider;
11 import com.intellij.openapi.vcs.history.VcsHistorySession;
12 import com.intellij.openapi.vcs.history.VcsRevisionNumber;
13 import com.intellij.openapi.vfs.VirtualFile;
14 import com.intellij.util.Consumer;
15 import com.intellij.vcs.commit.CommitWorkflowHandler;
16 import org.jetbrains.annotations.ApiStatus;
17
18 import java.io.File;
19 import java.util.List;
20
21
22 public interface VcsDataKeys {
23   DataKey<VcsKey> VCS = DataKey.create("VCS");
24
25   DataKey<VcsFileRevision> VCS_FILE_REVISION = DataKey.create("VCS_FILE_REVISION");
26   DataKey<VcsFileRevision[]> VCS_FILE_REVISIONS = DataKey.create("VCS_FILE_REVISIONS");
27   DataKey<VcsRevisionNumber> VCS_REVISION_NUMBER = DataKey.create("VCS_REVISION_NUMBER");
28   /**
29    * @see com.intellij.openapi.vcs.history.VcsRevisionNumberArrayRule
30    */
31   DataKey<VcsRevisionNumber[]> VCS_REVISION_NUMBERS = DataKey.create("VCS_REVISION_NUMBERS");
32
33   DataKey<File> IO_FILE = DataKey.create("IO_FILE");
34   DataKey<File[]> IO_FILE_ARRAY = DataKey.create("IO_FILE_ARRAY");
35   DataKey<VirtualFile> VCS_VIRTUAL_FILE = DataKey.create("VCS_VIRTUAL_FILE");
36   DataKey<FilePath> FILE_PATH = DataKey.create("FILE_PATH");
37
38   @ApiStatus.Internal DataKey<Iterable<FilePath>> FILE_PATHS = DataKey.create("VCS_FILE_PATHS");
39   /**
40    * Lazily iterable {@link com.intellij.openapi.actionSystem.CommonDataKeys#VIRTUAL_FILE_ARRAY}.
41    *
42    * @see com.intellij.openapi.vcs.VcsVirtualFilesRule
43    */
44   DataKey<Iterable<VirtualFile>> VIRTUAL_FILES = DataKey.create("VCS_VIRTUAL_FILES");
45
46   DataKey<ChangeList[]> CHANGE_LISTS = DataKey.create("vcs.ChangeList");
47   /**
48    * Selected changes. In some cases, may return all changes if selection is empty.
49    *
50    * @see #SELECTED_CHANGES
51    */
52   DataKey<Change[]> CHANGES = DataKey.create("vcs.Change");
53   /**
54    * Selected changes only.
55    */
56   DataKey<Change[]> SELECTED_CHANGES = DataKey.create("ChangeListView.SelectedChange");
57   /**
58    * Same as {@link #SELECTED_CHANGES}.
59    */
60   DataKey<Change[]> SELECTED_CHANGES_IN_DETAILS = DataKey.create("ChangeListView.SelectedChangesWithMovedSubtrees");
61   /**
62    * For multiple selection, return selected changes.
63    * For singular selection, return all changes and set selected index.
64    * For empty selection, return all changes.
65    *
66    * @see com.intellij.openapi.vcs.changes.VcsChangesSelectionRule
67    * @see com.intellij.openapi.vcs.changes.ui.VcsTreeModelData#getListSelectionOrAll
68    */
69   DataKey<ListSelection<Change>> CHANGES_SELECTION = DataKey.create("vcs.ChangesSelection");
70   /**
71    * Explicitly selected changes.
72    * <p>
73    * When a node in a tree is selected, {@link #SELECTED_CHANGES} will return all changes underneath.
74    * This key will return selected nodes only.
75    * This difference might be important when {@link AbstractVcs#areDirectoriesVersionedItems()} is {@code true}.
76    */
77   DataKey<Change[]> CHANGE_LEAD_SELECTION = DataKey.create("ChangeListView.ChangeLeadSelection");
78   /**
79    * Can be used to ensure that directory flags for SVN are initialized.
80    * Is potentially slow and should not be used in {@link com.intellij.openapi.actionSystem.AnAction#update}, use {@link #CHANGES} instead.
81    */
82   DataKey<Change[]> CHANGES_WITH_MOVED_CHILDREN = DataKey.create("ChangeListView.ChangesWithDetails");
83   DataKey<List<VirtualFile>> MODIFIED_WITHOUT_EDITING_DATA_KEY = DataKey.create("ChangeListView.ModifiedWithoutEditing");
84
85   /**
86    * Fast check for {@link #CHANGES} non-emptiness.
87    */
88   DataKey<Boolean> HAVE_SELECTED_CHANGES = DataKey.create("ChangeListView.HaveSelectedChanges");
89   /**
90    * Fast check for {@link #MODIFIED_WITHOUT_EDITING_DATA_KEY} non-emptiness.
91    */
92   DataKey<Boolean> HAVE_MODIFIED_WITHOUT_EDITING = DataKey.create("ChangeListView.HaveModifiedWithoutEditing");
93   /**
94    * Fast check for {@link com.intellij.openapi.vcs.changes.ui.ChangesListView#MISSING_FILES_DATA_KEY} non-emptiness.
95    * <p>
96    * See 80ee021430c03deef9b4378d124e1b603e207955 for {@link com.intellij.openapi.vcs.changes.ui.ChangesListView#LOCALLY_DELETED_CHANGES}
97    * vs {@link com.intellij.openapi.vcs.changes.ui.ChangesListView#MISSING_FILES_DATA_KEY} origins.
98    */
99   DataKey<Boolean> HAVE_LOCALLY_DELETED = DataKey.create("ChangeListView.HaveLocallyDeleted");
100
101   DataKey<Change> CURRENT_CHANGE = DataKey.create("vcs.CurrentChange");
102   DataKey<VirtualFile> CURRENT_UNVERSIONED = DataKey.create("ChangeListView.CurrentUnversionedFile");
103
104   DataKey<String> PRESET_COMMIT_MESSAGE = DataKey.create("PRESET_COMMIT_MESSAGE");
105   DataKey<CommitMessageI> COMMIT_MESSAGE_CONTROL = DataKey.create("COMMIT_MESSAGE_CONTROL");
106   DataKey<CommitWorkflowHandler> COMMIT_WORKFLOW_HANDLER = DataKey.create("Vcs.CommitWorkflowHandler");
107
108   DataKey<VcsHistorySession> HISTORY_SESSION = DataKey.create("VCS_HISTORY_SESSION");
109   /**
110    * true - if content has no matching local root (ex: history for remote repository without checking it out).
111    */
112   DataKey<Boolean> VCS_NON_LOCAL_HISTORY_SESSION = DataKey.create("VCS_NON_LOCAL_HISTORY_SESSION");
113   DataKey<VcsHistoryProvider> HISTORY_PROVIDER = DataKey.create("VCS_HISTORY_PROVIDER");
114
115   DataKey<Consumer<String>> REMOTE_HISTORY_CHANGED_LISTENER = DataKey.create("REMOTE_HISTORY_CHANGED_LISTENER");
116   DataKey<RepositoryLocation> REMOTE_HISTORY_LOCATION = DataKey.create("REMOTE_HISTORY_LOCATION");
117 }