View | Details | Raw Unified | Return to bug 172028
Collapse All | Expand All

(-)model/org/eclipse/jdt/core/util/CompilationUnitSorter.java (-16 / +3 lines)
Lines 352-361 Link Here
352
	 * <p>
352
	 * <p>
353
	 * The <code>compare</code> method of the given comparator is passed pairs
353
	 * The <code>compare</code> method of the given comparator is passed pairs
354
	 * of body declarations (subclasses of <code>BodyDeclaration</code>)
354
	 * of body declarations (subclasses of <code>BodyDeclaration</code>)
355
	 * representing body declarations at the same level. The nodes are from an
355
	 * representing body declarations at the same level. 
356
	 * AST of the specified level ({@link org.eclipse.jdt.core.dom.ASTParser#newParser(int)}.
357
	 * Clients will generally use AST.JLS3 since that will cover all
358
	 * constructs found in Java 1.0, 1.1, 1.2, 1.3, 1.4, and 1.5 source code.
359
	 * The comparator is called on body declarations of nested classes,
356
	 * The comparator is called on body declarations of nested classes,
360
	 * including anonymous and local classes, but always at the same level.
357
	 * including anonymous and local classes, but always at the same level.
361
	 * Clients need to provide a comparator implementation (there is no standard
358
	 * Clients need to provide a comparator implementation (there is no standard
Lines 413-422 Link Here
413
	 * <td width="50%"><code>modifiers, name, arguments<br>
410
	 * <td width="50%"><code>modifiers, name, arguments<br>
414
	 *        RELATIVE_ORDER property</code></td>
411
	 *        RELATIVE_ORDER property</code></td>
415
	 * </tr>
412
	 * </tr>
416
	 * </table> Clients should not rely on the AST nodes being properly parented
413
	 * </table>
417
	 * or on having source range information. (Future releases may provide
418
	 * options for requesting additional information like source positions, full
419
	 * ASTs, non-recursive sorting, etc.)
420
	 * </p>
414
	 * </p>
421
	 * 
415
	 * 
422
	 * @param unit
416
	 * @param unit
Lines 438-451 Link Here
438
	 *                if the compilation unit could not be sorted. Reasons
432
	 *                if the compilation unit could not be sorted. Reasons
439
	 *                include:
433
	 *                include:
440
	 *                <ul>
434
	 *                <ul>
441
	 *                <li> The given compilation unit does not exist
435
	 *                <li> The given unit was not created from a ICompilationUnit (INVALID_ELEMENT_TYPES)</li>
442
	 *                (ELEMENT_DOES_NOT_EXIST)</li>
443
	 *                <li> The given compilation unit is not a working copy
444
	 *                (INVALID_ELEMENT_TYPES)</li>
445
	 *                <li> A <code>CoreException</code> occurred while
446
	 *                accessing the underlying resource</li>
447
	 *                <li>The given compilation unit doesn't come from an ICompilationUnit and this ICompilationUnit is
448
	 *                not a working copy (NO_ELEMENTS_TO_PROCESS)</li>
449
	 *                </ul>
436
	 *                </ul>
450
	 * @exception IllegalArgumentException
437
	 * @exception IllegalArgumentException
451
	 *                if the given compilation unit is null or if the given
438
	 *                if the given compilation unit is null or if the given
(-)model/org/eclipse/jdt/internal/core/SortElementsOperation.java (-5 / +7 lines)
Lines 120-129 Link Here
120
	 * @return the edit or null if no sorting is required
120
	 * @return the edit or null if no sorting is required
121
	 */
121
	 */
122
	public TextEdit calculateEdit(org.eclipse.jdt.core.dom.CompilationUnit unit, TextEditGroup group) throws JavaModelException {
122
	public TextEdit calculateEdit(org.eclipse.jdt.core.dom.CompilationUnit unit, TextEditGroup group) throws JavaModelException {
123
		IJavaModelStatus status= this.verify();
123
		if (this.elementsToProcess.length != 1)
124
		if (!status.isOK()) {
124
			throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS));
125
			throw new JavaModelException(status);
125
		
126
		}
126
		if (!(this.elementsToProcess[0] instanceof ICompilationUnit))
127
			throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this.elementsToProcess[0]));
128
		
127
		try {
129
		try {
128
			beginTask(Messages.operation_sortelements, getMainAmountOfWork());
130
			beginTask(Messages.operation_sortelements, getMainAmountOfWork());
129
			
131
			
Lines 333-339 Link Here
333
		if (this.elementsToProcess[0] == null) {
335
		if (this.elementsToProcess[0] == null) {
334
			return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
336
			return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
335
		}
337
		}
336
		if (!(this.elementsToProcess[0] instanceof ICompilationUnit) || !((ICompilationUnit) this.elementsToProcess[0]).isWorkingCopy()) {
338
		if (!(this.elementsToProcess[0] instanceof ICompilationUnit)  || !((ICompilationUnit) this.elementsToProcess[0]).isWorkingCopy()) {
337
			return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this.elementsToProcess[0]);
339
			return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this.elementsToProcess[0]);
338
		}
340
		}
339
		return JavaModelStatus.VERIFIED_OK;
341
		return JavaModelStatus.VERIFIED_OK;

Return to bug 172028