Source:
public ProposalApplyResult apply(int index, boolean insert) { IDocument document = viewer.getDocument(); final List<Change> changes = new ArrayList<>(); document.addDocumentListener(new IDocumentListener() { @Override public void documentAboutToBeChanged(DocumentEvent event) { } @Override public void documentChanged(DocumentEvent event) { Change dto = DtoFactory.newDto(Change.class); dto.setLength(event.getLength()); dto.setOffset(event.getOffset()); dto.setText(event.getText()); changes.add(dto); } }); try { char trigger = (char)0; int stateMask = insert ? 0 : SWT.CTRL; ICompletionProposal p = proposals.get(index); ProposalApplyResult result = DtoFactory.newDto(ProposalApplyResult.class); if (p instanceof ChangeCorrectionProposal) { result.setChangeInfo(prepareChangeInfo((ChangeCorrectionProposal)p)); } if (p instanceof ICompletionProposalExtension2) { ICompletionProposalExtension2 e = (ICompletionProposalExtension2)p; e.apply(viewer, trigger, stateMask, offset); } else if (p instanceof ICompletionProposalExtension) { ICompletionProposalExtension e = (ICompletionProposalExtension)p; e.apply(document, trigger, offset); } else { p.apply(document); } result.setChanges(changes); Point selection = p.getSelection(document); if (selection != null) { Region region = DtoFactory.newDto(Region.class); region.setOffset(selection.x); region.setLength(selection.y); result.setSelection(region); } if (p instanceof HasLinkedModel) { result.setLinkedModeModel(((HasLinkedModel)p).getLinkedModel()); } return result; } catch (IndexOutOfBoundsException | CoreException e) { throw new IllegalArgumentException("Can't find completion: " + index); } }

Target:
public ProposalApplyResult apply(int index, boolean insert) { IDocument document = viewer.getDocument(); final List<Change> changes = new ArrayList<>(); document.addDocumentListener(new IDocumentListener() { @Override public void documentAboutToBeChanged(DocumentEvent event) { } @Override public void documentChanged(DocumentEvent event) { changes.add(DtoFactory.newDto(Change.class) .withLength(event.getLength()) .withOffset(event.getOffset()) .withText(event.getText())); } }); try { char trigger = (char)0; int stateMask = insert ? 0 : SWT.CTRL; ICompletionProposal completionProposal = proposals.get(index); ProposalApplyResult result = DtoFactory.newDto(ProposalApplyResult.class); if (completionProposal instanceof ChangeCorrectionProposal) { result.setChangeInfo(prepareChangeInfo((ChangeCorrectionProposal)completionProposal)); } if (completionProposal instanceof ICompletionProposalExtension2) { ICompletionProposalExtension2 completionProposalExtension2 = (ICompletionProposalExtension2)completionProposal; completionProposalExtension2.apply(viewer, trigger, stateMask, offset); } else if (completionProposal instanceof ICompletionProposalExtension) { ICompletionProposalExtension completionProposalExtension = (ICompletionProposalExtension)completionProposal; completionProposalExtension.apply(document, trigger, offset); } else { completionProposal.apply(document); } result.setChanges(changes); Point selection = completionProposal.getSelection(document); if (selection != null) { result.setSelection(DtoFactory.newDto(Region.class).withOffset(selection.x).withLength(selection.y)); } if (completionProposal instanceof HasLinkedModel) { result.setLinkedModeModel(((HasLinkedModel)completionProposal).getLinkedModel()); } return result; } catch (IndexOutOfBoundsException | CoreException e) { throw new IllegalArgumentException("Can't find completion: " + index, e); } }