Community
Participate
Working Groups
20050315 When selecting MyAnnotation declaration, and perform sort members (from outline), it sorts entire unit. import java.lang.annotation.*; @Target(ElementType.METHOD) @interface MyAnnotation { String name() default ""; String value(); } @MyAnnotation("type") public class Class4 { @MyAnnotation(value = "method") void foo(){ } }
The ComnpilationUnit sorter provided by JDT/Core always sorts the whole CU. Moving to JDT/Core since this needs additional API.
Indeed the CompilationUnitSorter sorts... a compilation unit. We could add an API that would give the context that we want to sort. The new implementation is using a DOM/AST tree. So we would simply need to visit a subpart of the tree instead of the whole cu. If we add a new API, I don't think it makes sense to add it inside CompilationUnitSorter. The name is misleading.
Philippe, this requires a new API. So if we want to fix it for 3.1 we need a new API for M6.
+1 if reasonable change. Note that it still sorts elements within a compilation unit, only could be given a scope to restrain action.
I could suggest: public static void sort(ICompilationUnit compilationUnit, IJavaElement elementToSort, int[] positions, Comparator comparator, int options, IProgressMonitor monitor) throws JavaModelException;