Skip to content

Guard against a missing reconciler in computeStyleRanges() - #4394

Merged
tobiasmelcher merged 1 commit into
eclipse-platform:masterfrom
vogella:lv/sourceviewer-reconciler-npe
Sep 21, 2026
Merged

tobiasmelcher merged 1 commit into
eclipse-platform:masterfrom
vogella:lv/sourceviewer-reconciler-npe

Conversation

@vogella

@vogella vogella commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

SourceViewer#computeStyleRanges() dereferenced fPresentationReconciler in the partition loop without a null check, so a viewer that was never configured threw a NullPointerException.
The existing early return for documents that are not IDocumentExtension3 did not cover this, because a plain Document implements that interface.
The method now returns the empty list, consistent with the other cases in which no styles can be computed.

This removes the need for callers to catch NullPointerException around the call, which would also swallow NPEs raised by real presentation repairers.
The new test in SourceViewerComputeStyleRangesTest fails with exactly that NPE without the guard; the whole class passes with it.

SourceViewer#computeStyleRanges() dereferenced fPresentationReconciler
in the partition loop without a null check, so a viewer that was never
configured threw an NPE. The early return for non-IDocumentExtension3
documents did not cover it, because a plain Document implements that
interface.

Return the empty list instead, so callers do not have to catch
NullPointerException and thereby hide NPEs raised by real repairers.

Assisted-by: multiple AI agents and layers of automated tooling 🤖

@tobiasmelcher tobiasmelcher left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks a lot Lars

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

   861 files  ±0     861 suites  ±0   49m 51s ⏱️ -32s
 8 337 tests +1   8 094 ✅ +1  243 💤 ±0  0 ❌ ±0 
20 880 runs  +3  20 210 ✅ +3  670 💤 ±0  0 ❌ ±0 

Results for commit 18ad633. ± Comparison against base commit a6b4946.

@tobiasmelcher
tobiasmelcher merged commit 06d1811 into eclipse-platform:master Sep 21, 2026
18 checks passed
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.

2 participants