Skip to content

Fix dead REPLACED check in the sample editor resource listener - #2415

Merged
vogella merged 1 commit into
eclipse-pde:masterfrom
vogella:sample-editor-replaced-flag
Aug 9, 2026
Merged

Fix dead REPLACED check in the sample editor resource listener#2415
vogella merged 1 commit into
eclipse-pde:masterfrom
vogella:sample-editor-replaced-flag

Conversation

@vogella

@vogella vogella commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

SampleEditor.InputFileListener closes the editor when its sample.properties input goes away, but the replacement case never worked: IResourceDelta.REPLACED is a delta flag, not a delta kind, so getKind() == IResourceDelta.REPLACED could never be true. getKind() only ever returns NO_CHANGE, ADDED, REMOVED, CHANGED, ADDED_PHANTOM or REMOVED_PHANTOM.

The fix tests REPLACED against getFlags() on a CHANGED delta, which is how ResourceComparator actually reports a resource that was deleted and recreated in the same operation. The removal case was already correct and is unchanged.

This is the same class of bug as the one fixed for TargetEditor in #2414, found while reviewing it.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Test Results

  129 files  ±0    129 suites  ±0   34m 30s ⏱️ - 3m 4s
3 531 tests ±0  3 477 ✅ ±0   54 💤 ±0  0 ❌ ±0 
9 396 runs  ±0  9 266 ✅ ±0  130 💤 ±0  0 ❌ ±0 

Results for commit e5d962f. ± Comparison against base commit e15c569.

♻️ This comment has been updated with latest results.

IResourceDelta.REPLACED is a delta flag, not a delta kind. getKind()
only returns NO_CHANGE, ADDED, REMOVED, CHANGED, ADDED_PHANTOM or
REMOVED_PHANTOM, so comparing it against REPLACED was always false and
the editor never closed when its sample.properties input was replaced.

Test REPLACED against getFlags() on a CHANGED delta instead, which is
how ResourceComparator reports a resource that was deleted and
recreated in the same operation.
@vogella
vogella force-pushed the sample-editor-replaced-flag branch from 11bf87f to e5d962f Compare August 9, 2026 07:29
@vogella

vogella commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Nothing in this repo contributes to the samples extension point, there is no sample.properties anywhere in the tree, SampleWizard isn't even registered as a newWizard (it's only ever constructed programmatically by ShowSampleAction), and the update site it bootstraps from is a long-dead http:// URL. In practice the editor only appears if some external contributor still ships that extension point.#

Still worth the fix, to guide users of this sample extension point.

@vogella
vogella merged commit f6968e0 into eclipse-pde:master Aug 9, 2026
19 checks passed
@vogella
vogella deleted the sample-editor-replaced-flag branch August 9, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant