Search in files and Find do not work with non-Latin characters
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
報告者は、whole-word matching のために検索テキストを \b でラップする箇所を2つ挙げている: org.eclipse.jface.text の FindReplaceDocumentAdapter と org.eclipse.search.core の PatternConstructor.java。それらの pattern を Pattern.UNICODE_CHARACTER_CLASS でコンパイルし、JDK 21+ でも word boundary が Unicode-aware のままになるようにする。Find と Search in files が非ラテンの whole word を引き続き match することを確認する。issue に extra test は指名されていない。
索引モデルが issue の本文から書いたものです。
説明
Problem description
In my Eclipse based product (sorry it is not open source), we found that in particular scenarios (such as "whole word only") Search in files and Find do not work with non-Latin characters with JDK later than v21.
To implement "whole word only", Eclipse code created a regex with the text surrounded by "\b". It is not processed correctly.
We assumed that the problem is in Java SDK and opened a ticket for them, but it was rejected with the following explanation:
The '\b' meta character behaviour has been changed in Semeru 21 or later versions. The change has been implemented because of the below OpenJDK issue.
OpenJDK Issue and Java 19 Release Note:
-----------------------------------------------------
[https://bugs.openjdk.org/browse/JDK-8282129](https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.openjdk.org_browse_JDK-2D8282129&d=DwQCaQ&c=BSDicqBQBDjDI9RkVyTcHQ&r=fhaoxtVu0e-iwX8nTZK86CwLEQtEiHmql8Am2TrpEK0&m=H0KLuEUYnT2W6zyi-I9erLSamgGyMUIx8jd872LgBl6Fxu5TvjUErd3pRBZT9FfQ&s=xW2STSDLKBbXNKOOMdqIGA3uJTJVGYmyVnhEDKEZxWU&e=)
[https://www.oracle.com/java/technologies/javase/19-relnote-issues.html#JDK-8264160](https://urldefense.proofpoint.com/v2/url?u=https-3A__www.oracle.com_java_technologies_javase_19-2Drelnote-2Dissues.html-23JDK-2D8264160&d=DwQCaQ&c=BSDicqBQBDjDI9RkVyTcHQ&r=fhaoxtVu0e-iwX8nTZK86CwLEQtEiHmql8Am2TrpEK0&m=H0KLuEUYnT2W6zyi-I9erLSamgGyMUIx8jd872LgBl6Fxu5TvjUErd3pRBZT9FfQ&s=9YDXr169fPzu3GN1s9KGaGhBBJXFuabt2Pq5jceny18&e=)
In Semeru 18 or earlier version, The \b was by default unicode aware. So it was able to process the Hebrew characters successfully.
However in Semeru 21 or later version, the \b meta character matches ASCII word characters by default. To match Hebrew string, the UNICODE_CHARACTER_CLASS must be set because it contains unicode characters.
How to set UNICODE_CHARACTER_CLASS ?
-----------------------------------------------------------------
Pattern pattern = Pattern.compile(findString, Pattern.UNICODE_CHARACTER_CLASS);
Reason behind the change:
------------------------------------------
In Semeru 18 or earlier versions, the \b (word boundary) behaviour was inconsistent with \w (word character) behaviour. The \w (word character) matches [a-zA-Z_0-9] in the absence of UNICODE_CHARACTER_CLASS being set. However the \b relies on j.l.Character.isLetterOrDigit along with a check for underscores and isLetterOrDigit method matches some unicode characters in addition to the range specified by \w (word character). However when UNICODE_CHARACTER_CLASS is set, the character range of both \w and \b is consistent.
In Semeru 21 or higher version, the \b and \w behaviour will be consistent whether UNICODE_CHARACTER_CLASS is set or not. The \b matcher is now uses ASCII_WORD() predicate in java.util.regex.CharPredicates to get the same range of characters as \w for determining word boundaries.
I am aware about two files where the change is required: FindReplaceDocumentAdapter class of org.eclipse.jface.text and PatternConstructor.java of org.eclipse.search.core.
Please set UNICODE_CHARACTER_CLASS there.
AFAIK there are no side effects for the change.
Tested under this environment:
- OS & version: Windows 11
- Eclipse IDE/Platform version (as shown in Help > About): Version: 2024-03 (4.31.0)
Community
- I understand reporting an issue to this OSS project does not mandate anyone to fix it. Other contributors may consider the issue, or not, at their own convenience. The most efficient way to get it fixed is that I fix it myself and contribute it back as a good quality patch to the project.
- 主要言語
- Java
- スター
- 124
- フォーク
- 269
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 63
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
eclipse-platform/eclipse.platform.ui のほかの issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
eclipse-platform/eclipse.platform.ui#4125 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
eclipse-platform/eclipse.platform.ui#4016 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
eclipse-platform/eclipse.platform.ui#2687 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Default background color changed for "welcome" area content対応中かも @vogella が今日担当しました。 オープンbug regression
難易度 2/5 1〜3時間 初心者へのやさしさ 53/100
eclipse-platform/eclipse.platform.ui#4484 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 半日 初心者へのやさしさ 55/100
eclipse-platform/eclipse.platform.ui#4471 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
eclipse-platform/eclipse.platform.ui の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
apache/rocketmq-dashboard#6610 ·
メンテナーはふだん 3 日以内に返信
-
`RedisList.reversed()` view returns an empty `range` and `trim` removes all elements対応中かも @CCCLL が今日担当しました。 オープンstatus: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
spring-projects/spring-data-redis#3461 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
javapathfinder/jpf-core#649 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
devops-thiago/ThrillhouseBot#1093 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
wimdeblauwe/htmx-spring-boot#205 ·