Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364857 - Syntax highlighter should be moved to a common place.
Summary: Syntax highlighter should be moved to a common place.
Status: RESOLVED FIXED
Alias: None
Product: Orion
Classification: ECD
Component: Client (show other bugs)
Version: 0.3   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 0.4 RC1   Edit
Assignee: Mark Macdonald CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-25 12:11 EST by libing wang CLA
Modified: 2012-02-01 17:24 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description libing wang CLA 2011-11-25 12:11:04 EST
Currently the syntax highlighter  is tied to setup.js.
It is hard for the compare editor to use it. We should move  the syntax highlighter to a common place. 
We also need a better way to understand the file type. We can't assume we can always tell file type by extension.
E.g. : RTC has special fileURI, where the file extension is not there. But their server can tell file type.
Comment 1 libing wang CLA 2012-01-30 09:24:52 EST
Bug 370126 may also require this.
One more thing not sure :
If there are 1000 lines in the file but I only use 5 lines, will the syntax highlight work ?
Comment 2 Mark Macdonald CLA 2012-01-30 15:00:40 EST
(In reply to comment #1)
> Bug 370126 may also require this.
> One more thing not sure :
> If there are 1000 lines in the file but I only use 5 lines, will the syntax
> highlight work ?

In the general case, no -- you won't get a correct result with just a snippet of the file. But it might be good enough for a preview.
Comment 3 Mark Macdonald CLA 2012-02-01 17:24:45 EST
I moved the 'syntaxHighlighter' object that was declared in setup.js (and copied in a few other places) into its own class. That class is shared between setup, search, and compare-container. This should allow the latter 2 places to automatically pick up additional language grammars that are plugged in or new content types that are registered.

At the moment it's very simple: it picks an appropriate styler for a content type, taking into account registered highlight provider services. (Note however, that you can't currently use the orion-codemirror plugin to style anything but the file editor on the coding page, see bug 370286.)

[1] http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=6bcb13d0739b534c47f4f77104b268afc90bfa4e
[2] http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=cabea058a81517f5b111acf53adeac47528d1016