Bug 31213 occurrences in file: exception trace in log
20030206 after i ran the action on a file outside of my classpath !ENTRY org.eclipse.jdt.ui 4 10001 Feb 07, 2003 10:48:29.593 !MESSAGE Internal Error !STACK 1 Java Model Exception: Java Model Status [ddd [in xxx] does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:482) at org.eclipse.jdt.internal.core.PackageFragmentRoot.getUnderlyingResource (PackageFragmentRoot.java:714) at org.eclipse.jdt.internal.core.PackageFragment.getUnderlyingResource (PackageFragment.java:249) at org.eclipse.jdt.internal.core.Openable.getUnderlyingResource (Openable.java:235) at org.eclipse.jdt.internal.core.CompilationUnit.getUnderlyingResource (CompilationUnit.java:546) at org.eclipse.jdt.internal.ui.search.FindOccurrencesEngine$FindOccurencesCUEngine. getMarkerOwner(FindOccurrencesEngine.java:116) at org.eclipse.jdt.internal.ui.search.FindOccurrencesEngine$1.run (FindOccurrencesEngine.java:178) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.execute (JavaModelOperation.java:343) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:671) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1588) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:2633) at org.eclipse.jdt.internal.ui.search.FindOccurrencesEngine$2.run (FindOccurrencesEngine.java:274) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:65) at org.eclipse.jdt.internal.ui.search.FindOccurrencesEngine.run (FindOccurrencesEngine.java:270) at org.eclipse.jdt.internal.ui.search.FindOccurrencesEngine.run (FindOccurrencesEngine.java:190) at org.eclipse.jdt.ui.actions.FindOccurrencesInFileAction.run (FindOccurrencesInFileAction.java:165) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:193) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:169) at org.eclipse.jface.action.Action.runWithEvent(Action.java:804) at org.eclipse.ui.actions.RetargetAction.runWithEvent (RetargetAction.java:177) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent (WWinPluginAction.java:207) at org.eclipse.ui.internal.WWinKeyBindingService.invoke (WWinKeyBindingService.java:135) at org.eclipse.ui.internal.WWinKeyBindingService.pressed (WWinKeyBindingService.java:116) at org.eclipse.ui.internal.WWinKeyBindingService$6.widgetSelected (WWinKeyBindingService.java:365) at org.eclipse.ui.internal.AcceleratorMenu$2.handleEvent (AcceleratorMenu.java:55) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:836) 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:1289) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1272) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at java.lang.reflect.Method.invoke(Native Method) 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/ui/actions/FindOccurrencesInFileAction.java
}
	/* (non-JavaDoc)
	 * Method declared in SelectionDispatchAction.
	 */
	protected final void run(ITextSelection ts) {
		IJavaElement input= getEditorInput(fEditor);
		FindOccurrencesEngine engine= FindOccurrencesEngine.create(input);
		try {
			String result= engine.run(ts.getOffset(), ts.getLength());
			if (result != null)
				showMessage(getShell(), fEditor, result);
		} catch (JavaModelException e) {
			JavaPlugin.log(e);
		}
	}
	private static IJavaElement getEditorInput(JavaEditor editor) {
		IEditorInput input= editor.getEditorInput();
		if (input instanceof IClassFileEditorInput)
			return ((IClassFileEditorInput)input).getClassFile();
		return  JavaPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
	} 
		
	private static void showMessage(Shell shell, JavaEditor editor, String msg) {
		IEditorStatusLine statusLine= (IEditorStatusLine) editor.getAdapter(IEditorStatusLine.class);
		if (statusLine != null) 
			statusLine.setMessage(true, msg, null); 
		shell.getDisplay().beep();
	}
}