Search in sources :

Example 1 with DiffHyperlink

use of com.intellij.execution.testframework.stacktrace.DiffHyperlink 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 DiffHyperlink

use of com.intellij.execution.testframework.stacktrace.DiffHyperlink in project intellij-community by JetBrains.

the class ViewAssertEqualsDiffAction method collectAvailableProviders.

private static List<DiffHyperlink> collectAvailableProviders(TestFrameworkRunningModel model) {
    final List<DiffHyperlink> providers = new ArrayList<>();
    if (model != null) {
        final AbstractTestProxy root = model.getRoot();
        final List<? extends AbstractTestProxy> allTests = root.getAllTests();
        for (AbstractTestProxy test : allTests) {
            if (test.isLeaf()) {
                providers.addAll(test.getDiffViewerProviders());
            }
        }
    }
    return providers;
}
Also used : DiffHyperlink(com.intellij.execution.testframework.stacktrace.DiffHyperlink) ArrayList(java.util.ArrayList) AbstractTestProxy(com.intellij.execution.testframework.AbstractTestProxy)

Example 3 with DiffHyperlink

use of com.intellij.execution.testframework.stacktrace.DiffHyperlink in project intellij-community by JetBrains.

the class ViewAssertEqualsDiffAction method openDiff.

public static boolean openDiff(DataContext context, @Nullable DiffHyperlink currentHyperlink) {
    final AbstractTestProxy testProxy = AbstractTestProxy.DATA_KEY.getData(context);
    final Project project = CommonDataKeys.PROJECT.getData(context);
    if (testProxy != null) {
        DiffHyperlink diffViewerProvider = testProxy.getDiffViewerProvider();
        if (diffViewerProvider != null) {
            final List<DiffHyperlink> providers = collectAvailableProviders(TestTreeView.MODEL_DATA_KEY.getData(context));
            int index = currentHyperlink != null ? providers.indexOf(currentHyperlink) : -1;
            if (index == -1)
                index = providers.indexOf(diffViewerProvider);
            new MyDiffWindow(project, providers, Math.max(0, index)).show();
            return true;
        }
    }
    if (currentHyperlink != null) {
        new MyDiffWindow(project, currentHyperlink).show();
        return true;
    }
    return false;
}
Also used : Project(com.intellij.openapi.project.Project) DiffHyperlink(com.intellij.execution.testframework.stacktrace.DiffHyperlink) AbstractTestProxy(com.intellij.execution.testframework.AbstractTestProxy)

Aggregations

DiffHyperlink (com.intellij.execution.testframework.stacktrace.DiffHyperlink)3 AbstractTestProxy (com.intellij.execution.testframework.AbstractTestProxy)2 DiffContent (com.intellij.diff.contents.DiffContent)1 ErrorDiffRequest (com.intellij.diff.requests.ErrorDiffRequest)1 SimpleDiffRequest (com.intellij.diff.requests.SimpleDiffRequest)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1