void (PsiElement @NotNull [] pattern, @NotNull ElementsRange patternReplacement, @NotNull Document refactoredDocument, @NotNull MethodNode methodNode, @NotNull TextRange methodRange, @NotNull List<? extends Duplicate> duplicateReplacements, @NotNull List<? extends Duplicate> excludedDuplicates) { PsiFile patternFile = pattern[0].getContainingFile(); myPatternDocument = FileDocumentManager.getInstance().getDocument(patternFile.getViewProvider().getVirtualFile()); if (myPatternDocument == null) { return; } myInitialDocumentStamp = myPatternDocument.getModificationStamp(); List<Range> diffRanges = new ArrayList<>(); Map<FragmentNode, Couple<TextRange>> linesBounds = new HashMap<>(); collectDiffRanges(refactoredDocument, diffRanges, linesBounds, duplicateReplacements); collectDiffRanges(refactoredDocument, diffRanges, linesBounds, excludedDuplicates); PsiElement anchorElement = myAnchor.getElement(); if (anchorElement != null) { int anchorLineNumber = getLineNumberAfter(myPatternDocument, anchorElement.getTextRange()); int anchorOffset = myPatternDocument.getLineStartOffset(anchorLineNumber); Range diffRange = new Range(anchorLineNumber, anchorLineNumber, getStartLineNumber(refactoredDocument, methodRange), getLineNumberAfter(refactoredDocument, methodRange)); diffRanges.add(diffRange); linesBounds.put(methodNode, Couple.of(new TextRange(anchorOffset, anchorOffset), getLinesRange(methodRange, refactoredDocument))); } TextRange patternRange = new ElementsRange(pattern).getTextRange(); TextRange replacementRange = patternReplacement.getTextRange(); Range diffRange = getDiffRange(patternRange, myPatternDocument, replacementRange, refactoredDocument); if (diffRange != null) { diffRanges.add(diffRange); linesBounds.put(myTree.getModel().getPatternNode(), Couple.of(getLinesRange(patternRange, myPatternDocument), getLinesRange(replacementRange, refactoredDocument))); } diffRanges.sort(Comparator.comparing(r -> r.start1)); DiffContentFactory contentFactory = DiffContentFactory.getInstance(); DocumentContent oldContent = contentFactory.create(myProject, myPatternDocument); DocumentContent newContent = contentFactory.create(myProject, refactoredDocument.getText(), patternFile.getFileType(), false); myDiffRequest = new PreviewDiffRequest(linesBounds, oldContent, newContent, node -> myTree.selectNode(node)); myDiffRequest.putUserData(DiffUserDataKeysEx.CUSTOM_DIFF_COMPUTER, getDiffComputer(diffRanges)); myDiffPanel.setRequest(myDiffRequest); myDiffRequest.onInitialized(); }