Bug 10577 Java Search: search scope "Selected resource" not working
Switch to new StructuredSelectionProvider intruduced this bug a) because the provider does not do code resolve if the input is not a selection service b) because at the time the selection service is asked for the selection it takes the selection form the newly opened Search view
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchPage.java
fInitialData= trySimpleTextSelection(selection);
		if (fInitialData == null)
			fInitialData= getDefaultInitValues();
		fJavaElement= fInitialData.javaElement;
		fCaseSensitive.setSelection(fInitialData.isCaseSensitive);
		fCaseSensitive.setEnabled(fInitialData.javaElement == null);
		fSearchFor[fInitialData.searchFor].setSelection(true);
		setLimitTo(fInitialData.searchFor);
		fLimitTo[fInitialData.limitTo].setSelection(true);		
		fPattern.setText(fInitialData.pattern);
	}
	private SearchPatternData tryStructuredSelection(ISelection selection) {
		if (!(selection instanceof IStructuredSelection))
			return null;
		Object o= ((IStructuredSelection)selection).getFirstElement();
		if (o instanceof IJavaElement) {
			return determineInitValuesFrom((IJavaElement)o);
		} else if (o instanceof ISearchResultViewEntry) {
			IJavaElement element= getJavaElement(((ISearchResultViewEntry)o).getSelectedMarker());
			return determineInitValuesFrom(element);
		} else if (o instanceof IAdaptable) {
			IJavaElement element= (IJavaElement)((IAdaptable)o).getAdapter(IJavaElement.class);
			if (element != null) {
				return determineInitValuesFrom(element);
			} else {
				IWorkbenchAdapter adapter= (IWorkbenchAdapter)((IAdaptable)o).getAdapter(IWorkbenchAdapter.class);
				return new SearchPatternData(TYPE, REFERENCES, adapter.getLabel(o), null);
			}
		}
		return null;