2

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.

Community
  • 1
  • 1
Redsandro
  • 11,060
  • 13
  • 76
  • 106
  • Look at the notation of the data in the Foo.Bar object. Isn't that JavaScript Object Notation? If not, call it whatever you like but the question is the same. – Redsandro May 15 '11 at 04:24

1 Answers1

0

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.

Redsandro
  • 11,060
  • 13
  • 76
  • 106
  • didnt work for me. for example at `self.addScript = function (src, callback) {` i have no highlighting of `addScript` – ulkas Dec 11 '13 at 16:55
  • 2
    sorry, it works!! had to reopen the file (restarting eclipse does not help, one must manually close and open the file) – ulkas Dec 11 '13 at 16:57