void (@NotNull AbstractTreeStructure treeStructure, @NotNull Runnable finish) { final SliceRootNode root = (SliceRootNode)treeStructure.getRootElement(); final Ref<SliceRootNode> newRootRef = Ref.create(null); final Map<SliceNode, NullAnalysisResult> map = createMap(); String encouragementPiece = " (may very well take the whole day)"; ProgressManager.getInstance().run(new Task.Backgroundable( root.getProject(), JavaRefactoringBundle.message("dataflow.to.here.expand.progress", encouragementPiece), true) { @Override public void run(final @NotNull ProgressIndicator indicator) { NullAnalysisResult leaves = calcNullableLeaves(root, treeStructure, map); SliceRootNode newRoot = ReadAction.compute(() -> createNewTree(leaves, root, map)); newRootRef.set(newRoot); } @Override public void onCancel() { finish.run(); } @Override public void onSuccess() { try { SliceRootNode newRoot = newRootRef.get(); if (newRoot == null) return; //cancelled groupByNullness(root, newRoot); } finally { finish.run(); } } }); }