use of com.intellij.diff.contents.DiffContent in project intellij-community by JetBrains.
the class OnesideDiffViewer method canShowRequest.
public static <T extends EditorHolder> boolean canShowRequest(@NotNull DiffContext context, @NotNull DiffRequest request, @NotNull EditorHolderFactory<T> factory) {
if (!(request instanceof ContentDiffRequest))
return false;
List<DiffContent> contents = ((ContentDiffRequest) request).getContents();
if (contents.size() != 2)
return false;
DiffContent content1 = contents.get(0);
DiffContent content2 = contents.get(1);
if (content1 instanceof EmptyContent) {
return factory.canShowContent(content2, context) && factory.wantShowContent(content2, context);
}
if (content2 instanceof EmptyContent) {
return factory.canShowContent(content1, context) && factory.wantShowContent(content1, context);
}
return false;
}
use of com.intellij.diff.contents.DiffContent in project intellij-community by JetBrains.
the class ThreesideDiffViewer method canShowRequest.
public static <T extends EditorHolder> boolean canShowRequest(@NotNull DiffContext context, @NotNull DiffRequest request, @NotNull EditorHolderFactory<T> factory) {
if (!(request instanceof ContentDiffRequest))
return false;
List<DiffContent> contents = ((ContentDiffRequest) request).getContents();
if (contents.size() != 3)
return false;
boolean canShow = true;
boolean wantShow = false;
for (DiffContent content : contents) {
canShow &= factory.canShowContent(content, context);
wantShow |= factory.wantShowContent(content, context);
}
return canShow && wantShow;
}
use of com.intellij.diff.contents.DiffContent in project intellij-community by JetBrains.
the class ThreesideDiffViewer method createEditorHolders.
@NotNull
protected List<T> createEditorHolders(@NotNull EditorHolderFactory<T> factory) {
List<DiffContent> contents = myRequest.getContents();
List<T> holders = new ArrayList<>(3);
for (int i = 0; i < 3; i++) {
DiffContent content = contents.get(i);
holders.add(factory.create(content, myContext));
}
return holders;
}
use of com.intellij.diff.contents.DiffContent in project intellij-community by JetBrains.
the class TextDiffViewerUtil method checkDifferentDocuments.
public static void checkDifferentDocuments(@NotNull ContentDiffRequest request) {
// Actually, this should be a valid case. But it has little practical sense and will require explicit checks everywhere.
// Some listeners will be processed once instead of 2 times, some listeners will cause illegal document modifications.
List<DiffContent> contents = request.getContents();
boolean sameDocuments = false;
for (int i = 0; i < contents.size(); i++) {
for (int j = i + 1; j < contents.size(); j++) {
DiffContent content1 = contents.get(i);
DiffContent content2 = contents.get(j);
if (!(content1 instanceof DocumentContent))
continue;
if (!(content2 instanceof DocumentContent))
continue;
sameDocuments |= ((DocumentContent) content1).getDocument() == ((DocumentContent) content2).getDocument();
}
}
if (sameDocuments) {
StringBuilder message = new StringBuilder();
message.append("DiffRequest with same documents detected\n");
message.append(request.toString()).append("\n");
for (DiffContent content : contents) {
message.append(content.toString()).append("\n");
}
LOG.warn(new Throwable(message.toString()));
}
}
use of com.intellij.diff.contents.DiffContent in project intellij-community by JetBrains.
the class MergeUtil method putRevisionInfo.
private static void putRevisionInfo(@NotNull List<? extends DiffContent> contents, @NotNull MergeData data) {
for (ThreeSide side : ThreeSide.values()) {
DiffContent content = side.select(contents);
FilePath filePath = side.select(data.CURRENT_FILE_PATH, data.ORIGINAL_FILE_PATH, data.LAST_FILE_PATH);
VcsRevisionNumber revision = side.select(data.CURRENT_REVISION_NUMBER, data.ORIGINAL_REVISION_NUMBER, data.LAST_REVISION_NUMBER);
if (filePath != null && revision != null) {
content.putUserData(DiffUserDataKeysEx.REVISION_INFO, Pair.create(filePath, revision));
}
}
}
Aggregations