Search in sources :

Example 1 with ErrorDiffRequest

use of com.intellij.diff.requests.ErrorDiffRequest in project intellij-community by JetBrains.

the class TestDiffRequestProcessor method loadRequest.

@NotNull
private DiffRequest loadRequest() {
    if (myIndex < 0 || myIndex >= myRequests.size())
        return NoDiffRequest.INSTANCE;
    DiffHyperlink hyperlink = myRequests.get(myIndex);
    try {
        String windowTitle = hyperlink.getDiffTitle();
        String text1 = hyperlink.getLeft();
        String text2 = hyperlink.getRight();
        VirtualFile file1 = findFile(hyperlink.getFilePath());
        VirtualFile file2 = findFile(hyperlink.getActualFilePath());
        DiffContent content1 = createContentWithTitle(getProject(), text1, file1, file2);
        DiffContent content2 = createContentWithTitle(getProject(), text2, file2, file1);
        String title1 = getContentTitle("diff.content.expected.title", file1);
        String title2 = getContentTitle("diff.content.actual.title", file2);
        return new SimpleDiffRequest(windowTitle, content1, content2, title1, title2);
    } catch (Exception e) {
        return new ErrorDiffRequest(e);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SimpleDiffRequest(com.intellij.diff.requests.SimpleDiffRequest) ErrorDiffRequest(com.intellij.diff.requests.ErrorDiffRequest) DiffHyperlink(com.intellij.execution.testframework.stacktrace.DiffHyperlink) DiffContent(com.intellij.diff.contents.DiffContent) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ErrorDiffRequest

use of com.intellij.diff.requests.ErrorDiffRequest in project intellij-community by JetBrains.

the class ChangeDiffRequestProducer method loadCurrentContents.

@NotNull
protected DiffRequest loadCurrentContents(@NotNull UserDataHolder context, @NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
    DiffRequestProducerException wrapperException = null;
    DiffRequestProducerException requestException = null;
    DiffViewerWrapper wrapper = null;
    try {
        for (ChangeDiffViewerWrapperProvider provider : ChangeDiffViewerWrapperProvider.EP_NAME.getExtensions()) {
            if (provider.canCreate(myProject, myChange)) {
                wrapper = provider.process(this, context, indicator);
                break;
            }
        }
    } catch (DiffRequestProducerException e) {
        wrapperException = e;
    }
    DiffRequest request = null;
    try {
        for (ChangeDiffRequestProvider provider : ChangeDiffRequestProvider.EP_NAME.getExtensions()) {
            if (provider.canCreate(myProject, myChange)) {
                request = provider.process(this, context, indicator);
                break;
            }
        }
        if (request == null)
            request = createRequest(myProject, myChange, context, indicator);
    } catch (DiffRequestProducerException e) {
        requestException = e;
    }
    if (requestException != null && wrapperException != null) {
        String message = requestException.getMessage() + "\n\n" + wrapperException.getMessage();
        throw new DiffRequestProducerException(message);
    }
    if (requestException != null) {
        request = new ErrorDiffRequest(getRequestTitle(myChange), requestException);
        LOG.info("Request: " + requestException.getMessage());
    }
    if (wrapperException != null) {
        LOG.info("Wrapper: " + wrapperException.getMessage());
    }
    request.putUserData(CHANGE_KEY, myChange);
    request.putUserData(DiffViewerWrapper.KEY, wrapper);
    for (Map.Entry<Key, Object> entry : myChangeContext.entrySet()) {
        request.putUserData(entry.getKey(), entry.getValue());
    }
    DiffUtil.putDataKey(request, VcsDataKeys.CURRENT_CHANGE, myChange);
    return request;
}
Also used : DiffRequestProducerException(com.intellij.diff.chains.DiffRequestProducerException) ErrorDiffRequest(com.intellij.diff.requests.ErrorDiffRequest) DiffViewerWrapper(com.intellij.diff.impl.DiffViewerWrapper) ErrorDiffRequest(com.intellij.diff.requests.ErrorDiffRequest) DiffRequest(com.intellij.diff.requests.DiffRequest) SimpleDiffRequest(com.intellij.diff.requests.SimpleDiffRequest) Map(java.util.Map) Key(com.intellij.openapi.util.Key) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ErrorDiffRequest (com.intellij.diff.requests.ErrorDiffRequest)2 SimpleDiffRequest (com.intellij.diff.requests.SimpleDiffRequest)2 NotNull (org.jetbrains.annotations.NotNull)2 DiffRequestProducerException (com.intellij.diff.chains.DiffRequestProducerException)1 DiffContent (com.intellij.diff.contents.DiffContent)1 DiffViewerWrapper (com.intellij.diff.impl.DiffViewerWrapper)1 DiffRequest (com.intellij.diff.requests.DiffRequest)1 DiffHyperlink (com.intellij.execution.testframework.stacktrace.DiffHyperlink)1 Key (com.intellij.openapi.util.Key)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Map (java.util.Map)1