Search in sources :

Example 1 with DiffNavigationContext

use of com.intellij.openapi.diff.DiffNavigationContext in project intellij-community by JetBrains.

the class MigrateToNewDiffUtil method convertRequestFair.

@Nullable
private static DiffRequest convertRequestFair(@NotNull com.intellij.openapi.diff.DiffRequest oldRequest) {
    if (oldRequest.getOnOkRunnable() != null)
        return null;
    //if (oldRequest.getBottomComponent() != null) return null; // TODO: we need EDT to make this check. Let's ignore bottom component.
    // TODO: migrate layers
    com.intellij.openapi.diff.DiffContent[] contents = oldRequest.getContents();
    String[] titles = oldRequest.getContentTitles();
    List<DiffContent> newContents = new ArrayList<>(contents.length);
    for (int i = 0; i < contents.length; i++) {
        DiffContent convertedContent = convertContent(oldRequest.getProject(), contents[i]);
        if (convertedContent == null)
            return null;
        newContents.add(convertedContent);
    }
    SimpleDiffRequest newRequest = new SimpleDiffRequest(oldRequest.getWindowTitle(), newContents, Arrays.asList(titles));
    DiffNavigationContext navigationContext = (DiffNavigationContext) oldRequest.getGenericData().get(DiffTool.SCROLL_TO_LINE.getName());
    if (navigationContext != null) {
        newRequest.putUserData(DiffUserDataKeysEx.NAVIGATION_CONTEXT, navigationContext);
    }
    return newRequest;
}
Also used : SimpleDiffRequest(com.intellij.diff.requests.SimpleDiffRequest) ArrayList(java.util.ArrayList) DiffNavigationContext(com.intellij.openapi.diff.DiffNavigationContext) DiffContent(com.intellij.diff.contents.DiffContent) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

DiffContent (com.intellij.diff.contents.DiffContent)1 SimpleDiffRequest (com.intellij.diff.requests.SimpleDiffRequest)1 DiffNavigationContext (com.intellij.openapi.diff.DiffNavigationContext)1 ArrayList (java.util.ArrayList)1 Nullable (org.jetbrains.annotations.Nullable)1