Search in sources :

Example 21 with DiffContent

use of com.intellij.diff.contents.DiffContent in project intellij-community by JetBrains.

the class DiffActionExecutor method createRemote.

@Nullable
protected DiffContent createRemote(final VcsRevisionNumber revisionNumber) throws IOException, VcsException {
    final ContentRevision fileRevision = myDiffProvider.createFileContent(revisionNumber, mySelectedFile);
    if (fileRevision == null)
        return null;
    DiffContentFactoryEx contentFactory = DiffContentFactoryEx.getInstanceEx();
    DiffContent diffContent;
    if (fileRevision instanceof BinaryContentRevision) {
        FilePath filePath = fileRevision.getFile();
        final byte[] content = ((BinaryContentRevision) fileRevision).getBinaryContent();
        if (content == null)
            return null;
        diffContent = contentFactory.createBinary(myProject, content, filePath.getFileType(), filePath.getName());
    } else if (fileRevision instanceof ByteBackedContentRevision) {
        byte[] content = ((ByteBackedContentRevision) fileRevision).getContentAsBytes();
        if (content == null)
            throw new VcsException("Failed to load content");
        diffContent = contentFactory.createFromBytes(myProject, content, fileRevision.getFile());
    } else {
        String content = fileRevision.getContent();
        if (content == null)
            throw new VcsException("Failed to load content");
        diffContent = contentFactory.create(myProject, content, fileRevision.getFile());
    }
    diffContent.putUserData(DiffUserDataKeysEx.REVISION_INFO, Pair.create(fileRevision.getFile(), fileRevision.getRevisionNumber()));
    return diffContent;
}
Also used : BinaryContentRevision(com.intellij.openapi.vcs.changes.BinaryContentRevision) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) ByteBackedContentRevision(com.intellij.openapi.vcs.changes.ByteBackedContentRevision) BinaryContentRevision(com.intellij.openapi.vcs.changes.BinaryContentRevision) DiffContentFactoryEx(com.intellij.diff.DiffContentFactoryEx) DiffContent(com.intellij.diff.contents.DiffContent) ByteBackedContentRevision(com.intellij.openapi.vcs.changes.ByteBackedContentRevision) Nullable(org.jetbrains.annotations.Nullable)

Example 22 with DiffContent

use of com.intellij.diff.contents.DiffContent 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;
}
Also used : ContentDiffRequest(com.intellij.diff.requests.ContentDiffRequest) DiffContent(com.intellij.diff.contents.DiffContent) Nullable(org.jetbrains.annotations.Nullable)

Example 23 with DiffContent

use of com.intellij.diff.contents.DiffContent in project intellij-community by JetBrains.

the class SmartTextDiffProvider method create.

@Nullable
public static TwosideTextDiffProvider create(@Nullable Project project, @NotNull ContentDiffRequest request, @NotNull TextDiffSettings settings, @NotNull Runnable rediff, @NotNull Disposable disposable) {
    DiffContent content1 = Side.LEFT.select(request.getContents());
    DiffContent content2 = Side.RIGHT.select(request.getContents());
    DiffIgnoredRangeProvider ignoredRangeProvider = getIgnoredRangeProvider(project, content1, content2);
    if (ignoredRangeProvider == null)
        return null;
    return new SmartTextDiffProvider(project, content1, content2, settings, rediff, disposable, ignoredRangeProvider);
}
Also used : DiffIgnoredRangeProvider(com.intellij.diff.lang.DiffIgnoredRangeProvider) DiffContent(com.intellij.diff.contents.DiffContent) Nullable(org.jetbrains.annotations.Nullable)

Example 24 with DiffContent

use of com.intellij.diff.contents.DiffContent in project intellij-community by JetBrains.

the class SmartTextDiffProvider method createNoIgnore.

@Nullable
public static TwosideTextDiffProvider.NoIgnore createNoIgnore(@Nullable Project project, @NotNull ContentDiffRequest request, @NotNull TextDiffSettings settings, @NotNull Runnable rediff, @NotNull Disposable disposable) {
    DiffContent content1 = Side.LEFT.select(request.getContents());
    DiffContent content2 = Side.RIGHT.select(request.getContents());
    DiffIgnoredRangeProvider ignoredRangeProvider = getIgnoredRangeProvider(project, content1, content2);
    if (ignoredRangeProvider == null)
        return null;
    return new SmartTextDiffProvider.NoIgnore(project, content1, content2, settings, rediff, disposable, ignoredRangeProvider);
}
Also used : DiffIgnoredRangeProvider(com.intellij.diff.lang.DiffIgnoredRangeProvider) DiffContent(com.intellij.diff.contents.DiffContent) Nullable(org.jetbrains.annotations.Nullable)

Example 25 with DiffContent

use of com.intellij.diff.contents.DiffContent in project intellij-community by JetBrains.

the class ExternalMergeTool method canShow.

public static boolean canShow(@NotNull MergeRequest request) {
    if (request instanceof ThreesideMergeRequest) {
        DiffContent outputContent = ((ThreesideMergeRequest) request).getOutputContent();
        if (!canProcessOutputContent(outputContent))
            return false;
        List<? extends DiffContent> contents = ((ThreesideMergeRequest) request).getContents();
        if (contents.size() != 3)
            return false;
        for (DiffContent content : contents) {
            if (!ExternalDiffToolUtil.canCreateFile(content))
                return false;
        }
        return true;
    }
    return false;
}
Also used : ThreesideMergeRequest(com.intellij.diff.merge.ThreesideMergeRequest) DiffContent(com.intellij.diff.contents.DiffContent)

Aggregations

DiffContent (com.intellij.diff.contents.DiffContent)37 SimpleDiffRequest (com.intellij.diff.requests.SimpleDiffRequest)14 NotNull (org.jetbrains.annotations.NotNull)12 Nullable (org.jetbrains.annotations.Nullable)10 ContentDiffRequest (com.intellij.diff.requests.ContentDiffRequest)7 ArrayList (java.util.ArrayList)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 IOException (java.io.IOException)6 DiffRequest (com.intellij.diff.requests.DiffRequest)5 DocumentContent (com.intellij.diff.contents.DocumentContent)3 FileContent (com.intellij.diff.contents.FileContent)3 Project (com.intellij.openapi.project.Project)3 FilePath (com.intellij.openapi.vcs.FilePath)3 DiffIgnoredRangeProvider (com.intellij.diff.lang.DiffIgnoredRangeProvider)2 BinaryMergeRequestImpl (com.intellij.diff.requests.BinaryMergeRequestImpl)2 NullRevisionsProgress (com.intellij.history.integration.ui.models.NullRevisionsProgress)2 Editor (com.intellij.openapi.editor.Editor)2 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)2 Ref (com.intellij.openapi.util.Ref)2 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)2