Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 180973 - [linked mode] Linked mode does not work with Unicode escapes
Summary: [linked mode] Linked mode does not work with Unicode escapes
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.5 M2   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 429221 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-04-04 11:27 EDT by Markus Keller CLA
Modified: 2014-09-15 19:52 EDT (History)
3 users (show)

See Also:
daniel_megert: review+


Attachments
Fix (6.90 KB, patch)
2014-09-11 10:54 EDT, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2007-04-04 11:27:31 EDT
HEAD

Linked mode does not work with Unicode escapes. E.g try the 'Rename in file' quick fix or the Rename refactoring (in lightweight mode) on 'B' here:

public class B {
	public static \u0042 newInstance() {
		return new \u0042();
	}
}

LinkedPositionGroup throws an exception because 'B' and '\u0042' don't have the same length and are considered to be different.

org.eclipse.jface.text.BadLocationException: First position: 'B' at 25, this position: '\u0042' at 45
at org.eclipse.jface.text.link.LinkedPositionGroup.enforceEqualContent(LinkedPositionGroup.java:130)
at org.eclipse.jface.text.link.LinkedPositionGroup.addPosition(LinkedPositionGroup.java:111)
at org.eclipse.jdt.internal.ui.text.correction.LinkedNamesAssistProposal.apply(LinkedNamesAssistProposal.java:127)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:806)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertSelectedProposalWithMask(CompletionProposalPopup.java:757)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:1164)
at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:786)
at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:460)
at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:60)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:947)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:706)
at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5047)
at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:4795)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:947)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:975)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:971)
at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1285)
at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3762)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3662)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4342)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2226)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3282)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2361)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2325)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:101)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:152)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:359)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:476)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:416)
at org.eclipse.equinox.launcher.Main.run(Main.java:1141)
at org.eclipse.equinox.launcher.Main.main(Main.java:1116)
Comment 1 Markus Keller CLA 2014-09-11 10:54:10 EDT
Created attachment 246962 [details]
Fix
Comment 2 Markus Keller CLA 2014-09-11 11:00:19 EDT
I don't think it's the link mode's job to ensure all positions have "equal" content. If an API client has a better understanding of "equal", then we should not block it. This patch also fixes bug 429221.

Dani, is this OK for you?

We could increase the version of org.eclipse.text to 3.6 to account for the externally visible behavior change, but OTOH, I don't think anybody should have relied on the BadLocationException that is no longer thrown.
Comment 3 Markus Keller CLA 2014-09-11 11:09:58 EDT
*** Bug 429221 has been marked as a duplicate of this bug. ***
Comment 4 Dani Megert CLA 2014-09-15 07:44:02 EDT
(In reply to Markus Keller from comment #2)
> I don't think it's the link mode's job to ensure all positions have "equal"
> content. If an API client has a better understanding of "equal", then we
> should not block it. This patch also fixes bug 429221.
> 
> Dani, is this OK for you?

Yes, with the changes to the Javadoc that we just discussed.


> We could increase the version of org.eclipse.text to 3.6 to account for the
> externally visible behavior change, but OTOH, I don't think anybody should
> have relied on the BadLocationException that is no longer thrown.

I agree.