mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
diff: "Jump to Source" - do not open temporary binary files
This commit is contained in:
@@ -251,7 +251,7 @@ public class DiffContentFactoryImpl extends DiffContentFactoryEx {
|
||||
@NotNull byte[] content,
|
||||
@NotNull FilePath filePath) throws IOException {
|
||||
if (filePath.getFileType().isBinary()) {
|
||||
return createBinary(project, content, filePath.getFileType(), filePath.getName());
|
||||
return createBinaryImpl(project, content, filePath.getFileType(), filePath.getName(), filePath.getVirtualFile());
|
||||
}
|
||||
|
||||
return createDocumentFromBytes(project, content, filePath);
|
||||
@@ -264,7 +264,7 @@ public class DiffContentFactoryImpl extends DiffContentFactoryEx {
|
||||
@NotNull VirtualFile highlightFile) throws IOException {
|
||||
// TODO: check if FileType.UNKNOWN is actually a text ?
|
||||
if (highlightFile.getFileType().isBinary()) {
|
||||
return createBinary(project, content, highlightFile.getFileType(), highlightFile.getName());
|
||||
return createBinaryImpl(project, content, highlightFile.getFileType(), highlightFile.getName(), highlightFile);
|
||||
}
|
||||
|
||||
return createDocumentFromBytes(project, content, highlightFile);
|
||||
@@ -290,6 +290,15 @@ public class DiffContentFactoryImpl extends DiffContentFactoryEx {
|
||||
@NotNull byte[] content,
|
||||
@NotNull FileType type,
|
||||
@NotNull String fileName) throws IOException {
|
||||
return createBinaryImpl(project, content, type, fileName, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private DiffContent createBinaryImpl(@Nullable Project project,
|
||||
@NotNull byte[] content,
|
||||
@NotNull FileType type,
|
||||
@NotNull String fileName,
|
||||
@Nullable VirtualFile highlightFile) throws IOException {
|
||||
// workaround - our JarFileSystem and decompilers can't process non-local files
|
||||
boolean useTemporalFile = type instanceof ArchiveFileType || BinaryFileTypeDecompilers.INSTANCE.forFileType(type) != null;
|
||||
|
||||
@@ -302,7 +311,7 @@ public class DiffContentFactoryImpl extends DiffContentFactoryEx {
|
||||
file.setWritable(false);
|
||||
}
|
||||
|
||||
return create(project, file);
|
||||
return new FileContentImpl(project, file, highlightFile);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -32,19 +32,34 @@ public class FileContentImpl extends DiffContentBase implements FileContent {
|
||||
@NotNull private final VirtualFile myFile;
|
||||
@Nullable private final Project myProject;
|
||||
@NotNull private final FileType myType;
|
||||
@Nullable private final VirtualFile myHighlightFile;
|
||||
|
||||
public FileContentImpl(@Nullable Project project, @NotNull VirtualFile file) {
|
||||
this(project, file, getHighlightFile(file));
|
||||
}
|
||||
|
||||
public FileContentImpl(@Nullable Project project,
|
||||
@NotNull VirtualFile file,
|
||||
@Nullable VirtualFile highlightFile) {
|
||||
assert file.isValid() && !file.isDirectory();
|
||||
myProject = project;
|
||||
myFile = file;
|
||||
myProject = project;
|
||||
myType = file.getFileType();
|
||||
myHighlightFile = highlightFile;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Navigatable getNavigatable() {
|
||||
if (myProject == null || myProject.isDefault() || !myFile.isValid()) return null;
|
||||
return new OpenFileDescriptor(myProject, myFile);
|
||||
if (myProject == null || myProject.isDefault()) return null;
|
||||
if (myHighlightFile == null || !myHighlightFile.isValid()) return null;
|
||||
return new OpenFileDescriptor(myProject, myHighlightFile);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static VirtualFile getHighlightFile(@NotNull VirtualFile file) {
|
||||
if (file.isInLocalFileSystem()) return file;
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+4
-4
@@ -226,9 +226,9 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer {
|
||||
|
||||
@NotNull
|
||||
private DiffRequest createRequest(@Nullable Project project,
|
||||
@NotNull Change change,
|
||||
@NotNull UserDataHolder context,
|
||||
@NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
|
||||
@NotNull Change change,
|
||||
@NotNull UserDataHolder context,
|
||||
@NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
|
||||
if (ChangesUtil.isTextConflictingChange(change)) { // three side diff
|
||||
// FIXME: This part is ugly as a VCS merge subsystem itself.
|
||||
|
||||
@@ -388,7 +388,7 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer {
|
||||
if (content == null) {
|
||||
throw new DiffRequestProducerException("Can't get binary revision content");
|
||||
}
|
||||
return contentFactory.createBinary(project, content, filePath.getFileType(), filePath.getName());
|
||||
return contentFactory.createFromBytes(project, content, filePath);
|
||||
}
|
||||
|
||||
if (revision instanceof ByteBackedContentRevision) {
|
||||
|
||||
Reference in New Issue
Block a user