Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 362337

Summary: Improved CSS syntax highlighting
Product: [ECD] Orion Reporter: Mihai Sucan <mihai.sucan>
Component: EditorAssignee: Mark Macdonald <mamacdon>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe, john.arthorne, mamacdon, mihai.sucan, Silenio_Quarti, simon_kaegi
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Mihai Sucan CLA 2011-10-28 12:06:35 EDT
The CSS syntax highlighter code matches // comments and /* comments */. The former style of comments is invalid in CSS.

This is needed for an upcoming Firefox developer tool, a Style Editor that uses Orion.
Comment 1 Mihai Sucan CLA 2011-10-28 12:09:30 EDT
This is a cross-post from:

https://bugzilla.mozilla.org/show_bug.cgi?id=680465
Comment 2 Simon Kaegi CLA 2011-10-28 14:42:44 EDT
Our basic syntax highlighter should be fixed ASAP but we're also looking at deeper tools here. e.g. validation would be nice...
Comment 3 Felipe Heidrich CLA 2011-10-28 14:54:09 EDT
I think Mark owns the CSS content assist component.

The CSS syntax highlight belongs to SSQ and FH (it is part of examples.textview.TextStyler). Reassigning to SSQ.
 

If Simon is asking to Mark to provide a new CSS syntax highlighter then please reassign this back to Mark.
Comment 4 Mihai Sucan CLA 2011-10-28 15:47:47 EDT
The main focus for this bug should be providing a CSS syntax highlighter that works better.

Would a TextMate grammar work for this? Or is that a performance problem?
Comment 5 Silenio Quarti CLA 2011-11-15 17:18:54 EST
I released a band-aid in the sample styler to stop highlighting single line comments, but the long term solution here is to replace this styler with either a textmate styler or one based in the code mirror modes.
Comment 7 Silenio Quarti CLA 2011-11-15 18:11:23 EST
Found a case where the styler would not highlight a multiline comment. I believe this is what this comment talks about.

https://bugzilla.mozilla.org/show_bug.cgi?id=680465#c0

Steps:

1) Start with an empty file (or type at the end of a file)
2) Type "/*" to start a comment
3) Type ENTER
4) Type some chars

The chars in step 4) should be highlight but are not.

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=be372554f725dcac2fabc46ebd10ea58a063831b
Comment 8 Mihai Sucan CLA 2011-11-16 14:55:23 EST
Silenio: thanks for your fixes!
Comment 9 Felipe Heidrich CLA 2011-12-05 16:40:04 EST
(In reply to comment #8)
> Silenio: thanks for your fixes!

Can we close this bug as fixed or reassign it to Mark (for the new css syntax highlighter) ?
Comment 10 Mihai Sucan CLA 2011-12-06 10:59:08 EST
(In reply to comment #9)
> (In reply to comment #8)
> > Silenio: thanks for your fixes!
> 
> Can we close this bug as fixed or reassign it to Mark (for the new css syntax
> highlighter) ?

I assume reassigning to Mark makes sense. The current fixes are workarounds to get us forward a bit with Orion in Firefox 11 - for which we are grateful - thank you!
Comment 11 Mihai Sucan CLA 2012-01-17 16:28:37 EST
Another stop-gap patch:

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=b318c3a8d5abde2d1c9d2dd2bb0dd16c76a6240d

(until the the new CSS syntax highlighter will become available)

This time we really needed to highlight the majority of known CSS keywords, in the Style Editor we are shipping in Firefox 11. This patch has already landed downstream (in the Mozilla Firefox codebase).

I hope this is fine. I landed it in the Orion repository because we are going for another Orion upstream update - this time we are taking in the code for the debugger ruler (new feature for us). We try to keep away forking our Orion copy.

Thank you!
Comment 12 Felipe Heidrich CLA 2012-01-18 13:48:09 EST
Thank you Mihai
Comment 13 John Arthorne CLA 2012-01-20 15:08:07 EST
Mark are we planning anything more here for 0.4? I'm guessing the CodeMirror styler is the direction to go here.
Comment 14 Mark Macdonald CLA 2012-01-20 15:28:06 EST
(In reply to comment #13)
> Mark are we planning anything more here for 0.4? I'm guessing the CodeMirror
> styler is the direction to go here.

Nothing more here for 0.4. 

And yes: you can get pretty good CSS highlighting today by using a CodeMirrorStyler in conjunction with css.js from CodeMirror.
Comment 15 Mihai Sucan CLA 2012-01-20 15:33:36 EST
(In reply to comment #14)
> (In reply to comment #13)
> > Mark are we planning anything more here for 0.4? I'm guessing the CodeMirror
> > styler is the direction to go here.
> 
> Nothing more here for 0.4. 
> 
> And yes: you can get pretty good CSS highlighting today by using a
> CodeMirrorStyler in conjunction with css.js from CodeMirror.

Has CodeMirrorStyler landed in the Orion repository? Are there any known performance concerns with the CodeMirrorStyler? Is the code license compatible with BSD?
Comment 16 John Arthorne CLA 2012-01-20 16:51:52 EST
(In reply to comment #15)
> Has CodeMirrorStyler landed in the Orion repository? Are there any known
> performance concerns with the CodeMirrorStyler? Is the code license compatible
> with BSD?

No it hasn't. it is currently still on GitHub:

https://github.com/mamacdon/orion-codemirror

The license is compatible, but Eclipse Foundation is concerned about provenance because the project doesn't keep track of who the contributors were (prior to its move to GitHub). We're trying to work that out. Whether that is acceptable to Mozilla is a separate question I guess.
Comment 17 Mark Macdonald CLA 2012-01-20 16:58:34 EST
(In reply to comment #16)
> (In reply to comment #15)
> > Has CodeMirrorStyler landed in the Orion repository? Are there any known
> > performance concerns with the CodeMirrorStyler? Is the code license compatible
> > with BSD?
> 
> No it hasn't. it is currently still on GitHub:
> 
> https://github.com/mamacdon/orion-codemirror
> 
> The license is compatible, but Eclipse Foundation is concerned about provenance
> because the project doesn't keep track of who the contributors were (prior to
> its move to GitHub). We're trying to work that out. Whether that is acceptable
> to Mozilla is a separate question I guess.

To be clear, the CodeMirrorStyler has landed in Orion (see mirror.js) -- but it does not include any code from the CodeMirror project for the reason John explained. The CodeMirrorStyler is just a driver. To make it useful you'd need to combine it with one of the language modes from the CodeMirror project (see [1]).

> Are there any known
> performance concerns with the CodeMirrorStyler?

Nothing known, although CodeMirrorStyler hasn't yet been as thoroughly performance tested as TextStyler.

[1] https://github.com/marijnh/CodeMirror2/tree/master/mode
Comment 18 Mihai Sucan CLA 2012-01-21 05:18:57 EST
Thanks for your answers.

I will contact the right people within Mozilla to check if we can integrate code from CodeMirror2 into the Firefox codebase. I hope we can, so we can use their syntax highlighter for CSS.

If we can do that, do you guys recommend we switch to CM2-based syntax highlighters for JS and HTML as well?
Comment 19 Mark Macdonald CLA 2012-01-24 18:40:03 EST
(In reply to comment #18)
> Thanks for your answers.
> 
> I will contact the right people within Mozilla to check if we can integrate
> code from CodeMirror2 into the Firefox codebase. I hope we can, so we can use
> their syntax highlighter for CSS.
> 
> If we can do that, do you guys recommend we switch to CM2-based syntax
> highlighters for JS and HTML as well?

CM2's HTML mode is worth trying -- it's much more comprehensive than the sample htmlGrammar.

As for JS, the TextStyler currently provides a few unique features: coloring of JSDoc tags and HTML markup within comments, comment folding and TODOs (if AnnotationModel is used), and brace/paren matching. If those are important to you, you'll want to stick with TextStyler for the time being.
Comment 20 John Arthorne CLA 2012-07-06 08:37:12 EDT
Changing title because original reported problem with comments was addressed.
Comment 21 Silenio Quarti CLA 2014-03-03 14:47:02 EST
This has been addressed by bug#421274.

*** This bug has been marked as a duplicate of bug 421274 ***