Remove dependency intellij.platform.diff.impl -> intellij.platform.vcs, IDEA-CR-1366

GitOrigin-RevId: 3f914e4174f33ba581f47dd42c43939cbb3dda53
This commit is contained in:
Evgeniy.Stepanov
2020-04-28 19:16:33 +00:00
committed by intellij-monorepo-bot
parent 4b81851c82
commit 7538e55642
51 changed files with 366 additions and 168 deletions
@@ -6,7 +6,14 @@ cannot.create.diff.error=Cannot create diff element from: {0}
cannot.compare.error=Diff manager cannot compare ''{0}'' and ''{1}''
unknown.file.type.error=Unknown file type: {0}
dialog.title.diff.for.range=Diff for Range
diff.content.title.up.to.date=Base revision
diff.content.title.current.range=Current
refresh.failed.message=Refresh failed: {0}
save.merge.result.command.name=Merge
rollback.change.command.name=Rollback Change
compare.file.vs.file.dialog.title={0} vs {1}
diff.content.editor.content.title=Editor
diff.content.clipboard.content.title=From clipboard
@@ -0,0 +1,33 @@
// Copyright 2000-2020 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.
package com.intellij.diff;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil;
import org.jetbrains.annotations.NotNull;
@State(
name = "DiffApplicationSettings",
storages = @Storage("vcs.xml"),
reportStatistic = true
)
public class DiffApplicationSettings implements PersistentStateComponent<DiffApplicationSettings> {
public boolean SHOW_LST_WORD_DIFFERENCES = true;
public static DiffApplicationSettings getInstance() {
return ServiceManager.getService(DiffApplicationSettings.class);
}
@Override
public DiffApplicationSettings getState() {
return this;
}
@Override
public void loadState(@NotNull DiffApplicationSettings state) {
XmlSerializerUtil.copyBean(state, this);
}
}
@@ -0,0 +1,27 @@
// Copyright 2000-2020 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.
package com.intellij.diff.vcs;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.LocalFilePath;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@ApiStatus.Internal
public class DiffVcsFacade {
@NotNull
public static DiffVcsFacade getInstance() {
return ServiceManager.getService(DiffVcsFacade.class);
}
@NotNull
public FilePath getFilePath(@NotNull String path) {
return new LocalFilePath(path, false);
}
@NotNull
public FilePath getFilePath(@NotNull VirtualFile virtualFile) {
return new LocalFilePath(virtualFile.getPath(), virtualFile.isDirectory());
}
}
@@ -0,0 +1,7 @@
// Copyright 2000-2020 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.
package com.intellij.openapi;
public final class LineNumberConstants {
public static final int ABSENT_LINE_NUMBER = -1;
public static final int FAKE_LINE_NUMBER = -2;
}
@@ -11,8 +11,6 @@
<orderEntry type="module" module-name="intellij.platform.diff" exported="" />
<orderEntry type="module" module-name="intellij.platform.ide" />
<orderEntry type="module" module-name="intellij.platform.ide.impl" />
<orderEntry type="module" module-name="intellij.platform.vcs.core" />
<orderEntry type="module" module-name="intellij.platform.vcs" />
<orderEntry type="module" module-name="intellij.platform.lang" />
<orderEntry type="library" name="Guava" level="project" />
<orderEntry type="library" name="miglayout-swing" level="project" />
@@ -7,6 +7,7 @@ import com.intellij.diff.contents.*;
import com.intellij.diff.tools.util.DiffNotifications;
import com.intellij.diff.util.DiffUserDataKeysEx;
import com.intellij.diff.util.DiffUtil;
import com.intellij.diff.vcs.DiffVcsFacade;
import com.intellij.ide.highlighter.ArchiveFileType;
import com.intellij.lang.properties.charset.Native2AsciiCharset;
import com.intellij.openapi.application.ReadAction;
@@ -34,7 +35,6 @@ import com.intellij.ui.LightColors;
import com.intellij.util.LineSeparator;
import com.intellij.util.ObjectUtils;
import com.intellij.util.PathUtil;
import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -270,7 +270,7 @@ public class DiffContentFactoryImpl extends DiffContentFactoryEx {
@NotNull FileType fileType,
@NotNull String fileName) throws IOException {
if (isBinaryContent(content, fileType)) {
return createBinaryImpl(project, content, fileType, VcsUtil.getFilePath(fileName), null);
return createBinaryImpl(project, content, fileType, DiffVcsFacade.getInstance().getFilePath(fileName), null);
}
return createDocumentFromBytes(project, content, fileType, fileName);
@@ -282,7 +282,7 @@ public class DiffContentFactoryImpl extends DiffContentFactoryEx {
byte @NotNull [] content,
@NotNull VirtualFile highlightFile) throws IOException {
if (isBinaryContent(content, highlightFile.getFileType())) {
return createBinaryImpl(project, content, highlightFile.getFileType(), VcsUtil.getFilePath(highlightFile), highlightFile);
return createBinaryImpl(project, content, highlightFile.getFileType(), DiffVcsFacade.getInstance().getFilePath(highlightFile), highlightFile);
}
return createDocumentFromBytes(project, content, highlightFile);
@@ -336,7 +336,7 @@ public class DiffContentFactoryImpl extends DiffContentFactoryEx {
byte @NotNull [] content,
@NotNull FileType type,
@NotNull String fileName) throws IOException {
return createBinaryImpl(project, content, type, VcsUtil.getFilePath(fileName), null);
return createBinaryImpl(project, content, type, DiffVcsFacade.getInstance().getFilePath(fileName), null);
}
@@ -593,7 +593,7 @@ public class DiffContentFactoryImpl extends DiffContentFactoryEx {
public DocumentContentBuilder contextByHighlightFile(@Nullable VirtualFile file) {
if (file != null) {
context = new Context.ByHighlightFile(file);
originalFilePath = VcsUtil.getFilePath(file);
originalFilePath = DiffVcsFacade.getInstance().getFilePath(file);
fileName = file.getName();
}
return this;
@@ -606,7 +606,7 @@ public class DiffContentFactoryImpl extends DiffContentFactoryEx {
context = new Context.ByReferent(referent);
VirtualFile file = referent.getHighlightFile();
if (file != null) {
originalFilePath = VcsUtil.getFilePath(file);
originalFilePath = DiffVcsFacade.getInstance().getFilePath(file);
fileName = file.getName();
}
}
@@ -17,6 +17,7 @@ import com.intellij.diff.requests.ContentDiffRequest;
import com.intellij.diff.requests.SimpleDiffRequest;
import com.intellij.diff.requests.TextMergeRequestImpl;
import com.intellij.diff.util.DiffUtil;
import com.intellij.diff.vcs.DiffVcsFacade;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.diff.DiffBundle;
import com.intellij.openapi.editor.Document;
@@ -26,7 +27,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
import com.intellij.vcsUtil.VcsUtil;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -100,14 +100,14 @@ public class DiffRequestFactoryImpl extends DiffRequestFactory {
@Override
public String getContentTitle(@Nullable VirtualFile file) {
if (file == null) return null;
return getContentTitle(VcsUtil.getFilePath(file));
return getContentTitle(DiffVcsFacade.getInstance().getFilePath(file));
}
@NotNull
@Override
public String getTitle(@Nullable VirtualFile file1, @Nullable VirtualFile file2) {
FilePath path1 = file1 != null ? VcsUtil.getFilePath(file1) : null;
FilePath path2 = file2 != null ? VcsUtil.getFilePath(file2) : null;
FilePath path1 = file1 != null ? DiffVcsFacade.getInstance().getFilePath(file1) : null;
FilePath path2 = file2 != null ? DiffVcsFacade.getInstance().getFilePath(file2) : null;
return getTitle(path1, path2, " vs ");
}
@@ -5,10 +5,10 @@ import com.intellij.diff.chains.SimpleDiffRequestChain.DiffRequestProducerWrappe
import com.intellij.diff.requests.ErrorDiffRequest;
import com.intellij.diff.requests.LoadingDiffRequest;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.util.BackgroundTaskUtil;
import com.intellij.util.EventDispatcher;
import com.intellij.util.ListSelection;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.CalledInBackground;
import org.jetbrains.annotations.NotNull;
@@ -50,10 +50,7 @@ import com.intellij.openapi.util.UserDataHolder;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy;
import com.intellij.ui.HintHint;
import com.intellij.ui.JBColor;
import com.intellij.ui.JBSplitter;
import com.intellij.ui.LightweightHint;
import com.intellij.ui.*;
import com.intellij.ui.components.JBPanelWithEmptyText;
import com.intellij.ui.components.panels.Wrapper;
import com.intellij.ui.mac.TouchbarDataKeys;
@@ -62,7 +59,6 @@ import com.intellij.ui.scale.JBUIScale;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import com.intellij.vcsUtil.UIVcsUtilKt;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -149,7 +145,7 @@ public abstract class DiffRequestProcessor implements Disposable {
JPanel statusPanel = JBUI.Panels.simplePanel(myToolbarStatusPanel).addToLeft(myProgressBar);
JPanel topPanel = JBUI.Panels.simplePanel(myToolbarWrapper).addToRight(statusPanel);
UIVcsUtilKt.installVisibilityReferent(topPanel, myToolbar.getComponent());
GuiUtils.installVisibilityReferent(topPanel, myToolbar.getComponent());
Splitter bottomContentSplitter = new JBSplitter(true, "DiffRequestProcessor.BottomComponentSplitter", 0.8f);
bottomContentSplitter.setFirstComponent(myContentPanel);
@@ -19,9 +19,6 @@ import com.intellij.openapi.util.Couple;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vcs.merge.MergeData;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.projectImport.ProjectOpenProcessor;
import com.intellij.util.Function;
@@ -174,33 +171,6 @@ public class MergeUtil {
Messages.getQuestionIcon()) == Messages.YES;
}
public static void putRevisionInfos(@NotNull MergeRequest request, @NotNull MergeData data) {
if (request instanceof ThreesideMergeRequest) {
List<? extends DiffContent> contents = ((ThreesideMergeRequest)request).getContents();
putRevisionInfo(contents, data);
}
}
public static void putRevisionInfos(@NotNull DiffRequest request, @NotNull MergeData data) {
if (request instanceof ContentDiffRequest) {
List<? extends DiffContent> contents = ((ContentDiffRequest)request).getContents();
if (contents.size() == 3) {
putRevisionInfo(contents, data);
}
}
}
private static void putRevisionInfo(@NotNull List<? extends DiffContent> contents, @NotNull MergeData data) {
for (ThreeSide side : ThreeSide.values()) {
DiffContent content = side.select(contents);
FilePath filePath = side.select(data.CURRENT_FILE_PATH, data.ORIGINAL_FILE_PATH, data.LAST_FILE_PATH);
VcsRevisionNumber revision = side.select(data.CURRENT_REVISION_NUMBER, data.ORIGINAL_REVISION_NUMBER, data.LAST_REVISION_NUMBER);
if (filePath != null && revision != null) {
content.putUserData(DiffUserDataKeysEx.REVISION_INFO, Pair.create(filePath, revision));
}
}
}
public static void reportProjectFileChangeIfNeeded(@Nullable Project project, @Nullable VirtualFile file) {
if (project != null && file != null && isProjectFile(file)) {
StoreReloadManager.getInstance().saveChangedProjectFile(file, project);
@@ -24,16 +24,19 @@ import com.intellij.diff.requests.DiffRequest;
import com.intellij.execution.ExecutionException;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.diff.DiffBundle;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.vcsUtil.VcsUtil;
import com.intellij.util.ListSelection;
import com.intellij.util.ThrowableConvertor;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -86,7 +89,7 @@ public class ExternalDiffTool {
private static List<DiffRequest> loadRequestsUnderProgress(@Nullable Project project,
@NotNull DiffRequestChain chain) throws Throwable {
if (chain instanceof AsyncDiffRequestChain) {
return VcsUtil.computeWithModalProgress(project, DiffBundle.message("progress.title.loading.requests"), true, indicator -> {
return computeWithModalProgress(project, DiffBundle.message("progress.title.loading.requests"), true, indicator -> {
ListSelection<? extends DiffRequestProducer> listSelection = ((AsyncDiffRequestChain)chain).loadRequestsInBackground();
return collectRequests(project, listSelection.getList(), listSelection.getSelectedIndex(), indicator);
});
@@ -95,7 +98,7 @@ public class ExternalDiffTool {
List<? extends DiffRequestProducer> allProducers = chain.getRequests();
int index = chain.getIndex();
return VcsUtil.computeWithModalProgress(project, DiffBundle.message("progress.title.loading.requests"), true, indicator -> {
return computeWithModalProgress(project, DiffBundle.message("progress.title.loading.requests"), true, indicator -> {
return collectRequests(project, allProducers, index, indicator);
});
}
@@ -138,6 +141,19 @@ public class ExternalDiffTool {
return requests;
}
private static <T> T computeWithModalProgress(@Nullable Project project,
@NotNull @Nls String title,
boolean canBeCancelled,
@NotNull ThrowableConvertor<? super ProgressIndicator, T, ? extends Exception> computable)
throws Exception {
return ProgressManager.getInstance().run(new Task.WithResult<T, Exception>(project, title, canBeCancelled) {
@Override
protected T compute(@NotNull ProgressIndicator indicator) throws Exception {
return computable.convert(indicator);
}
});
}
public static void showRequest(@Nullable Project project, @NotNull DiffRequest request) throws ExecutionException, IOException {
request.onAssigned(true);
try {
@@ -13,9 +13,6 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Couple;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.TIntFunction;
@@ -34,7 +31,6 @@ public interface DiffUserDataKeysEx extends DiffUserDataKeys {
* Override line numbers in editor gutter (function "document line -> user-visible line number")
*/
Key<TIntFunction> LINE_NUMBER_CONVERTOR = Key.create("Diff.LineNumberConvertor");
Key<Pair<FilePath, VcsRevisionNumber>> REVISION_INFO = Key.create("Diff.RevisionInfo");
Key<String> FILE_NAME = Key.create("Diff.FileName");
Key<Boolean> DIFF_IN_EDITOR = Key.create("Diff.DiffInEditor");
@@ -27,7 +27,6 @@ import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.ComponentUtil;
import com.intellij.ui.TableUtil;
@@ -254,7 +253,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode
}
catch (IOException e) {
LOG.warn(e);
reportException(VcsBundle.message("refresh.failed.message", StringUtil.decapitalize(e.getLocalizedMessage())));
reportException(DiffBundle.message("refresh.failed.message", StringUtil.decapitalize(e.getLocalizedMessage())));
}
finally {
if (myTree != null) {
@@ -283,7 +282,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode
}
catch (final IOException e) {
LOG.warn(e);
reportException(VcsBundle.message("refresh.failed.message", StringUtil.decapitalize(e.getLocalizedMessage())));
reportException(DiffBundle.message("refresh.failed.message", StringUtil.decapitalize(e.getLocalizedMessage())));
}
finally {
myTree.setSource(mySource);
@@ -5,6 +5,7 @@ import com.intellij.codeInsight.hint.EditorFragmentComponent;
import com.intellij.codeInsight.hint.EditorHintListener;
import com.intellij.codeInsight.hint.HintManager;
import com.intellij.codeInsight.hint.HintManagerImpl;
import com.intellij.diff.DiffApplicationSettings;
import com.intellij.diff.DiffContentFactory;
import com.intellij.diff.DiffManager;
import com.intellij.diff.comparison.ByWord;
@@ -40,8 +41,6 @@ import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vcs.VcsApplicationSettings;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.*;
import com.intellij.util.ui.JBUI;
@@ -93,7 +92,7 @@ public abstract class LineStatusMarkerPopupRenderer extends LineStatusMarkerRend
}
private static boolean isShowInnerDifferences() {
return VcsApplicationSettings.getInstance().SHOW_LST_WORD_DIFFERENCES;
return DiffApplicationSettings.getInstance().SHOW_LST_WORD_DIFFERENCES;
}
@Nullable
@@ -524,10 +523,10 @@ public abstract class LineStatusMarkerPopupRenderer extends LineStatusMarkerRend
myTracker.getVirtualFile(),
getCurrentTextRange(ourRange));
SimpleDiffRequest request = new SimpleDiffRequest(VcsBundle.message("dialog.title.diff.for.range"),
SimpleDiffRequest request = new SimpleDiffRequest(DiffBundle.message("dialog.title.diff.for.range"),
vcsContent, currentContent,
VcsBundle.message("diff.content.title.up.to.date"),
VcsBundle.message("diff.content.title.current.range"));
DiffBundle.message("diff.content.title.up.to.date"),
DiffBundle.message("diff.content.title.current.range"));
DiffManager.getInstance().showDiff(myTracker.getProject(), request);
}
@@ -567,13 +566,13 @@ public abstract class LineStatusMarkerPopupRenderer extends LineStatusMarkerRend
@Override
public boolean isSelected(@NotNull AnActionEvent e) {
return VcsApplicationSettings.getInstance().SHOW_LST_WORD_DIFFERENCES;
return DiffApplicationSettings.getInstance().SHOW_LST_WORD_DIFFERENCES;
}
@Override
public void setSelected(@NotNull AnActionEvent e, boolean state) {
if (!myTracker.isValid()) return;
VcsApplicationSettings.getInstance().SHOW_LST_WORD_DIFFERENCES = state;
DiffApplicationSettings.getInstance().SHOW_LST_WORD_DIFFERENCES = state;
Range newRange = myTracker.findRange(myRange);
if (newRange != null) {
@@ -18,18 +18,18 @@ package com.intellij.openapi.vcs.ex
import com.intellij.diff.util.DiffUtil
import com.intellij.diff.util.Side
import com.intellij.openapi.Disposable
import com.intellij.openapi.LineNumberConstants
import com.intellij.openapi.application.Application
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.WriteThread
import com.intellij.openapi.command.CommandProcessor
import com.intellij.openapi.command.undo.UndoConstants
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.diff.DiffBundle
import com.intellij.openapi.editor.Document
import com.intellij.openapi.editor.impl.DocumentImpl
import com.intellij.openapi.localVcs.UpToDateLineNumberProvider.ABSENT_LINE_NUMBER
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.vcs.VcsBundle
import com.intellij.openapi.vcs.ex.DocumentTracker.Block
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.containers.nullize
@@ -334,7 +334,7 @@ abstract class LineStatusTrackerBase<R : Range> : LineStatusTrackerI<R> {
protected fun runBulkRollback(condition: (Block) -> Boolean) {
if (!isValid()) return
updateDocument(Side.RIGHT, VcsBundle.message("command.name.rollback.change")) {
updateDocument(Side.RIGHT, DiffBundle.message("rollback.change.command.name")) {
documentTracker.partiallyApplyBlocks(Side.RIGHT, condition) { block, shift ->
fireLinesUnchanged(block.start + shift, block.start + shift + (block.vcsEnd - block.vcsStart))
}
@@ -370,7 +370,7 @@ abstract class LineStatusTrackerBase<R : Range> : LineStatusTrackerI<R> {
private fun transferLine(line: Int, approximate: Boolean, fromVcs: Boolean): Int {
LOCK.read {
if (!isValid()) return if (approximate) line else ABSENT_LINE_NUMBER
if (!isValid()) return if (approximate) line else LineNumberConstants.ABSENT_LINE_NUMBER
var result = line
@@ -381,7 +381,7 @@ abstract class LineStatusTrackerBase<R : Range> : LineStatusTrackerI<R> {
val endLine2 = if (fromVcs) block.end else block.vcsEnd
if (line in startLine1 until endLine1) {
return if (approximate) startLine2 else ABSENT_LINE_NUMBER
return if (approximate) startLine2 else LineNumberConstants.ABSENT_LINE_NUMBER
}
if (endLine1 > line) return result
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2020 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.
package com.intellij.openapi.vcs;
import com.intellij.openapi.editor.Document;
@@ -20,13 +6,13 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.encoding.EncodingManager;
import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
import com.intellij.util.PathUtil;
import com.intellij.vcsUtil.VcsFileUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -92,7 +78,7 @@ public class LocalFilePath implements FilePath {
@Override
public boolean isUnder(@NotNull FilePath parent, boolean strict) {
return VcsFileUtil.isAncestor(parent, this, strict);
return FileUtil.startsWith(this.getPath(), parent.getPath(), SystemInfo.isFileSystemCaseSensitive, strict);
}
@Override
@@ -31,6 +31,8 @@ import javax.swing.table.TableColumnModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.lang.reflect.InvocationTargetException;
public final class GuiUtils {
@@ -305,4 +307,25 @@ public final class GuiUtils {
size.width = fontMetrics.charWidth('a') * charCount;
return size;
}
public static void installVisibilityReferent(JComponent owner, JComponent referent) {
referent.addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(ComponentEvent e) {
toggleVisibility(e);
}
@Override
public void componentHidden(ComponentEvent e) {
toggleVisibility(e);
}
private void toggleVisibility(ComponentEvent e) {
Component component = e.getComponent();
if (component != null) {
owner.setVisible(component.isVisible());
}
}
});
}
}
@@ -0,0 +1,87 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.util;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* Utility class used to preserve index during 'map' operations
*/
public class ListSelection<T> {
@NotNull private final List<T> myList;
private final int mySelectedIndex;
private ListSelection(@NotNull List<T> list, int selectedIndex) {
myList = list;
if (selectedIndex >= 0 && selectedIndex < list.size()) {
mySelectedIndex = selectedIndex;
}
else {
mySelectedIndex = 0;
}
}
@NotNull
public static <V> ListSelection<V> createAt(@NotNull List<V> list, int selectedIndex) {
return new ListSelection<>(list, selectedIndex);
}
@NotNull
public static <V> ListSelection<V> create(@NotNull List<V> list, V selected) {
return createAt(list, list.indexOf(selected));
}
@NotNull
public static <V> ListSelection<V> create(V @NotNull [] array, V selected) {
return create(Arrays.asList(array), selected);
}
@NotNull
public static <V> ListSelection<V> createSingleton(@NotNull V element) {
return createAt(Collections.singletonList(element), 0);
}
@NotNull
public List<T> getList() {
return myList;
}
public int getSelectedIndex() {
return mySelectedIndex;
}
public boolean isEmpty() {
return myList.isEmpty();
}
@NotNull
public <V> ListSelection<V> map(@NotNull NullableFunction<? super T, ? extends V> convertor) {
int newSelectionIndex = -1;
List<V> result = new ArrayList<>();
for (int i = 0; i < myList.size(); i++) {
if (i == mySelectedIndex) newSelectionIndex = result.size();
V out = convertor.fun(myList.get(i));
if (out != null) result.add(out);
}
return new ListSelection<>(result, newSelectionIndex);
}
}
@@ -236,6 +236,7 @@
<applicationService serviceImplementation="com.intellij.diff.impl.DiffSettingsHolder"/>
<applicationService serviceImplementation="com.intellij.diff.tools.util.base.TextDiffSettingsHolder"/>
<applicationService serviceImplementation="com.intellij.diff.tools.external.ExternalDiffSettings"/>
<applicationService serviceImplementation="com.intellij.diff.vcs.DiffVcsFacade"/>
<applicationConfigurable groupId="tools" id="diff.base"
bundle="messages.DiffBundle"
key="configurable.DiffSettingsConfigurable.display.name"
@@ -95,6 +95,10 @@
<openapi.vcs.history.actions.ShowDiffAfterWithLocalAction.ExtensionProvider implementation="com.intellij.openapi.vcs.history.impl.VcsSelectionHistoryDialog$MyDiffAfterWithLocalAction"/>
<diff.actions.ShowDiffAction.ExtensionProvider implementation="com.intellij.openapi.vcs.history.impl.VcsSelectionHistoryDialog$MyDiffAction"/>
<applicationService serviceInterface="com.intellij.diff.vcs.DiffVcsFacade"
serviceImplementation="com.intellij.diff.DiffVcsFacadeImpl"
overrides="true"/>
<selectInTarget implementation="com.intellij.openapi.vcs.changes.SelectInChangesViewTarget"/>
<search.projectOptionsTopHitProvider implementation="com.intellij.openapi.vcs.configurable.VcsOptionsTopHitProvider"/>
@@ -16,6 +16,7 @@
package com.intellij.openapi;
import com.intellij.util.NullableFunction;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@@ -23,18 +24,16 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* @deprecated use @see com.intellij.util.ListSelection instead
*/
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2020.3")
public class ListSelection<T> {
@NotNull private final List<T> myList;
private final int mySelectedIndex;
@NotNull private final com.intellij.util.ListSelection<T> myInstance;
private ListSelection(@NotNull List<T> list, int selectedIndex) {
myList = list;
if (selectedIndex >= 0 && selectedIndex < list.size()) {
mySelectedIndex = selectedIndex;
}
else {
mySelectedIndex = 0;
}
myInstance = com.intellij.util.ListSelection.createAt(list, selectedIndex);
}
@NotNull
@@ -60,24 +59,24 @@ public class ListSelection<T> {
@NotNull
public List<T> getList() {
return myList;
return myInstance.getList();
}
public int getSelectedIndex() {
return mySelectedIndex;
return myInstance.getSelectedIndex();
}
public boolean isEmpty() {
return myList.isEmpty();
return myInstance.getList().isEmpty();
}
@NotNull
public <V> ListSelection<V> map(@NotNull NullableFunction<? super T, ? extends V> convertor) {
int newSelectionIndex = -1;
List<V> result = new ArrayList<>();
for (int i = 0; i < myList.size(); i++) {
if (i == mySelectedIndex) newSelectionIndex = result.size();
V out = convertor.fun(myList.get(i));
for (int i = 0; i < getList().size(); i++) {
if (i == getSelectedIndex()) newSelectionIndex = result.size();
V out = convertor.fun(getList().get(i));
if (out != null) result.add(out);
}
return new ListSelection<>(result, newSelectionIndex);
@@ -15,9 +15,11 @@
*/
package com.intellij.openapi.localVcs;
import com.intellij.openapi.LineNumberConstants;
public interface UpToDateLineNumberProvider {
int ABSENT_LINE_NUMBER = -1;
int FAKE_LINE_NUMBER = -2;
int ABSENT_LINE_NUMBER = LineNumberConstants.ABSENT_LINE_NUMBER;
int FAKE_LINE_NUMBER = LineNumberConstants.FAKE_LINE_NUMBER;
int getLineCount();
int getLineNumber(int currentNumber);
@@ -20,7 +20,6 @@ public class VcsApplicationSettings implements PersistentStateComponent<VcsAppli
public String PATCH_STORAGE_LOCATION = null;
public boolean SHOW_WHITESPACES_IN_LST = true;
public boolean SHOW_LST_GUTTER_MARKERS = true;
public boolean SHOW_LST_WORD_DIFFERENCES = true;
public boolean DETECT_PATCH_ON_THE_FLY = false;
public boolean ENABLE_PARTIAL_CHANGELISTS = true;
public boolean MANAGE_IGNORE_FILES = false;
@@ -2,7 +2,6 @@
package com.intellij.openapi.vcs;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vcs.changes.Change;
@@ -13,6 +12,7 @@ import com.intellij.openapi.vcs.history.VcsHistorySession;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
import com.intellij.util.ListSelection;
import com.intellij.vcs.commit.CommitWorkflowHandler;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NonNls;
@@ -1,21 +0,0 @@
// Copyright 2000-2019 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.
package com.intellij.vcsUtil
import java.awt.event.ComponentAdapter
import java.awt.event.ComponentEvent
import javax.swing.JComponent
object UIVcsUtilKt {
@JvmStatic
fun JComponent.installVisibilityReferent(referent: JComponent) {
referent.addComponentListener(object: ComponentAdapter() {
override fun componentHidden(e: ComponentEvent) = toggleVisibility(e)
override fun componentShown(e: ComponentEvent) = toggleVisibility(e)
private fun toggleVisibility(e: ComponentEvent) {
val component = e.component ?: return
isVisible = component.isVisible
}
})
}
}
@@ -120,11 +120,7 @@ configuration.tab.name.general.settings=General Settings
configuration.commit.message.margin.title=Commit message right margin
configuration.commit.message.margin.prompt=Commit message right margin (columns):
action.name.rollback=Rollback
command.name.rollback.change=Rollback Change
action.name.show.difference=Show Difference
dialog.title.diff.for.range=Diff for Range
diff.content.title.up.to.date=Base revision
diff.content.title.current.range=Current
settings.filter.update.project.info.by.scope=Filter Update Project information by scope
settings.partial.changelists.enable.checkbox=Track changed blocks in text files separately
settings.show.conflict.resolve.dialog.checkbox=Show &dialog on attempt to edit file from non-active changelist
@@ -746,8 +742,6 @@ todo.handler.only.both=<html><body>{0, choice, 1#One|2#{0}} added/edited TODO {0
paths.affected.in.revision=Paths Affected in Revision {0}
#Dir diff
refresh.failed.message=Refresh failed: {0}
executable.select.label=&Path to {0} executable:
executable.select.title=Select Executable
executable.select.description=Select executable file to be used for VCS operations
@@ -26,5 +26,6 @@
<orderEntry type="library" name="miglayout-swing" level="project" />
<orderEntry type="library" name="StreamEx" level="project" />
<orderEntry type="module" module-name="intellij.platform.statistics" />
<orderEntry type="module" module-name="intellij.platform.util" />
</component>
</module>
@@ -0,0 +1,12 @@
// Copyright 2000-2020 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.
package com.intellij.diff
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.Pair
import com.intellij.openapi.vcs.FilePath
import com.intellij.openapi.vcs.history.VcsRevisionNumber
object DiffVcsDataKeys {
@JvmField
val REVISION_INFO: Key<Pair<FilePath, VcsRevisionNumber>> = Key.create("Merge.RevisionInfo")
}
@@ -0,0 +1,17 @@
// Copyright 2000-2020 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.
package com.intellij.diff
import com.intellij.diff.vcs.DiffVcsFacade
import com.intellij.openapi.vcs.FilePath
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.vcsUtil.VcsUtil
class DiffVcsFacadeImpl : DiffVcsFacade() {
override fun getFilePath(path: String): FilePath {
return VcsUtil.getFilePath(path)
}
override fun getFilePath(virtualFile: VirtualFile): FilePath {
return VcsUtil.getFilePath(virtualFile)
}
}
@@ -18,7 +18,6 @@ import com.intellij.diff.tools.util.base.DiffViewerBase;
import com.intellij.diff.tools.util.base.DiffViewerListener;
import com.intellij.diff.tools.util.side.OnesideTextDiffViewer;
import com.intellij.diff.tools.util.side.TwosideTextDiffViewer;
import com.intellij.diff.util.DiffUserDataKeysEx;
import com.intellij.diff.util.Side;
import com.intellij.diff.util.ThreeSide;
import com.intellij.notification.Notification;
@@ -45,6 +44,7 @@ import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vcs.impl.BackgroundableActionLock;
import com.intellij.openapi.vcs.impl.UpToDateLineNumberProviderImpl;
import com.intellij.openapi.vcs.impl.VcsBackgroundableActions;
import com.intellij.diff.DiffVcsDataKeys;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.IdeFrame;
import com.intellij.ui.BalloonLayoutData;
@@ -236,7 +236,7 @@ public class AnnotateDiffViewerAction {
if (loader != null) return loader;
}
Pair<FilePath, VcsRevisionNumber> info = content.getUserData(DiffUserDataKeysEx.REVISION_INFO);
Pair<FilePath, VcsRevisionNumber> info = content.getUserData(DiffVcsDataKeys.REVISION_INFO);
if (info != null) {
FilePath filePath = info.first;
AbstractVcs vcs = VcsUtil.getVcsFor(project, filePath);
@@ -9,7 +9,6 @@ import com.intellij.diff.contents.DiffContent;
import com.intellij.diff.requests.DiffRequest;
import com.intellij.diff.requests.SimpleDiffRequest;
import com.intellij.diff.util.DiffUserDataKeys;
import com.intellij.diff.util.DiffUserDataKeysEx;
import com.intellij.diff.util.Side;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileDocumentManager;
@@ -32,6 +31,7 @@ import com.intellij.openapi.vcs.diff.DiffProvider;
import com.intellij.openapi.vcs.diff.ItemLatestState;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vcs.impl.VcsBackgroundableActions;
import com.intellij.diff.DiffVcsDataKeys;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.NotNull;
@@ -90,7 +90,7 @@ public abstract class DiffActionExecutor {
diffContent = contentFactory.create(myProject, content, fileRevision.getFile());
}
diffContent.putUserData(DiffUserDataKeysEx.REVISION_INFO, Pair.create(fileRevision.getFile(), fileRevision.getRevisionNumber()));
diffContent.putUserData(DiffVcsDataKeys.REVISION_INFO, Pair.create(fileRevision.getFile(), fileRevision.getRevisionNumber()));
return diffContent;
}
@@ -20,7 +20,6 @@ import com.intellij.diff.DiffManager;
import com.intellij.diff.chains.DiffRequestChain;
import com.intellij.diff.chains.DiffRequestProducerException;
import com.intellij.diff.util.DiffUserDataKeysEx;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
import com.intellij.openapi.actionSystem.IdeActions;
@@ -44,6 +43,7 @@ import com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain;
import com.intellij.openapi.vcs.changes.ui.ChangesComparator;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
import com.intellij.util.ListSelection;
import com.intellij.util.containers.CacheOneStepIterator;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -16,9 +16,9 @@
package com.intellij.openapi.vcs.changes;
import com.intellij.ide.impl.dataRules.GetDataRule;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.vcs.VcsDataKeys;
import com.intellij.util.ListSelection;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -2,7 +2,6 @@
package com.intellij.openapi.vcs.changes.actions;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.AnActionExtensionProvider;
@@ -19,6 +18,7 @@ import com.intellij.openapi.vcs.changes.ContentRevision;
import com.intellij.openapi.vcs.changes.CurrentContentRevision;
import com.intellij.openapi.vcs.changes.committed.CommittedChangesBrowserUseCase;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ListSelection;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.NotNull;
@@ -14,7 +14,6 @@ import com.intellij.diff.contents.DiffContent;
import com.intellij.diff.contents.DocumentContent;
import com.intellij.diff.contents.FileContent;
import com.intellij.diff.impl.DiffViewerWrapper;
import com.intellij.diff.merge.MergeUtil;
import com.intellij.diff.requests.ContentDiffRequest;
import com.intellij.diff.requests.DiffRequest;
import com.intellij.diff.requests.ErrorDiffRequest;
@@ -47,6 +46,8 @@ import com.intellij.openapi.vcs.changes.actions.diff.lst.LocalChangeListDiffRequ
import com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain;
import com.intellij.openapi.vcs.impl.LineStatusTrackerManager;
import com.intellij.openapi.vcs.merge.MergeData;
import com.intellij.diff.DiffVcsDataKeys;
import com.intellij.openapi.vcs.merge.MergeUtils;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ThreeState;
@@ -327,7 +328,7 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer, ChangeDif
contentFactory.createFromBytes(project, mergeData.LAST, file));
SimpleDiffRequest request = new SimpleDiffRequest(title, contents, titles);
MergeUtil.putRevisionInfos(request, mergeData);
MergeUtils.putRevisionInfos(request, mergeData);
return request;
}
@@ -441,7 +442,7 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer, ChangeDif
content = contentFactory.create(project, revisionContent, filePath);
}
content.putUserData(DiffUserDataKeysEx.REVISION_INFO, Pair.create(revision.getFile(), revision.getRevisionNumber()));
content.putUserData(DiffVcsDataKeys.REVISION_INFO, Pair.create(revision.getFile(), revision.getRevisionNumber()));
return content;
}
@@ -18,7 +18,6 @@ package com.intellij.openapi.vcs.changes.actions.diff;
import com.intellij.diff.DiffManager;
import com.intellij.diff.chains.DiffRequestChain;
import com.intellij.diff.util.DiffUserDataKeys;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.actionSystem.ActionPlaces;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.AnActionExtensionProvider;
@@ -29,6 +28,7 @@ import com.intellij.openapi.util.Key;
import com.intellij.openapi.vcs.VcsDataKeys;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain;
import com.intellij.util.ListSelection;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -7,7 +7,6 @@ import com.intellij.diff.chains.DiffRequestChain;
import com.intellij.diff.chains.DiffRequestProducerException;
import com.intellij.diff.util.DiffUserDataKeysEx;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.project.Project;
@@ -16,6 +15,7 @@ import com.intellij.openapi.vcs.changes.*;
import com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain;
import com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain.Producer;
import com.intellij.openapi.vcs.changes.ui.ChangesListView;
import com.intellij.util.ListSelection;
import com.intellij.util.concurrency.FutureResult;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -12,7 +12,6 @@ import com.intellij.diff.requests.SimpleDiffRequest;
import com.intellij.diff.requests.UnknownFileTypeDiffRequest;
import com.intellij.diff.tools.util.SoftHardCacheMap;
import com.intellij.diff.util.DiffUtil;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.AnActionExtensionProvider;
import com.intellij.openapi.actionSystem.CommonDataKeys;
@@ -41,6 +40,7 @@ import com.intellij.openapi.vcs.changes.patch.ApplyPatchForBaseRevisionTexts;
import com.intellij.openapi.vcs.changes.patch.tool.PatchDiffRequest;
import com.intellij.openapi.vcs.changes.ui.ChangeDiffRequestChain;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ListSelection;
import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.CalledInBackground;
import org.jetbrains.annotations.NotNull;
@@ -16,7 +16,6 @@ import com.intellij.ide.dnd.aware.DnDAwareTree;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationAction;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
@@ -52,6 +51,7 @@ import com.intellij.ui.content.impl.ContentImpl;
import com.intellij.util.Consumer;
import com.intellij.util.IconUtil;
import com.intellij.util.IconUtil.IconSizeWrapper;
import com.intellij.util.ListSelection;
import com.intellij.util.PathUtil;
import com.intellij.util.containers.UtilKt;
import com.intellij.util.text.DateFormatUtil;
@@ -3,7 +3,6 @@ package com.intellij.openapi.vcs.changes.ui;
import com.intellij.diff.actions.impl.GoToChangePopupBuilder;
import com.intellij.diff.chains.*;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
@@ -13,6 +12,7 @@ import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.changes.actions.diff.ChangeGoToChangePopupAction;
import com.intellij.util.Consumer;
import com.intellij.util.ListSelection;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
@@ -185,7 +185,7 @@ public class ChangeDiffRequestChain extends DiffRequestChainBase implements GoTo
public static abstract class Async extends AsyncDiffRequestChain implements GoToChangePopupBuilder.Chain {
@NotNull
@Override
protected abstract ListSelection<? extends ChangeDiffRequestChain.Producer> loadRequestProducers() throws DiffRequestProducerException;
protected abstract ListSelection<? extends Producer> loadRequestProducers() throws DiffRequestProducerException;
@Nullable
@Override
@@ -5,7 +5,6 @@ import com.intellij.diff.DiffDialogHints;
import com.intellij.diff.DiffManager;
import com.intellij.diff.chains.DiffRequestChain;
import com.intellij.diff.util.DiffUserDataKeys;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.ActionUtil;
import com.intellij.openapi.project.DumbAwareAction;
@@ -15,6 +14,7 @@ import com.intellij.openapi.vcs.changes.actions.diff.ChangeDiffRequestProducer;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.SideBorder;
import com.intellij.util.ListSelection;
import com.intellij.util.containers.ContainerUtil;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NotNull;
@@ -4,7 +4,6 @@ package com.intellij.openapi.vcs.changes.ui;
import com.intellij.diff.DiffDialogHints;
import com.intellij.ide.DeleteProvider;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.ActionUtil;
import com.intellij.openapi.actionSystem.ex.CheckboxAction;
@@ -23,6 +22,7 @@ import com.intellij.openapi.vcs.changes.actions.diff.ShowDiffAction;
import com.intellij.openapi.vcs.changes.actions.diff.ShowDiffContext;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.ListSelection;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -1,7 +1,6 @@
// Copyright 2000-2020 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.
package com.intellij.openapi.vcs.changes.ui;
import com.intellij.openapi.ListSelection;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FilePath;
@@ -9,6 +8,7 @@ import com.intellij.openapi.vcs.VcsDataKeys;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangesUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ListSelection;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -21,7 +21,6 @@ import com.intellij.diff.DiffRequestFactoryImpl;
import com.intellij.diff.contents.DiffContent;
import com.intellij.diff.requests.DiffRequest;
import com.intellij.diff.requests.SimpleDiffRequest;
import com.intellij.diff.util.DiffUserDataKeysEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
@@ -32,6 +31,7 @@ import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.diff.DiffVcsDataKeys;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.encoding.EncodingManager;
@@ -46,7 +46,7 @@ import static com.intellij.diff.DiffRequestFactoryImpl.DIFF_TITLE_RENAME_SEPARAT
public class VcsHistoryUtil {
@Deprecated
public static final Key<Pair<FilePath, VcsRevisionNumber>> REVISION_INFO_KEY = DiffUserDataKeysEx.REVISION_INFO;
public static final Key<Pair<FilePath, VcsRevisionNumber>> REVISION_INFO_KEY = DiffVcsDataKeys.REVISION_INFO;
private static final Logger LOG = Logger.getInstance(VcsHistoryUtil.class);
@@ -105,8 +105,8 @@ public class VcsHistoryUtil {
final DiffRequest request = new SimpleDiffRequest(title, diffContent1, diffContent2, title1, title2);
diffContent1.putUserData(DiffUserDataKeysEx.REVISION_INFO, getRevisionInfo(revision1));
diffContent2.putUserData(DiffUserDataKeysEx.REVISION_INFO, getRevisionInfo(revision2));
diffContent1.putUserData(DiffVcsDataKeys.REVISION_INFO, getRevisionInfo(revision1));
diffContent2.putUserData(DiffVcsDataKeys.REVISION_INFO, getRevisionInfo(revision2));
WaitForProgressToShow.runOrInvokeLaterAboveProgress(() -> DiffManager.getInstance().showDiff(project, request), null, project);
}
@@ -0,0 +1,46 @@
// Copyright 2000-2020 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.
package com.intellij.openapi.vcs.merge
import com.intellij.diff.DiffVcsDataKeys
import com.intellij.diff.contents.DiffContent
import com.intellij.diff.merge.MergeRequest
import com.intellij.diff.merge.ThreesideMergeRequest
import com.intellij.diff.requests.ContentDiffRequest
import com.intellij.diff.requests.DiffRequest
import com.intellij.diff.util.ThreeSide
import com.intellij.openapi.util.Pair
import com.intellij.openapi.vcs.FilePath
import com.intellij.openapi.vcs.history.VcsRevisionNumber
object MergeUtils {
@JvmStatic
fun putRevisionInfos(request: MergeRequest, data: MergeData) {
if (request is ThreesideMergeRequest) {
val contents = request.contents
putRevisionInfo(contents, data)
}
}
@JvmStatic
fun putRevisionInfos(request: DiffRequest, data: MergeData) {
if (request is ContentDiffRequest) {
val contents = request.contents
if (contents.size == 3) {
putRevisionInfo(contents, data)
}
}
}
private fun putRevisionInfo(contents: List<DiffContent>, data: MergeData) {
for (side in ThreeSide.values()) {
val content = side.select(contents)
val filePath: FilePath? = side.select(data.CURRENT_FILE_PATH, data.ORIGINAL_FILE_PATH, data.LAST_FILE_PATH)
val revision: VcsRevisionNumber? = side.select(data.CURRENT_REVISION_NUMBER, data.ORIGINAL_REVISION_NUMBER,
data.LAST_REVISION_NUMBER)
if (filePath != null && revision != null) {
content.putUserData(DiffVcsDataKeys.REVISION_INFO, Pair.create(filePath, revision))
}
}
}
}
@@ -38,7 +38,6 @@ import com.intellij.ui.DoubleClickListener
import com.intellij.ui.TableSpeedSearch
import com.intellij.ui.components.Label
import com.intellij.ui.layout.*
import com.intellij.ui.scale.JBUIScale
import com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns
import com.intellij.ui.treeStructure.treetable.TreeTable
import com.intellij.ui.treeStructure.treetable.TreeTableModel
@@ -428,7 +427,7 @@ open class MultipleFileMergeDialog(
request = requestFactory.createMergeRequest(project, file, byteContents, title, contentTitles, callback)
}
MergeUtil.putRevisionInfos(request, mergeData)
MergeUtils.putRevisionInfos(request, mergeData)
}
catch (e: InvalidDiffRequestException) {
if (e.cause is FileTooBigException) {
@@ -43,7 +43,6 @@ import com.intellij.vcs.log.util.BekUtil;
import com.intellij.vcs.log.util.VcsLogUiUtil;
import com.intellij.vcs.log.util.VcsLogUtil;
import com.intellij.vcs.log.visible.VisiblePack;
import com.intellij.vcsUtil.UIVcsUtilKt;
import net.miginfocom.swing.MigLayout;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -247,7 +246,7 @@ public class MainFrame extends JPanel implements DataProvider, Disposable {
leftCornerToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
JPanel panel = new JPanel(new MigLayout("ins 0, fill", "[]0[left]0[left, fill]push[right]", "center"));
UIVcsUtilKt.installVisibilityReferent(panel, toolbar.getComponent());
GuiUtils.installVisibilityReferent(panel, toolbar.getComponent());
panel.add(leftCornerToolbar.getComponent());
panel.add(textFilter);
panel.add(toolbar.getComponent());
@@ -21,6 +21,7 @@ import com.intellij.openapi.vcs.history.ShortVcsRevisionNumber;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.ComponentUtil;
import com.intellij.ui.GuiUtils;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.SideBorder;
import com.intellij.ui.components.panels.Wrapper;
@@ -44,7 +45,6 @@ import com.intellij.vcs.log.ui.VcsLogActionPlaces;
import com.intellij.vcs.log.util.StopWatch;
import com.intellij.vcs.log.util.VcsLogUiUtil;
import com.intellij.vcs.log.util.VcsLogUtil;
import com.intellij.vcsUtil.UIVcsUtilKt;
import com.intellij.vcsUtil.VcsFileUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.Nls;
@@ -104,7 +104,7 @@ public class VcsLogChangesBrowser extends ChangesBrowserBase implements Disposab
JComponent toolbarComponent = getToolbar().getComponent();
myToolbarWrapper = new Wrapper(toolbarComponent);
UIVcsUtilKt.installVisibilityReferent(myToolbarWrapper, toolbarComponent);
GuiUtils.installVisibilityReferent(myToolbarWrapper, toolbarComponent);
init();
@@ -19,6 +19,7 @@ import com.intellij.openapi.util.Key
import com.intellij.openapi.util.UserDataHolder
import com.intellij.openapi.vcs.impl.BackgroundableActionLock
import com.intellij.openapi.vcs.merge.MergeDialogCustomizer
import com.intellij.openapi.vcs.merge.MergeUtils
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.ui.EditorNotificationPanel
import com.intellij.ui.EditorNotifications
@@ -72,7 +73,7 @@ object MergeConflictResolveUtil {
request.putUserData(DiffUserDataKeysEx.EDITORS_TITLE_CUSTOMIZER,
listOf(leftTitleCustomizer, centerTitleCustomizer, rightTitleCustomizer))
}
MergeUtil.putRevisionInfos(request, mergeData)
MergeUtils.putRevisionInfos(request, mergeData)
MergeCallback.register(request, MyMergeCallback(resolver))
return request
}
@@ -7,7 +7,6 @@ import com.intellij.diff.contents.DiffContent;
import com.intellij.diff.contents.EmptyContent;
import com.intellij.diff.requests.DiffRequest;
import com.intellij.diff.requests.SimpleDiffRequest;
import com.intellij.diff.util.DiffUserDataKeysEx;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -23,6 +22,7 @@ import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ContentRevision;
import com.intellij.openapi.vcs.history.VcsDiffUtil;
import com.intellij.diff.DiffVcsDataKeys;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
@@ -230,7 +230,7 @@ public class GitLogDiffHandler implements VcsLogDiffHandler {
}
}
diffContent.putUserData(DiffUserDataKeysEx.REVISION_INFO, new Pair<>(path, revisionNumber));
diffContent.putUserData(DiffVcsDataKeys.REVISION_INFO, new Pair<>(path, revisionNumber));
return diffContent;
}