### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/core/util/CompilationUnitSorter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/CompilationUnitSorter.java,v retrieving revision 1.36 diff -u -r1.36 CompilationUnitSorter.java --- model/org/eclipse/jdt/core/util/CompilationUnitSorter.java 23 Jan 2007 14:58:32 -0000 1.36 +++ model/org/eclipse/jdt/core/util/CompilationUnitSorter.java 31 Jan 2007 14:52:46 -0000 @@ -352,10 +352,7 @@ *

* The compare method of the given comparator is passed pairs * of body declarations (subclasses of BodyDeclaration) - * representing body declarations at the same level. The nodes are from an - * AST of the specified level ({@link org.eclipse.jdt.core.dom.ASTParser#newParser(int)}. - * Clients will generally use AST.JLS3 since that will cover all - * constructs found in Java 1.0, 1.1, 1.2, 1.3, 1.4, and 1.5 source code. + * representing body declarations at the same level. * The comparator is called on body declarations of nested classes, * including anonymous and local classes, but always at the same level. * Clients need to provide a comparator implementation (there is no standard @@ -413,10 +410,7 @@ * modifiers, name, arguments
* RELATIVE_ORDER property
* - * Clients should not rely on the AST nodes being properly parented - * or on having source range information. (Future releases may provide - * options for requesting additional information like source positions, full - * ASTs, non-recursive sorting, etc.) + * *

* * @param unit @@ -438,14 +432,7 @@ * if the compilation unit could not be sorted. Reasons * include: * * @exception IllegalArgumentException * if the given compilation unit is null or if the given Index: model/org/eclipse/jdt/internal/core/SortElementsOperation.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SortElementsOperation.java,v retrieving revision 1.37 diff -u -r1.37 SortElementsOperation.java --- model/org/eclipse/jdt/internal/core/SortElementsOperation.java 23 Jan 2007 14:58:32 -0000 1.37 +++ model/org/eclipse/jdt/internal/core/SortElementsOperation.java 31 Jan 2007 14:52:47 -0000 @@ -120,10 +120,12 @@ * @return the edit or null if no sorting is required */ public TextEdit calculateEdit(org.eclipse.jdt.core.dom.CompilationUnit unit, TextEditGroup group) throws JavaModelException { - IJavaModelStatus status= this.verify(); - if (!status.isOK()) { - throw new JavaModelException(status); - } + if (this.elementsToProcess.length != 1) + throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS)); + + if (!(this.elementsToProcess[0] instanceof ICompilationUnit)) + throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this.elementsToProcess[0])); + try { beginTask(Messages.operation_sortelements, getMainAmountOfWork()); @@ -333,7 +335,7 @@ if (this.elementsToProcess[0] == null) { return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS); } - if (!(this.elementsToProcess[0] instanceof ICompilationUnit) || !((ICompilationUnit) this.elementsToProcess[0]).isWorkingCopy()) { + if (!(this.elementsToProcess[0] instanceof ICompilationUnit) || !((ICompilationUnit) this.elementsToProcess[0]).isWorkingCopy()) { return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this.elementsToProcess[0]); } return JavaModelStatus.VERIFIED_OK;