1、Eclipse 的 undo/redo 的菜单命令标签(edit -> Undo Typing)
的源代码位置:
org.eclipse.text.undo.DocumentUndoManager.UndoableTextChange#UndoableTextChange
// location: org.eclipse.text.undo.DocumentUndoManager
2、从 Workbench 获取 IDocument
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart editorPart = IDE.openEditor(page, file);
IDocument doc = ((ITextEditor)editorPart).getDocumentProvider().getDocument(editorPart.getEditorInput());
3、从 Workbench 获取 ITextViewer
IEditorPart editorPart = getSite().getPage().getActiveEditor();
if (editorPart != null) {
ITextOperationTarget target =
(ITextOperationTarget)editorPart.getAdapter(ITextOperationTarget.class);