Bug 78746 - [Contributions] [JFace] Compiler error message containing '& ' is rendered with '_' in status line
Summary: [Contributions] [JFace] Compiler error message containing '& ' is rendered wi...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M5   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 107585 169281 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-11-16 11:50 EST by Markus Keller CLA
Modified: 2008-02-05 10:15 EST (History)
7 users (show)

See Also:


Attachments
StatusLine v01 (1.05 KB, patch)
2008-01-07 11:05 EST, Paul Webster 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 2004-11-16 11:50:06 EST
I200411111200 + jdt.core and ui from HEAD:

In a java editor:
interface I {
    static void m(/*caret_here*/);
}

The compiler message is "Illegal modifier for the interface method m in type I;
only public & abstract are permitted". In the workbench window status line, '& '
is rendered as '_' (a mnemonic Alt+Space ?-).

The spec for IStatusLineManager#set*Message(..) doesn't mention this behavior.
Solving bug 2135 would probably solve this problem, too.
Comment 1 Dani Megert CLA 2004-11-16 12:07:27 EST
Status line for messages comes from Platform UI. AFAIK the & handling is native
behavior and hence the only solution is to fix bug 2135.
Comment 2 Dani Megert CLA 2004-11-16 12:21:54 EST
Or maybe patching the string before being set if the same API applies as in
Label.setText(String).
Comment 3 Markus Keller CLA 2006-08-15 13:43:41 EDT
Another gem is the compiler warning for
    Arrays.asList(1, "X");

Status line says:
    Type safety : A generic array of ObjectComparable<?>Serializable is created
    for a varargs parameter

... and the S of Serializable is underlined. What the heck is ObjectComparable?
Comment 4 Dani Megert CLA 2006-08-16 02:59:00 EDT
I see the problem and I think it needs to be addressed.

Another question is whether it is a good idea to use '&' in problem messages. In my opinion the message reads badly even without this bug. Maybe worth a bug report against JDT Core. Markus?


Susan,
can you look at this bug (or better: bug 2135)?

Thanks
Dani
Comment 5 Markus Keller CLA 2006-08-16 04:54:15 EDT
The bug for jdt.core is bug 154029.
Comment 6 Susan McCourt CLA 2006-08-17 12:54:42 EDT
In my opinion the error messages shouldn't use the mnemonic character.  The word "and" should be used.  If there is a legitimate case of needing to communicate the ampersand character in the message, then I'd be willing to bump up the priority in this bug. Is there such a case that we know about?
Comment 7 Markus Keller CLA 2006-08-17 13:35:06 EDT
IMO, the workbench should not try to impose a restricted character set on clients of the status line. We cannot rule out that there are (human- | programming-) languages where & is a perfectly valid and common character.

In the case of "...only public & abstract...", I agree that "and" would be better style. But in the case of "Object & Comparable<?> & Serializable", there's no way to avoid &, since the & character is the standard way how type intersections are expressed in Java 5.0.
Comment 8 Susan McCourt CLA 2006-08-17 14:04:30 EDT
Thanks for the example of type intersections, that is what I needed to understand.

I'll mark this to be looked at during 3.3, keeping bug #2135 (using a read only text) in mind.  One thing I want to do in 3.3 is clean up all the different error message area implementations in the dialog framework, and it's possible we could use the outcome of this to show the compiler errors.  (See bug #148085)
Comment 9 Paul Webster CLA 2007-01-02 19:11:28 EST
*** Bug 169281 has been marked as a duplicate of this bug. ***
Comment 10 Susan McCourt CLA 2007-05-01 19:13:47 EDT
moving this to SWT for the future.  
CLabel hardcodes the text draw flags to include SWT.DRAW_MNEMONIC.  This should be opened up to clients, since there are times when the label should not include a mnemonic.  I don't think it's appropriate for JFace to render the label itself to work around this problem.
Comment 11 Steve Northover CLA 2007-05-18 09:29:33 EDT
We could add this API, but it would be inconsist with the way native controls handle it.  To get a &, you double them (&&).
Comment 12 Dani Megert CLA 2007-05-18 09:36:40 EDT
OK, but then the bug should be moved back to Platform UI to escape &.
Comment 13 Markus Keller CLA 2007-12-02 19:06:27 EST
> OK, but then the bug should be moved back to Platform UI to escape &.

Yes, back to Plat/UI. Filed bug 211696 for SWT to specify CLabel#setText(..).
Comment 14 Markus Keller CLA 2007-12-02 19:10:34 EST
*** Bug 107585 has been marked as a duplicate of this bug. ***
Comment 15 Markus Keller CLA 2007-12-02 19:27:59 EST
This should be fixed for 3.4, since
org.eclipse.jface.action.StatusLineContributionItem became API with bug 102616.
Comment 16 Dani Megert CLA 2007-12-03 05:06:25 EST
Note that setToolTipText(String) has the same problem.
Comment 17 Paul Webster CLA 2007-12-03 09:46:37 EST
I've escaped any incoming & to && in StatusLineContributionItem

PW
Comment 18 Paul Webster CLA 2007-12-11 12:09:11 EST
In I20071211-0010
PW
Comment 19 Markus Keller CLA 2008-01-04 05:42:04 EST
Not verified/fixed in M4.
Looks like the fix also needs to go into org.eclipse.jface.action.StatusLine.
Comment 20 Paul Webster CLA 2008-01-07 11:05:17 EST
Created attachment 86318 [details]
StatusLine v01

Fix for StatusLine:
Arrays.asList(1, "X");

PW
Comment 21 Paul Webster CLA 2008-01-07 11:06:48 EST
Released >20080107
PW
Comment 22 Paul Webster CLA 2008-02-05 10:15:00 EST
In I20080205-0010
PW