Skip to content

Add tracing to org.eclipse.text text stores#3801

Open
trancexpress wants to merge 2 commits intoeclipse-platform:masterfrom
trancexpress:gh3800
Open

Add tracing to org.eclipse.text text stores#3801
trancexpress wants to merge 2 commits intoeclipse-platform:masterfrom
trancexpress:gh3800

Conversation

@trancexpress
Copy link
Contributor

Fixes: #3800

@trancexpress
Copy link
Contributor Author

The debug options in org.eclipse.text so far are:

src/org/eclipse/jface/text/AbstractDocument.java:       private static final boolean DEBUG= false;
src/org/eclipse/jface/text/AbstractDocument.java:               if (DEBUG) {
src/org/eclipse/jface/text/AbstractDocument.java:                       if (DEBUG) {
src/org/eclipse/jface/text/AbstractDocument.java:                       if (DEBUG) {
src/org/eclipse/jface/text/AbstractLineTracker.java:    private static final boolean DEBUG= false;
src/org/eclipse/jface/text/AbstractLineTracker.java:            if (DEBUG) {

Since the plug-in is not a singleton, there is no activator and no options. So we cannot create a regular debug trace.

@trancexpress
Copy link
Contributor Author

The trace messages look like this:

| main | 2026-03-20 11:04:17.176 | org.eclipse.text | GapTextStore.replace() offset=0, length=0
package test1;
public class E1 {
    public void foo( Object o ) {
        String s    = (String)o;
    }
}
| main | 2026-03-20 11:04:17.176 | org.eclipse.text | GapTextStore.replace() offset=97, length=0
 
| main | 2026-03-20 11:04:17.178 | org.eclipse.text | CopyOnWriteTextStore.replace() offset=83, length=4
 
| main | 2026-03-20 11:04:17.178 | org.eclipse.text | GapTextStore.replace() offset=83, length=4
 
| main | 2026-03-20 11:04:17.178 | org.eclipse.text | CopyOnWriteTextStore.replace() offset=62, length=1
| main | 2026-03-20 11:04:17.179 | org.eclipse.text | GapTextStore.replace() offset=62, length=1
| main | 2026-03-20 11:04:17.179 | org.eclipse.text | CopyOnWriteTextStore.replace() offset=53, length=1
| main | 2026-03-20 11:04:17.179 | org.eclipse.text | GapTextStore.replace() offset=53, length=1

The ones from the usual debug tracing look like this:

| main | 2026-03-20 11:04:17.189 | org.eclipse.jdt.core | /debug | org.eclipse.jdt.internal.core.NameLookup | findSecondaryType | 705 | JavaModelManager.secondaryTypes(TestSetupProject,false) |
| main | 2026-03-20 11:04:17.190 | org.eclipse.jdt.core | /debug | org.eclipse.jdt.internal.core.NameLookup | findSecondaryType | 705 | JavaModelManager.secondaryTypes(TestSetupProject,false) |
| main | 2026-03-20 11:04:17.190 | org.eclipse.jdt.core | /debug | org.eclipse.jdt.internal.core.NameLookup | findSecondaryType | 705 | JavaModelManager.secondaryTypes(TestSetupProject,false) |

@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2026

Test Results

   852 files  ±0     852 suites  ±0   54m 49s ⏱️ +22s
 7 864 tests ±0   7 621 ✅ ±0  243 💤 ±0  0 ❌ ±0 
20 118 runs  ±0  19 462 ✅ ±0  656 💤 ±0  0 ❌ ±0 

Results for commit e8edc21. ± Comparison against base commit db33b10.

♻️ This comment has been updated with latest results.

@laeubi
Copy link
Contributor

laeubi commented Mar 20, 2026

@trancexpress in general there is no need to create an Issue and then a PR with only "fixes" as it create only much notifications.

So unless you just want to document a problem (that other maybe work on) just create a PR with a meaningful title and description also for the commit message so it is clear why it is changed (the what is visible from the git diff already). This way one don't really need to lookup the issue first to understand what a PR does, you have less clicks and people who watch the repository has less mails to read.

Copy link
Contributor

@laeubi laeubi left a comment

Choose a reason for hiding this comment

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

Since the plug-in is not a singleton, there is no activator and no options.

This is completely unrelated. Any Bundle can have an Activator and if there is none but you need it (e.g. for tracing) then please do so instead of inventing an own Tracing facility (what then lacks configuration through UI and a like).

Also an Activator is not the only way to get hold of the tracing so if you need help let us know but platform already contains a lot of examples how tracing can be used.

@trancexpress trancexpress force-pushed the gh3800 branch 2 times, most recently from 47959e7 to 7b92501 Compare March 20, 2026 10:40
@trancexpress
Copy link
Contributor Author

This is completely unrelated. Any Bundle can have an Activator and if there is none but you need it (e.g. for tracing) then please do so instead of inventing an own Tracing facility (what then lacks configuration through UI and a like).

Ah, thank you for the hint!

Can you check the change now? I'm not sure about the MANIFEST.MF changes.

Also are there some examples in platform how to set debug tracing options per preferences? I keep forgetting how that works...

@trancexpress
Copy link
Contributor Author

trancexpress commented Mar 20, 2026

I wonder if we should also adjust these:

src/org/eclipse/jface/text/AbstractDocument.java:       private static final boolean DEBUG= false;
src/org/eclipse/jface/text/AbstractDocument.java:               if (DEBUG) {
src/org/eclipse/jface/text/AbstractDocument.java:                       if (DEBUG) {
src/org/eclipse/jface/text/AbstractDocument.java:                       if (DEBUG) {
src/org/eclipse/jface/text/AbstractLineTracker.java:    private static final boolean DEBUG= false;
src/org/eclipse/jface/text/AbstractLineTracker.java:            if (DEBUG) {

Now that there is proper tracing...

The @since tag does bother me, the code is not in an internal package:

	/**
	 * Tells whether this class is in debug mode.
	 *
	 * @since 3.1
	 */
	private static final boolean DEBUG= false;

Still, changing static final fields per reflection is not simple in newer Java versions. Maybe we just replace them?

@laeubi
Copy link
Contributor

laeubi commented Mar 20, 2026

In the Run config there is a "tracing" tab and inside the IDE you can go to Window>Preferences>General>Tracing

@trancexpress
Copy link
Contributor Author

In the Run config there is a "tracing" tab and inside the IDE you can go to Window>Preferences>General>Tracing

I meant programmatically, ftom a test.

org.eclipse.jface.text.templates; text="split"; mandatory:="text",
org.eclipse.text.edits,
org.eclipse.text.html,
org.eclipse.text.internal,
Copy link
Contributor

Choose a reason for hiding this comment

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

You should not export this package and that's likely why you get warnings with since tag. The name does not matter this is now public API!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@laeubi please advise how to avoid the export of the package. Or, I've changed it to have the internal attribute, is this enough?

I need to enable the debug option in: org.eclipse.jdt.ui.tests.quickfix.SaveParticipantTest.setUp()

E.g. JDT verbose mode is enabled like this:

	@Override
	public void setUp() throws Exception {
		...
		JavaModelManager.VERBOSE = true;

@laeubi
Copy link
Contributor

laeubi commented Mar 20, 2026

In the Run config there is a "tracing" tab and inside the IDE you can go to Window>Preferences>General>Tracing

I meant programmatically, ftom a test.

You mean only during the execution of one test method? Apart from that test of course can also be executed with tracing (in the UI and Tycho).

Apart from that you can modify it at runtime with the DebugOptions setDebugEnabled / setOption

@laeubi
Copy link
Contributor

laeubi commented Mar 20, 2026

I wonder if we should also adjust these

If we can use proper tracing why not...

@trancexpress
Copy link
Contributor Author

trancexpress commented Mar 20, 2026

Apart from that you can modify it at runtime with the DebugOptions setDebugEnabled / setOption

How do I get to the DebugOptions of TextPlugin though? I can extend org.eclipse.core.runtime.Plugin, but the plug-in is still not a singleton. I cant access the class if the package is not exported either, to call org.osgi.framework.FrameworkUtil.getBundle(Class<?>).

I'm still not sure how to enable debug in org.eclipse.jdt.ui.tests.quickfix.SaveParticipantTest.setUp(), when the package is not exported.

With the exported package, all I need in the test is: TextPlugin.DEBUG = true;

This change adds an activator to org.eclipse.text,
as well as debug tracing to set/replace methods in
CopyOnWriteTextStore and GapTextStore.

Fixes: eclipse-platform#3800
@eclipse-platform-bot
Copy link
Contributor

eclipse-platform-bot commented Mar 20, 2026

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

bundles/org.eclipse.text/META-INF/MANIFEST.MF

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 5319a8f059b593ace4990b33cb3c8dbd6e27c290 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <platform-bot@eclipse.org>
Date: Sat, 21 Mar 2026 13:13:01 +0000
Subject: [PATCH] Version bump(s) for 4.40 stream


diff --git a/bundles/org.eclipse.text/META-INF/MANIFEST.MF b/bundles/org.eclipse.text/META-INF/MANIFEST.MF
index 96fa400f27..ea963949ec 100644
--- a/bundles/org.eclipse.text/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.text/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.text
-Bundle-Version: 3.14.600.qualifier
+Bundle-Version: 3.14.700.qualifier
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
 Bundle-Activator: org.eclipse.text.internal.TextPlugin
-- 
2.53.0

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

@trancexpress
Copy link
Contributor Author

trancexpress commented Mar 20, 2026

On MacOS a test failed:

org.opentest4j.AssertionFailedError: CleanupAddon should ensure that partStack is not rendered anymore, as all childs have been removed ==> expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
	at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:214)
	at org.eclipse.e4.ui.tests.workbench.PartRenderingEngineTests.ensureCleanUpAddonCleansUp(PartRenderingEngineTests.java:2453)

#3581

On Windows something broke:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:5.0.3-SNAPSHOT:test (default-test) on project org.eclipse.ui.tests.rcp: An unexpected error occurred while launching the test runtime (process returned error code 1 (HRESULT Code 0x1, check for example https://www.hresult.info/ for further details)). The process logfile D:\a\eclipse.platform.ui\eclipse.platform.ui\tests\org.eclipse.ui.tests.rcp\target\work\data\.metadata\.log might contain further details. Command-line used to launch the sub-process was C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\21.0.10-7.0\x64\bin\java.exe -Dosgi.noShutdown=false -Dosgi.os=win32 -Dosgi.ws=win32 -Dosgi.arch=x86_64 --add-modules=ALL-SYSTEM -Dosgi.clean=true -ea -jar C:\Users\runneradmin\.m2\repository\p2\osgi\bundle\org.eclipse.equinox.launcher\1.7.100.v20251111-0406\org.eclipse.equinox.launcher-1.7.100.v20251111-0406.jar -data D:\a\eclipse.platform.ui\eclipse.platform.ui\tests\org.eclipse.ui.tests.rcp\target\work\data -install D:\a\eclipse.platform.ui\eclipse.platform.ui\tests\org.eclipse.ui.tests.rcp\target\work -configuration D:\a\eclipse.platform.ui\eclipse.platform.ui\tests\org.eclipse.ui.tests.rcp\target\work\configuration -application org.eclipse.tycho.surefire.osgibooter.headlesstest -testproperties D:\a\eclipse.platform.ui\eclipse.platform.ui\tests\org.eclipse.ui.tests.rcp\target\surefire.properties in working directory D:\a\eclipse.platform.ui\eclipse.platform.ui\tests\org.eclipse.ui.tests.rcp

@trancexpress trancexpress requested a review from laeubi March 21, 2026 14:08
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.

Add tracing to text stores

3 participants