use of com.intellij.diff.requests.TextMergeRequestImpl in project intellij-community by JetBrains.
the class DiffRequestFactoryImpl method createTextMergeRequest.
@NotNull
@Override
public TextMergeRequest createTextMergeRequest(@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();
final Document outputDocument = FileDocumentManager.getInstance().getDocument(output);
if (outputDocument == null)
throw new InvalidDiffRequestException("Can't get output document: " + output.getPresentableUrl());
if (!DiffUtil.canMakeWritable(outputDocument))
throw new InvalidDiffRequestException("Output is read only: " + output.getPresentableUrl());
DocumentContent outputContent = myContentFactory.create(project, outputDocument);
CharSequence originalContent = outputDocument.getImmutableCharSequence();
List<DocumentContent> contents = new ArrayList<>(3);
for (byte[] bytes : byteContents) {
contents.add(myContentFactory.createDocumentFromBytes(project, bytes, output));
}
return new TextMergeRequestImpl(project, outputContent, originalContent, contents, title, contentTitles, applyCallback);
}
use of com.intellij.diff.requests.TextMergeRequestImpl in project intellij-community by JetBrains.
the class DiffRequestFactoryImpl method createMergeRequest.
//
// Merge
//
@NotNull
@Override
public MergeRequest createMergeRequest(@Nullable Project project, @Nullable FileType fileType, @NotNull Document outputDocument, @NotNull List<String> textContents, @Nullable String title, @NotNull List<String> titles, @Nullable Consumer<MergeResult> applyCallback) throws InvalidDiffRequestException {
if (textContents.size() != 3)
throw new IllegalArgumentException();
if (titles.size() != 3)
throw new IllegalArgumentException();
if (!DiffUtil.canMakeWritable(outputDocument))
throw new InvalidDiffRequestException("Output is read only");
DocumentContent outputContent = myContentFactory.create(project, outputDocument, fileType);
CharSequence originalContent = outputDocument.getImmutableCharSequence();
List<DocumentContent> contents = new ArrayList<>(3);
for (String text : textContents) {
contents.add(myContentFactory.create(project, text, fileType));
}
return new TextMergeRequestImpl(project, outputContent, originalContent, contents, title, titles, applyCallback);
}
Aggregations