/** * Returns the {@link TextEditChangeGroup text edit change groups} managed by this * text change. * * @return the text edit change groups */ public TextEditChangeGroup[] getTextEditChangeGroups() { final TextEditBasedChangeGroup[] groups= getChangeGroups(); final TextEditChangeGroup[] result= new TextEditChangeGroup[groups.length]; System.arraycopy(groups, 0, result, 0, groups.length); return result; }
/** * Returns the {@link TextEditChangeGroup text edit change groups} managed by this * text change. * * @return the text edit change groups */ public TextEditChangeGroup[] getTextEditChangeGroups() { final TextEditBasedChangeGroup[] groups= getChangeGroups(); final TextEditChangeGroup[] result= new TextEditChangeGroup[groups.length]; System.arraycopy(groups, 0, result, 0, groups.length); return result; }
/** * Returns the {@link TextEditChangeGroup text edit change groups} managed by this * text change. * * @return the text edit change groups */ public TextEditChangeGroup[] getTextEditChangeGroups() { final TextEditBasedChangeGroup[] groups= getChangeGroups(); final TextEditChangeGroup[] result= new TextEditChangeGroup[groups.length]; System.arraycopy(groups, 0, result, 0, groups.length); return 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 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); }
return new TextEditProcessor(document, new MultiTextEdit(0,0), flags); List excludes= new ArrayList(0); TextEditBasedChangeGroup[] groups= getChangeGroups(); for (int index= 0; index < groups.length; index++) { TextEditBasedChangeGroup edit= groups[index];
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, 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; } }
public static Change addFields(ICompilationUnit cu, List<String> fields) throws CoreException { AccessorClassModifier sourceModification= new AccessorClassModifier(cu); String message= Messages.format(NLSMessages.AccessorClassModifier_add_fields_to_accessor, BasicElementLabels.getFileName(cu)); TextChange change= new CompilationUnitChange(message, cu); MultiTextEdit multiTextEdit= new MultiTextEdit(); change.setEdit(multiTextEdit); for (int i= 0; i < fields.size(); i++) { String field= fields.get(i); NLSSubstitution substitution= new NLSSubstitution(NLSSubstitution.EXTERNALIZED, field, null, null, null); sourceModification.addKey(substitution, change); } if (change.getChangeGroups().length == 0) return null; change.addEdit(sourceModification.getTextEdit()); return change; }
public static Change removeFields(ICompilationUnit cu, List<String> fields) throws CoreException { AccessorClassModifier sourceModification= new AccessorClassModifier(cu); String message= Messages.format(NLSMessages.AccessorClassModifier_remove_fields_from_accessor, BasicElementLabels.getFileName(cu)); TextChange change= new CompilationUnitChange(message, cu); MultiTextEdit multiTextEdit= new MultiTextEdit(); change.setEdit(multiTextEdit); for (int i= 0; i < fields.size(); i++) { String field= fields.get(i); NLSSubstitution substitution= new NLSSubstitution(NLSSubstitution.EXTERNALIZED, field, null, null, null); sourceModification.removeKey(substitution, change); } if (change.getChangeGroups().length == 0) return null; change.addEdit(sourceModification.getTextEdit()); return change; }
public static Change addFields(ICompilationUnit cu, List<String> fields) throws CoreException { AccessorClassModifier sourceModification= new AccessorClassModifier(cu); String message= Messages.format(NLSMessages.AccessorClassModifier_add_fields_to_accessor, BasicElementLabels.getFileName(cu)); TextChange change= new CompilationUnitChange(message, cu); MultiTextEdit multiTextEdit= new MultiTextEdit(); change.setEdit(multiTextEdit); for (int i= 0; i < fields.size(); i++) { String field= fields.get(i); NLSSubstitution substitution= new NLSSubstitution(NLSSubstitution.EXTERNALIZED, field, null, null, null); sourceModification.addKey(substitution, change); } if (change.getChangeGroups().length == 0) return null; change.addEdit(sourceModification.getTextEdit()); return change; }
public static Change removeFields(ICompilationUnit cu, List<String> fields) throws CoreException { AccessorClassModifier sourceModification= new AccessorClassModifier(cu); String message= Messages.format(NLSMessages.AccessorClassModifier_remove_fields_from_accessor, BasicElementLabels.getFileName(cu)); TextChange change= new CompilationUnitChange(message, cu); MultiTextEdit multiTextEdit= new MultiTextEdit(); change.setEdit(multiTextEdit); for (int i= 0; i < fields.size(); i++) { String field= fields.get(i); NLSSubstitution substitution= new NLSSubstitution(NLSSubstitution.EXTERNALIZED, field, null, null, null); sourceModification.removeKey(substitution, change); } if (change.getChangeGroups().length == 0) return null; change.addEdit(sourceModification.getTextEdit()); return change; }
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); } }
if (change.getChangeGroups().length == 0) return null;
if (change.getChangeGroups().length == 0) return null;
if (change.getChangeGroups().length == 0) return null;