Bug 345377

Summary: [syntax highlighting] provide distinct coloring for string delimiters
Product: [Eclipse Project] JDT Reporter: Florian Lasinger <florian>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P3 CC: daniel_megert, deepakazad, markus.kell.r, sebastian.zarnekow
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Florian Lasinger CLA 2011-05-11 04:43:39 EDT
Build Identifier: 20110301-1815

String literals can be syntax colored in Eclipse, but the enclosing quotes will always have the same color as the string itself.

This can become very hard to read if you output large amounts of quotes. A reason to do so could be generating javascript funtions.

Simple example
String cmd = "alert(\"" + msg + "\")"


Reproducible: Always
Comment 1 Sebastian Zarnekow CLA 2011-05-11 05:17:13 EDT
I think it would be interesting to highlight escape sequences in strings, too.
Comment 2 Florian Lasinger CLA 2011-05-11 05:44:27 EDT
Absolutely!
Comment 3 Markus Keller CLA 2011-05-11 09:46:36 EDT
> I think it would be interesting to highlight escape sequences in strings, too.

Bug 106721 is the same request for the Java Properties File editor.

If we color the escaped characters, I think the start/end quotes can stay as they are. We have to see whether we also want to color the \ and \u etc.:
- Pro: In "Hall\u00F6le", the whole \uHHHH can be identified as an escape
- Con: In "\\\\\\\n", everything becomes colored and you can't easily count the real backslashes.
Comment 4 Sebastian Zarnekow CLA 2011-05-11 09:50:01 EDT
(In reply to comment #3)
> Bug 106721 is the same request for the Java Properties File editor.
> 
> If we color the escaped characters, I think the start/end quotes can stay as
> they are. We have to see whether we also want to color the \ and \u etc.:
> - Pro: In "Hall\u00F6le", the whole \uHHHH can be identified as an escape
> - Con: In "\\\\\\\n", everything becomes colored and you can't easily count the
> real backslashes.

A hover that shows the actual string value could be helpful.
Comment 5 Deepak Azad CLA 2011-05-11 09:58:53 EDT
(In reply to comment #4)
> A hover that shows the actual string value could be helpful.
We already have this support in Properties file editor, and should add it to the Java editor as well.

(In reply to comment #3)
> If we color the escaped characters, I think the start/end quotes can stay as
> they are. 
Agree

> - Con: In "\\\\\\\n", everything becomes colored and you can't easily count the
> real backslashes.
How often do we have so many backslasehs? In any case, the hover with the real string should help here.
Comment 6 Florian Lasinger CLA 2011-05-11 10:36:40 EDT
> If we color the escaped characters, I think the start/end quotes can stay as
> they are. 

There may be use cases with single quotes or other characters but without escape sequences where reading of strigs could be simplified. Usually the user knows best.

I don't know how much effort this would be to implement and maintain, but at least having the option would be highly welcome. It can be off by default.