mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
diff: expose DiffRequestFactoryImpl methods via its interface
GitOrigin-RevId: 451f79c7436dbe722069d1e8c12e512091f7a7bc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
79a8154cf9
commit
bca5ef6d62
@@ -97,8 +97,13 @@ a:com.intellij.diff.DiffRequestFactory
|
||||
- a:createTextMergeRequestFromFiles(com.intellij.openapi.project.Project,com.intellij.openapi.vfs.VirtualFile,java.util.List,java.lang.String,java.util.List,com.intellij.util.Consumer):com.intellij.diff.merge.TextMergeRequest
|
||||
- a:getContentTitle(com.intellij.openapi.vfs.VirtualFile):java.lang.String
|
||||
- s:getInstance():com.intellij.diff.DiffRequestFactory
|
||||
- a:getTitle(com.intellij.openapi.vcs.FilePath):java.lang.String
|
||||
- a:getTitle(com.intellij.openapi.vfs.VirtualFile):java.lang.String
|
||||
- a:getTitle(com.intellij.openapi.vfs.VirtualFile,com.intellij.openapi.vfs.VirtualFile):java.lang.String
|
||||
- getTitle(com.intellij.openapi.vfs.VirtualFile,com.intellij.openapi.vfs.VirtualFile):java.lang.String
|
||||
- a:getTitleForComparison(com.intellij.openapi.vcs.FilePath,com.intellij.openapi.vcs.FilePath):java.lang.String
|
||||
- a:getTitleForComparison(com.intellij.openapi.vfs.VirtualFile,com.intellij.openapi.vfs.VirtualFile):java.lang.String
|
||||
- a:getTitleForModification(com.intellij.openapi.vcs.FilePath,com.intellij.openapi.vcs.FilePath):java.lang.String
|
||||
- a:getTitleForModification(com.intellij.openapi.vfs.VirtualFile,com.intellij.openapi.vfs.VirtualFile):java.lang.String
|
||||
com.intellij.diff.DiffRequestPanel
|
||||
- com.intellij.openapi.Disposable
|
||||
- a:getComponent():javax.swing.JComponent
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Consumer;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
@@ -48,6 +49,9 @@ public abstract class DiffRequestFactory {
|
||||
// Titles
|
||||
//
|
||||
|
||||
/**
|
||||
* See also the prettier {@link com.intellij.openapi.vcs.history.DiffTitleFilePathCustomizer}
|
||||
*/
|
||||
@NlsContexts.Label
|
||||
@Nullable
|
||||
@Contract("null->null; !null->!null")
|
||||
@@ -55,11 +59,49 @@ public abstract class DiffRequestFactory {
|
||||
|
||||
@NlsContexts.DialogTitle
|
||||
@NotNull
|
||||
public abstract String getTitle(@Nullable VirtualFile file1, @Nullable VirtualFile file2);
|
||||
public abstract String getTitle(@NotNull VirtualFile file);
|
||||
|
||||
/**
|
||||
* @deprecated Prefer using {@link #getTitleForComparison} or {@link #getTitleForModification} explicitly.
|
||||
*/
|
||||
@NlsContexts.DialogTitle
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public String getTitle(@Nullable VirtualFile file1, @Nullable VirtualFile file2) {
|
||||
return getTitleForComparison(file1, file2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Title for 'file1 vs file2' diffs. Ex: "compare two selected files".
|
||||
*/
|
||||
@NlsContexts.DialogTitle
|
||||
@NotNull
|
||||
public abstract String getTitleForComparison(@Nullable VirtualFile file1, @Nullable VirtualFile file2);
|
||||
|
||||
/**
|
||||
* Title for 'file1 was changed into file2' diffs. Ex: "show file change in a commit".
|
||||
*/
|
||||
@NlsContexts.DialogTitle
|
||||
@NotNull
|
||||
public abstract String getTitleForModification(@Nullable VirtualFile file1, @Nullable VirtualFile file2);
|
||||
|
||||
@NlsContexts.DialogTitle
|
||||
@NotNull
|
||||
public abstract String getTitle(@NotNull VirtualFile file);
|
||||
public abstract String getTitle(@NotNull FilePath path);
|
||||
|
||||
/**
|
||||
* Title for 'path1 vs path2' diffs. Ex: "compare two selected files".
|
||||
*/
|
||||
@NlsContexts.DialogTitle
|
||||
@NotNull
|
||||
public abstract String getTitleForComparison(@Nullable FilePath path1, @Nullable FilePath path2);
|
||||
|
||||
/**
|
||||
* Title for 'path1 was changed into path2' diffs. Ex: "show file history for commit".
|
||||
*/
|
||||
@NlsContexts.DialogTitle
|
||||
@NotNull
|
||||
public abstract String getTitleForModification(@Nullable FilePath path1, @Nullable FilePath path2);
|
||||
|
||||
//
|
||||
// Merge
|
||||
|
||||
@@ -2746,6 +2746,7 @@ f:com.intellij.diff.util.DiffUtil
|
||||
- s:addActionBlock(com.intellij.openapi.actionSystem.DefaultActionGroup,java.util.List,Z):V
|
||||
- s:addActionBlock(com.intellij.openapi.actionSystem.DefaultActionGroup,com.intellij.openapi.actionSystem.AnAction[]):V
|
||||
- s:addNotification(com.intellij.diff.util.DiffNotificationProvider,com.intellij.openapi.util.UserDataHolder):V
|
||||
- s:addTitleCustomizers(com.intellij.diff.merge.MergeRequest,java.util.List):com.intellij.diff.merge.MergeRequest
|
||||
- s:addTitleCustomizers(com.intellij.diff.requests.DiffRequest,java.util.List):com.intellij.diff.requests.DiffRequest
|
||||
- s:applyModification(com.intellij.openapi.editor.Document,I,I,com.intellij.openapi.editor.Document,I,I):V
|
||||
- s:applyModification(com.intellij.openapi.editor.Document,I,I,java.util.List):V
|
||||
|
||||
@@ -22,10 +22,7 @@ import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.LocalFilePath;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Consumer;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -60,7 +57,7 @@ public class DiffRequestFactoryImpl extends DiffRequestFactory {
|
||||
String title1 = getContentTitle(file1);
|
||||
String title2 = getContentTitle(file2);
|
||||
|
||||
String title = getTitle(file1, file2);
|
||||
String title = getTitleForComparison(file1, file2);
|
||||
|
||||
return new SimpleDiffRequest(title, content1, content2, title1, title2);
|
||||
}
|
||||
@@ -104,21 +101,23 @@ public class DiffRequestFactoryImpl extends DiffRequestFactory {
|
||||
@Override
|
||||
public String getContentTitle(@Nullable VirtualFile file) {
|
||||
if (file == null) return null;
|
||||
return getContentTitle(new LocalFilePath(file.getPath(), file.isDirectory()));
|
||||
return getContentTitle(toFilePath(file));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getTitle(@Nullable VirtualFile file1, @Nullable VirtualFile file2) {
|
||||
FilePath path1 = file1 != null ? new LocalFilePath(file1.getPath(), file1.isDirectory()) : null;
|
||||
FilePath path2 = file2 != null ? new LocalFilePath(file2.getPath(), file2.isDirectory()) : null;
|
||||
return getTitle(path1, path2, DIFF_TITLE_SEPARATOR);
|
||||
public @NotNull String getTitleForModification(@Nullable VirtualFile file1, @Nullable VirtualFile file2) {
|
||||
return getTitleForModification(toFilePath(file1), toFilePath(file2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitleForComparison(@Nullable VirtualFile file1, @Nullable VirtualFile file2) {
|
||||
return getTitleForComparison(toFilePath(file1), toFilePath(file2));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getTitle(@NotNull VirtualFile file) {
|
||||
return getTitle(file, null);
|
||||
return getTitleForComparison(file, null);
|
||||
}
|
||||
|
||||
@Nls
|
||||
@@ -129,10 +128,27 @@ public class DiffRequestFactoryImpl extends DiffRequestFactory {
|
||||
return getContentTitle(path.getName(), path.getPresentableUrl(), parent != null ? parent.getPresentableUrl() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitle(@NotNull FilePath path) {
|
||||
return getTitleForComparison(path, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitleForComparison(@Nullable FilePath path1, @Nullable FilePath path2) {
|
||||
return getTitle(path1, path2, DIFF_TITLE_SEPARATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getTitleForModification(@Nullable FilePath path1, @Nullable FilePath path2) {
|
||||
return getTitle(path1, path2, DIFF_TITLE_RENAME_SEPARATOR);
|
||||
}
|
||||
|
||||
@Nls
|
||||
@NotNull
|
||||
public static String getTitle(@Nullable FilePath path1, @Nullable FilePath path2, @NotNull @Nls String separator) {
|
||||
assert path1 != null || path2 != null;
|
||||
if (path1 == null && path2 == null) {
|
||||
return DiffBundle.message("diff.files.dialog.title");
|
||||
}
|
||||
|
||||
if (path1 == null || path2 == null) {
|
||||
return getContentTitle(chooseNotNull(path1, path2));
|
||||
@@ -453,4 +469,10 @@ public class DiffRequestFactoryImpl extends DiffRequestFactory {
|
||||
throw new InvalidDiffRequestException("Can't read from file", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Contract("!null -> !null; null -> null")
|
||||
private static @Nullable LocalFilePath toFilePath(@Nullable VirtualFile file) {
|
||||
if (file == null) return null;
|
||||
return new LocalFilePath(file.getPath(), file.isDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public abstract class BaseShowDiffAction extends DumbAwareAction {
|
||||
chain.setWindowTitle(requestFactory.getTitle(baseFile));
|
||||
}
|
||||
else {
|
||||
chain.setWindowTitle(requestFactory.getTitle(file1, file2));
|
||||
chain.setWindowTitle(requestFactory.getTitleForComparison(file1, file2));
|
||||
}
|
||||
return chain;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class CompareClipboardWithSelectionAction extends BaseShowDiffAction {
|
||||
|
||||
VirtualFile editorFile = FileDocumentManager.getInstance().getFile(editor.getDocument());
|
||||
String editorContentTitle = editorFile != null
|
||||
? DiffRequestFactory.getInstance().getContentTitle(editorFile)
|
||||
? DiffRequestFactory.getInstance().getTitle(editorFile)
|
||||
: DiffBundle.message("diff.content.editor.content.title");
|
||||
if (editor.getSelectionModel().hasSelection()) {
|
||||
editorContentTitle = DiffBundle.message("diff.content.selection.from.file.content.title", editorContentTitle);
|
||||
|
||||
@@ -88,7 +88,7 @@ private class MyDiffRequestProducer(private val project: Project?, private val f
|
||||
DiffRequestFactory.getInstance().getTitle(base)
|
||||
}
|
||||
else {
|
||||
DiffRequestFactory.getInstance().getTitle(files[0], files[1])
|
||||
DiffRequestFactory.getInstance().getTitleForComparison(files[0], files[1])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -428,7 +428,7 @@ public class DirDiffTableModel extends AbstractTableModel implements DirDiffMode
|
||||
myTarget instanceof VirtualFileDiffElement) {
|
||||
VirtualFile srcFile = ((VirtualFileDiffElement)mySource).getValue();
|
||||
VirtualFile trgFile = ((VirtualFileDiffElement)myTarget).getValue();
|
||||
return DiffRequestFactory.getInstance().getTitle(srcFile, trgFile);
|
||||
return DiffRequestFactory.getInstance().getTitleForComparison(srcFile, trgFile);
|
||||
}
|
||||
return IdeBundle.message("diff.dialog.title", mySource.getPresentablePath(), myTarget.getPresentablePath());
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static com.intellij.diff.DiffRequestFactoryImpl.DIFF_TITLE_RENAME_SEPARATOR;
|
||||
import static com.intellij.util.ObjectUtils.tryCast;
|
||||
import static com.intellij.vcsUtil.VcsUtil.getShortRevisionString;
|
||||
|
||||
@@ -379,7 +378,7 @@ public final class ChangeDiffRequestProducer implements DiffRequestProducer, Cha
|
||||
public static @NotNull @Nls String getRequestTitle(@NotNull Change change) {
|
||||
FilePath bPath = ChangesUtil.getBeforePath(change);
|
||||
FilePath aPath = ChangesUtil.getAfterPath(change);
|
||||
return DiffRequestFactoryImpl.getTitle(bPath, aPath, DIFF_TITLE_RENAME_SEPARATOR);
|
||||
return DiffRequestFactory.getInstance().getTitleForModification(bPath, aPath);
|
||||
}
|
||||
|
||||
public static @NotNull @Nls String getRevisionTitle(@Nullable ContentRevision revision, @NotNull @Nls String defaultValue) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.intellij.openapi.vcs.history;
|
||||
|
||||
import com.intellij.diff.DiffContentFactoryEx;
|
||||
import com.intellij.diff.DiffManager;
|
||||
import com.intellij.diff.DiffRequestFactoryImpl;
|
||||
import com.intellij.diff.DiffRequestFactory;
|
||||
import com.intellij.diff.DiffVcsDataKeys;
|
||||
import com.intellij.diff.contents.DiffContent;
|
||||
import com.intellij.diff.requests.DiffRequest;
|
||||
@@ -28,8 +28,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.intellij.diff.DiffRequestFactoryImpl.DIFF_TITLE_RENAME_SEPARATOR;
|
||||
|
||||
public final class VcsHistoryUtil {
|
||||
private static final Logger LOG = Logger.getInstance(VcsHistoryUtil.class);
|
||||
|
||||
@@ -74,13 +72,7 @@ public final class VcsHistoryUtil {
|
||||
FilePath path1 = getRevisionPath(revision1);
|
||||
FilePath path2 = getRevisionPath(revision2);
|
||||
|
||||
String title;
|
||||
if (path1 != null && path2 != null) {
|
||||
title = DiffRequestFactoryImpl.getTitle(path1, path2, DIFF_TITLE_RENAME_SEPARATOR);
|
||||
}
|
||||
else {
|
||||
title = DiffRequestFactoryImpl.getContentTitle(path);
|
||||
}
|
||||
String title = path1 != null || path2 != null ? DiffRequestFactory.getInstance().getTitleForModification(path1, path2) : null;
|
||||
|
||||
DiffContent diffContent1 = loadContentForDiff(project, path, revision1);
|
||||
DiffContent diffContent2 = loadContentForDiff(project, path, revision2);
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.intellij.openapi.vcs.update;
|
||||
import com.intellij.diff.DiffContentFactoryEx;
|
||||
import com.intellij.diff.DiffDialogHints;
|
||||
import com.intellij.diff.DiffManager;
|
||||
import com.intellij.diff.DiffRequestFactoryImpl;
|
||||
import com.intellij.diff.DiffRequestFactory;
|
||||
import com.intellij.diff.chains.DiffRequestChain;
|
||||
import com.intellij.diff.chains.DiffRequestProducer;
|
||||
import com.intellij.diff.chains.DiffRequestProducerException;
|
||||
@@ -174,7 +174,7 @@ public class ShowUpdatedDiffActionProvider implements AnActionExtensionProvider
|
||||
content2 = contentFactory.createFromBytes(myProject, bytes2, myFilePath);
|
||||
}
|
||||
|
||||
String title = DiffRequestFactoryImpl.getContentTitle(myFilePath);
|
||||
String title = DiffRequestFactory.getInstance().getTitle(myFilePath);
|
||||
return new SimpleDiffRequest(title,
|
||||
content1,
|
||||
content2,
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
package git4idea.diff
|
||||
|
||||
import com.intellij.diff.DiffContentFactory
|
||||
import com.intellij.diff.DiffRequestFactoryImpl
|
||||
import com.intellij.diff.DiffRequestFactoryImpl.DIFF_TITLE_RENAME_SEPARATOR
|
||||
import com.intellij.diff.DiffRequestFactory
|
||||
import com.intellij.diff.chains.DiffRequestProducerException
|
||||
import com.intellij.diff.requests.DiffRequest
|
||||
import com.intellij.diff.requests.SimpleDiffRequest
|
||||
@@ -51,7 +50,7 @@ class GitSubmoduleDiffRequestProvider : ChangeDiffRequestProvider {
|
||||
val factory = DiffContentFactory.getInstance()
|
||||
val beforeContent = beforeRevision?.content?.let { factory.create(it) } ?: factory.createEmpty()
|
||||
val afterContent = afterRevision?.content?.let { factory.create(it) } ?: factory.createEmpty()
|
||||
val title = DiffRequestFactoryImpl.getTitle(beforeRevision?.file, afterRevision?.file, DIFF_TITLE_RENAME_SEPARATOR)
|
||||
val title = DiffRequestFactory.getInstance().getTitleForModification(beforeRevision?.file, afterRevision?.file)
|
||||
return SimpleDiffRequest(GitBundle.message("label.diff.content.title.submodule.suffix", title),
|
||||
beforeContent,
|
||||
afterContent,
|
||||
|
||||
@@ -3,7 +3,7 @@ package git4idea.index
|
||||
|
||||
import com.intellij.diff.DiffContentFactory
|
||||
import com.intellij.diff.DiffContentFactoryEx
|
||||
import com.intellij.diff.DiffRequestFactoryImpl
|
||||
import com.intellij.diff.DiffRequestFactory
|
||||
import com.intellij.diff.DiffVcsDataKeys
|
||||
import com.intellij.diff.chains.DiffRequestProducerException
|
||||
import com.intellij.diff.contents.DiffContent
|
||||
@@ -49,7 +49,6 @@ import git4idea.repo.GitRepositoryManager
|
||||
import git4idea.util.GitFileUtils
|
||||
import org.jetbrains.annotations.Nls
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
|
||||
fun createTwoSidesDiffRequestProducer(project: Project,
|
||||
statusNode: GitFileStatusNode,
|
||||
@@ -417,11 +416,10 @@ private fun GitFileStatusNode.has(contentVersion: ContentVersion): Boolean = sta
|
||||
|
||||
@Nls
|
||||
private fun getTitle(status: GitFileStatus, kind: NodeKind): String {
|
||||
return DiffRequestFactoryImpl.getTitle(status.path, kind.origPath(status),
|
||||
DiffRequestFactoryImpl.DIFF_TITLE_RENAME_SEPARATOR)
|
||||
return DiffRequestFactory.getInstance().getTitleForModification(status.path, kind.origPath(status))
|
||||
}
|
||||
|
||||
@Nls
|
||||
private fun getTitle(status: GitFileStatus): String {
|
||||
return DiffRequestFactoryImpl.getTitle(status.path, status.origPath, DiffRequestFactoryImpl.DIFF_TITLE_RENAME_SEPARATOR)
|
||||
return DiffRequestFactory.getInstance().getTitleForModification(status.path, status.origPath)
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package git4idea.log;
|
||||
|
||||
import com.intellij.diff.DiffContentFactoryEx;
|
||||
import com.intellij.diff.DiffDialogHints;
|
||||
import com.intellij.diff.DiffManager;
|
||||
import com.intellij.diff.DiffVcsDataKeys;
|
||||
import com.intellij.diff.*;
|
||||
import com.intellij.diff.chains.DiffRequestProducer;
|
||||
import com.intellij.diff.chains.SimpleDiffRequestChain;
|
||||
import com.intellij.diff.chains.SimpleDiffRequestProducer;
|
||||
@@ -39,8 +36,6 @@ import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import static com.intellij.diff.DiffRequestFactoryImpl.DIFF_TITLE_RENAME_SEPARATOR;
|
||||
import static com.intellij.diff.DiffRequestFactoryImpl.getTitle;
|
||||
import static com.intellij.util.ObjectUtils.chooseNotNull;
|
||||
|
||||
public class GitLogDiffHandler implements VcsLogDiffHandler {
|
||||
@@ -70,7 +65,7 @@ public class GitLogDiffHandler implements VcsLogDiffHandler {
|
||||
DiffContent leftDiffContent = createDiffContent(root, leftPath, leftHash);
|
||||
DiffContent rightDiffContent = createDiffContent(root, rightPath, rightHash);
|
||||
|
||||
return new SimpleDiffRequest(getTitle(leftPath, rightPath, DIFF_TITLE_RENAME_SEPARATOR),
|
||||
return new SimpleDiffRequest(DiffRequestFactory.getInstance().getTitleForModification(leftPath, rightPath),
|
||||
leftDiffContent, rightDiffContent,
|
||||
leftHash.asString(), rightHash.asString());
|
||||
});
|
||||
@@ -89,7 +84,7 @@ public class GitLogDiffHandler implements VcsLogDiffHandler {
|
||||
DiffRequestProducer requestProducer = SimpleDiffRequestProducer.create(localPath, () -> {
|
||||
DiffContent leftDiffContent = createDiffContent(root, revisionPath, revisionHash);
|
||||
DiffContent rightDiffContent = createCurrentDiffContent(localPath);
|
||||
return new SimpleDiffRequest(getTitle(revisionPath, localPath, DIFF_TITLE_RENAME_SEPARATOR),
|
||||
return new SimpleDiffRequest(DiffRequestFactory.getInstance().getTitleForModification(revisionPath, localPath),
|
||||
leftDiffContent, rightDiffContent,
|
||||
revisionHash.asString(),
|
||||
GitBundle.message("git.log.diff.handler.local.version.content.title"));
|
||||
|
||||
Reference in New Issue
Block a user