Bug 66501 [typing] In smart mode: Delete Next/Previous Word delete selection
200406092000 In the java editor, Delete Next Word (Ctrl+Delete) and Delete Previous Word (Ctrl+Backspace) behave unexpected. They should always just delete the selection iff it is not zero-length. That's the behavior we're used to with unmodified Delete and Backspace, and it's also what the Text Editor already does. void foo() { System.out.println(123); } Set cursor to before "out.", then press 2x Ctrl+Shift+Right to select "out." with the caret after the selection. Expected: Ctrl+Delete deletes selection. Was: Ctrl+Delete then deletes "println", leaving the selection alone. Similar problems with Ctrl+Backspace and when caret is at the start of the selection.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java
if ( !(element instanceof ISourceReference))
			return null;
		
		if (element.getElementType() == IJavaElement.IMPORT_DECLARATION) {
			
			IImportDeclaration declaration= (IImportDeclaration) element;
			IImportContainer container= (IImportContainer) declaration.getParent();
			ISourceRange srcRange= null;
			
			try {
				srcRange= container.getSourceRange();
			} catch (JavaModelException e) {
			}
			
			if (srcRange != null && srcRange.getOffset() == caret)
				return container;
		}
		
		return (ISourceReference) element;
	}
	/**
	 * Returns the most narrow java element including the given offset.
	 * 
	 * @param offset the offset inside of the requested element
	 * @param reconcile <code>true</code> if editor input should be reconciled in advance
	 * @return the most narrow java element
	 * @since 3.0
	 */
	protected IJavaElement getElementAt(int offset, boolean reconcile) {
		return getElementAt(offset);