Skip to content

Avoid the full ancestor chain walk when removing elements from the Project Explorer - #4260

Open
vogella wants to merge 2 commits into
eclipse-platform:masterfrom
vogella:navigator-parent-lookup
Open

Avoid the full ancestor chain walk when removing elements from the Project Explorer#4260
vogella wants to merge 2 commits into
eclipse-platform:masterfrom
vogella:navigator-parent-lookup

Conversation

@vogella

@vogella vogella commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Deleting many files below a collapsed project freezes the Project Explorer. AbstractTreeViewer.getParentElement prefers ITreePathContentProvider, so the Common Navigator answers through getParents, which compiles complete paths up to the root although only the last segment of the first path is ever used. Every ancestor level above the immediate parent is computed and discarded, and each level asks every enabled content extension for a parent, which with JDT enabled runs JavaCore.create and hasJavaNature against the workspace tree. AbstractTreeViewer.internalRemove takes that branch for elements that have no widget, so files that were never made visible pay the full walk one by one.

CommonViewer now asks getParent first and falls back to the inherited behaviour when it returns null, which confines the change to the Common Navigator instead of reordering the two content provider interfaces for every JFace client. The performance test added in #4259 reports 3.5ms against 18.6ms for 2000 files ten folders deep.

The first commit has to stay ahead of the second. getParent passed the Object[] holder rather than its element to pipelineParent, so whenever no pipelined overriding extension supplied a parent it handed that array back and getParent returned an Object[] instead of a parent element. pipelineParent also started from a null suggestion, so the first pipelined provider was never told the parent the overridden extension had already computed.

getParent() passed the Object[] holder instead of its element to
pipelineParent(), so whenever no pipelined overriding extension returned
a parent, pipelineParent() handed that array back as the fallback and
getParent() returned an Object[] rather than a parent element.

pipelineParent() also started with a null suggestion, so the first
pipelined provider was asked for a parent without being told the parent
the overridden extension had already computed. Seed the suggestion with
the current parent, which is what findParent() does on the equivalent
getParents() path.
AbstractTreeViewer.getParentElement() prefers ITreePathContentProvider,
so for the Common Navigator it calls getParents(), which compiles
complete paths up to the root. Only the last segment of the first path
is used, so every ancestor level above the immediate parent is computed
and discarded, and each level asks every enabled content extension for a
parent. With JDT enabled that runs JavaCore.create and hasJavaNature per
level, which hit the workspace tree.

AbstractTreeViewer.internalRemove() takes this branch for elements that
have no widget, so deleting many never expanded files paid the full walk
per element and froze the UI. Override getParentElement() to ask
getParent() first and fall back to the inherited behaviour when it
returns null.
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

   858 files  ±0     858 suites  ±0   59m 29s ⏱️ + 4m 57s
 8 172 tests ±0   7 929 ✅ ±0  243 💤 ±0  0 ❌ ±0 
20 418 runs  ±0  19 762 ✅ ±0  656 💤 ±0  0 ❌ ±0 

Results for commit 6034db8. ± Comparison against base commit 6e05cae.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant