Skip to content

Fix TargetPlatformPresentationReconciler: stop scanning past damage end#2284

Open
vogella wants to merge 2 commits intoeclipse-pde:masterfrom
vogella:full-qualified-access
Open

Fix TargetPlatformPresentationReconciler: stop scanning past damage end#2284
vogella wants to merge 2 commits intoeclipse-pde:masterfrom
vogella:full-qualified-access

Conversation

@vogella
Copy link
Copy Markdown
Contributor

@vogella vogella commented Apr 6, 2026

Summary

Fixes #2283 (also related to eclipse-platform/eclipse.platform.ui#2276).

TargetPlatformPresentationReconciler.createPresentation() overrides the default
PresentationReconciler behaviour to always scan from offset 0. This is
necessary to correctly handle multi-line XML comment rules (<!-- ... -->):
without the full context from the start of the document, a comment that opened
before the damaged region would not be recognised.

However, the scan was running all the way to document.getLength() even though
the TextPresentation returned is constructed with the damage region as its
extent — meaning any style ranges added for content after the damage end are
silently discarded. This results in O(document length) work on the UI thread
for every keystroke, causing noticeable freezes in large .target files.

Changes

  • TargetPlatformPresentationReconciler — change the upper bound of
    TextUtilities.computePartitioning() from document.getLength() to
    damage.getOffset() + damage.getLength(). Scanning still starts at offset 0
    (multi-line rule correctness is preserved); it just stops where it would have
    discarded results anyway.

  • MANIFEST.MF (genericeditor.extension) — declare
    org.eclipse.pde.genericeditor.extension.tests as a friend of the
    reconciler.presentation package so the new tests can subclass the reconciler.

  • TargetPlatformPresentationReconcilerTest — new test class covering:

    • simple document, full damage
    • damage covering only the end of the document
    • multi-line comment before the damage region
    • damage region inside a multi-line comment

Known limitation

For edits very close to the end of a large file the gain is small (the damage
end ≈ the document end). A more thorough fix — e.g. caching scanner state
between edits, using a real IDocumentPartitioner for comments, or moving
reconciliation off the UI thread — is left for a follow-up.

Test plan

  • Compiles cleanly (mvn clean compile on the two affected bundles)
  • TargetPlatformPresentationReconcilerTest passes in a running Eclipse test environment
  • All existing AllTargetEditorTests continue to pass

🤖 Generated with Claude Code

@eclipse-pde-bot
Copy link
Copy Markdown
Contributor

eclipse-pde-bot commented Apr 6, 2026

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

ui/org.eclipse.pde.genericeditor.extension.tests/META-INF/MANIFEST.MF
ui/org.eclipse.pde.genericeditor.extension.tests/pom.xml

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From 0fa2556683520335d6b82feebcfa16423c685d74 Mon Sep 17 00:00:00 2001
From: Eclipse PDE Bot <pde-bot@eclipse.org>
Date: Mon, 6 Apr 2026 10:58:02 +0000
Subject: [PATCH] Version bump(s) for 4.40 stream


diff --git a/ui/org.eclipse.pde.genericeditor.extension.tests/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.genericeditor.extension.tests/META-INF/MANIFEST.MF
index 035112ee37..e40d9d7d57 100644
--- a/ui/org.eclipse.pde.genericeditor.extension.tests/META-INF/MANIFEST.MF
+++ b/ui/org.eclipse.pde.genericeditor.extension.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: Tests for Generic Target Platform Editor
 Bundle-SymbolicName: org.eclipse.pde.genericeditor.extension.tests
-Bundle-Version: 1.3.200.qualifier
+Bundle-Version: 1.3.300.qualifier
 Bundle-Vendor: Eclipse.org
 Bundle-RequiredExecutionEnvironment: JavaSE-21
 Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
diff --git a/ui/org.eclipse.pde.genericeditor.extension.tests/pom.xml b/ui/org.eclipse.pde.genericeditor.extension.tests/pom.xml
index 8b3cafceec..4f98690f41 100644
--- a/ui/org.eclipse.pde.genericeditor.extension.tests/pom.xml
+++ b/ui/org.eclipse.pde.genericeditor.extension.tests/pom.xml
@@ -18,7 +18,7 @@
     <relativePath>../../</relativePath>
   </parent>
   <artifactId>org.eclipse.pde.genericeditor.extension.tests</artifactId>
-  <version>1.3.200-SNAPSHOT</version>
+  <version>1.3.300-SNAPSHOT</version>
   <packaging>eclipse-test-plugin</packaging>
 
   <properties>
-- 
2.53.0

Further information are available in Common Build Issues - Missing version increments.

@vogella vogella force-pushed the full-qualified-access branch from ad4c2fd to e08d95d Compare April 6, 2026 10:55
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

Test Results

  150 files  + 3    150 suites  +3   37m 51s ⏱️ + 1m 36s
3 501 tests + 4  3 447 ✅ + 4   54 💤 ±0  0 ❌ ±0 
9 324 runs  +12  9 194 ✅ +12  130 💤 ±0  0 ❌ ±0 

Results for commit c91f39e. ± Comparison against base commit 1aece37.

♻️ This comment has been updated with latest results.

vogella and others added 2 commits April 6, 2026 21:26
The reconciler always scanned the full document (offset 0 to
document.getLength()) on every keystroke to ensure multi-line XML
comment rules are honoured. While scanning from offset 0 is required
for correctness, scanning *past* the damage end is wasted work because
the returned TextPresentation is bounded by the damage region and
silently discards any style ranges beyond it.

Change the upper bound of TextUtilities.computePartitioning() from
document.getLength() to damage.getOffset() + damage.getLength(). This
avoids scanning content whose results would be thrown away, while
preserving the full-context scan from offset 0 that multi-line rules
require.

Add TargetPlatformPresentationReconcilerTest to verify correctness for
the common cases: simple documents, partial damage regions, multi-line
comments before the damage, and damage inside a multi-line comment.

Fixes: eclipse-pde#2283

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vogella vogella force-pushed the full-qualified-access branch from 30a7061 to c91f39e Compare April 6, 2026 19:26
@vogella vogella marked this pull request as ready for review April 8, 2026 07:25
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.

PDE Reconciler slow and blocking the UI

2 participants