private TextEditBasedChangeGroup[] getSortedChangeGroups(TextEditBasedChange change) { TextEditBasedChangeGroup[] edits= change.getChangeGroups(); List<TextEditBasedChangeGroup> result= new ArrayList<>(edits.length); for (int i= 0; i < edits.length; i++) { if (!edits[i].getTextEditGroup().isEmpty()) result.add(edits[i]); } Comparator<TextEditBasedChangeGroup> comparator= new OffsetComparator(); Collections.sort(result, comparator); return result.toArray(new TextEditBasedChangeGroup[result.size()]); }
private TextEditBasedChangeGroup[] getSortedChangeGroups(TextEditBasedChange change) { TextEditBasedChangeGroup[] groups= change.getChangeGroups(); List result= new ArrayList(groups.length); for (int i= 0; i < groups.length; i++) { if (!groups[i].getTextEditGroup().isEmpty()) result.add(groups[i]); } Comparator comparator= new OffsetComparator(); Collections.sort(result, comparator); return (TextEditBasedChangeGroup[])result.toArray(new TextEditBasedChangeGroup[result.size()]); }
private TextEditBasedChangeGroup[] getSortedChangeGroups(TextEditBasedChange change) { TextEditBasedChangeGroup[] edits= change.getChangeGroups(); List result= new ArrayList(edits.length); for (int i= 0; i < edits.length; i++) { if (!edits[i].getTextEditGroup().isEmpty()) result.add(edits[i]); } Comparator comparator= new OffsetComparator(); Collections.sort(result, comparator); return (TextEditBasedChangeGroup[])result.toArray(new TextEditBasedChangeGroup[result.size()]); }
private TextEditBasedChangeGroup[] getSortedChangeGroups(TextEditBasedChange change) { TextEditBasedChangeGroup[] edits= change.getChangeGroups(); List<TextEditBasedChangeGroup> result= new ArrayList<>(edits.length); for (int i= 0; i < edits.length; i++) { if (!edits[i].getTextEditGroup().isEmpty()) result.add(edits[i]); } Comparator<TextEditBasedChangeGroup> comparator= new OffsetComparator(); Collections.sort(result, comparator); return result.toArray(new TextEditBasedChangeGroup[result.size()]); }
private IRegion getRegion(TextEditBasedChangeGroup[] changes) { if (changes == ALL_EDITS) { if (fEdit == null) return null; return fEdit.getRegion(); } else { List<TextEdit> edits= new ArrayList<>(); for (int i= 0; i < changes.length; i++) { edits.addAll(Arrays.asList(changes[i].getTextEditGroup().getTextEdits())); } if (edits.size() == 0) return null; return TextEdit.getCoverage(edits.toArray(new TextEdit[edits.size()])); } }
private IRegion getRegion(TextEditBasedChangeGroup[] changes) { if (changes == ALL_EDITS) { if (fEdit == null) return null; return fEdit.getRegion(); } else { List edits= new ArrayList(); for (int i= 0; i < changes.length; i++) { edits.addAll(Arrays.asList(changes[i].getTextEditGroup().getTextEdits())); } if (edits.size() == 0) return null; return TextEdit.getCoverage((TextEdit[]) edits.toArray(new TextEdit[edits.size()])); } }
private IRegion getRegion(TextEditBasedChangeGroup[] changes) { if (changes == ALL_EDITS) { if (fEdit == null) return null; return fEdit.getRegion(); } else { List<TextEdit> edits= new ArrayList<>(); for (int i= 0; i < changes.length; i++) { edits.addAll(Arrays.asList(changes[i].getTextEditGroup().getTextEdits())); } if (edits.size() == 0) return null; return TextEdit.getCoverage(edits.toArray(new TextEdit[edits.size()])); } }
private IRegion getNewRegion(TextEditBasedChangeGroup[] changes) { if (changes == ALL_EDITS) { if (fEdit == null) return null; return fCopier.getCopy(fEdit).getRegion(); } else { List<TextEdit> result= new ArrayList<>(); for (int c= 0; c < changes.length; c++) { TextEdit[] edits= changes[c].getTextEditGroup().getTextEdits(); for (int e= 0; e < edits.length; e++) { TextEdit copy= fCopier.getCopy(edits[e]); if (copy != null) result.add(copy); } } if (result.size() == 0) return null; return TextEdit.getCoverage(result.toArray(new TextEdit[result.size()])); } }
private IRegion getNewRegion(TextEditBasedChangeGroup[] changes) { if (changes == ALL_EDITS) { if (fEdit == null) return null; return fCopier.getCopy(fEdit).getRegion(); } else { List<TextEdit> result= new ArrayList<>(); for (int c= 0; c < changes.length; c++) { TextEdit[] edits= changes[c].getTextEditGroup().getTextEdits(); for (int e= 0; e < edits.length; e++) { TextEdit copy= fCopier.getCopy(edits[e]); if (copy != null) result.add(copy); } } if (result.size() == 0) return null; return TextEdit.getCoverage(result.toArray(new TextEdit[result.size()])); } }
private IRegion getNewRegion(TextEditBasedChangeGroup[] changes) { if (changes == ALL_EDITS) { if (fEdit == null) return null; return fCopier.getCopy(fEdit).getRegion(); } else { List result= new ArrayList(); for (int c= 0; c < changes.length; c++) { TextEdit[] edits= changes[c].getTextEditGroup().getTextEdits(); for (int e= 0; e < edits.length; e++) { TextEdit copy= fCopier.getCopy(edits[e]); if (copy != null) result.add(copy); } } if (result.size() == 0) return null; return TextEdit.getCoverage((TextEdit[]) result.toArray(new TextEdit[result.size()])); } }
/** * Adds a new text change to this composite change. * <p> * The text change which is added is not changed in any way. Rather * the contents of the text change are retrieved and stored internally * in this composite text change. * </p> * * @param change * the text change to add */ public final void addChange(final TextChange change) { Assert.isNotNull(change); final ComposableBufferChange result= new ComposableBufferChange(); result.setEdit(change.getEdit()); final TextEditBasedChangeGroup[] groups= change.getChangeGroups(); final List list= new ArrayList(groups.length); for (int index= 0; index < groups.length; index++) { final TextEditBasedChangeGroup group= new ComposableBufferChangeGroup(this, groups[index].getTextEditGroup()); list.add(group); addChangeGroup(group); } result.setGroups(list); fChanges.add(result); }
/** * Adds a new text change to this composite change. * <p> * The text change which is added is not changed in any way. Rather * the contents of the text change are retrieved and stored internally * in this composite text change. * </p> * * @param change * the text change to add */ public final void addChange(final TextChange change) { Assert.isNotNull(change); final ComposableBufferChange result= new ComposableBufferChange(); result.setEdit(change.getEdit()); final TextEditBasedChangeGroup[] groups= change.getChangeGroups(); final List<TextEditBasedChangeGroup> list= new ArrayList<>(groups.length); for (int index= 0; index < groups.length; index++) { final TextEditBasedChangeGroup group= new ComposableBufferChangeGroup(this, groups[index].getTextEditGroup()); list.add(group); addChangeGroup(group); } result.setGroups(list); fChanges.add(result); }
/** * Adds a new text change to this composite change. * <p> * The text change which is added is not changed in any way. Rather * the contents of the text change are retrieved and stored internally * in this composite text change. * </p> * * @param change * the text change to add */ public final void addChange(final TextChange change) { Assert.isNotNull(change); final ComposableBufferChange result= new ComposableBufferChange(); result.setEdit(change.getEdit()); final TextEditBasedChangeGroup[] groups= change.getChangeGroups(); final List<TextEditBasedChangeGroup> list= new ArrayList<>(groups.length); for (int index= 0; index < groups.length; index++) { final TextEditBasedChangeGroup group= new ComposableBufferChangeGroup(this, groups[index].getTextEditGroup()); list.add(group); addChangeGroup(group); } result.setGroups(list); fChanges.add(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<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, 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 static void copyChangeGroups(CompilationUnitChange target, CompilationUnitChange source) { TextEditBasedChangeGroup[] changeGroups= source.getChangeGroups(); for (int i= 0; i < changeGroups.length; i++) { TextEditGroup textEditGroup= changeGroups[i].getTextEditGroup(); TextEditGroup newGroup; if (textEditGroup instanceof CategorizedTextEditGroup) { String label= textEditGroup.getName(); newGroup= new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label))); } else { newGroup= new TextEditGroup(textEditGroup.getName()); } TextEdit[] textEdits= textEditGroup.getTextEdits(); for (int j= 0; j < textEdits.length; j++) { newGroup.addTextEdit(textEdits[j]); } target.addTextEditGroup(newGroup); } }
private static void copyChangeGroups(CompilationUnitChange target, CompilationUnitChange source) { TextEditBasedChangeGroup[] changeGroups= source.getChangeGroups(); for (int i= 0; i < changeGroups.length; i++) { TextEditGroup textEditGroup= changeGroups[i].getTextEditGroup(); TextEditGroup newGroup; if (textEditGroup instanceof CategorizedTextEditGroup) { String label= textEditGroup.getName(); newGroup= new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label))); } else { newGroup= new TextEditGroup(textEditGroup.getName()); } TextEdit[] textEdits= textEditGroup.getTextEdits(); for (int j= 0; j < textEdits.length; j++) { newGroup.addTextEdit(textEdits[j]); } target.addTextEditGroup(newGroup); } }
private static void copyChangeGroups(CompilationUnitChange target, TextChange source) { TextEditBasedChangeGroup[] changeGroups= source.getChangeGroups(); for (int i= 0; i < changeGroups.length; i++) { TextEditGroup textEditGroup= changeGroups[i].getTextEditGroup(); TextEditGroup newGroup; if (textEditGroup instanceof CategorizedTextEditGroup) { String label= textEditGroup.getName(); newGroup= new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label))); } else { newGroup= new TextEditGroup(textEditGroup.getName()); } TextEdit[] textEdits= textEditGroup.getTextEdits(); for (int j= 0; j < textEdits.length; j++) { newGroup.addTextEdit(textEdits[j]); } target.addTextEditGroup(newGroup); } }