void () { Block b = myCalculator.getSelectionFor(myLeftRevision, new Progress() { @Override public void processed(int percentage) { // should be already processed. } }); Document d = myGateway.getDocument(myRightEntry.getPath()); int from = d.getLineStartOffset(myFromLine); int to = d.getLineEndOffset(myToLine); d.replaceString(from, to, b.getBlockContent()); }