editor.setFinalCaretOffset(range.getExclusiveEnd()); }
if (range != null && range.isValid()) {  } }*/ editor.setFinalCaretOffset(viewer.getSelectedRange().x);
	public void apply(IDocument document) {		try {			ICompilationUnit unit= JavaModelUtil.toOriginal(getCompilationUnit());			IStatus status= Resources.makeCommittable(unit.getResource(), null);			if (!status.isOK()) {				String label= CorrectionMessages.getString("CUCorrectionProposal.error.title"); //$NON-NLS-1$				String message= CorrectionMessages.getString("CUCorrectionProposal.error.message"); //$NON-NLS-1$				ErrorDialog.openError(JavaPlugin.getActiveWorkbenchShell(), label, message, status);				return;			}						CompilationUnitChange change= getCompilationUnitChange();						GroupDescription selection= getSelectionDescription();			GroupDescription[] linked= getLinkedRanges();						IEditorPart part= null;			if (selection != null || linked != null) {				change.setKeepExecutedTextEdits(true);								part= EditorUtility.isOpenInEditor(unit);				if (part == null) {					part= EditorUtility.openInEditor(unit, true);				}				IWorkbenchPage page= JavaPlugin.getActivePage();				if (page != null && part != null) {					page.bringToTop(part);				}			}						super.apply(document);			if (part == null) {				return;			}						if (linked != null && part instanceof JavaEditor) {				// enter linked mode				ITextViewer viewer= ((JavaEditor) part).getViewer();				LinkedPositionManager manager= new LinkedPositionManager(viewer.getDocument());				LinkedPositionUI editor= new LinkedPositionUI(viewer, manager);								for (int i= 0; i < linked.length; i++) {					GroupDescription curr= linked[i];					TextRange range= change.getNewTextRange(curr.getTextEdits());					manager.addPosition(range.getOffset(), range.getLength());					if (i == 0) {						editor.setInitialOffset(range.getOffset());					}				}				if (selection != null) {					TextRange range= change.getNewTextRange(selection.getTextEdits());					editor.setFinalCaretOffset(range.getExclusiveEnd());									}				editor.enter();								IRegion region= editor.getSelectedRegion();				viewer.setSelectedRange(region.getOffset(), region.getLength());				} else if (selection != null && part instanceof ITextEditor) {				// select a result				TextRange range= change.getNewTextRange(selection.getTextEdits());				((ITextEditor) part).selectAndReveal(range.getOffset(), range.getLength());			}		} catch (CoreException e) {			JavaPlugin.log(e);		} catch (BadLocationException e) {			JavaPlugin.log(e);		}			}