use of com.intellij.diff.requests.BinaryMergeRequestImpl in project intellij-community by JetBrains.
the class DiffRequestFactoryImpl method createBinaryMergeRequest.
@NotNull
@Override
public MergeRequest createBinaryMergeRequest(@Nullable Project project, @NotNull VirtualFile output, @NotNull List<byte[]> byteContents, @Nullable String title, @NotNull List<String> contentTitles, @Nullable Consumer<MergeResult> applyCallback) throws InvalidDiffRequestException {
if (byteContents.size() != 3)
throw new IllegalArgumentException();
if (contentTitles.size() != 3)
throw new IllegalArgumentException();
try {
FileContent outputContent = myContentFactory.createFile(project, output);
if (outputContent == null)
throw new InvalidDiffRequestException("Can't process file: " + output);
byte[] originalContent = output.contentsToByteArray();
List<DiffContent> contents = new ArrayList<>(3);
for (byte[] bytes : byteContents) {
contents.add(myContentFactory.createFromBytes(project, bytes, output));
}
return new BinaryMergeRequestImpl(project, outputContent, originalContent, contents, byteContents, title, contentTitles, applyCallback);
} catch (IOException e) {
throw new InvalidDiffRequestException("Can't read from file", e);
}
}
use of com.intellij.diff.requests.BinaryMergeRequestImpl in project intellij-community by JetBrains.
the class DiffRequestFactoryImpl method createBinaryMergeRequestFromFiles.
@NotNull
public MergeRequest createBinaryMergeRequestFromFiles(@Nullable Project project, @NotNull VirtualFile output, @NotNull List<VirtualFile> fileContents, @Nullable String title, @NotNull List<String> contentTitles, @Nullable Consumer<MergeResult> applyCallback) throws InvalidDiffRequestException {
if (fileContents.size() != 3)
throw new IllegalArgumentException();
if (contentTitles.size() != 3)
throw new IllegalArgumentException();
try {
FileContent outputContent = myContentFactory.createFile(project, output);
if (outputContent == null)
throw new InvalidDiffRequestException("Can't process file: " + output.getPresentableUrl());
byte[] originalContent = output.contentsToByteArray();
List<DiffContent> contents = new ArrayList<>(3);
List<byte[]> byteContents = new ArrayList<>(3);
for (VirtualFile file : fileContents) {
FileContent content = myContentFactory.createFile(project, file);
if (content == null)
throw new InvalidDiffRequestException("Can't process file: " + file.getPresentableUrl());
contents.add(content);
// TODO: we can read contents from file when needed
byteContents.add(file.contentsToByteArray());
}
return new BinaryMergeRequestImpl(project, outputContent, originalContent, contents, byteContents, title, contentTitles, applyCallback);
} catch (IOException e) {
throw new InvalidDiffRequestException("Can't read from file", e);
}
}
Aggregations