Skip to content

Conversation

@vogella
Copy link
Contributor

@vogella vogella commented Nov 14, 2025

possible

In #3517 we discuss which automatic clean-ups we should add. This is the result of a manual run in eclipse-platform.ui to see if this clean-up has issues. Also by running it manually before enabling the clean-ups we avoid creating PR per bundle.

@laeubi
Copy link
Contributor

laeubi commented Nov 14, 2025

So do you see any issues with that or not?

@vogella
Copy link
Contributor Author

vogella commented Nov 14, 2025

@jjohnstn I think the change in AbstractTemplatePage are incorrect:


// Before (CORRECT):
pattern.replaceAll("\$", "\$\$")

// After (INCORRECT):
pattern.replace("$", "$$")

Problem: The original code was escaping $ for regex replacement strings, not for regex patterns. In replaceAll(), the replacement string has special meaning for $ (backreferences like $1, $2). To insert a literal $,
you need \$\$ (which becomes $$ after Java string escaping).

However, String.replace() doesn't interpret $ specially in the replacement string. So while $$ will insert two literal dollar signs, the original intent was to escape one dollar sign for template syntax.

Impact: This changes behavior - templates with $ will now have $$ instead of being properly escaped for the template engine.


If you agree, I can open an issue in JDT UI

@vogella
Copy link
Contributor Author

vogella commented Nov 14, 2025

Converting to draft so that this is not merged.

@merks
Copy link
Contributor

merks commented Nov 14, 2025

I'm a big confused....

This method

	public static void main(String[] args) {
		for (var pattern : List.of("$", "$$", "${}")) {
			System.err.println(pattern.replaceAll("\\$", "\\$\\$"));
			System.err.println(pattern.replace("$", "$$"));
			System.err.println();
		}
	}

prints this result

$$
$$

$$$$
$$$$

$${}
$${}

So I'm tying to imagine a string for which they would print out two different results...

@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 2025

Test Results

 3 018 files  ±0   3 018 suites  ±0   2h 26m 31s ⏱️ + 14m 53s
 8 248 tests ±0   8 000 ✅ ±0  248 💤 ±0  0 ❌ ±0 
23 664 runs  ±0  22 873 ✅ ±0  791 💤 ±0  0 ❌ ±0 

Results for commit c50c69d. ± Comparison against base commit 60a8a9c.

♻️ This comment has been updated with latest results.

@vogella
Copy link
Contributor Author

vogella commented Nov 14, 2025

I'm a big confused....

This method

	public static void main(String[] args) {
		for (var pattern : List.of("$", "$$", "${}")) {
			System.err.println(pattern.replaceAll("\\$", "\\$\\$"));
			System.err.println(pattern.replace("$", "$$"));
			System.err.println();
		}
	}

prints this result

$$
$$

$$$$
$$$$

$${}
$${}

So I'm tying to imagine a string for which they would print out two different results...

You're absolutely right to be confused - I made an error! Let me verify this myself:

import java.util.List;

    public class TestStringReplace {
        public static void main(String[] args) {
            System.out.println("Testing different patterns:");
            for (var pattern : List.of("$", "$$", "${}", "$1", "test$middle", "$start", "end$")) {
                String replaceAllResult = pattern.replaceAll("\\$", "\\$\\$");
                String replaceResult = pattern.replace("$", "$$");
                System.out.println("Input: '" + pattern + "'");
                System.out.println("  replaceAll: '" + replaceAllResult + "'");
                System.out.println("  replace:    '" + replaceResult + "'");
                System.out.println("  Same? " + replaceAllResult.equals(replaceResult));
                System.out.println();
            }
        }
    }

I was wrong. @jjohnstn please ignore my request.

I would still wait this converting this to a real PR again, as IMHO we should not apply such clean-ups shortly before a release.

@vogella vogella force-pushed the string-replace-cleanup branch from 23a1e0d to c9bf7e6 Compare November 14, 2025 19:19
@vogella vogella marked this pull request as ready for review December 12, 2025 08:50
@vogella vogella force-pushed the string-replace-cleanup branch from c9bf7e6 to 66111b0 Compare December 17, 2025 09:52
@eclipse-platform-bot
Copy link
Contributor

eclipse-platform-bot commented Dec 17, 2025

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

tests/org.eclipse.tests.urischeme/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 d568441e59272e73dcca388fce84011a84dea586 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <platform-bot@eclipse.org>
Date: Wed, 17 Dec 2025 15:50:10 +0000
Subject: [PATCH] Version bump(s) for 4.39 stream


diff --git a/tests/org.eclipse.tests.urischeme/META-INF/MANIFEST.MF b/tests/org.eclipse.tests.urischeme/META-INF/MANIFEST.MF
index 8bcb74a983..c73fabb94e 100644
--- a/tests/org.eclipse.tests.urischeme/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.tests.urischeme/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
 Bundle-Name: %Plugin.name
 Bundle-Vendor: %Plugin.Providername
 Bundle-SymbolicName: org.eclipse.tests.urischeme
-Bundle-Version: 1.2.700.qualifier
+Bundle-Version: 1.2.800.qualifier
 Bundle-Localization: plugin
 Fragment-Host: org.eclipse.urischeme;bundle-version="1.1.100"
 Import-Package: org.junit.jupiter.api;version="[5.14.0,6.0.0)",
-- 
2.52.0

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

@akurtakov
Copy link
Member

Please wait for #3594 to land as it was quite a work and I would appreciate less conflicts in it.

@vogella vogella force-pushed the string-replace-cleanup branch from 73d4851 to 66111b0 Compare December 17, 2025 15:44
possible

In eclipse-platform#3517
we discuss which automatic clean-ups we should add. This is the result
of a manual run in eclipse-platform.ui to see if this clean-up has
issues. Also by running it manually before enabling the clean-ups we
avoid creating PR per bundle.
@vogella vogella force-pushed the string-replace-cleanup branch from 66111b0 to b5241de Compare December 17, 2025 15:45
@vogella vogella merged commit 5fe841f into eclipse-platform:master Dec 18, 2025
18 checks passed
@vogella vogella deleted the string-replace-cleanup branch December 18, 2025 08:13
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.

5 participants