Bug 18163 Add Import should ignore leading/trailing whitespace
It often happens to me that I have selected i.e. "Node " instead of "Node" because I made my selection by using "Shift + Ctrl + Right". When I then use Ctrl+M (Add Import) nothing happens because of the trailing whitespace within the selection.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/AddImportOnSelectionAction.java
}
	
	public AddImportOnSelectionAction() {
		this(null);
	}
	
	public void update() {
		setEnabled(fEditor != null && !fEditor.isEditorInputReadOnly());
	}	
			
	private ICompilationUnit getCompilationUnit () {
		IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();				
		return manager.getWorkingCopy(fEditor.getEditorInput());
	}
	
	/*
	 * @see org.eclipse.jface.action.IAction#run()
	 */
	public void run() {
		ICompilationUnit cu= getCompilationUnit();
		if (cu != null) {
			ISelection s= fEditor.getSelectionProvider().getSelection();
			IDocument doc= fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
			ITextSelection selection= (ITextSelection) s;
			
			if (doc != null) {
				try {
					int nameStart= getNameStart(doc, selection.getOffset());
					int nameEnd= getNameEnd(doc, selection.getOffset() + selection.getLength());
					int len= nameEnd - nameStart;