Bug 308147 - [BiDi] DBCS3.6: Fail to open rename refactoring popup when renaming Ext-B variants (surrogates)
Summary: [BiDi] DBCS3.6: Fail to open rename refactoring popup when renaming Ext-B var...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.6 M7   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 308356
Blocks:
  Show dependency tree
 
Reported: 2010-04-06 01:19 EDT by Masaihko Maedera CLA
Modified: 2010-04-30 00:54 EDT (History)
6 users (show)

See Also:


Attachments
bug308147.zip, a Java Project with screen shots. (20.25 KB, application/x-zip-compressed)
2010-04-06 01:26 EDT, Masaihko Maedera CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Masaihko Maedera CLA 2010-04-06 01:19:21 EDT
Build Identifier: I20100330-0800

OS:Windows 7
JRE:IBM JRE 1.6
Locale:Japanese

When renaming variants that contain Ext-B characters with Alt+Shift+R,
Java Editor does not open a hover help that shows more details.

Reproducible: Always

Steps to Reproduce:
1.Import bugXXXX.zip attached to this bug report, which is a Java project. 
2.See screenshot1.png and screenshot2.png
3.Move the cursot on str\u53f1 and press Alt+Shift+R, it is correct.
4.Move the cursot on str\ud842\udf9f and press Alt+Shift+R, it is wrong.
Comment 1 Masaihko Maedera CLA 2010-04-06 01:26:04 EDT
Created attachment 163858 [details]
bug308147.zip, a Java Project with screen shots.
Comment 2 Markus Keller CLA 2010-04-06 10:34:37 EDT
To reproduce, the project encoding must be set to UTF-8.

The problem is that codeSelect(..) doesn't work for the second local variable. The AST is fine in this case.

The missing popup is because we fall back to the 'Rename in File' quick assist in that case (which is sometimes useful when the code is not compiling but should be used here).
Comment 3 Olivier Thomann CLA 2010-04-07 11:55:30 EDT
(In reply to comment #2)
> The problem is that codeSelect(..) doesn't work for the second local variable.
> The AST is fine in this case.
I think the problem comes from the region computation. On the second local variable the region length is 3 and not 4 even if the variable name has 4 characters.
In org.eclipse.jface.text.TextViewerHoverManager#computeInformation()
	final IRegion region= hover.getHoverRegion(fTextViewer, offset);

The region is computed using:
Character.isJavaIdentifierPart(c) to find out if the next character should be included in the region.
This is not that simple when Unicode 4 is involved. This is exactly the case here.
\ud842\udf9f is a high surrogate followed by a low surrogate.
If the first character is within 0xd800 and 0xdbff, then the second part must be within 0xdc00 and 0xdfff.
You can see the way we read the next character in:
org.eclipse.jdt.internal.compiler.parser.Scanner.getNextCharAsJavaIdentifierPart()

We might have a bug in codeSelect(..), but the region's length must be fixed first.
Moving back to JDT/UI for comment.
Comment 4 Markus Keller CLA 2010-04-07 13:14:35 EDT
The fix for bug 308356 solves the steps in comment 0. But the Javadoc hover is still broken for such variables, since the JavaWordFinder does not consider supplementary characters.

Since support for code points has only been added in Java 1.5, the fix needs to implement this manually (like the Scanner in JDT Core).
Comment 5 Markus Keller CLA 2010-04-09 08:55:03 EDT
Original problem is fixed in HEAD, see bug 308612 for the hover.
Comment 6 Masaihko Maedera CLA 2010-04-30 00:54:32 EDT
I verified that this bug is fixed on I20100426-0852.