Project: JDT
Bug 172944 [package explorer] refreshes whole project when single compilation unit saved
Reported: 2007-02-05 17:02:49 | Status: resolved fixed

3.3 M4 - had many projects loaded, with many errors due to missing prerequisites - made an innocuous change to one file (adding a void foo() method) - this led to various notifications, the end result of which was that the Package Explorer did a complete refresh of the containing project and a downstream project, which also caused a label update event for every visible element in these projects (I had expanded all packages, so there were a lot of these) - this occurred despite the resource delta indicating that there were only changes to the affected file's content - all other changes were either to binary files or to markers The stack for the refresh of one of the projects looks like: Thread [Worker-51] (Suspended (entry into method postRefresh in PackageExplorerContentProvider)) PackageExplorerContentProvider.postRefresh(List, boolean) line: 650 PackageExplorerContentProvider.postRefresh(Object, int, Object) line: 634 PackageExplorerContentProvider.processResourceDeltas(IResourceDelta[], Object) line: 614 PackageExplorerContentProvider.processDelta(IJavaElementDelta) line: 457 PackageExplorerContentProvider.processAffectedChildren(IJavaElementDelta[]) line: 497 PackageExplorerContentProvider.handleAffectedChildren(IJavaElementDelta, IJavaElement) line: 492 PackageExplorerContentProvider.processDelta(IJavaElementDelta) line: 460 PackageExplorerContentProvider.elementChanged(ElementChangedEvent) line: 107 DeltaProcessor$3.run() line: 1531 SafeRunner.run(ISafeRunnable) line: 37 DeltaProcessor.notifyListeners(IJavaElementDelta, int, IElementChangedListener[], int[], int) line: 1521 DeltaProcessor.firePostChangeDelta(IJavaElementDelta, IElementChangedListener[], int[], int) line: 1356 DeltaProcessor.fire(IJavaElementDelta, int) line: 1335 DeltaProcessor.resourceChanged(IResourceChangeEvent) line: 1895 DeltaProcessingState.resourceChanged(IResourceChangeEvent) line: 369 NotificationManager$2.run() line: 282 SafeRunner.run(ISafeRunnable) line: 37 NotificationManager.notify(ResourceChangeListenerList$ListenerEntry[], IResourceChangeEvent, boolean) line: 276 NotificationManager.broadcastChanges(ElementTree, ResourceChangeEvent, boolean) line: 148 Workspace.broadcastPostChange() line: 257 Workspace.endOperation(ISchedulingRule, boolean, IProgressMonitor) line: 964 AutoBuildJob.doBuild(IProgressMonitor) line: 169 AutoBuildJob.run(IProgressMonitor) line: 222 Worker.run() line: 58 Tracing backwards: - In PackageExplorerContentProvider.processResourceDeltas(IResourceDelta[], Object), it fired the postRefresh because deltas.length > 1. Here, the model element is the project, and the child deltas are for META-INF and plugin.xml. The changes here are to markers only, so no structural changes to the viewer should be necessary. - In DeltaProcessor.resourceChanged(IResourceChangeEvent), the optimization check isAffectedBy(delta) returned true because some binary files had been added. All changes outside of bin were only to markers. I'd expect isAffectedBy to ignore binary/derived files (I'm assuming the Java model is only computed from source files).

Files changed in fix:
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerContentProvider.java