Bug 60077 NPE in JavaSearchTableContentProvider
Smoke Test: I200404220800.from20040427_1125 - earlier, made one search for type "Test" in Java Browsing Perspective - switched to Java Perspective (Search view not visible) - some editing in TestResult.java - enabled "Show Source of Selected Element Only" and selected class TestResult in Outline - used regex find-replace: find: "\s(\w*)\(.*\)\s*\{\s*\n\s*", replace: "method: \1" - had cursor before method addError(..) - pressed Find, pressed Replace/Find (this replaced the "Test" reference in the parameters) -> error dialog and log: Error Apr 27, 2004 12:00:48.314 java.lang.NullPointerException java.lang.NullPointerException at org.eclipse.jdt.internal.ui.search.JavaSearchTableContentProvider.elementsChanged(JavaSearchTableContentProvider.java:32) at org.eclipse.jdt.internal.ui.search.JavaSearchResultPage.elementsChanged(JavaSearchResultPage.java:191) at org.eclipse.search.ui.text.AbstractTextSearchViewPage.runBatchedUpdates(AbstractTextSearchViewPage.java:834) at org.eclipse.search.ui.text.AbstractTextSearchViewPage.access$0(AbstractTextSearchViewPage.java:824) at org.eclipse.search.ui.text.AbstractTextSearchViewPage$UpdateUIJob.runInUIThread(AbstractTextSearchViewPage.java:111) at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:82) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:106) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:2569) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2274) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1437) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1408) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:244) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:280) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:240) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:117) 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:267) at org.eclipse.core.launcher.Main.run(Main.java:699) at org.eclipse.core.launcher.Main.main(Main.java:683)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchTableContentProvider.java
private TableViewer fTableViewer;
	public JavaSearchTableContentProvider(TableViewer viewer) {
		fTableViewer= viewer;
	}
	public Object[] getElements(Object inputElement) {
		if (inputElement instanceof JavaSearchResult)
			return ((JavaSearchResult)inputElement).getElements();
		return EMPTY_ARR;
	}
	public void elementsChanged(Object[] updatedElements) {
		int addCount= 0;
		int removeCount= 0;
		for (int i= 0; i < updatedElements.length; i++) {
			if (fResult.getMatchCount(updatedElements[i]) > 0) {
				if (fTableViewer.testFindItem(updatedElements[i]) != null)
					fTableViewer.refresh(updatedElements[i]);
				else
					fTableViewer.add(updatedElements[i]);
				addCount++;
			} else {
				fTableViewer.remove(updatedElements[i]);
				removeCount++;
			}
		}
	}
	public void clear() {
		fTableViewer.refresh();
	}
}