/** * Returns the edits that were executed during preview generation * instead of the given array of original edits. The method requires * that <code>setKeepPreviewEdits</code> is set to <code>true</code> * and that a preview has been requested via one of the <code> * getPreview*</code> methods. * <p> * The method returns an empty array if none of the original edits * is managed by this text change. * </p> * * @param originals an array of original edits managed by this text * change * * @return an array of edits containing the corresponding edits * executed during preview generation */ public TextEdit[] getPreviewEdits(TextEdit[] originals) { Assert.isTrue(getKeepPreviewEdits() && fCopier != null && originals != null); if (originals.length == 0) return new TextEdit[0]; List result= new ArrayList(originals.length); for (int i= 0; i < originals.length; i++) { TextEdit copy= fCopier.getCopy(originals[i]); if (copy != null) result.add(copy); } return (TextEdit[]) result.toArray(new TextEdit[result.size()]); }
/** * Returns the edits that were executed during preview generation * instead of the given array of original edits. The method requires * that <code>setKeepPreviewEdits</code> is set to <code>true</code> * and that a preview has been requested via one of the <code> * getPreview*</code> methods. * <p> * The method returns an empty array if none of the original edits * is managed by this text change. * </p> * * @param originals an array of original edits managed by this text * change * * @return an array of edits containing the corresponding edits * executed during preview generation */ public TextEdit[] getPreviewEdits(TextEdit[] originals) { Assert.isTrue(getKeepPreviewEdits() && fCopier != null && originals != null); if (originals.length == 0) return new TextEdit[0]; List<TextEdit> result= new ArrayList<>(originals.length); for (int i= 0; i < originals.length; i++) { TextEdit copy= fCopier.getCopy(originals[i]); if (copy != null) result.add(copy); } return result.toArray(new TextEdit[result.size()]); }
/** * Returns the edits that were executed during preview generation * instead of the given array of original edits. The method requires * that <code>setKeepPreviewEdits</code> is set to <code>true</code> * and that a preview has been requested via one of the <code> * getPreview*</code> methods. * <p> * The method returns an empty array if none of the original edits * is managed by this text change. * </p> * * @param originals an array of original edits managed by this text * change * * @return an array of edits containing the corresponding edits * executed during preview generation */ public TextEdit[] getPreviewEdits(TextEdit[] originals) { Assert.isTrue(getKeepPreviewEdits() && fCopier != null && originals != null); if (originals.length == 0) return new TextEdit[0]; List<TextEdit> result= new ArrayList<>(originals.length); for (int i= 0; i < originals.length; i++) { TextEdit copy= fCopier.getCopy(originals[i]); if (copy != null) result.add(copy); } return result.toArray(new TextEdit[result.size()]); }
/** * Returns the edit that got executed during preview generation * instead of the given original. The method requires that <code> * setKeepPreviewEdits</code> is set to <code>true</code> and that * a preview has been requested via one of the <code>getPreview* * </code> methods. * <p> * The method returns <code>null</code> if the original isn't managed * by this text change. * </p> * * @param original the original edit managed by this text change * * @return the edit executed during preview generation */ public TextEdit getPreviewEdit(TextEdit original) { Assert.isTrue(getKeepPreviewEdits() && fCopier != null && original != null); return fCopier.getCopy(original); }
/** * Returns the edit that got executed during preview generation * instead of the given original. The method requires that <code> * setKeepPreviewEdits</code> is set to <code>true</code> and that * a preview has been requested via one of the <code>getPreview* * </code> methods. * <p> * The method returns <code>null</code> if the original isn't managed * by this text change. * </p> * * @param original the original edit managed by this text change * * @return the edit executed during preview generation */ public TextEdit getPreviewEdit(TextEdit original) { Assert.isTrue(getKeepPreviewEdits() && fCopier != null && original != null); return fCopier.getCopy(original); }
/** * Returns the edit that got executed during preview generation * instead of the given original. The method requires that <code> * setKeepPreviewEdits</code> is set to <code>true</code> and that * a preview has been requested via one of the <code>getPreview* * </code> methods. * <p> * The method returns <code>null</code> if the original isn't managed * by this text change. * </p> * * @param original the original edit managed by this text change * * @return the edit executed during preview generation */ public TextEdit getPreviewEdit(TextEdit original) { Assert.isTrue(getKeepPreviewEdits() && fCopier != null && original != null); return fCopier.getCopy(original); }
fCopier= new TextEditCopier(fEdit); TextEdit copiedEdit= fCopier.perform(); boolean keep= getKeepPreviewEdits(); if (keep) flags= flags | TextEdit.UPDATE_REGIONS;
private TextEditProcessor createTextEditProcessor(IDocument document, int flags, boolean preview) { if (fEdit == null) return new TextEditProcessor(document, new MultiTextEdit(0,0), flags); List<TextEdit> excludes= new ArrayList<>(0); TextEditBasedChangeGroup[] groups= getChangeGroups(); for (int index= 0; index < groups.length; index++) { TextEditBasedChangeGroup edit= groups[index]; if (!edit.isEnabled()) { excludes.addAll(Arrays.asList(edit.getTextEditGroup().getTextEdits())); } } if (preview) { fCopier= new TextEditCopier(fEdit); TextEdit copiedEdit= fCopier.perform(); boolean keep= getKeepPreviewEdits(); if (keep) flags= flags | TextEdit.UPDATE_REGIONS; LocalTextEditProcessor result= new LocalTextEditProcessor(document, copiedEdit, flags); result.setExcludes(mapEdits( excludes.toArray(new TextEdit[excludes.size()]), fCopier)); if (!keep) fCopier= null; return result; } else { LocalTextEditProcessor result= new LocalTextEditProcessor(document, fEdit, flags | TextEdit.UPDATE_REGIONS); result.setExcludes(excludes.toArray(new TextEdit[excludes.size()])); return result; } }
private TextEditProcessor createTextEditProcessor(IDocument document, int flags, TextEditBasedChangeGroup[] changes) { if (fEdit == null) return new TextEditProcessor(document, new MultiTextEdit(0,0), flags); List<TextEdit> includes= new ArrayList<>(0); for (int c= 0; c < changes.length; c++) { TextEditBasedChangeGroup change= changes[c]; Assert.isTrue(change.getTextEditChange() == this); if (change.isEnabled()) { includes.addAll(Arrays.asList(change.getTextEditGroup().getTextEdits())); } } fCopier= new TextEditCopier(fEdit); TextEdit copiedEdit= fCopier.perform(); boolean keep= getKeepPreviewEdits(); if (keep) flags= flags | TextEdit.UPDATE_REGIONS; LocalTextEditProcessor result= new LocalTextEditProcessor(document, copiedEdit, flags); result.setIncludes(mapEdits( includes.toArray(new TextEdit[includes.size()]), fCopier)); if (!keep) fCopier= null; return result; }
private TextEditProcessor createTextEditProcessor(IDocument document, int flags, boolean preview) { if (fEdit == null) return new TextEditProcessor(document, new MultiTextEdit(0,0), flags); List<TextEdit> excludes= new ArrayList<>(0); TextEditBasedChangeGroup[] groups= getChangeGroups(); for (int index= 0; index < groups.length; index++) { TextEditBasedChangeGroup edit= groups[index]; if (!edit.isEnabled()) { excludes.addAll(Arrays.asList(edit.getTextEditGroup().getTextEdits())); } } if (preview) { fCopier= new TextEditCopier(fEdit); TextEdit copiedEdit= fCopier.perform(); boolean keep= getKeepPreviewEdits(); if (keep) flags= flags | TextEdit.UPDATE_REGIONS; LocalTextEditProcessor result= new LocalTextEditProcessor(document, copiedEdit, flags); result.setExcludes(mapEdits( excludes.toArray(new TextEdit[excludes.size()]), fCopier)); if (!keep) fCopier= null; return result; } else { LocalTextEditProcessor result= new LocalTextEditProcessor(document, fEdit, flags | TextEdit.UPDATE_REGIONS); result.setExcludes(excludes.toArray(new TextEdit[excludes.size()])); return result; } }
private TextEditProcessor createTextEditProcessor(IDocument document, int flags, TextEditBasedChangeGroup[] changes) { if (fEdit == null) return new TextEditProcessor(document, new MultiTextEdit(0,0), flags); List includes= new ArrayList(0); for (int c= 0; c < changes.length; c++) { TextEditBasedChangeGroup change= changes[c]; Assert.isTrue(change.getTextEditChange() == this); if (change.isEnabled()) { includes.addAll(Arrays.asList(change.getTextEditGroup().getTextEdits())); } } fCopier= new TextEditCopier(fEdit); TextEdit copiedEdit= fCopier.perform(); boolean keep= getKeepPreviewEdits(); if (keep) flags= flags | TextEdit.UPDATE_REGIONS; LocalTextEditProcessor result= new LocalTextEditProcessor(document, copiedEdit, flags); result.setIncludes(mapEdits( (TextEdit[])includes.toArray(new TextEdit[includes.size()]), fCopier)); if (!keep) fCopier= null; return result; }
private TextEditProcessor createTextEditProcessor(IDocument document, int flags, TextEditBasedChangeGroup[] changes) { if (fEdit == null) return new TextEditProcessor(document, new MultiTextEdit(0,0), flags); List<TextEdit> includes= new ArrayList<>(0); for (int c= 0; c < changes.length; c++) { TextEditBasedChangeGroup change= changes[c]; Assert.isTrue(change.getTextEditChange() == this); if (change.isEnabled()) { includes.addAll(Arrays.asList(change.getTextEditGroup().getTextEdits())); } } fCopier= new TextEditCopier(fEdit); TextEdit copiedEdit= fCopier.perform(); boolean keep= getKeepPreviewEdits(); if (keep) flags= flags | TextEdit.UPDATE_REGIONS; LocalTextEditProcessor result= new LocalTextEditProcessor(document, copiedEdit, flags); result.setIncludes(mapEdits( includes.toArray(new TextEdit[includes.size()]), fCopier)); if (!keep) fCopier= null; return result; }
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); } }
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); } }
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); } }