Search in sources :

Example 6 with TextEditProcessor

use of org.eclipse.text.edits.TextEditProcessor in project che by eclipse.

the class TextChange method getPreviewDocument.

//---- private helper methods --------------------------------------------------
private PreviewAndRegion getPreviewDocument(TextEditBasedChangeGroup[] changes, IProgressMonitor pm) throws CoreException {
    IDocument document = new Document(getCurrentDocument(pm).get());
    boolean trackChanges = getKeepPreviewEdits();
    setKeepPreviewEdits(true);
    TextEditProcessor processor = changes == ALL_EDITS ? createTextEditProcessor(document, TextEdit.NONE, true) : createTextEditProcessor(document, TextEdit.NONE, changes);
    try {
        processor.performEdits();
        return new PreviewAndRegion(document, getNewRegion(changes));
    } catch (BadLocationException e) {
        throw Changes.asCoreException(e);
    } finally {
        setKeepPreviewEdits(trackChanges);
    }
}
Also used : TextEditProcessor(org.eclipse.text.edits.TextEditProcessor) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) IDocument(org.eclipse.jface.text.IDocument) BadLocationException(org.eclipse.jface.text.BadLocationException)

Aggregations

TextEditProcessor (org.eclipse.text.edits.TextEditProcessor)6 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)4 TextEdit (org.eclipse.text.edits.TextEdit)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 BadLocationException (org.eclipse.jface.text.BadLocationException)3 TextEditCopier (org.eclipse.text.edits.TextEditCopier)3 Document (org.eclipse.jface.text.Document)2 IDocument (org.eclipse.jface.text.IDocument)2 IRegion (org.eclipse.jface.text.IRegion)2 MalformedTreeException (org.eclipse.text.edits.MalformedTreeException)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Set (java.util.Set)1 ASTNode (org.eclipse.jdt.core.dom.ASTNode)1 ASTRewrite (org.eclipse.jdt.core.dom.rewrite.ASTRewrite)1 BadPositionCategoryException (org.eclipse.jface.text.BadPositionCategoryException)1