mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs] Don't create FilePath object when not needed
Use the given VirtualFile, or just String fileName.
This commit is contained in:
+5
-5
@@ -224,7 +224,7 @@ public class ChangeDiffRequestPresentable implements DiffRequestPresentable {
|
||||
final FileType type = rev.getFile().getFileType();
|
||||
if (! type.isBinary()) return true;
|
||||
if (FileTypes.UNKNOWN.equals(type)) {
|
||||
final boolean associatedToText = checkAssociate(myProject, rev.getFile(), context);
|
||||
final boolean associatedToText = checkAssociate(myProject, rev.getFile().getName(), context);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -255,17 +255,17 @@ public class ChangeDiffRequestPresentable implements DiffRequestPresentable {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean checkAssociate(final Project project, final FilePath file, DiffChainContext context) {
|
||||
final String pattern = FileUtilRt.getExtension(file.getName()).toLowerCase();
|
||||
public static boolean checkAssociate(final Project project, String fileName, DiffChainContext context) {
|
||||
final String pattern = FileUtilRt.getExtension(fileName).toLowerCase();
|
||||
if (context.contains(pattern)) return false;
|
||||
int rc = Messages.showOkCancelDialog(project,
|
||||
VcsBundle.message("diff.unknown.file.type.prompt", file.getName()),
|
||||
VcsBundle.message("diff.unknown.file.type.prompt", fileName),
|
||||
VcsBundle.message("diff.unknown.file.type.title"),
|
||||
VcsBundle.message("diff.unknown.file.type.associate"),
|
||||
CommonBundle.getCancelButtonText(),
|
||||
Messages.getQuestionIcon());
|
||||
if (rc == Messages.OK) {
|
||||
FileType fileType = FileTypeChooser.associateFileType(file.getName());
|
||||
FileType fileType = FileTypeChooser.associateFileType(fileName);
|
||||
return fileType != null && !fileType.isBinary();
|
||||
} else {
|
||||
context.add(pattern);
|
||||
|
||||
+2
-4
@@ -24,7 +24,6 @@ import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.FilePathImpl;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ChangesUtil;
|
||||
@@ -59,9 +58,8 @@ public class ConflictedDiffRequestPresentable implements DiffRequestPresentable
|
||||
public MyResult step(DiffChainContext context) {
|
||||
if (myChange.getAfterRevision() == null) return createErrorResult();
|
||||
FileType type = myChange.getVirtualFile() != null ? myChange.getVirtualFile().getFileType() : null;
|
||||
FilePathImpl filePath = new FilePathImpl(myFile);
|
||||
if (filePath.getFileType().isBinary()) {
|
||||
final boolean nowItIsText = ChangeDiffRequestPresentable.checkAssociate(myProject, filePath, context);
|
||||
if (myFile.getFileType().isBinary()) {
|
||||
final boolean nowItIsText = ChangeDiffRequestPresentable.checkAssociate(myProject, myFile.getName(), context);
|
||||
if (! nowItIsText) {
|
||||
return createErrorResult();
|
||||
}
|
||||
|
||||
+3
-5
@@ -22,7 +22,6 @@ import com.intellij.openapi.diff.SimpleDiffRequest;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Getter;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.FilePathImpl;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.changes.actions.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -44,9 +43,8 @@ public class MergedDiffRequestPresentable implements DiffRequestPresentable {
|
||||
}
|
||||
|
||||
public MyResult step(DiffChainContext context) {
|
||||
FilePathImpl filePath = new FilePathImpl(myFile);
|
||||
if (filePath.getFileType().isBinary()) {
|
||||
final boolean nowItIsText = ChangeDiffRequestPresentable.checkAssociate(myProject, filePath, context);
|
||||
if (myFile.getFileType().isBinary()) {
|
||||
final boolean nowItIsText = ChangeDiffRequestPresentable.checkAssociate(myProject, myFile.getName(), context);
|
||||
if (! nowItIsText) {
|
||||
final SimpleDiffRequest request = new SimpleDiffRequest(myProject, null);
|
||||
return new MyResult(request, DiffPresentationReturnValue.removeFromList);
|
||||
@@ -61,7 +59,7 @@ public class MergedDiffRequestPresentable implements DiffRequestPresentable {
|
||||
.create3WayDiffRequest(revisionTexts.getLocal().toString(),
|
||||
revisionTexts.getPatched(),
|
||||
revisionTexts.getBase().toString(),
|
||||
filePath.getFileType(), myProject, null, null);
|
||||
myFile.getFileType(), myProject, null, null);
|
||||
request.setWindowTitle(VcsBundle.message("patch.apply.conflict.title", FileUtil.toSystemDependentName(myFile.getPresentableUrl())));
|
||||
request.setVersionTitles(new String[] {"Current Version", "Base Version", FileUtil.toSystemDependentName(myAfterTitle)});
|
||||
return new MyResult(request, DiffPresentationReturnValue.useRequest);
|
||||
|
||||
Reference in New Issue
Block a user