/** * Creates a new group category set containing the union of the given two * group category sets * * @param one the first set of group categories * @param two the second set of group categories * * @return the union */ public static GroupCategorySet union(GroupCategorySet one, GroupCategorySet two) { Assert.isNotNull(one); Assert.isNotNull(two); // for performance we are using identity here. This is // valid since group categories are value objects and // therefore best used as static final fields. if (one == two) return one; if (one == NONE) return two; if (two == NONE) return one; Set combined= new HashSet(); combined.addAll(one.asList()); combined.addAll(two.asList()); return new GroupCategorySet(combined); }
/** * Creates a new group category set containing the union of the given two * group category sets * * @param one the first set of group categories * @param two the second set of group categories * * @return the union */ public static GroupCategorySet union(GroupCategorySet one, GroupCategorySet two) { Assert.isNotNull(one); Assert.isNotNull(two); // for performance we are using identity here. This is // valid since group categories are value objects and // therefore best used as static final fields. if (one == two) return one; if (one == NONE) return two; if (two == NONE) return one; Set<GroupCategory> combined= new HashSet<>(); combined.addAll(one.asList()); combined.addAll(two.asList()); return new GroupCategorySet(combined); }
/** * Creates a new group category set containing the union of the given two * group category sets * * @param one the first set of group categories * @param two the second set of group categories * * @return the union */ public static GroupCategorySet union(GroupCategorySet one, GroupCategorySet two) { Assert.isNotNull(one); Assert.isNotNull(two); // for performance we are using identity here. This is // valid since group categories are value objects and // therefore best used as static final fields. if (one == two) return one; if (one == NONE) return two; if (two == NONE) return one; Set<GroupCategory> combined= new HashSet<>(); combined.addAll(one.asList()); combined.addAll(two.asList()); return new GroupCategorySet(combined); }
protected TextEditGroup createTextEditGroup(String label) { if (label.length() > 0){ return new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label))); } else { return new TextEditGroup(label); } }
protected TextEditGroup createTextEditGroup(String label, CompilationUnitRewrite rewrite) { if (label.length() > 0) { return rewrite.createCategorizedGroupDescription(label, new GroupCategorySet(new GroupCategory(label, label, label))); } else { return rewrite.createGroupDescription(label); } }
protected TextEditGroup createTextEditGroup(String label, CompilationUnitRewrite rewrite) { if (label.length() > 0) { return rewrite.createCategorizedGroupDescription(label, new GroupCategorySet(new GroupCategory(label, label, label))); } else { return rewrite.createGroupDescription(label); } }
@Override public CompilationUnitChange createChange(IProgressMonitor progressMonitor) throws CoreException { String label= fChangeDescription; CompilationUnitChange result= new CompilationUnitChange(label, fUnit); result.setEdit(fEdit); result.addTextEditGroup(new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label)))); return result; }
@Override public CompilationUnitChange createChange(IProgressMonitor progressMonitor) throws CoreException { String label= fChangeDescription; CompilationUnitChange result= new CompilationUnitChange(label, fUnit); result.setEdit(fEdit); result.addTextEditGroup(new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label)))); return result; }
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, boolean sortMembers, boolean sortFields) throws CoreException { if (!sortMembers && !sortFields) return null; ICompilationUnit cu= (ICompilationUnit)compilationUnit.getJavaElement(); String label= FixMessages.SortMembersFix_Change_description; CategorizedTextEditGroup group= new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label))); TextEdit edit= CompilationUnitSorter.sort(compilationUnit, new DefaultJavaElementComparator(!sortFields), 0, group, null); if (edit == null) return null; return new SortMembersFix(edit, cu, FixMessages.SortMembersFix_Fix_description); }
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, boolean sortMembers, boolean sortFields) throws CoreException { if (!sortMembers && !sortFields) return null; ICompilationUnit cu= (ICompilationUnit)compilationUnit.getJavaElement(); String label= FixMessages.SortMembersFix_Change_description; CategorizedTextEditGroup group= new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label))); TextEdit edit= CompilationUnitSorter.sort(compilationUnit, new DefaultJavaElementComparator(!sortFields), 0, group, null); if (edit == null) return null; return new SortMembersFix(edit, cu, FixMessages.SortMembersFix_Fix_description); }
if (edit != null) { String label= FixMessages.StringFix_RemoveNonNls_description; result.add(new CategorizedTextEditGroup(label, edit, new GroupCategorySet(new GroupCategory(label, label, label)))); for (int j= 0; j < edits.length; j++) { String label= FixMessages.StringFix_AddNonNls_description; result.add(new CategorizedTextEditGroup(label, edits[j], new GroupCategorySet(new GroupCategory(label, label, label))));
if (edit != null) { String label= FixMessages.StringFix_RemoveNonNls_description; result.add(new CategorizedTextEditGroup(label, edit, new GroupCategorySet(new GroupCategory(label, label, label)))); for (int j= 0; j < edits.length; j++) { String label= FixMessages.StringFix_AddNonNls_description; result.add(new CategorizedTextEditGroup(label, edits[j], new GroupCategorySet(new GroupCategory(label, label, label))));
if (edit != null) { String label= FixMessages.StringFix_RemoveNonNls_description; result.add(new CategorizedTextEditGroup(label, edit, new GroupCategorySet(new GroupCategory(label, label, label)))); for (int j= 0; j < edits.length; j++) { String label= FixMessages.StringFix_AddNonNls_description; result.add(new CategorizedTextEditGroup(label, edits[j], new GroupCategorySet(new GroupCategory(label, label, label))));
public TextChange createChange() throws CoreException { CompilationUnitChange result= new CompilationUnitChange(getDescription(), getCompilationUnit()); result.setEdit(edit); String label= getDescription(); result.addTextEditGroup(new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label)))); return result; }
public static IFix createCleanUp(ICompilationUnit unit, boolean singleLine, boolean multiLine, boolean javaDoc, HashMap preferences) throws CoreException { if (!singleLine && !multiLine && !javaDoc) return null; String content= unit.getBuffer().getContents(); Document document= new Document(content); final List edits= format(document, singleLine, multiLine, javaDoc, preferences); if (edits.size() == 0) return null; MultiTextEdit resultEdit= new MultiTextEdit(); resultEdit.addChildren((TextEdit[])edits.toArray(new TextEdit[edits.size()])); TextChange change= new CompilationUnitChange(MultiFixMessages.CommentFormatFix_description, unit); change.setEdit(resultEdit); String label= MultiFixMessages.CommentFormatFix_description; CategorizedTextEditGroup group= new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label))); group.addTextEdit(resultEdit); change.addTextEditGroup(group); return new CommentFormatFix(change, unit); }
public static IFix createCleanUp(CompilationUnit compilationUnit, boolean sortMembers, boolean sortFields) throws CoreException { if (!sortMembers && !sortFields) return null; ICompilationUnit cu= (ICompilationUnit)compilationUnit.getJavaElement(); String label= FixMessages.SortMembersFix_Change_description; CategorizedTextEditGroup group= new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label))); TextEdit edit= CompilationUnitSorter.sort(compilationUnit, new DefaultJavaElementComparator(!sortFields), 0, group, null); if (edit == null) return null; TextChange change= new CompilationUnitChange(label, cu); change.setEdit(edit); change.addTextEditGroup(group); return new SortMembersFix(change, cu); }
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); } }
change.setEdit(edit); CategorizedTextEditGroup group= new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label))); group.addTextEdit(edit); change.addTextEditGroup(group); change.setEdit(multiEdit); CategorizedTextEditGroup group= new CategorizedTextEditGroup(label, new GroupCategorySet(new GroupCategory(label, label, label))); group.addTextEdit(multiEdit); change.addTextEditGroup(group);