Java Code Examples for org.eclipse.text.edits.TextEdit#accept()
The following examples show how to use
org.eclipse.text.edits.TextEdit#accept() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CUCorrectionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public Object getAdditionalProposalInfo(IProgressMonitor monitor) { StringBuffer buf= new StringBuffer(); try { TextChange change= getTextChange(); change.setKeepPreviewEdits(true); IDocument previewDocument= change.getPreviewDocument(monitor); TextEdit rootEdit= change.getPreviewEdit(change.getEdit()); EditAnnotator ea= new EditAnnotator(buf, previewDocument); rootEdit.accept(ea); ea.unchangedUntil(previewDocument.getLength()); // Final pre-existing region } catch (CoreException e) { JavaPlugin.log(e); } return buf.toString(); }
Example 2
Source File: PropertiesQuickAssistProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public Object getAdditionalProposalInfo(IProgressMonitor monitor) { final StringBuffer buf= new StringBuffer(); try { for (int i= 0; i < fChanges.length; i++) { if (fChanges[i] instanceof TextChange) { TextChange change= (TextChange) fChanges[i]; String filename= getFileName(change); if (filename != null) { buf.append("<b>"); //$NON-NLS-1$ buf.append(filename); buf.append("</b>"); //$NON-NLS-1$ buf.append("<br>"); //$NON-NLS-1$ } change.setKeepPreviewEdits(true); IDocument currentContent= change.getCurrentDocument(monitor); TextEdit rootEdit= change.getEdit(); EditAnnotator ea= new EditAnnotator(buf, currentContent) { @Override protected boolean rangeRemoved(TextEdit edit) { return annotateEdit(edit, "<del>", "</del>"); //$NON-NLS-1$ //$NON-NLS-2$ } }; rootEdit.accept(ea); ea.unchangedUntil(currentContent.getLength()); // Final pre-existing region buf.append("<br><br>"); //$NON-NLS-1$ } } } catch (CoreException e) { JavaPlugin.log(e); } return buf.toString(); }