I am using Eclipse Helios*
with PDT, and when I am editing JavaScript files with the default JavaScript Editor
(JSDT), code highlighting (Mark Occurrences
) is not working for JSON-style (or Object Literal
if you will) declarations.
*) Question also valid for Eclipse Indigo
with webtools
and JSDT
3.7.2
Example:
Foo = {};
Foo.Bar = Foo.Bar || {};
Foo.Bar = {
bar: function(str) {
alert(str)
},
baz: function(str) {
this.bar(str); // This bar *is* highlighted though
}
};
Foo.Bar.baz('text');
No Bar, bar or baz is highlighted. For now, I humbly edit the JavaScript part of projects in Notepad++ because it just highlights every occurrence of whatever is currently selected.
Is there a common practice for Eclipse JavaScript developers to get code highlighting work correctly, using the popular Object开发者_开发问答 Literal
notation? An option or update I missed?
-update-
I have found that code highlighting depends on the code being properly outlined. Altough commonly used, Object Literal
outlining still seems rare in javascript editors.
The Spket Javascript Editor does partial Object Literal
outlining, and the Aptana Javascript Editor does full Object Literal
outlining. But both loses other important functionality. A quest for the editor with the least loss of functionality is currently in progress in this question.
I have a partial answer to my own question.
The Spket JavaScript editor plugin for Eclipse does exactly what I want. Here is the Eclipse repository. Excellent code highlighting. I really don't know why the default JS editor has problems with this.
Two problems with this plugin are: 1) Not free/libre. You can use it for non-commercial purposes. 2) Less advanced code coloring.
I hope someone can improve on this and find a free/libre/open solution.
精彩评论