use of com.intellij.diff.requests.ContentDiffRequest in project intellij-community by JetBrains.
the class AnnotateDiffViewerAction method createTwosideAnnotationsLoader.
@Nullable
private static FileAnnotationLoader createTwosideAnnotationsLoader(@NotNull Project project, @NotNull DiffRequest request, @NotNull Side side) {
Change change = request.getUserData(ChangeDiffRequestProducer.CHANGE_KEY);
if (change != null) {
ContentRevision revision = side.select(change.getBeforeRevision(), change.getAfterRevision());
if (revision != null) {
AbstractVcs vcs = ChangesUtil.getVcsForChange(change, project);
if (revision instanceof CurrentContentRevision) {
VirtualFile file = ((CurrentContentRevision) revision).getVirtualFile();
FileAnnotationLoader loader = doCreateAnnotationsLoader(project, vcs, file);
if (loader != null)
return loader;
} else {
FileAnnotationLoader loader = doCreateAnnotationsLoader(vcs, revision.getFile(), revision.getRevisionNumber());
if (loader != null)
return loader;
}
}
}
if (request instanceof ContentDiffRequest) {
ContentDiffRequest requestEx = (ContentDiffRequest) request;
if (requestEx.getContents().size() == 2) {
DiffContent content = side.select(requestEx.getContents());
return createAnnotationsLoader(project, content);
}
}
return null;
}
use of com.intellij.diff.requests.ContentDiffRequest in project intellij-community by JetBrains.
the class CompareClipboardWithSelectionAction method getEditorFileType.
@Nullable
private static FileType getEditorFileType(@NotNull AnActionEvent e) {
DiffContent content = e.getData(DiffDataKeys.CURRENT_CONTENT);
if (content != null && content.getContentType() != null)
return content.getContentType();
DiffRequest request = e.getData(DiffDataKeys.DIFF_REQUEST);
if (request instanceof ContentDiffRequest) {
for (DiffContent diffContent : ((ContentDiffRequest) request).getContents()) {
FileType type = diffContent.getContentType();
if (type != null && type != UnknownFileType.INSTANCE)
return type;
}
}
return null;
}
use of com.intellij.diff.requests.ContentDiffRequest in project intellij-community by JetBrains.
the class CompareFileWithEditorAction method getDiffRequest.
@Nullable
@Override
protected DiffRequest getDiffRequest(@NotNull AnActionEvent e) {
Project project = e.getProject();
VirtualFile selectedFile = getSelectedFile(e);
VirtualFile currentFile = getEditingFile(e);
assert selectedFile != null && currentFile != null;
ContentDiffRequest request = DiffRequestFactory.getInstance().createFromFiles(project, selectedFile, currentFile);
DiffContent editorContent = request.getContents().get(1);
if (editorContent instanceof DocumentContent) {
Editor[] editors = EditorFactory.getInstance().getEditors(((DocumentContent) editorContent).getDocument());
if (editors.length != 0) {
request.putUserData(DiffUserDataKeys.SCROLL_TO_LINE, Pair.create(Side.RIGHT, editors[0].getCaretModel().getLogicalPosition().line));
}
}
return request;
}
use of com.intellij.diff.requests.ContentDiffRequest in project intellij-community by JetBrains.
the class TwosideDiffViewer 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;
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.requests.ContentDiffRequest in project intellij-community by JetBrains.
the class AnnotateDiffViewerAction method createThreesideAnnotationsLoader.
@Nullable
private static FileAnnotationLoader createThreesideAnnotationsLoader(@NotNull Project project, @NotNull DiffRequest request, @NotNull ThreeSide side) {
if (request instanceof ContentDiffRequest) {
ContentDiffRequest requestEx = (ContentDiffRequest) request;
if (requestEx.getContents().size() == 3) {
DiffContent content = side.select(requestEx.getContents());
FileAnnotationLoader loader = createAnnotationsLoader(project, content);
if (loader != null)
return loader;
}
}
return null;
}
Aggregations