Bug 27223 Search: NPE in goto marker action
!ENTRY org.eclipse.ui 4 4 Nov 27, 2002 11:44:06.250 !MESSAGE Unhandled exception caught in event loop. !ENTRY org.eclipse.ui 4 0 Nov 27, 2002 11:44:06.265 !MESSAGE Argument not valid !STACK 0 java.lang.IllegalArgumentException: Argument not valid at org.eclipse.swt.SWT.error(SWT.java:2166) at org.eclipse.swt.SWT.error(SWT.java:2110) at org.eclipse.swt.custom.StyledText.setCaretOffset(StyledText.java:6880) at org.eclipse.jface.text.TextViewer.handleVerifyEvent(TextViewer.java:2651) at org.eclipse.jface.text.TextViewer$TextVerifyListener.verifyText(TextViewer.java:317) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:187) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:825) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:850) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:834) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:641) at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:5597) at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:6577) at org.eclipse.swt.custom.StyledText.doContent(StyledText.java:2663) at org.eclipse.swt.custom.StyledText.handleKey(StyledText.java:5023) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5046) at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:4811) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:825) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1692) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1410) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1370) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1353) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:841) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:247) at org.eclipse.core.launcher.Main.run(Main.java:703) at org.eclipse.core.launcher.Main.main(Main.java:539)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/GotoMarkerAction.java
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.javaeditor.InternalClassFileEditorInput;
import org.eclipse.jdt.internal.ui.util.SelectionUtil;
public class GotoMarkerAction extends Action {
	private IEditorPart fEditor;
	
	public GotoMarkerAction(){
		WorkbenchHelp.setHelp(this, IJavaHelpContextIds.GOTO_MARKER_ACTION);		
	}
	
	public void run() {
		ISearchResultView view= SearchUI.getSearchResultView();		
		Object element= SelectionUtil.getSingleElement(view.getSelection());
		if (element instanceof ISearchResultViewEntry) {
			ISearchResultViewEntry entry= (ISearchResultViewEntry)element;
			show(entry.getSelectedMarker());
		}
	}
	private void show(IMarker marker) {
		IResource resource= marker.getResource();
		if (resource == null || !resource.exists())
			return;
		IWorkbenchPage wbPage= JavaPlugin.getActivePage();
		IJavaElement javaElement= SearchUtil.getJavaElement(marker);
		if (javaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT)
			gotoPackagesView(javaElement, wbPage);
		else {